Find this useful? Enter your email to receive occasional updates for securing PHP code.

Signing you up...

Thank you for signing up!

PHP Decode

<?php namespace Tests\Prophecy\Doubler\Generator; use Fixtures\Prophecy\SelfReferencing; ..

Decoded Output download

<?php
 namespace Tests\Prophecy\Doubler\Generator; use Fixtures\Prophecy\SelfReferencing; use PHPUnit\Framework\TestCase; use Prophecy\Doubler\Generator\ClassMirror; use Prophecy\Doubler\Generator\Node\ArgumentTypeNode; use Prophecy\Doubler\Generator\Node\ReturnTypeNode; use Prophecy\Exception\Doubler\ClassMirrorException; use Prophecy\Exception\InvalidArgumentException; use Prophecy\Prophet; class ClassMirrorTest extends TestCase { public function it_reflects_allowed_magic_methods() { $class = new \ReflectionClass("Fixtures\Prophecy\SpecialMethods"); $mirror = new ClassMirror(); $node = $mirror->reflect($class, array()); $this->assertCount(7, $node->getMethods()); } public function it_reflects_protected_abstract_methods() { $class = new \ReflectionClass("Fixtures\Prophecy\WithProtectedAbstractMethod"); $mirror = new ClassMirror(); $classNode = $mirror->reflect($class, array()); $this->assertEquals("Fixtures\Prophecy\WithProtectedAbstractMethod", $classNode->getParentClass()); $methodNodes = $classNode->getMethods(); $this->assertCount(1, $methodNodes); $this->assertEquals("protected", $methodNodes["innerDetail"]->getVisibility()); } public function it_reflects_public_static_methods() { $class = new \ReflectionClass("Fixtures\Prophecy\WithStaticMethod"); $mirror = new ClassMirror(); $classNode = $mirror->reflect($class, array()); $this->assertEquals("Fixtures\Prophecy\WithStaticMethod", $classNode->getParentClass()); $methodNodes = $classNode->getMethods(); $this->assertCount(1, $methodNodes); $this->assertTrue($methodNodes["innerDetail"]->isStatic()); } public function it_marks_required_args_without_types_as_not_optional() { $class = new \ReflectionClass("Fixtures\Prophecy\WithArguments"); $mirror = new ClassMirror(); $classNode = $mirror->reflect($class, array()); $methodNode = $classNode->getMethod("methodWithoutTypeHints"); $argNodes = $methodNode->getArguments(); $this->assertCount(1, $argNodes); $this->assertEquals("arg", $argNodes[0]->getName()); $this->assertEquals(new ArgumentTypeNode(), $argNodes[0]->getTypeNode()); $this->assertFalse($argNodes[0]->isOptional()); $this->assertNull($argNodes[0]->getDefault()); $this->assertFalse($argNodes[0]->isPassedByReference()); $this->assertFalse($argNodes[0]->isVariadic()); } public function it_properly_reads_methods_arguments_with_types() { $class = new \ReflectionClass("Fixtures\Prophecy\WithArguments"); $mirror = new ClassMirror(); $classNode = $mirror->reflect($class, array()); $methodNode = $classNode->getMethod("methodWithArgs"); $argNodes = $methodNode->getArguments(); $this->assertCount(3, $argNodes); $this->assertEquals("arg_1", $argNodes[0]->getName()); $this->assertEquals(new ArgumentTypeNode("ArrayAccess"), $argNodes[0]->getTypeNode()); $this->assertFalse($argNodes[0]->isOptional()); $this->assertEquals("arg_2", $argNodes[1]->getName()); $this->assertEquals(new ArgumentTypeNode("array"), $argNodes[1]->getTypeNode()); $this->assertTrue($argNodes[1]->isOptional()); $this->assertEquals(array(), $argNodes[1]->getDefault()); $this->assertFalse($argNodes[1]->isPassedByReference()); $this->assertFalse($argNodes[1]->isVariadic()); $this->assertEquals("arg_3", $argNodes[2]->getName()); $this->assertEquals(new ArgumentTypeNode("ArrayAccess", "null"), $argNodes[2]->getTypeNode()); $this->assertTrue($argNodes[2]->isOptional()); $this->assertNull($argNodes[2]->getDefault()); $this->assertFalse($argNodes[2]->isPassedByReference()); $this->assertFalse($argNodes[2]->isVariadic()); } public function it_properly_reads_methods_arguments_with_callable_types() { $class = new \ReflectionClass("Fixtures\Prophecy\WithCallableArgument"); $mirror = new ClassMirror(); $classNode = $mirror->reflect($class, array()); $methodNode = $classNode->getMethod("methodWithArgs"); $argNodes = $methodNode->getArguments(); $this->assertCount(2, $argNodes); $this->assertEquals("arg_1", $argNodes[0]->getName()); $this->assertEquals(new ArgumentTypeNode("callable"), $argNodes[0]->getTypeNode()); $this->assertFalse($argNodes[0]->isOptional()); $this->assertFalse($argNodes[0]->isPassedByReference()); $this->assertFalse($argNodes[0]->isVariadic()); $this->assertEquals("arg_2", $argNodes[1]->getName()); $this->assertEquals(new ArgumentTypeNode("callable", "null"), $argNodes[1]->getTypeNode()); $this->assertTrue($argNodes[1]->isOptional()); $this->assertNull($argNodes[1]->getDefault()); $this->assertFalse($argNodes[1]->isPassedByReference()); $this->assertFalse($argNodes[1]->isVariadic()); } public function it_properly_reads_methods_variadic_arguments() { $class = new \ReflectionClass("Fixtures\Prophecy\WithVariadicArgument"); $mirror = new ClassMirror(); $classNode = $mirror->reflect($class, array()); $methodNode = $classNode->getMethod("methodWithArgs"); $argNodes = $methodNode->getArguments(); $this->assertCount(1, $argNodes); $this->assertEquals("args", $argNodes[0]->getName()); $this->assertEquals(new ArgumentTypeNode(), $argNodes[0]->getTypeNode()); $this->assertFalse($argNodes[0]->isOptional()); $this->assertFalse($argNodes[0]->isPassedByReference()); $this->assertTrue($argNodes[0]->isVariadic()); } public function it_properly_reads_methods_typehinted_variadic_arguments() { $class = new \ReflectionClass("Fixtures\Prophecy\WithTypehintedVariadicArgument"); $mirror = new ClassMirror(); $classNode = $mirror->reflect($class, array()); $methodNode = $classNode->getMethod("methodWithTypeHintedArgs"); $argNodes = $methodNode->getArguments(); $this->assertCount(1, $argNodes); $this->assertEquals("args", $argNodes[0]->getName()); $this->assertEquals(new ArgumentTypeNode("array"), $argNodes[0]->getTypeNode()); $this->assertFalse($argNodes[0]->isOptional()); $this->assertFalse($argNodes[0]->isPassedByReference()); $this->assertTrue($argNodes[0]->isVariadic()); } public function it_marks_passed_by_reference_args_as_passed_by_reference() { $class = new \ReflectionClass("Fixtures\Prophecy\WithReferences"); $mirror = new ClassMirror(); $classNode = $mirror->reflect($class, array()); $this->assertTrue($classNode->hasMethod("methodWithReferenceArgument")); $argNodes = $classNode->getMethod("methodWithReferenceArgument")->getArguments(); $this->assertCount(2, $argNodes); $this->assertTrue($argNodes[0]->isPassedByReference()); $this->assertTrue($argNodes[1]->isPassedByReference()); } public function it_throws_an_exception_if_class_is_final() { $class = new \ReflectionClass("Fixtures\Prophecy\FinalClass"); $mirror = new ClassMirror(); $this->expectException(ClassMirrorException::class); $mirror->reflect($class, array()); } public function it_ignores_final_methods() { $class = new \ReflectionClass("Fixtures\Prophecy\WithFinalMethod"); $mirror = new ClassMirror(); $classNode = $mirror->reflect($class, array()); $this->assertCount(0, $classNode->getMethods()); } public function it_marks_final_methods_as_unextendable() { $class = new \ReflectionClass("Fixtures\Prophecy\WithFinalMethod"); $mirror = new ClassMirror(); $classNode = $mirror->reflect($class, array()); $this->assertCount(1, $classNode->getUnextendableMethods()); $this->assertFalse($classNode->isExtendable("finalImplementation")); } public function it_throws_an_exception_if_interface_provided_instead_of_class() { $class = new \ReflectionClass("Fixtures\Prophecy\EmptyInterface"); $mirror = new ClassMirror(); $this->expectException(InvalidArgumentException::class); $mirror->reflect($class, array()); } public function it_reflects_all_interfaces_methods() { $mirror = new ClassMirror(); $classNode = $mirror->reflect(null, array(new \ReflectionClass("Fixtures\Prophecy\Named"), new \ReflectionClass("Fixtures\Prophecy\ModifierInterface"))); $this->assertEquals("stdClass", $classNode->getParentClass()); $this->assertEquals(array("Prophecy\Doubler\Generator\ReflectionInterface", "Fixtures\Prophecy\ModifierInterface", "Fixtures\Prophecy\Named"), $classNode->getInterfaces()); $this->assertCount(3, $classNode->getMethods()); $this->assertTrue($classNode->hasMethod("getName")); $this->assertTrue($classNode->hasMethod("isAbstract")); $this->assertTrue($classNode->hasMethod("getVisibility")); } public function it_ignores_virtually_private_methods() { $class = new \ReflectionClass("Fixtures\Prophecy\WithVirtuallyPrivateMethod"); $mirror = new ClassMirror(); $classNode = $mirror->reflect($class, array()); $this->assertCount(2, $classNode->getMethods()); $this->assertTrue($classNode->hasMethod("isAbstract")); $this->assertTrue($classNode->hasMethod("__toString")); $this->assertFalse($classNode->hasMethod("_getName")); } public function it_does_not_throw_exception_for_virtually_private_finals() { $class = new \ReflectionClass("Fixtures\Prophecy\WithFinalVirtuallyPrivateMethod"); $mirror = new ClassMirror(); $classNode = $mirror->reflect($class, array()); $this->assertCount(0, $classNode->getMethods()); } public function it_reflects_return_typehints() { $class = new \ReflectionClass("Fixtures\Prophecy\WithReturnTypehints"); $mirror = new ClassMirror(); $classNode = $mirror->reflect($class, array()); $this->assertCount(3, $classNode->getMethods()); $this->assertTrue($classNode->hasMethod("getName")); $this->assertTrue($classNode->hasMethod("getSelf")); $this->assertTrue($classNode->hasMethod("getParent")); $this->assertEquals(new ReturnTypeNode("string"), $classNode->getMethod("getName")->getReturnTypeNode()); $this->assertEquals(new ReturnTypeNode("\Fixtures\Prophecy\WithReturnTypehints"), $classNode->getMethod("getSelf")->getReturnTypeNode()); $this->assertEquals(new ReturnTypeNode("\Fixtures\Prophecy\EmptyClass"), $classNode->getMethod("getParent")->getReturnTypeNode()); } public function it_throws_an_exception_if_class_provided_in_interfaces_list() { $class = new \ReflectionClass("Fixtures\Prophecy\EmptyClass"); $mirror = new ClassMirror(); $this->expectException(\InvalidArgumentException::class); $mirror->reflect(null, array($class)); } public function it_throws_an_exception_if_not_reflection_provided_as_interface() { $mirror = new ClassMirror(); $this->expectException(\InvalidArgumentException::class); $mirror->reflect(null, array(null)); } public function it_doesnt_use_scalar_typehints() { if (PHP_VERSION_ID >= 80000) { $this->markTestSkipped("Internal types have scalar hints in PHP 8"); } $mirror = new ClassMirror(); $classNode = $mirror->reflect(new \ReflectionClass("ReflectionMethod"), array()); $method = $classNode->getMethod("export"); $arguments = $method->getArguments(); $this->assertEquals(new ArgumentTypeNode(), $arguments[0]->getTypeNode()); $this->assertEquals(new ArgumentTypeNode(), $arguments[1]->getTypeNode()); $this->assertEquals(new ArgumentTypeNode(), $arguments[2]->getTypeNode()); } public function it_doesnt_fail_to_typehint_nonexistent_FQCN() { $mirror = new ClassMirror(); $classNode = $mirror->reflect(new \ReflectionClass("Fixtures\Prophecy\OptionalDepsClass"), array()); $method = $classNode->getMethod("iHaveAStrangeTypeHintedArg"); $arguments = $method->getArguments(); $this->assertEquals(new ArgumentTypeNode("I\Simply\Am\Nonexistent"), $arguments[0]->getTypeNode()); } public function it_doesnt_fail_on_array_nullable_parameter_with_not_null_default_value() { $mirror = new ClassMirror(); $classNode = $mirror->reflect(new \ReflectionClass("Fixtures\Prophecy\NullableArrayParameter"), array()); $method = $classNode->getMethod("iHaveNullableArrayParameterWithNotNullDefaultValue"); $arguments = $method->getArguments(); $this->assertEquals(new ArgumentTypeNode("array", "null"), $arguments[0]->getTypeNode()); } public function it_doesnt_fail_to_typehint_nonexistent_RQCN() { $mirror = new ClassMirror(); $classNode = $mirror->reflect(new \ReflectionClass("Fixtures\Prophecy\OptionalDepsClass"), array()); $method = $classNode->getMethod("iHaveAnEvenStrangerTypeHintedArg"); $arguments = $method->getArguments(); $this->assertEquals(new ArgumentTypeNode("I\Simply\Am\Not"), $arguments[0]->getTypeNode()); } function it_doesnt_fail_when_method_is_extended_with_more_params() { $mirror = new ClassMirror(); $classNode = $mirror->reflect(new \ReflectionClass("Fixtures\Prophecy\MethodWithAdditionalParam"), array(new \ReflectionClass("Fixtures\Prophecy\Named"))); $method = $classNode->getMethod("getName"); $this->assertCount(1, $method->getArguments()); $method = $classNode->getMethod("methodWithoutTypeHints"); $this->assertCount(2, $method->getArguments()); } function it_doesnt_fail_to_mock_self_referencing_interface() { $mirror = new ClassMirror(); $classNode = $mirror->reflect(null, array(new \ReflectionClass(SelfReferencing::class))); $method = $classNode->getMethod("__invoke"); $this->assertCount(1, $method->getArguments()); $this->assertEquals(new ArgumentTypeNode(SelfReferencing::class), $method->getArguments()[0]->getTypeNode()); $this->assertEquals(new ReturnTypeNode(SelfReferencing::class), $method->getReturnTypeNode()); } function it_changes_argument_names_if_they_are_varying() { $prophet = new Prophet(); $class = $prophet->prophesize("ReflectionClass"); $method = $prophet->prophesize("ReflectionMethod"); $parameter = $prophet->prophesize("ReflectionParameter"); if (PHP_VERSION_ID >= 80200) { $class->isReadOnly()->willReturn(false); } $class->getName()->willReturn("Custom\ClassName"); $class->isInterface()->willReturn(false); $class->isFinal()->willReturn(false); $class->getMethods(\ReflectionMethod::IS_PUBLIC)->willReturn(array($method)); $class->getMethods(\ReflectionMethod::IS_ABSTRACT)->willReturn(array()); $method->getParameters()->willReturn(array($parameter)); $method->getName()->willReturn("methodName"); $method->isFinal()->willReturn(false); $method->isProtected()->willReturn(false); $method->isStatic()->willReturn(false); $method->returnsReference()->willReturn(false); $method->hasReturnType()->willReturn(false); $method->getDeclaringClass()->willReturn($class); if (\PHP_VERSION_ID >= 80100) { $method->hasTentativeReturnType()->willReturn(false); } $parameter->getName()->willReturn("..."); $parameter->isDefaultValueAvailable()->willReturn(true); $parameter->getDefaultValue()->willReturn(null); $parameter->isPassedByReference()->willReturn(false); $parameter->allowsNull()->willReturn(true); $parameter->getClass()->willReturn($class); $parameter->getType()->willReturn(null); $parameter->hasType()->willReturn(false); $parameter->isVariadic()->willReturn(false); $mirror = new ClassMirror(); $classNode = $mirror->reflect($class->reveal(), array()); $methodNodes = $classNode->getMethods(); $argumentNodes = $methodNodes["methodName"]->getArguments(); $argumentNode = $argumentNodes[0]; $this->assertEquals("__dot_dot_dot__", $argumentNode->getName()); } public function it_can_double_a_class_with_union_return_types() { if (PHP_VERSION_ID < 80000) { $this->markTestSkipped("Union types are not supported in this PHP version"); } $classNode = (new ClassMirror())->reflect(new \ReflectionClass("Fixtures\Prophecy\UnionReturnTypes"), array()); $methodNode = $classNode->getMethods()["doSomething"]; $this->assertSame(array("\stdClass", "bool"), $methodNode->getReturnTypeNode()->getTypes()); } public function it_can_double_a_class_with_union_return_type_with_false() { if (PHP_VERSION_ID < 80000) { $this->markTestSkipped("Union types with false are not supported in this PHP version"); } $classNode = (new ClassMirror())->reflect(new \ReflectionClass("Fixtures\Prophecy\UnionReturnTypeFalse"), array()); $methodNode = $classNode->getMethods()["method"]; $this->assertSame(array("\stdClass", "false"), $methodNode->getReturnTypeNode()->getTypes()); } public function it_can_double_a_class_with_union_argument_types() { if (PHP_VERSION_ID < 80000) { $this->markTestSkipped("Union types are not supported in this PHP version"); } $classNode = (new ClassMirror())->reflect(new \ReflectionClass("Fixtures\Prophecy\UnionArgumentTypes"), array()); $methodNode = $classNode->getMethods()["doSomething"]; $this->assertEquals(new ArgumentTypeNode("bool", "\stdClass"), $methodNode->getArguments()[0]->getTypeNode()); } public function it_can_double_a_class_with_union_argument_type_with_false() { if (PHP_VERSION_ID < 80000) { $this->markTestSkipped("Union types with false are not supported in this PHP version"); } $classNode = (new ClassMirror())->reflect(new \ReflectionClass("Fixtures\Prophecy\UnionArgumentTypeFalse"), array()); $methodNode = $classNode->getMethods()["method"]; $this->assertEquals(new ArgumentTypeNode("false", "\stdClass"), $methodNode->getArguments()[0]->getTypeNode()); } public function it_can_double_a_class_with_mixed_types() { if (PHP_VERSION_ID < 80000) { $this->markTestSkipped("Mixed type is not supported in this PHP version"); } $classNode = (new ClassMirror())->reflect(new \ReflectionClass("Fixtures\Prophecy\MixedTypes"), array()); $methodNode = $classNode->getMethods()["doSomething"]; $this->assertEquals(new ArgumentTypeNode("mixed"), $methodNode->getArguments()[0]->getTypeNode()); $this->assertEquals(new ReturnTypeNode("mixed"), $methodNode->getReturnTypeNode()); } public function it_can_double_inherited_self_return_type() { $classNode = (new ClassMirror())->reflect(new \ReflectionClass("Fixtures\Prophecy\ClassExtendAbstractWithMethodWithReturnType"), array()); $methodNode = $classNode->getMethods()["returnSelf"]; $this->assertEquals(new ReturnTypeNode("Fixtures\Prophecy\AbstractBaseClassWithMethodWithReturnType"), $methodNode->getReturnTypeNode()); } public function it_can_double_never_return_type() { if (PHP_VERSION_ID < 80100) { $this->markTestSkipped("Never type is not supported in this PHP version"); } $classNode = (new ClassMirror())->reflect(new \ReflectionClass("Fixtures\Prophecy\NeverType"), array()); $methodNode = $classNode->getMethods()["doSomething"]; $this->assertEquals(new ReturnTypeNode("never"), $methodNode->getReturnTypeNode()); } public function it_can_not_double_an_enum() { if (PHP_VERSION_ID < 80100) { $this->markTestSkipped("Enums are not supported in this PHP version"); } $this->expectException(ClassMirrorException::class); $classNode = (new ClassMirror())->reflect(new \ReflectionClass("Fixtures\Prophecy\Enum"), array()); } public function it_can_not_double_intersection_return_types() { if (PHP_VERSION_ID < 80100) { $this->markTestSkipped("Intersection types are not supported in this PHP version"); } $this->expectException(ClassMirrorException::class); $classNode = (new ClassMirror())->reflect(new \ReflectionClass("Fixtures\Prophecy\IntersectionReturnType"), array()); } public function it_can_not_double_intersection_argument_types() { if (PHP_VERSION_ID < 80100) { $this->markTestSkipped("Intersection types are not supported in this PHP version"); } $this->expectException(ClassMirrorException::class); $classNode = (new ClassMirror())->reflect(new \ReflectionClass("Fixtures\Prophecy\IntersectionArgumentType"), array()); } public function it_can_double_a_standalone_return_type_of_false() { if (PHP_VERSION_ID < 80200) { $this->markTestSkipped("Standalone return type of false is not supported in this PHP version"); } $classNode = (new ClassMirror())->reflect(new \ReflectionClass("Fixtures\Prophecy\StandaloneReturnTypeFalse"), array()); $methodNode = $classNode->getMethods()["method"]; $this->assertEquals(new ReturnTypeNode("false"), $methodNode->getReturnTypeNode()); } public function it_can_double_a_standalone_parameter_type_of_false() { if (PHP_VERSION_ID < 80200) { $this->markTestSkipped("Standalone parameter type of false is not supported in this PHP version"); } $classNode = (new ClassMirror())->reflect(new \ReflectionClass("Fixtures\Prophecy\StandaloneParameterTypeFalse"), array()); $method = $classNode->getMethod("method"); $arguments = $method->getArguments(); $this->assertEquals(new ArgumentTypeNode("false"), $arguments[0]->getTypeNode()); } public function it_can_double_a_nullable_return_type_of_false() { if (PHP_VERSION_ID < 80200) { $this->markTestSkipped("Nullable return type of false is not supported in this PHP version"); } $classNode = (new ClassMirror())->reflect(new \ReflectionClass("Fixtures\Prophecy\NullableReturnTypeFalse"), array()); $methodNode = $classNode->getMethods()["method"]; $this->assertEquals(new ReturnTypeNode("null", "false"), $methodNode->getReturnTypeNode()); } public function it_can_double_a_nullable_parameter_type_of_false() { if (PHP_VERSION_ID < 80200) { $this->markTestSkipped("Nullable parameter type of false is not supported in this PHP version"); } $classNode = (new ClassMirror())->reflect(new \ReflectionClass("Fixtures\Prophecy\NullableParameterTypeFalse"), array()); $method = $classNode->getMethod("method"); $arguments = $method->getArguments(); $this->assertEquals(new ArgumentTypeNode("null", "false"), $arguments[0]->getTypeNode()); } public function it_can_not_double_dnf_intersection_argument_types() { if (PHP_VERSION_ID < 80200) { $this->markTestSkipped("DNF intersection types are not supported in this PHP version"); } $this->expectException(ClassMirrorException::class); $classNode = (new ClassMirror())->reflect(new \ReflectionClass("Fixtures\Prophecy\DnfArgumentType"), array()); } public function it_can_not_double_dnf_intersection_return_types() { if (PHP_VERSION_ID < 80200) { $this->markTestSkipped("DNF intersection types are not supported in this PHP version"); } $this->expectException(ClassMirrorException::class); $classNode = (new ClassMirror())->reflect(new \ReflectionClass("Fixtures\Prophecy\DnfReturnType"), array()); } public function it_can_double_a_standalone_return_type_of_true() { if (PHP_VERSION_ID < 80200) { $this->markTestSkipped("Standalone return type of true is not supported in this PHP version"); } $classNode = (new ClassMirror())->reflect(new \ReflectionClass("Fixtures\Prophecy\StandaloneReturnTypeTrue"), array()); $methodNode = $classNode->getMethods()["method"]; $this->assertEquals(new ReturnTypeNode("true"), $methodNode->getReturnTypeNode()); } public function it_reflects_non_read_only_class() { $classNode = (new ClassMirror())->reflect(new \ReflectionClass("Fixtures\Prophecy\EmptyClass"), array()); $this->assertFalse($classNode->isReadOnly()); } public function it_can_double_a_standalone_parameter_type_of_true() { if (PHP_VERSION_ID < 80200) { $this->markTestSkipped("Standalone parameter type of true is not supported in this PHP version"); } $classNode = (new ClassMirror())->reflect(new \ReflectionClass("Fixtures\Prophecy\StandaloneParameterTypeTrue"), array()); $method = $classNode->getMethod("method"); $arguments = $method->getArguments(); $this->assertEquals(new ArgumentTypeNode("true"), $arguments[0]->getTypeNode()); } public function it_can_double_a_nullable_return_type_of_true() { if (PHP_VERSION_ID < 80200) { $this->markTestSkipped("Nullable return type of true is not supported in this PHP version"); } $classNode = (new ClassMirror())->reflect(new \ReflectionClass("Fixtures\Prophecy\NullableReturnTypeTrue"), array()); $methodNode = $classNode->getMethods()["method"]; $this->assertEquals(new ReturnTypeNode("null", "true"), $methodNode->getReturnTypeNode()); } public function it_can_double_a_nullable_parameter_type_of_true() { if (PHP_VERSION_ID < 80200) { $this->markTestSkipped("Nullable parameter type of true is not supported in this PHP version"); } $classNode = (new ClassMirror())->reflect(new \ReflectionClass("Fixtures\Prophecy\NullableParameterTypeTrue"), array()); $method = $classNode->getMethod("method"); $arguments = $method->getArguments(); $this->assertEquals(new ArgumentTypeNode("null", "true"), $arguments[0]->getTypeNode()); } public function it_can_double_a_standalone_return_type_of_null() { if (PHP_VERSION_ID < 80200) { $this->markTestSkipped("Standalone return type of null is not supported in this PHP version"); } $classNode = (new ClassMirror())->reflect(new \ReflectionClass("Fixtures\Prophecy\StandaloneReturnTypeNull"), array()); $methodNode = $classNode->getMethods()["method"]; $this->assertEquals(new ReturnTypeNode("null"), $methodNode->getReturnTypeNode()); } public function it_can_double_a_standalone_parameter_type_of_null() { if (PHP_VERSION_ID < 80200) { $this->markTestSkipped("Standalone parameter type of null is not supported in this PHP version"); } $classNode = (new ClassMirror())->reflect(new \ReflectionClass("Fixtures\Prophecy\StandaloneParameterTypeNull"), array()); $method = $classNode->getMethod("method"); $arguments = $method->getArguments(); $this->assertEquals(new ArgumentTypeNode("null"), $arguments[0]->getTypeNode()); } public function it_reflects_read_only_class() { if (PHP_VERSION_ID < 80200) { $this->markTestSkipped("Read only classes are not supported in this PHP version"); } $classNode = (new ClassMirror())->reflect(new \ReflectionClass("Fixtures\Prophecy\ReadOnlyClass"), array()); $this->assertTrue($classNode->isReadOnly()); } } ?>

Did this file decode correctly?

Original Code

<?php
 namespace Tests\Prophecy\Doubler\Generator; use Fixtures\Prophecy\SelfReferencing; use PHPUnit\Framework\TestCase; use Prophecy\Doubler\Generator\ClassMirror; use Prophecy\Doubler\Generator\Node\ArgumentTypeNode; use Prophecy\Doubler\Generator\Node\ReturnTypeNode; use Prophecy\Exception\Doubler\ClassMirrorException; use Prophecy\Exception\InvalidArgumentException; use Prophecy\Prophet; class ClassMirrorTest extends TestCase { public function it_reflects_allowed_magic_methods() { $class = new \ReflectionClass("\x46\x69\x78\164\x75\x72\145\163\x5c\x50\162\x6f\x70\x68\x65\143\171\134\123\160\145\x63\x69\x61\154\115\145\164\x68\157\144\x73"); $mirror = new ClassMirror(); $node = $mirror->reflect($class, array()); $this->assertCount(7, $node->getMethods()); } public function it_reflects_protected_abstract_methods() { $class = new \ReflectionClass("\x46\151\170\x74\x75\162\145\x73\x5c\120\x72\157\160\150\x65\x63\x79\x5c\x57\151\x74\150\x50\162\157\164\x65\143\164\145\144\x41\x62\x73\164\x72\x61\143\164\x4d\x65\x74\x68\x6f\144"); $mirror = new ClassMirror(); $classNode = $mirror->reflect($class, array()); $this->assertEquals("\x46\x69\x78\x74\x75\x72\145\x73\x5c\x50\x72\x6f\x70\x68\x65\x63\171\x5c\127\151\164\150\x50\162\x6f\x74\x65\x63\x74\145\x64\x41\x62\x73\x74\x72\141\x63\x74\x4d\x65\164\x68\157\x64", $classNode->getParentClass()); $methodNodes = $classNode->getMethods(); $this->assertCount(1, $methodNodes); $this->assertEquals("\x70\162\x6f\164\x65\x63\x74\145\x64", $methodNodes["\151\156\156\145\162\104\x65\164\x61\x69\x6c"]->getVisibility()); } public function it_reflects_public_static_methods() { $class = new \ReflectionClass("\x46\x69\170\x74\165\162\x65\x73\134\x50\x72\157\160\150\x65\x63\171\134\x57\151\x74\150\x53\x74\141\164\x69\x63\115\x65\x74\x68\157\x64"); $mirror = new ClassMirror(); $classNode = $mirror->reflect($class, array()); $this->assertEquals("\106\151\x78\x74\x75\x72\145\x73\x5c\x50\162\157\160\150\145\143\x79\x5c\127\x69\164\150\x53\x74\x61\164\x69\143\115\145\x74\x68\157\144", $classNode->getParentClass()); $methodNodes = $classNode->getMethods(); $this->assertCount(1, $methodNodes); $this->assertTrue($methodNodes["\151\156\156\x65\162\x44\145\164\141\x69\154"]->isStatic()); } public function it_marks_required_args_without_types_as_not_optional() { $class = new \ReflectionClass("\106\x69\x78\x74\165\162\x65\x73\x5c\x50\162\x6f\x70\x68\145\x63\171\x5c\127\x69\x74\x68\101\162\147\x75\x6d\x65\156\x74\x73"); $mirror = new ClassMirror(); $classNode = $mirror->reflect($class, array()); $methodNode = $classNode->getMethod("\155\145\x74\150\157\144\x57\x69\164\x68\157\x75\x74\x54\x79\160\x65\x48\x69\x6e\x74\x73"); $argNodes = $methodNode->getArguments(); $this->assertCount(1, $argNodes); $this->assertEquals("\x61\x72\147", $argNodes[0]->getName()); $this->assertEquals(new ArgumentTypeNode(), $argNodes[0]->getTypeNode()); $this->assertFalse($argNodes[0]->isOptional()); $this->assertNull($argNodes[0]->getDefault()); $this->assertFalse($argNodes[0]->isPassedByReference()); $this->assertFalse($argNodes[0]->isVariadic()); } public function it_properly_reads_methods_arguments_with_types() { $class = new \ReflectionClass("\106\x69\170\164\165\x72\x65\163\134\x50\162\157\x70\150\145\x63\x79\134\x57\151\x74\150\101\x72\x67\165\x6d\x65\x6e\x74\x73"); $mirror = new ClassMirror(); $classNode = $mirror->reflect($class, array()); $methodNode = $classNode->getMethod("\x6d\x65\164\x68\x6f\x64\127\x69\164\150\101\x72\x67\x73"); $argNodes = $methodNode->getArguments(); $this->assertCount(3, $argNodes); $this->assertEquals("\141\x72\x67\x5f\61", $argNodes[0]->getName()); $this->assertEquals(new ArgumentTypeNode("\x41\162\x72\141\171\101\143\143\x65\163\x73"), $argNodes[0]->getTypeNode()); $this->assertFalse($argNodes[0]->isOptional()); $this->assertEquals("\141\162\x67\x5f\x32", $argNodes[1]->getName()); $this->assertEquals(new ArgumentTypeNode("\141\x72\x72\x61\171"), $argNodes[1]->getTypeNode()); $this->assertTrue($argNodes[1]->isOptional()); $this->assertEquals(array(), $argNodes[1]->getDefault()); $this->assertFalse($argNodes[1]->isPassedByReference()); $this->assertFalse($argNodes[1]->isVariadic()); $this->assertEquals("\141\162\147\x5f\x33", $argNodes[2]->getName()); $this->assertEquals(new ArgumentTypeNode("\x41\x72\162\x61\171\x41\143\x63\145\x73\x73", "\156\165\154\x6c"), $argNodes[2]->getTypeNode()); $this->assertTrue($argNodes[2]->isOptional()); $this->assertNull($argNodes[2]->getDefault()); $this->assertFalse($argNodes[2]->isPassedByReference()); $this->assertFalse($argNodes[2]->isVariadic()); } public function it_properly_reads_methods_arguments_with_callable_types() { $class = new \ReflectionClass("\x46\x69\170\x74\165\162\145\x73\134\120\x72\x6f\x70\150\x65\x63\171\x5c\127\151\164\150\x43\x61\x6c\x6c\141\x62\154\145\x41\162\147\165\155\145\x6e\164"); $mirror = new ClassMirror(); $classNode = $mirror->reflect($class, array()); $methodNode = $classNode->getMethod("\155\145\x74\x68\157\x64\x57\x69\164\x68\101\162\147\x73"); $argNodes = $methodNode->getArguments(); $this->assertCount(2, $argNodes); $this->assertEquals("\x61\x72\x67\137\x31", $argNodes[0]->getName()); $this->assertEquals(new ArgumentTypeNode("\x63\x61\x6c\154\141\x62\154\x65"), $argNodes[0]->getTypeNode()); $this->assertFalse($argNodes[0]->isOptional()); $this->assertFalse($argNodes[0]->isPassedByReference()); $this->assertFalse($argNodes[0]->isVariadic()); $this->assertEquals("\x61\x72\147\x5f\x32", $argNodes[1]->getName()); $this->assertEquals(new ArgumentTypeNode("\x63\x61\154\154\x61\x62\x6c\x65", "\x6e\x75\154\154"), $argNodes[1]->getTypeNode()); $this->assertTrue($argNodes[1]->isOptional()); $this->assertNull($argNodes[1]->getDefault()); $this->assertFalse($argNodes[1]->isPassedByReference()); $this->assertFalse($argNodes[1]->isVariadic()); } public function it_properly_reads_methods_variadic_arguments() { $class = new \ReflectionClass("\106\x69\170\164\165\x72\145\163\x5c\120\x72\x6f\x70\150\145\x63\171\x5c\127\x69\x74\150\x56\141\162\x69\x61\144\151\143\x41\162\147\x75\x6d\145\156\x74"); $mirror = new ClassMirror(); $classNode = $mirror->reflect($class, array()); $methodNode = $classNode->getMethod("\x6d\145\x74\x68\157\144\127\151\164\x68\x41\x72\x67\163"); $argNodes = $methodNode->getArguments(); $this->assertCount(1, $argNodes); $this->assertEquals("\141\162\147\x73", $argNodes[0]->getName()); $this->assertEquals(new ArgumentTypeNode(), $argNodes[0]->getTypeNode()); $this->assertFalse($argNodes[0]->isOptional()); $this->assertFalse($argNodes[0]->isPassedByReference()); $this->assertTrue($argNodes[0]->isVariadic()); } public function it_properly_reads_methods_typehinted_variadic_arguments() { $class = new \ReflectionClass("\x46\151\x78\164\x75\x72\145\163\x5c\x50\162\x6f\x70\150\x65\x63\171\134\127\x69\x74\150\124\x79\160\145\x68\x69\x6e\164\x65\144\126\141\162\151\x61\144\151\143\x41\x72\147\x75\155\145\156\164"); $mirror = new ClassMirror(); $classNode = $mirror->reflect($class, array()); $methodNode = $classNode->getMethod("\x6d\145\164\x68\157\x64\x57\x69\164\x68\124\171\160\x65\x48\x69\156\164\x65\144\x41\x72\147\163"); $argNodes = $methodNode->getArguments(); $this->assertCount(1, $argNodes); $this->assertEquals("\141\162\147\163", $argNodes[0]->getName()); $this->assertEquals(new ArgumentTypeNode("\141\x72\162\x61\171"), $argNodes[0]->getTypeNode()); $this->assertFalse($argNodes[0]->isOptional()); $this->assertFalse($argNodes[0]->isPassedByReference()); $this->assertTrue($argNodes[0]->isVariadic()); } public function it_marks_passed_by_reference_args_as_passed_by_reference() { $class = new \ReflectionClass("\x46\151\x78\164\165\162\x65\x73\134\120\x72\157\x70\x68\145\143\171\x5c\127\x69\x74\150\122\145\146\x65\162\145\156\x63\x65\163"); $mirror = new ClassMirror(); $classNode = $mirror->reflect($class, array()); $this->assertTrue($classNode->hasMethod("\155\145\164\x68\x6f\x64\127\x69\164\x68\x52\145\x66\145\162\x65\156\143\145\x41\x72\x67\x75\155\x65\156\x74")); $argNodes = $classNode->getMethod("\155\145\x74\150\157\144\x57\151\164\150\x52\145\146\x65\162\x65\156\143\x65\101\x72\x67\165\155\x65\156\x74")->getArguments(); $this->assertCount(2, $argNodes); $this->assertTrue($argNodes[0]->isPassedByReference()); $this->assertTrue($argNodes[1]->isPassedByReference()); } public function it_throws_an_exception_if_class_is_final() { $class = new \ReflectionClass("\106\x69\170\x74\x75\x72\145\163\x5c\x50\x72\157\x70\x68\x65\x63\x79\x5c\x46\151\x6e\x61\154\x43\x6c\141\163\163"); $mirror = new ClassMirror(); $this->expectException(ClassMirrorException::class); $mirror->reflect($class, array()); } public function it_ignores_final_methods() { $class = new \ReflectionClass("\106\151\170\x74\165\162\145\163\134\120\162\x6f\x70\x68\x65\x63\x79\x5c\127\x69\x74\x68\x46\x69\x6e\x61\154\115\x65\x74\x68\x6f\x64"); $mirror = new ClassMirror(); $classNode = $mirror->reflect($class, array()); $this->assertCount(0, $classNode->getMethods()); } public function it_marks_final_methods_as_unextendable() { $class = new \ReflectionClass("\106\151\x78\164\x75\162\145\163\x5c\x50\162\x6f\x70\x68\145\143\171\134\x57\151\164\x68\x46\151\x6e\x61\154\x4d\x65\164\150\x6f\144"); $mirror = new ClassMirror(); $classNode = $mirror->reflect($class, array()); $this->assertCount(1, $classNode->getUnextendableMethods()); $this->assertFalse($classNode->isExtendable("\146\151\156\x61\x6c\x49\155\x70\154\145\x6d\x65\x6e\164\x61\164\151\x6f\156")); } public function it_throws_an_exception_if_interface_provided_instead_of_class() { $class = new \ReflectionClass("\106\x69\170\164\165\x72\x65\x73\134\120\162\x6f\x70\x68\145\143\171\134\105\155\160\164\171\x49\x6e\x74\x65\x72\x66\x61\143\145"); $mirror = new ClassMirror(); $this->expectException(InvalidArgumentException::class); $mirror->reflect($class, array()); } public function it_reflects_all_interfaces_methods() { $mirror = new ClassMirror(); $classNode = $mirror->reflect(null, array(new \ReflectionClass("\x46\151\170\164\x75\162\x65\163\134\x50\162\157\x70\x68\145\143\x79\x5c\116\x61\155\145\144"), new \ReflectionClass("\x46\x69\x78\x74\x75\162\145\x73\x5c\x50\x72\x6f\x70\150\145\143\x79\134\115\157\x64\151\x66\151\145\162\x49\x6e\x74\145\162\x66\x61\x63\145"))); $this->assertEquals("\x73\164\144\x43\x6c\x61\163\x73", $classNode->getParentClass()); $this->assertEquals(array("\x50\x72\x6f\160\150\145\143\171\134\x44\x6f\x75\x62\x6c\x65\162\134\x47\145\x6e\145\x72\x61\x74\157\x72\134\x52\x65\146\x6c\x65\x63\x74\x69\x6f\156\111\156\x74\145\162\146\x61\143\x65", "\106\151\x78\x74\165\162\x65\x73\134\x50\x72\157\160\150\x65\143\171\x5c\x4d\x6f\x64\x69\146\151\145\162\111\x6e\164\x65\x72\146\x61\x63\145", "\106\151\x78\164\x75\x72\x65\x73\x5c\120\x72\x6f\x70\150\145\143\x79\x5c\116\x61\155\x65\144"), $classNode->getInterfaces()); $this->assertCount(3, $classNode->getMethods()); $this->assertTrue($classNode->hasMethod("\147\x65\x74\116\x61\155\145")); $this->assertTrue($classNode->hasMethod("\151\x73\101\142\163\x74\162\141\143\x74")); $this->assertTrue($classNode->hasMethod("\147\x65\164\x56\151\x73\x69\x62\151\154\151\x74\x79")); } public function it_ignores_virtually_private_methods() { $class = new \ReflectionClass("\106\x69\x78\x74\x75\x72\145\x73\134\120\162\157\x70\x68\x65\143\x79\134\127\151\x74\150\126\151\162\164\165\141\x6c\x6c\171\120\x72\x69\x76\141\164\x65\115\145\x74\150\x6f\x64"); $mirror = new ClassMirror(); $classNode = $mirror->reflect($class, array()); $this->assertCount(2, $classNode->getMethods()); $this->assertTrue($classNode->hasMethod("\x69\163\101\142\163\x74\x72\x61\x63\164")); $this->assertTrue($classNode->hasMethod("\137\137\x74\157\x53\164\x72\151\156\147")); $this->assertFalse($classNode->hasMethod("\x5f\x67\145\x74\x4e\x61\x6d\x65")); } public function it_does_not_throw_exception_for_virtually_private_finals() { $class = new \ReflectionClass("\106\151\170\164\165\x72\145\x73\x5c\120\162\x6f\x70\x68\145\x63\171\x5c\127\151\164\x68\x46\151\156\141\154\126\x69\x72\164\x75\141\x6c\154\x79\x50\162\151\x76\x61\x74\145\115\145\164\x68\157\x64"); $mirror = new ClassMirror(); $classNode = $mirror->reflect($class, array()); $this->assertCount(0, $classNode->getMethods()); } public function it_reflects_return_typehints() { $class = new \ReflectionClass("\106\x69\170\x74\x75\162\x65\x73\x5c\120\162\157\160\150\145\x63\x79\x5c\x57\x69\x74\x68\122\x65\164\x75\x72\156\x54\x79\x70\145\x68\x69\x6e\x74\163"); $mirror = new ClassMirror(); $classNode = $mirror->reflect($class, array()); $this->assertCount(3, $classNode->getMethods()); $this->assertTrue($classNode->hasMethod("\147\145\x74\116\x61\155\x65")); $this->assertTrue($classNode->hasMethod("\147\145\x74\x53\145\154\x66")); $this->assertTrue($classNode->hasMethod("\147\145\x74\x50\141\x72\x65\156\x74")); $this->assertEquals(new ReturnTypeNode("\x73\x74\162\151\156\147"), $classNode->getMethod("\x67\145\164\x4e\141\155\x65")->getReturnTypeNode()); $this->assertEquals(new ReturnTypeNode("\x5c\106\151\x78\x74\165\x72\145\x73\134\x50\162\157\x70\150\x65\143\x79\x5c\127\x69\x74\150\122\x65\164\x75\x72\156\x54\x79\160\x65\150\x69\156\164\163"), $classNode->getMethod("\x67\x65\x74\x53\x65\154\146")->getReturnTypeNode()); $this->assertEquals(new ReturnTypeNode("\134\106\151\170\x74\x75\x72\145\x73\134\120\x72\x6f\x70\150\145\143\171\134\x45\x6d\x70\164\x79\103\x6c\x61\x73\163"), $classNode->getMethod("\x67\x65\164\x50\x61\x72\x65\156\x74")->getReturnTypeNode()); } public function it_throws_an_exception_if_class_provided_in_interfaces_list() { $class = new \ReflectionClass("\x46\151\x78\164\x75\162\145\163\134\120\162\157\x70\150\145\143\x79\134\105\155\x70\164\x79\x43\x6c\x61\163\163"); $mirror = new ClassMirror(); $this->expectException(\InvalidArgumentException::class); $mirror->reflect(null, array($class)); } public function it_throws_an_exception_if_not_reflection_provided_as_interface() { $mirror = new ClassMirror(); $this->expectException(\InvalidArgumentException::class); $mirror->reflect(null, array(null)); } public function it_doesnt_use_scalar_typehints() { if (PHP_VERSION_ID >= 80000) { $this->markTestSkipped("\111\156\x74\x65\162\x6e\141\154\x20\x74\x79\160\145\x73\40\150\x61\166\x65\40\x73\x63\141\154\x61\x72\x20\x68\x69\x6e\164\x73\x20\151\x6e\40\120\x48\x50\40\70"); } $mirror = new ClassMirror(); $classNode = $mirror->reflect(new \ReflectionClass("\122\145\x66\154\x65\x63\x74\x69\157\x6e\115\x65\x74\x68\157\144"), array()); $method = $classNode->getMethod("\145\170\x70\x6f\x72\164"); $arguments = $method->getArguments(); $this->assertEquals(new ArgumentTypeNode(), $arguments[0]->getTypeNode()); $this->assertEquals(new ArgumentTypeNode(), $arguments[1]->getTypeNode()); $this->assertEquals(new ArgumentTypeNode(), $arguments[2]->getTypeNode()); } public function it_doesnt_fail_to_typehint_nonexistent_FQCN() { $mirror = new ClassMirror(); $classNode = $mirror->reflect(new \ReflectionClass("\106\x69\170\164\x75\x72\145\x73\x5c\120\x72\x6f\160\x68\145\143\171\134\117\x70\x74\x69\x6f\x6e\141\x6c\104\145\x70\x73\103\x6c\141\163\x73"), array()); $method = $classNode->getMethod("\151\110\x61\166\145\101\123\x74\162\x61\156\147\x65\124\171\160\x65\110\x69\156\164\145\x64\101\x72\x67"); $arguments = $method->getArguments(); $this->assertEquals(new ArgumentTypeNode("\x49\x5c\123\151\155\160\x6c\x79\134\101\155\x5c\116\x6f\x6e\x65\170\151\x73\x74\x65\x6e\x74"), $arguments[0]->getTypeNode()); } public function it_doesnt_fail_on_array_nullable_parameter_with_not_null_default_value() { $mirror = new ClassMirror(); $classNode = $mirror->reflect(new \ReflectionClass("\x46\x69\x78\164\x75\162\145\x73\x5c\120\162\157\x70\x68\x65\143\x79\134\116\165\x6c\x6c\x61\142\154\145\101\162\x72\141\171\120\141\x72\x61\155\x65\x74\x65\x72"), array()); $method = $classNode->getMethod("\x69\x48\141\166\145\116\x75\x6c\154\141\142\154\145\x41\x72\x72\x61\171\120\141\x72\141\x6d\145\x74\145\162\127\151\164\150\116\x6f\164\116\165\x6c\x6c\x44\145\x66\141\165\x6c\x74\x56\x61\154\x75\x65"); $arguments = $method->getArguments(); $this->assertEquals(new ArgumentTypeNode("\x61\162\162\141\171", "\156\165\x6c\x6c"), $arguments[0]->getTypeNode()); } public function it_doesnt_fail_to_typehint_nonexistent_RQCN() { $mirror = new ClassMirror(); $classNode = $mirror->reflect(new \ReflectionClass("\106\151\x78\164\x75\162\145\163\x5c\x50\162\x6f\x70\150\x65\143\x79\134\117\160\164\x69\x6f\156\x61\154\x44\x65\x70\163\103\x6c\141\x73\x73"), array()); $method = $classNode->getMethod("\151\110\x61\166\x65\101\x6e\x45\166\x65\156\x53\x74\x72\141\156\147\x65\162\124\171\160\145\x48\151\156\164\145\x64\x41\x72\x67"); $arguments = $method->getArguments(); $this->assertEquals(new ArgumentTypeNode("\111\134\123\x69\x6d\x70\154\171\134\x41\155\x5c\116\x6f\164"), $arguments[0]->getTypeNode()); } function it_doesnt_fail_when_method_is_extended_with_more_params() { $mirror = new ClassMirror(); $classNode = $mirror->reflect(new \ReflectionClass("\106\151\170\x74\165\x72\145\163\134\x50\x72\157\x70\x68\145\143\171\134\x4d\145\164\x68\x6f\144\x57\151\x74\150\x41\x64\x64\151\x74\151\157\156\x61\154\120\141\x72\141\155"), array(new \ReflectionClass("\106\151\x78\164\165\162\x65\x73\x5c\120\x72\157\x70\150\x65\143\x79\134\x4e\141\155\145\x64"))); $method = $classNode->getMethod("\147\x65\x74\116\x61\155\x65"); $this->assertCount(1, $method->getArguments()); $method = $classNode->getMethod("\x6d\145\164\x68\157\x64\x57\x69\164\x68\157\165\164\x54\171\160\x65\110\151\x6e\x74\163"); $this->assertCount(2, $method->getArguments()); } function it_doesnt_fail_to_mock_self_referencing_interface() { $mirror = new ClassMirror(); $classNode = $mirror->reflect(null, array(new \ReflectionClass(SelfReferencing::class))); $method = $classNode->getMethod("\x5f\137\151\156\166\157\x6b\145"); $this->assertCount(1, $method->getArguments()); $this->assertEquals(new ArgumentTypeNode(SelfReferencing::class), $method->getArguments()[0]->getTypeNode()); $this->assertEquals(new ReturnTypeNode(SelfReferencing::class), $method->getReturnTypeNode()); } function it_changes_argument_names_if_they_are_varying() { $prophet = new Prophet(); $class = $prophet->prophesize("\122\x65\x66\154\x65\143\164\151\157\156\x43\154\x61\x73\163"); $method = $prophet->prophesize("\122\145\x66\154\145\x63\x74\151\x6f\156\115\x65\164\x68\157\144"); $parameter = $prophet->prophesize("\x52\x65\x66\x6c\145\x63\164\x69\x6f\x6e\120\x61\x72\x61\155\x65\164\145\162"); if (PHP_VERSION_ID >= 80200) { $class->isReadOnly()->willReturn(false); } $class->getName()->willReturn("\103\165\163\x74\157\x6d\x5c\103\x6c\141\x73\163\116\141\x6d\x65"); $class->isInterface()->willReturn(false); $class->isFinal()->willReturn(false); $class->getMethods(\ReflectionMethod::IS_PUBLIC)->willReturn(array($method)); $class->getMethods(\ReflectionMethod::IS_ABSTRACT)->willReturn(array()); $method->getParameters()->willReturn(array($parameter)); $method->getName()->willReturn("\155\x65\x74\150\x6f\144\116\141\155\145"); $method->isFinal()->willReturn(false); $method->isProtected()->willReturn(false); $method->isStatic()->willReturn(false); $method->returnsReference()->willReturn(false); $method->hasReturnType()->willReturn(false); $method->getDeclaringClass()->willReturn($class); if (\PHP_VERSION_ID >= 80100) { $method->hasTentativeReturnType()->willReturn(false); } $parameter->getName()->willReturn("\56\56\x2e"); $parameter->isDefaultValueAvailable()->willReturn(true); $parameter->getDefaultValue()->willReturn(null); $parameter->isPassedByReference()->willReturn(false); $parameter->allowsNull()->willReturn(true); $parameter->getClass()->willReturn($class); $parameter->getType()->willReturn(null); $parameter->hasType()->willReturn(false); $parameter->isVariadic()->willReturn(false); $mirror = new ClassMirror(); $classNode = $mirror->reflect($class->reveal(), array()); $methodNodes = $classNode->getMethods(); $argumentNodes = $methodNodes["\155\145\x74\150\157\144\x4e\141\x6d\x65"]->getArguments(); $argumentNode = $argumentNodes[0]; $this->assertEquals("\137\x5f\144\x6f\x74\137\144\x6f\x74\x5f\x64\x6f\164\x5f\137", $argumentNode->getName()); } public function it_can_double_a_class_with_union_return_types() { if (PHP_VERSION_ID < 80000) { $this->markTestSkipped("\x55\x6e\151\157\x6e\40\x74\x79\x70\x65\x73\x20\141\162\145\x20\x6e\x6f\x74\x20\x73\x75\160\x70\x6f\162\x74\x65\x64\x20\151\x6e\40\164\x68\151\x73\x20\x50\x48\120\40\166\145\x72\163\x69\x6f\x6e"); } $classNode = (new ClassMirror())->reflect(new \ReflectionClass("\x46\151\x78\x74\165\162\x65\163\134\120\x72\x6f\x70\x68\145\x63\171\x5c\125\x6e\x69\157\156\122\x65\x74\165\162\156\124\171\160\145\x73"), array()); $methodNode = $classNode->getMethods()["\x64\x6f\123\157\155\145\x74\150\x69\x6e\x67"]; $this->assertSame(array("\134\x73\x74\x64\103\x6c\x61\x73\163", "\x62\157\x6f\x6c"), $methodNode->getReturnTypeNode()->getTypes()); } public function it_can_double_a_class_with_union_return_type_with_false() { if (PHP_VERSION_ID < 80000) { $this->markTestSkipped("\125\156\x69\x6f\x6e\x20\x74\x79\x70\145\x73\40\167\x69\x74\150\40\146\141\x6c\163\145\x20\141\x72\x65\x20\x6e\157\164\x20\163\165\160\160\x6f\162\x74\x65\x64\40\x69\156\40\x74\x68\x69\x73\x20\x50\x48\120\40\166\145\162\163\x69\157\156"); } $classNode = (new ClassMirror())->reflect(new \ReflectionClass("\106\x69\x78\x74\x75\x72\145\x73\134\x50\162\x6f\x70\x68\145\143\171\x5c\x55\156\151\x6f\156\122\145\164\x75\162\x6e\x54\171\x70\145\106\141\x6c\x73\x65"), array()); $methodNode = $classNode->getMethods()["\155\x65\164\150\157\144"]; $this->assertSame(array("\x5c\x73\164\144\103\154\x61\x73\x73", "\146\141\x6c\x73\x65"), $methodNode->getReturnTypeNode()->getTypes()); } public function it_can_double_a_class_with_union_argument_types() { if (PHP_VERSION_ID < 80000) { $this->markTestSkipped("\125\156\x69\x6f\x6e\x20\164\x79\x70\x65\163\40\x61\x72\145\40\x6e\157\x74\x20\x73\x75\x70\160\157\162\164\x65\x64\40\x69\156\40\x74\150\151\x73\x20\x50\110\x50\40\166\145\x72\163\151\x6f\x6e"); } $classNode = (new ClassMirror())->reflect(new \ReflectionClass("\x46\151\170\x74\165\162\x65\163\x5c\120\x72\157\x70\x68\145\x63\171\134\x55\156\151\157\x6e\101\162\x67\x75\155\145\156\x74\x54\x79\160\145\163"), array()); $methodNode = $classNode->getMethods()["\144\x6f\x53\x6f\x6d\x65\x74\150\x69\156\147"]; $this->assertEquals(new ArgumentTypeNode("\x62\157\157\x6c", "\x5c\x73\x74\x64\103\154\141\x73\x73"), $methodNode->getArguments()[0]->getTypeNode()); } public function it_can_double_a_class_with_union_argument_type_with_false() { if (PHP_VERSION_ID < 80000) { $this->markTestSkipped("\x55\156\151\x6f\156\x20\164\171\x70\x65\x73\x20\x77\151\164\x68\40\x66\141\x6c\163\x65\40\x61\x72\x65\x20\156\x6f\164\x20\163\165\x70\x70\x6f\x72\164\x65\144\40\151\156\x20\164\150\151\163\x20\120\110\x50\40\166\145\x72\163\151\x6f\156"); } $classNode = (new ClassMirror())->reflect(new \ReflectionClass("\106\x69\170\164\165\x72\x65\163\x5c\x50\x72\157\160\150\145\x63\x79\x5c\125\x6e\x69\x6f\x6e\x41\162\147\165\155\145\156\164\124\171\160\145\106\141\x6c\163\x65"), array()); $methodNode = $classNode->getMethods()["\x6d\145\x74\150\x6f\x64"]; $this->assertEquals(new ArgumentTypeNode("\146\141\x6c\163\145", "\134\163\x74\144\103\x6c\141\x73\163"), $methodNode->getArguments()[0]->getTypeNode()); } public function it_can_double_a_class_with_mixed_types() { if (PHP_VERSION_ID < 80000) { $this->markTestSkipped("\x4d\151\170\x65\x64\x20\164\171\x70\145\x20\151\163\40\156\x6f\x74\40\x73\165\160\x70\157\162\x74\x65\x64\40\151\x6e\40\164\150\151\x73\40\120\x48\120\40\166\x65\x72\x73\151\x6f\x6e"); } $classNode = (new ClassMirror())->reflect(new \ReflectionClass("\106\151\x78\164\165\x72\145\163\x5c\120\x72\x6f\x70\150\145\143\x79\x5c\x4d\x69\170\145\x64\x54\171\160\x65\x73"), array()); $methodNode = $classNode->getMethods()["\144\x6f\123\157\x6d\145\x74\150\151\x6e\x67"]; $this->assertEquals(new ArgumentTypeNode("\155\x69\x78\x65\x64"), $methodNode->getArguments()[0]->getTypeNode()); $this->assertEquals(new ReturnTypeNode("\x6d\x69\x78\x65\x64"), $methodNode->getReturnTypeNode()); } public function it_can_double_inherited_self_return_type() { $classNode = (new ClassMirror())->reflect(new \ReflectionClass("\106\151\170\164\165\x72\145\x73\134\x50\x72\157\x70\150\x65\x63\171\x5c\103\x6c\141\163\163\x45\x78\x74\145\156\x64\x41\x62\x73\x74\x72\x61\143\164\127\151\x74\150\115\x65\x74\x68\x6f\x64\x57\x69\x74\150\x52\x65\x74\x75\162\156\124\x79\x70\x65"), array()); $methodNode = $classNode->getMethods()["\162\145\x74\x75\162\156\x53\145\x6c\x66"]; $this->assertEquals(new ReturnTypeNode("\106\151\170\x74\x75\x72\x65\163\x5c\x50\162\157\x70\x68\x65\143\171\x5c\x41\142\163\x74\162\x61\x63\x74\x42\x61\x73\145\x43\x6c\141\163\163\x57\151\164\150\x4d\145\x74\x68\x6f\x64\x57\151\x74\x68\x52\145\164\x75\x72\156\124\171\x70\x65"), $methodNode->getReturnTypeNode()); } public function it_can_double_never_return_type() { if (PHP_VERSION_ID < 80100) { $this->markTestSkipped("\x4e\x65\166\x65\162\x20\164\x79\x70\145\x20\x69\163\40\156\157\x74\x20\x73\x75\x70\x70\x6f\162\164\x65\144\x20\x69\156\x20\164\x68\x69\163\40\120\x48\x50\40\x76\x65\162\163\x69\157\156"); } $classNode = (new ClassMirror())->reflect(new \ReflectionClass("\x46\x69\170\164\x75\162\145\163\x5c\x50\x72\157\160\150\145\143\x79\134\116\x65\x76\x65\162\x54\x79\160\145"), array()); $methodNode = $classNode->getMethods()["\144\157\x53\x6f\155\145\x74\x68\x69\x6e\x67"]; $this->assertEquals(new ReturnTypeNode("\x6e\145\166\145\x72"), $methodNode->getReturnTypeNode()); } public function it_can_not_double_an_enum() { if (PHP_VERSION_ID < 80100) { $this->markTestSkipped("\x45\x6e\165\x6d\163\x20\141\x72\145\x20\x6e\x6f\x74\x20\163\x75\160\160\157\162\164\145\144\x20\151\x6e\x20\x74\150\x69\163\40\120\110\120\x20\x76\145\162\x73\x69\157\156"); } $this->expectException(ClassMirrorException::class); $classNode = (new ClassMirror())->reflect(new \ReflectionClass("\106\x69\x78\x74\x75\x72\145\163\134\x50\x72\157\160\x68\x65\143\171\134\105\x6e\x75\155"), array()); } public function it_can_not_double_intersection_return_types() { if (PHP_VERSION_ID < 80100) { $this->markTestSkipped("\x49\156\x74\x65\x72\x73\145\x63\164\x69\x6f\x6e\x20\x74\171\160\145\163\x20\x61\x72\145\x20\x6e\x6f\x74\40\x73\x75\x70\x70\x6f\162\x74\x65\144\x20\x69\156\40\164\150\151\163\40\120\x48\x50\x20\166\x65\162\163\151\157\156"); } $this->expectException(ClassMirrorException::class); $classNode = (new ClassMirror())->reflect(new \ReflectionClass("\106\151\170\164\x75\162\145\163\134\120\x72\157\x70\x68\145\x63\x79\134\x49\156\x74\145\x72\163\x65\x63\x74\151\157\156\x52\145\164\x75\162\x6e\x54\171\x70\x65"), array()); } public function it_can_not_double_intersection_argument_types() { if (PHP_VERSION_ID < 80100) { $this->markTestSkipped("\111\156\164\145\162\163\145\x63\x74\151\157\x6e\x20\164\x79\x70\145\163\40\141\x72\145\40\156\157\164\40\x73\x75\160\x70\157\x72\x74\x65\x64\x20\x69\x6e\x20\164\x68\151\x73\x20\x50\x48\x50\40\166\x65\162\163\151\x6f\x6e"); } $this->expectException(ClassMirrorException::class); $classNode = (new ClassMirror())->reflect(new \ReflectionClass("\x46\x69\170\x74\165\162\145\x73\x5c\x50\x72\157\160\x68\145\143\171\x5c\111\156\x74\145\162\x73\145\143\x74\x69\x6f\x6e\x41\162\x67\165\x6d\145\x6e\x74\x54\x79\160\145"), array()); } public function it_can_double_a_standalone_return_type_of_false() { if (PHP_VERSION_ID < 80200) { $this->markTestSkipped("\x53\164\x61\x6e\x64\141\154\157\156\145\x20\162\145\x74\165\x72\156\40\x74\x79\160\x65\x20\x6f\x66\40\146\x61\154\x73\x65\40\x69\163\x20\156\x6f\x74\x20\163\165\x70\x70\157\162\x74\x65\144\x20\x69\x6e\40\164\x68\151\163\x20\x50\x48\x50\x20\166\145\x72\163\151\x6f\156"); } $classNode = (new ClassMirror())->reflect(new \ReflectionClass("\x46\x69\x78\164\165\x72\x65\x73\134\x50\162\x6f\x70\x68\145\x63\171\134\123\164\x61\156\x64\x61\154\157\x6e\145\122\x65\x74\165\x72\x6e\124\171\x70\145\x46\x61\x6c\163\145"), array()); $methodNode = $classNode->getMethods()["\x6d\145\164\x68\157\x64"]; $this->assertEquals(new ReturnTypeNode("\146\141\154\163\145"), $methodNode->getReturnTypeNode()); } public function it_can_double_a_standalone_parameter_type_of_false() { if (PHP_VERSION_ID < 80200) { $this->markTestSkipped("\x53\164\x61\x6e\144\x61\x6c\157\156\145\x20\160\x61\x72\x61\x6d\x65\164\145\x72\x20\164\x79\160\145\40\157\146\x20\146\x61\x6c\x73\145\x20\151\x73\x20\156\x6f\164\40\x73\165\x70\160\157\x72\164\x65\x64\x20\151\x6e\40\x74\150\151\163\40\120\110\120\x20\x76\145\162\163\151\157\156"); } $classNode = (new ClassMirror())->reflect(new \ReflectionClass("\106\x69\x78\x74\x75\x72\145\163\134\x50\x72\x6f\x70\150\x65\x63\171\134\123\164\141\x6e\x64\x61\154\x6f\x6e\x65\x50\x61\162\141\x6d\x65\164\145\162\124\x79\160\145\106\141\x6c\163\x65"), array()); $method = $classNode->getMethod("\155\x65\x74\x68\x6f\144"); $arguments = $method->getArguments(); $this->assertEquals(new ArgumentTypeNode("\146\141\x6c\163\x65"), $arguments[0]->getTypeNode()); } public function it_can_double_a_nullable_return_type_of_false() { if (PHP_VERSION_ID < 80200) { $this->markTestSkipped("\x4e\x75\x6c\x6c\x61\142\154\x65\x20\162\145\x74\x75\x72\x6e\x20\x74\x79\160\x65\40\x6f\x66\40\146\141\154\163\145\x20\151\x73\x20\x6e\x6f\x74\x20\163\165\160\x70\157\162\x74\145\x64\40\x69\156\x20\164\150\151\163\x20\x50\x48\120\40\166\145\x72\163\x69\x6f\156"); } $classNode = (new ClassMirror())->reflect(new \ReflectionClass("\x46\151\x78\164\x75\x72\145\x73\134\120\162\x6f\x70\x68\x65\143\x79\134\x4e\165\154\x6c\141\142\154\x65\122\145\x74\x75\162\156\x54\x79\160\x65\x46\x61\x6c\163\145"), array()); $methodNode = $classNode->getMethods()["\155\145\x74\x68\x6f\144"]; $this->assertEquals(new ReturnTypeNode("\x6e\165\x6c\x6c", "\x66\141\154\x73\x65"), $methodNode->getReturnTypeNode()); } public function it_can_double_a_nullable_parameter_type_of_false() { if (PHP_VERSION_ID < 80200) { $this->markTestSkipped("\116\165\154\x6c\x61\142\x6c\145\40\x70\141\162\141\155\145\164\145\162\40\164\171\x70\x65\x20\157\x66\40\146\141\x6c\x73\145\40\x69\163\x20\156\x6f\x74\x20\x73\x75\160\x70\x6f\162\x74\145\x64\x20\x69\x6e\x20\164\150\x69\x73\x20\x50\x48\120\x20\166\x65\162\163\151\157\156"); } $classNode = (new ClassMirror())->reflect(new \ReflectionClass("\x46\x69\170\164\165\162\x65\163\134\120\162\157\x70\150\x65\143\171\x5c\x4e\x75\154\154\141\142\x6c\145\120\x61\x72\x61\x6d\x65\164\145\162\124\171\x70\145\x46\141\154\163\145"), array()); $method = $classNode->getMethod("\155\x65\164\x68\157\x64"); $arguments = $method->getArguments(); $this->assertEquals(new ArgumentTypeNode("\156\165\x6c\154", "\146\141\154\163\x65"), $arguments[0]->getTypeNode()); } public function it_can_not_double_dnf_intersection_argument_types() { if (PHP_VERSION_ID < 80200) { $this->markTestSkipped("\x44\x4e\x46\40\x69\156\164\145\162\x73\145\x63\164\151\157\156\x20\164\171\x70\x65\163\x20\x61\x72\145\x20\156\157\x74\x20\163\165\160\160\157\x72\164\x65\x64\40\151\156\40\164\150\151\163\40\x50\x48\x50\x20\x76\145\162\x73\151\x6f\x6e"); } $this->expectException(ClassMirrorException::class); $classNode = (new ClassMirror())->reflect(new \ReflectionClass("\106\x69\x78\164\165\x72\145\163\x5c\x50\162\157\x70\x68\145\143\171\x5c\x44\x6e\146\101\x72\x67\x75\155\x65\156\x74\124\x79\x70\145"), array()); } public function it_can_not_double_dnf_intersection_return_types() { if (PHP_VERSION_ID < 80200) { $this->markTestSkipped("\104\116\106\40\151\x6e\x74\145\162\163\145\x63\x74\x69\x6f\x6e\x20\164\171\x70\x65\163\40\141\162\x65\40\156\x6f\x74\x20\x73\165\160\x70\x6f\x72\x74\145\144\x20\x69\156\x20\164\x68\151\163\x20\120\110\120\40\x76\x65\x72\163\151\x6f\156"); } $this->expectException(ClassMirrorException::class); $classNode = (new ClassMirror())->reflect(new \ReflectionClass("\106\151\170\164\x75\x72\145\x73\x5c\x50\162\x6f\160\150\145\x63\171\134\x44\x6e\x66\122\145\x74\165\162\x6e\124\171\160\145"), array()); } public function it_can_double_a_standalone_return_type_of_true() { if (PHP_VERSION_ID < 80200) { $this->markTestSkipped("\123\x74\141\156\144\x61\154\157\x6e\145\40\x72\145\164\x75\x72\x6e\x20\x74\x79\x70\x65\40\x6f\x66\x20\164\162\165\x65\40\x69\x73\x20\156\157\164\40\x73\165\x70\x70\x6f\162\164\x65\x64\x20\x69\x6e\x20\164\150\x69\x73\40\x50\110\x50\x20\166\x65\x72\163\151\x6f\x6e"); } $classNode = (new ClassMirror())->reflect(new \ReflectionClass("\106\151\170\164\x75\162\x65\x73\134\x50\x72\x6f\160\x68\145\x63\171\x5c\123\164\141\156\x64\x61\154\x6f\x6e\145\x52\145\164\x75\x72\156\124\x79\x70\145\x54\x72\165\145"), array()); $methodNode = $classNode->getMethods()["\155\145\x74\150\x6f\x64"]; $this->assertEquals(new ReturnTypeNode("\164\162\x75\x65"), $methodNode->getReturnTypeNode()); } public function it_reflects_non_read_only_class() { $classNode = (new ClassMirror())->reflect(new \ReflectionClass("\x46\151\170\164\165\x72\x65\163\x5c\x50\162\x6f\x70\150\145\x63\x79\134\105\155\160\164\171\103\154\x61\163\x73"), array()); $this->assertFalse($classNode->isReadOnly()); } public function it_can_double_a_standalone_parameter_type_of_true() { if (PHP_VERSION_ID < 80200) { $this->markTestSkipped("\123\164\x61\x6e\144\x61\x6c\157\156\x65\x20\x70\x61\162\141\x6d\145\x74\x65\162\40\x74\x79\160\x65\x20\157\146\40\x74\162\x75\145\40\151\163\x20\156\157\164\40\163\x75\x70\x70\x6f\x72\x74\145\x64\40\x69\x6e\40\164\x68\151\163\40\x50\x48\120\x20\166\x65\x72\x73\151\157\156"); } $classNode = (new ClassMirror())->reflect(new \ReflectionClass("\x46\x69\170\x74\x75\162\x65\163\134\x50\162\x6f\160\x68\x65\x63\171\x5c\x53\164\x61\156\x64\141\154\x6f\156\145\120\x61\x72\141\155\x65\164\x65\x72\124\x79\x70\x65\x54\162\x75\x65"), array()); $method = $classNode->getMethod("\x6d\x65\164\x68\x6f\144"); $arguments = $method->getArguments(); $this->assertEquals(new ArgumentTypeNode("\164\x72\165\x65"), $arguments[0]->getTypeNode()); } public function it_can_double_a_nullable_return_type_of_true() { if (PHP_VERSION_ID < 80200) { $this->markTestSkipped("\116\x75\x6c\154\141\142\154\145\40\162\145\164\165\x72\x6e\40\x74\171\160\145\40\157\x66\40\x74\162\165\145\40\x69\163\40\x6e\x6f\164\40\163\x75\x70\x70\x6f\x72\164\145\144\40\151\x6e\x20\164\150\x69\163\x20\120\110\120\x20\166\145\x72\163\x69\x6f\156"); } $classNode = (new ClassMirror())->reflect(new \ReflectionClass("\x46\151\x78\x74\165\x72\x65\163\134\120\x72\x6f\160\x68\x65\143\x79\134\116\165\154\x6c\141\x62\154\145\x52\x65\x74\165\x72\156\124\171\x70\x65\124\x72\x75\145"), array()); $methodNode = $classNode->getMethods()["\155\145\164\150\157\x64"]; $this->assertEquals(new ReturnTypeNode("\x6e\x75\154\154", "\164\x72\x75\145"), $methodNode->getReturnTypeNode()); } public function it_can_double_a_nullable_parameter_type_of_true() { if (PHP_VERSION_ID < 80200) { $this->markTestSkipped("\116\x75\x6c\154\x61\x62\154\x65\40\160\x61\162\141\155\x65\x74\x65\162\x20\x74\171\x70\145\40\157\x66\x20\164\x72\165\x65\40\x69\x73\x20\156\x6f\x74\x20\x73\x75\x70\160\157\162\x74\x65\144\40\151\156\x20\x74\x68\151\163\40\x50\x48\x50\x20\x76\x65\x72\x73\151\157\x6e"); } $classNode = (new ClassMirror())->reflect(new \ReflectionClass("\106\151\x78\164\165\x72\145\163\134\x50\162\157\160\x68\x65\143\x79\134\116\165\x6c\x6c\141\142\x6c\145\120\x61\x72\x61\x6d\x65\x74\145\162\x54\x79\160\145\124\x72\165\x65"), array()); $method = $classNode->getMethod("\x6d\145\x74\x68\x6f\x64"); $arguments = $method->getArguments(); $this->assertEquals(new ArgumentTypeNode("\x6e\165\154\x6c", "\x74\162\x75\145"), $arguments[0]->getTypeNode()); } public function it_can_double_a_standalone_return_type_of_null() { if (PHP_VERSION_ID < 80200) { $this->markTestSkipped("\123\x74\141\x6e\144\141\x6c\x6f\x6e\x65\40\162\145\x74\165\162\x6e\x20\164\x79\160\x65\40\157\x66\x20\156\165\154\x6c\x20\x69\x73\x20\156\x6f\x74\x20\x73\x75\x70\x70\157\162\x74\x65\x64\x20\x69\x6e\x20\x74\x68\x69\163\40\x50\110\x50\40\166\145\162\163\x69\157\x6e"); } $classNode = (new ClassMirror())->reflect(new \ReflectionClass("\x46\x69\170\164\165\162\145\163\x5c\120\x72\x6f\160\150\145\143\x79\x5c\123\164\x61\156\144\x61\x6c\157\x6e\x65\x52\x65\164\165\162\156\124\171\160\x65\x4e\x75\x6c\154"), array()); $methodNode = $classNode->getMethods()["\x6d\145\x74\150\157\144"]; $this->assertEquals(new ReturnTypeNode("\x6e\x75\154\154"), $methodNode->getReturnTypeNode()); } public function it_can_double_a_standalone_parameter_type_of_null() { if (PHP_VERSION_ID < 80200) { $this->markTestSkipped("\123\x74\141\156\144\x61\154\x6f\x6e\x65\x20\160\x61\x72\141\155\145\164\x65\162\x20\164\171\160\x65\40\157\x66\x20\156\x75\154\154\40\x69\163\40\x6e\x6f\x74\x20\163\x75\160\160\x6f\162\x74\145\144\x20\151\156\40\x74\x68\151\x73\x20\x50\110\120\40\x76\145\x72\163\151\x6f\156"); } $classNode = (new ClassMirror())->reflect(new \ReflectionClass("\x46\x69\170\164\x75\162\145\163\x5c\x50\162\157\x70\150\x65\143\171\x5c\123\x74\141\156\144\x61\154\x6f\x6e\x65\120\x61\162\x61\x6d\x65\164\145\162\x54\171\x70\145\x4e\x75\x6c\154"), array()); $method = $classNode->getMethod("\155\x65\164\150\x6f\x64"); $arguments = $method->getArguments(); $this->assertEquals(new ArgumentTypeNode("\x6e\165\x6c\x6c"), $arguments[0]->getTypeNode()); } public function it_reflects_read_only_class() { if (PHP_VERSION_ID < 80200) { $this->markTestSkipped("\122\145\x61\x64\40\x6f\156\x6c\x79\x20\x63\x6c\141\163\x73\x65\x73\40\141\162\x65\x20\156\157\x74\x20\x73\165\x70\160\157\x72\164\145\x64\40\151\x6e\40\164\150\151\x73\x20\120\110\x50\40\x76\145\162\x73\151\157\156"); } $classNode = (new ClassMirror())->reflect(new \ReflectionClass("\x46\151\x78\164\x75\x72\145\x73\x5c\120\x72\157\x70\150\x65\143\171\134\122\145\x61\144\117\x6e\x6c\171\103\x6c\x61\163\x73"), array()); $this->assertTrue($classNode->isReadOnly()); } }

Function Calls

None

Variables

None

Stats

MD5 ab98fb8f0788b6f6802c79b33502d528
Eval Count 0
Decode Time 145 ms