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 phpDocumentor\Reflection; use Doctrine\Deprecations\PHPUnit\VerifyDeprec..
Decoded Output download
<?php
namespace phpDocumentor\Reflection; use Doctrine\Deprecations\PHPUnit\VerifyDeprecations; use InvalidArgumentException; use phpDocumentor\Reflection\PseudoTypes\ArrayShape; use phpDocumentor\Reflection\PseudoTypes\ArrayShapeItem; use phpDocumentor\Reflection\PseudoTypes\CallableString; use phpDocumentor\Reflection\PseudoTypes\ConstExpression; use phpDocumentor\Reflection\PseudoTypes\False_; use phpDocumentor\Reflection\PseudoTypes\FloatValue; use phpDocumentor\Reflection\PseudoTypes\HtmlEscapedString; use phpDocumentor\Reflection\PseudoTypes\IntegerRange; use phpDocumentor\Reflection\PseudoTypes\IntegerValue; use phpDocumentor\Reflection\PseudoTypes\List_; use phpDocumentor\Reflection\PseudoTypes\ListShape; use phpDocumentor\Reflection\PseudoTypes\ListShapeItem; use phpDocumentor\Reflection\PseudoTypes\LiteralString; use phpDocumentor\Reflection\PseudoTypes\LowercaseString; use phpDocumentor\Reflection\PseudoTypes\NegativeInteger; use phpDocumentor\Reflection\PseudoTypes\NonEmptyArray; use phpDocumentor\Reflection\PseudoTypes\NonEmptyList; use phpDocumentor\Reflection\PseudoTypes\NonEmptyLowercaseString; use phpDocumentor\Reflection\PseudoTypes\NonEmptyString; use phpDocumentor\Reflection\PseudoTypes\Numeric_; use phpDocumentor\Reflection\PseudoTypes\NumericString; use phpDocumentor\Reflection\PseudoTypes\ObjectShape; use phpDocumentor\Reflection\PseudoTypes\ObjectShapeItem; use phpDocumentor\Reflection\PseudoTypes\PositiveInteger; use phpDocumentor\Reflection\PseudoTypes\StringValue; use phpDocumentor\Reflection\PseudoTypes\TraitString; use phpDocumentor\Reflection\PseudoTypes\True_; use phpDocumentor\Reflection\Types\Array_; use phpDocumentor\Reflection\Types\ArrayKey; use phpDocumentor\Reflection\Types\Boolean; use phpDocumentor\Reflection\Types\Callable_; use phpDocumentor\Reflection\Types\CallableParameter; use phpDocumentor\Reflection\Types\ClassString; use phpDocumentor\Reflection\Types\Collection; use phpDocumentor\Reflection\Types\Compound; use phpDocumentor\Reflection\Types\Context; use phpDocumentor\Reflection\Types\Expression; use phpDocumentor\Reflection\Types\Float_; use phpDocumentor\Reflection\Types\Integer; use phpDocumentor\Reflection\Types\InterfaceString; use phpDocumentor\Reflection\Types\Intersection; use phpDocumentor\Reflection\Types\Iterable_; use phpDocumentor\Reflection\Types\Mixed_; use phpDocumentor\Reflection\Types\Never_; use phpDocumentor\Reflection\Types\Null_; use phpDocumentor\Reflection\Types\Nullable; use phpDocumentor\Reflection\Types\Object_; use phpDocumentor\Reflection\Types\Parent_; use phpDocumentor\Reflection\Types\Resource_; use phpDocumentor\Reflection\Types\Scalar; use phpDocumentor\Reflection\Types\Self_; use phpDocumentor\Reflection\Types\Static_; use phpDocumentor\Reflection\Types\String_; use phpDocumentor\Reflection\Types\This; use phpDocumentor\Reflection\Types\Void_; use PHPUnit\Framework\TestCase; use RuntimeException; use stdClass; use function get_class; class TypeResolverTest extends TestCase { use VerifyDeprecations; public function testResolvingKeywords(string $keyword, string $expectedClass) : void { $fixture = new TypeResolver(); $resolvedType = $fixture->resolve($keyword, new Context('')); $this->assertInstanceOf($expectedClass, $resolvedType); } public function testResolvingClassStrings(string $classString, bool $throwsException) : void { $fixture = new TypeResolver(); if ($throwsException) { $this->expectException(RuntimeException::class); } $resolvedType = $fixture->resolve($classString, new Context('')); $this->assertInstanceOf(ClassString::class, $resolvedType); } public function testResolvingInterfaceStrings(string $interfaceString, bool $throwsException) : void { $fixture = new TypeResolver(); if ($throwsException) { $this->expectException(RuntimeException::class); } $resolvedType = $fixture->resolve($interfaceString, new Context('')); $this->assertInstanceOf(InterfaceString::class, $resolvedType); } public function testResolvingFQSENs(string $fqsen) : void { $fixture = new TypeResolver(); $resolvedType = $fixture->resolve($fqsen, new Context('')); $this->assertInstanceOf(Object_::class, $resolvedType); $this->assertInstanceOf(Fqsen::class, $resolvedType->getFqsen()); $this->assertSame($fqsen, (string) $resolvedType); } public function testResolvingRelativeQSENsBasedOnNamespace() : void { $fixture = new TypeResolver(); $resolvedType = $fixture->resolve("DocBlock", new Context("phpDocumentor\Reflection")); $this->assertInstanceOf(Object_::class, $resolvedType); $this->assertInstanceOf(Fqsen::class, $resolvedType->getFqsen()); $this->assertSame("\phpDocumentor\Reflection\DocBlock", (string) $resolvedType); } public function testResolvingRelativeQSENsBasedOnNamespaceAlias() : void { $fixture = new TypeResolver(); $resolvedType = $fixture->resolve("m\Array_", new Context("phpDocumentor\Reflection", array("m" => "\phpDocumentor\Reflection\Types"))); $this->assertInstanceOf(Object_::class, $resolvedType); $this->assertInstanceOf(Fqsen::class, $resolvedType->getFqsen()); $this->assertSame("\phpDocumentor\Reflection\Types\Array_", (string) $resolvedType); } public function testResolvingTypedArrays() : void { $fixture = new TypeResolver(); $resolvedType = $fixture->resolve("string[]", new Context('')); $this->assertInstanceOf(Array_::class, $resolvedType); $this->assertSame("string[]", (string) $resolvedType); $this->assertInstanceOf(Compound::class, $resolvedType->getKeyType()); $this->assertInstanceOf(String_::class, $resolvedType->getValueType()); } public function testResolvingNullableTypes() : void { $fixture = new TypeResolver(); $resolvedType = $fixture->resolve("?string", new Context('')); $this->assertInstanceOf(Nullable::class, $resolvedType); $this->assertInstanceOf(String_::class, $resolvedType->getActualType()); $this->assertSame("?string", (string) $resolvedType); } public function testResolvingNestedTypedArrays() : void { $fixture = new TypeResolver(); $resolvedType = $fixture->resolve("string[][]", new Context('')); $childValueType = $resolvedType->getValueType(); $this->assertInstanceOf(Array_::class, $resolvedType); $this->assertSame("string[][]", (string) $resolvedType); $this->assertInstanceOf(Compound::class, $resolvedType->getKeyType()); $this->assertInstanceOf(Array_::class, $childValueType); $this->assertSame("string[]", (string) $childValueType); $this->assertInstanceOf(Compound::class, $childValueType->getKeyType()); $this->assertInstanceOf(String_::class, $childValueType->getValueType()); } public function testResolvingCompoundTypes() : void { $fixture = new TypeResolver(); $resolvedType = $fixture->resolve("string|Reflection\DocBlock", new Context("phpDocumentor")); $this->assertInstanceOf(Compound::class, $resolvedType); $this->assertSame("string|\phpDocumentor\Reflection\DocBlock", (string) $resolvedType); $firstType = $resolvedType->get(0); $secondType = $resolvedType->get(1); $this->assertInstanceOf(String_::class, $firstType); $this->assertInstanceOf(Object_::class, $secondType); $this->assertInstanceOf(Fqsen::class, $secondType->getFqsen()); } public function testResolvingAmpersandCompoundTypes() : void { $fixture = new TypeResolver(); $resolvedType = $fixture->resolve("Reflection\DocBlock&\PHPUnit\Framework\MockObject\MockObject ", new Context("phpDocumentor")); $this->assertInstanceOf(Intersection::class, $resolvedType); $this->assertSame("\phpDocumentor\Reflection\DocBlock&\PHPUnit\Framework\MockObject\MockObject", (string) $resolvedType); $firstType = $resolvedType->get(0); $secondType = $resolvedType->get(1); $this->assertInstanceOf(Object_::class, $firstType); $this->assertInstanceOf(Fqsen::class, $firstType->getFqsen()); $this->assertInstanceOf(Object_::class, $secondType); $this->assertInstanceOf(Fqsen::class, $secondType->getFqsen()); } public function testResolvingMixedCompoundTypes() : void { $fixture = new TypeResolver(); $resolvedType = $fixture->resolve("(Reflection\DocBlock&\PHPUnit\Framework\MockObject\MockObject)|null", new Context("phpDocumentor")); $this->assertInstanceOf(Compound::class, $resolvedType); $this->assertSame("(\phpDocumentor\Reflection\DocBlock&\PHPUnit\Framework\MockObject\MockObject)|null", (string) $resolvedType); $firstType = $resolvedType->get(0); $secondType = $resolvedType->get(1); $this->assertInstanceOf(Expression::class, $firstType); $this->assertSame("(\phpDocumentor\Reflection\DocBlock&\PHPUnit\Framework\MockObject\MockObject)", (string) $firstType); $this->assertInstanceOf(Null_::class, $secondType); $resolvedType = $firstType->getValueType(); $firstSubType = $resolvedType->get(0); $secondSubType = $resolvedType->get(1); $this->assertInstanceOf(Object_::class, $firstSubType); $this->assertInstanceOf(Fqsen::class, $secondSubType->getFqsen()); $this->assertInstanceOf(Object_::class, $secondSubType); $this->assertInstanceOf(Fqsen::class, $secondSubType->getFqsen()); } public function testResolvingCompoundTypedArrayTypes() : void { $fixture = new TypeResolver(); $resolvedType = $fixture->resolve("\stdClass[]|Reflection\DocBlock[]", new Context("phpDocumentor")); $this->assertInstanceOf(Compound::class, $resolvedType); $this->assertSame("\stdClass[]|\phpDocumentor\Reflection\DocBlock[]", (string) $resolvedType); $firstType = $resolvedType->get(0); $secondType = $resolvedType->get(1); $this->assertInstanceOf(Array_::class, $firstType); $this->assertInstanceOf(Array_::class, $secondType); $this->assertInstanceOf(Object_::class, $firstType->getValueType()); $this->assertInstanceOf(Object_::class, $secondType->getValueType()); } public function testResolvingArrayExpressionObjectsTypes() : void { $fixture = new TypeResolver(); $resolvedType = $fixture->resolve("(\stdClass|Reflection\DocBlock)[]", new Context("phpDocumentor")); $this->assertInstanceOf(Array_::class, $resolvedType); $this->assertSame("(\stdClass|\phpDocumentor\Reflection\DocBlock)[]", (string) $resolvedType); $valueType = $resolvedType->getValueType(); $this->assertInstanceOf(Compound::class, $valueType); $firstType = $valueType->get(0); $secondType = $valueType->get(1); $this->assertInstanceOf(Object_::class, $firstType); $this->assertInstanceOf(Object_::class, $secondType); } public function testResolvingArrayExpressionSimpleTypes() : void { $fixture = new TypeResolver(); $resolvedType = $fixture->resolve("(string|\stdClass|boolean)[]", new Context('')); $this->assertInstanceOf(Array_::class, $resolvedType); $this->assertSame("(string|\stdClass|bool)[]", (string) $resolvedType); $valueType = $resolvedType->getValueType(); $this->assertInstanceOf(Compound::class, $valueType); $firstType = $valueType->get(0); $secondType = $valueType->get(1); $thirdType = $valueType->get(2); $this->assertInstanceOf(String_::class, $firstType); $this->assertInstanceOf(Object_::class, $secondType); $this->assertInstanceOf(Boolean::class, $thirdType); } public function testResolvingArrayOfArrayExpressionTypes() : void { $fixture = new TypeResolver(); $resolvedType = $fixture->resolve("(string|\stdClass)[][]", new Context('')); $this->assertInstanceOf(Array_::class, $resolvedType); $this->assertSame("(string|\stdClass)[][]", (string) $resolvedType); $parentArrayType = $resolvedType->getValueType(); $this->assertInstanceOf(Array_::class, $parentArrayType); $valueType = $parentArrayType->getValueType(); $this->assertInstanceOf(Compound::class, $valueType); $firstType = $valueType->get(0); $secondType = $valueType->get(1); $this->assertInstanceOf(String_::class, $firstType); $this->assertInstanceOf(Object_::class, $secondType); } public function testReturnEmptyCompoundOnAnUnclosedArrayExpressionType() : void { $this->expectException(RuntimeException::class); $fixture = new TypeResolver(); $fixture->resolve("(string|\stdClass", new Context('')); } public function testResolvingArrayExpressionOrCompoundTypes() : void { $fixture = new TypeResolver(); $resolvedType = $fixture->resolve("\stdClass|(string|\stdClass)[]|bool", new Context('')); $this->assertInstanceOf(Compound::class, $resolvedType); $this->assertSame("\stdClass|(string|\stdClass)[]|bool", (string) $resolvedType); $firstType = $resolvedType->get(0); $this->assertInstanceOf(Object_::class, $firstType); $secondType = $resolvedType->get(1); $this->assertInstanceOf(Array_::class, $secondType); $thirdType = $resolvedType->get(2); $this->assertInstanceOf(Boolean::class, $thirdType); $valueType = $secondType->getValueType(); $this->assertInstanceOf(Compound::class, $valueType); $firstArrayType = $valueType->get(0); $secondArrayType = $valueType->get(1); $this->assertInstanceOf(String_::class, $firstArrayType); $this->assertInstanceOf(Object_::class, $secondArrayType); } public function testResolvingIterableExpressionSimpleTypes() : void { $fixture = new TypeResolver(); $resolvedType = $fixture->resolve("iterable<string|\stdClass|boolean>", new Context('')); $this->assertInstanceOf(Iterable_::class, $resolvedType); $this->assertSame("iterable<string|\stdClass|bool>", (string) $resolvedType); $valueType = $resolvedType->getValueType(); $this->assertInstanceOf(Compound::class, $valueType); $firstType = $valueType->get(0); $secondType = $valueType->get(1); $thirdType = $valueType->get(2); $this->assertInstanceOf(String_::class, $firstType); $this->assertInstanceOf(Object_::class, $secondType); $this->assertInstanceOf(Boolean::class, $thirdType); } public function testResolvingCompoundTypesWithTwoArrays() : void { $fixture = new TypeResolver(); $resolvedType = $fixture->resolve("integer[]|string[]", new Context('')); $this->assertInstanceOf(Compound::class, $resolvedType); $this->assertSame("int[]|string[]", (string) $resolvedType); $firstType = $resolvedType->get(0); $secondType = $resolvedType->get(1); $this->assertInstanceOf(Array_::class, $firstType); $this->assertInstanceOf(Integer::class, $firstType->getValueType()); $this->assertInstanceOf(Array_::class, $secondType); $this->assertInstanceOf(String_::class, $secondType->getValueType()); } public function testAddingAKeyword() : void { $typeMock = self::createStub(Type::class); $fixture = new TypeResolver(); $fixture->addKeyword("mock", get_class($typeMock)); $result = $fixture->resolve("mock", new Context('')); $this->assertInstanceOf(get_class($typeMock), $result); $this->assertNotSame($typeMock, $result); } public function testAddingAKeywordFailsIfTypeClassDoesNotExist() : void { $this->expectException(InvalidArgumentException::class); $fixture = new TypeResolver(); $fixture->addKeyword("mock", "IDoNotExist"); } public function testAddingAKeywordFailsIfTypeClassDoesNotImplementTypeInterface() : void { $this->expectException(InvalidArgumentException::class); $fixture = new TypeResolver(); $fixture->addKeyword("mock", stdClass::class); } public function testExceptionIsThrownIfTypeIsEmpty() : void { $this->expectException(InvalidArgumentException::class); $fixture = new TypeResolver(); $fixture->resolve(" ", new Context('')); } public function testInvalidArrayOperator() : void { $this->expectException(RuntimeException::class); $fixture = new TypeResolver(); $fixture->resolve("[]", new Context('')); } public function provideKeywords() : array { return array(array("string", String_::class), array("class-string", ClassString::class), array("html-escaped-string", HtmlEscapedString::class), array("lowercase-string", LowercaseString::class), array("non-empty-lowercase-string", NonEmptyLowercaseString::class), array("non-empty-string", NonEmptyString::class), array("numeric-string", NumericString::class), array("numeric", Numeric_::class), array("trait-string", TraitString::class), array("int", Integer::class), array("integer", Integer::class), array("positive-int", PositiveInteger::class), array("negative-int", NegativeInteger::class), array("float", Float_::class), array("double", Float_::class), array("bool", Boolean::class), array("boolean", Boolean::class), array("true", Boolean::class), array("true", True_::class), array("false", Boolean::class), array("false", False_::class), array("resource", Resource_::class), array("null", Null_::class), array("callable", Callable_::class), array("callable-string", CallableString::class), array("callback", Callable_::class), array("array", Array_::class), array("array-key", ArrayKey::class), array("scalar", Scalar::class), array("object", Object_::class), array("mixed", Mixed_::class), array("void", Void_::class), array("$this", This::class), array("static", Static_::class), array("self", Self_::class), array("parent", Parent_::class), array("iterable", Iterable_::class), array("never", Never_::class), array("literal-string", LiteralString::class), array("list", List_::class), array("non-empty-list", NonEmptyList::class), array("non-empty-array", NonEmptyArray::class)); } public function provideClassStrings() : array { return array(array("class-string<\phpDocumentor\Reflection>", false), array("class-string<\phpDocumentor\Reflection\DocBlock>", false), array("class-string<string>", true)); } public function provideInterfaceStrings() : array { return array(array("interface-string<\phpDocumentor\Reflection>", false), array("interface-string<\phpDocumentor\Reflection\DocBlock>", false), array("interface-string<string>", true)); } public function provideFqcn() : array { return array("namespace" => array("\phpDocumentor\Reflection"), "class" => array("\phpDocumentor\Reflection\DocBlock"), "class with emoji" => array("\My\360\x9f\x98\x81Class")); } public function testArrayKeyValueSpecification() : void { $fixture = new TypeResolver(); $type = $fixture->resolve("array<string,array<int,string>>", new Context('')); $this->assertEquals(new Array_(new Array_(new String_(), new Integer()), new String_()), $type); } public function testTypeBuilding(string $type, Type $expected, bool $deprecation = false) : void { if ($deprecation) { $this->expectDeprecationWithIdentifier("https://github.com/phpDocumentor/TypeResolver/issues/184"); } else { $this->expectNoDeprecationWithIdentifier("https://github.com/phpDocumentor/TypeResolver/issues/184"); } $fixture = new TypeResolver(); $actual = $fixture->resolve($type, new Context("phpDocumentor")); self::assertEquals($expected, $actual); } public function typeProvider() : array { return array(array("string", new String_()), array("( string )", new String_()), array("\Foo\Bar\Baz", new Object_(new Fqsen("\Foo\Bar\Baz"))), array("string|int", new Compound(array(new String_(), new Integer()))), array("string&int", new Intersection(array(new String_(), new Integer()))), array("string & (int | float)", new Intersection(array(new String_(), new Expression(new Compound(array(new Integer(), new Float_())))))), array("string[]", new Array_(new String_())), array("$this", new This()), array("?int", new Nullable(new Integer())), array("self", new Self_())); } public function genericsProvider() : array { return array(array("array<int, Foo\Bar>", new Array_(new Object_(new Fqsen("\phpDocumentor\Foo\Bar")), new Integer())), array("array<string|int, Foo\Bar>", new Array_(new Object_(new Fqsen("\phpDocumentor\Foo\Bar")), new Compound(array(new String_(), new Integer())))), array("Collection<array-key, int>[]", new Array_(new Collection(new Fqsen("\phpDocumentor\Collection"), new Integer(), new ArrayKey()))), array("class-string", new ClassString(null)), array("class-string<Foo>", new ClassString(new Fqsen("\phpDocumentor\Foo"))), array("interface-string<Foo>", new InterfaceString(new Fqsen("\phpDocumentor\Foo"))), array("List<Foo>", new List_(new Object_(new Fqsen("\phpDocumentor\Foo")))), array("int<1, 100>", new IntegerRange("1", "100"))); } public function callableProvider() : array { return array(array("callable", new Callable_()), array("callable()", new Callable_()), array("callable(): Foo", new Callable_(array(), new Object_(new Fqsen("\phpDocumentor\Foo")))), array("callable(): (Foo&Bar)", new Callable_(array(), new Intersection(array(new Object_(new Fqsen("\phpDocumentor\Foo")), new Object_(new Fqsen("\phpDocumentor\Bar")))))), array("callable(A&...$a=, B&...=, C): Foo", new Callable_(array(new CallableParameter(new Object_(new Fqsen("\phpDocumentor\A")), "a", true, true, true), new CallableParameter(new Object_(new Fqsen("\phpDocumentor\B")), null, true, true, true), new CallableParameter(new Object_(new Fqsen("\phpDocumentor\C")), null, false, false, false)), new Object_(new Fqsen("\phpDocumentor\Foo"))))); } public function constExpressions() : array { return array(array("123", new IntegerValue(123)), array("true", new True_()), array("123.2", new FloatValue(123.2)), array(""bar"", new StringValue("bar")), array("Foo::FOO_CONSTANT", new ConstExpression(new Object_(new Fqsen("\phpDocumentor\Foo")), "FOO_CONSTANT")), array("Foo::FOO_*", new ConstExpression(new Object_(new Fqsen("\phpDocumentor\Foo")), "FOO_*")), array("self::*|null", new Compound(array(new ConstExpression(new Self_(), "*"), new Null_())))); } public function shapeStructures() : array { return array(array("array{foo: string, bar: int}", new ArrayShape(new ArrayShapeItem("foo", new String_(), false), new ArrayShapeItem("bar", new Integer(), false))), array("array{foo?: string, bar: int}", new ArrayShape(new ArrayShapeItem("foo", new String_(), true), new ArrayShapeItem("bar", new Integer(), false))), array("object{foo: string, bar: int}", new ObjectShape(new ObjectShapeItem("foo", new String_(), false), new ObjectShapeItem("bar", new Integer(), false))), array("list{1}", new ListShape(new ListShapeItem(null, new IntegerValue(1), false)))); } public function illegalLegacyFormatProvider() : array { return array(array("?string |bool", new Compound(array(new Nullable(new String_()), new Boolean())), true), array("?string|?bool", new Compound(array(new Nullable(new String_()), new Nullable(new Boolean()))), true), array("?string|?bool|null", new Compound(array(new Nullable(new String_()), new Nullable(new Boolean()), new Null_())), true), array("?string|bool|Foo", new Compound(array(new Nullable(new String_()), new Boolean(), new Object_(new Fqsen("\phpDocumentor\Foo")))), true), array("?string&bool", new Intersection(array(new Nullable(new String_()), new Boolean())), true), array("?string&bool|Foo", new Intersection(array(new Nullable(new String_()), new Compound(array(new Boolean(), new Object_(new Fqsen("\phpDocumentor\Foo")))))), true), array("?string&?bool|null", new Compound(array(new Intersection(array(new Nullable(new String_()), new Nullable(new Boolean()))), new Null_())), true)); } } ?>
Did this file decode correctly?
Original Code
<?php
namespace phpDocumentor\Reflection; use Doctrine\Deprecations\PHPUnit\VerifyDeprecations; use InvalidArgumentException; use phpDocumentor\Reflection\PseudoTypes\ArrayShape; use phpDocumentor\Reflection\PseudoTypes\ArrayShapeItem; use phpDocumentor\Reflection\PseudoTypes\CallableString; use phpDocumentor\Reflection\PseudoTypes\ConstExpression; use phpDocumentor\Reflection\PseudoTypes\False_; use phpDocumentor\Reflection\PseudoTypes\FloatValue; use phpDocumentor\Reflection\PseudoTypes\HtmlEscapedString; use phpDocumentor\Reflection\PseudoTypes\IntegerRange; use phpDocumentor\Reflection\PseudoTypes\IntegerValue; use phpDocumentor\Reflection\PseudoTypes\List_; use phpDocumentor\Reflection\PseudoTypes\ListShape; use phpDocumentor\Reflection\PseudoTypes\ListShapeItem; use phpDocumentor\Reflection\PseudoTypes\LiteralString; use phpDocumentor\Reflection\PseudoTypes\LowercaseString; use phpDocumentor\Reflection\PseudoTypes\NegativeInteger; use phpDocumentor\Reflection\PseudoTypes\NonEmptyArray; use phpDocumentor\Reflection\PseudoTypes\NonEmptyList; use phpDocumentor\Reflection\PseudoTypes\NonEmptyLowercaseString; use phpDocumentor\Reflection\PseudoTypes\NonEmptyString; use phpDocumentor\Reflection\PseudoTypes\Numeric_; use phpDocumentor\Reflection\PseudoTypes\NumericString; use phpDocumentor\Reflection\PseudoTypes\ObjectShape; use phpDocumentor\Reflection\PseudoTypes\ObjectShapeItem; use phpDocumentor\Reflection\PseudoTypes\PositiveInteger; use phpDocumentor\Reflection\PseudoTypes\StringValue; use phpDocumentor\Reflection\PseudoTypes\TraitString; use phpDocumentor\Reflection\PseudoTypes\True_; use phpDocumentor\Reflection\Types\Array_; use phpDocumentor\Reflection\Types\ArrayKey; use phpDocumentor\Reflection\Types\Boolean; use phpDocumentor\Reflection\Types\Callable_; use phpDocumentor\Reflection\Types\CallableParameter; use phpDocumentor\Reflection\Types\ClassString; use phpDocumentor\Reflection\Types\Collection; use phpDocumentor\Reflection\Types\Compound; use phpDocumentor\Reflection\Types\Context; use phpDocumentor\Reflection\Types\Expression; use phpDocumentor\Reflection\Types\Float_; use phpDocumentor\Reflection\Types\Integer; use phpDocumentor\Reflection\Types\InterfaceString; use phpDocumentor\Reflection\Types\Intersection; use phpDocumentor\Reflection\Types\Iterable_; use phpDocumentor\Reflection\Types\Mixed_; use phpDocumentor\Reflection\Types\Never_; use phpDocumentor\Reflection\Types\Null_; use phpDocumentor\Reflection\Types\Nullable; use phpDocumentor\Reflection\Types\Object_; use phpDocumentor\Reflection\Types\Parent_; use phpDocumentor\Reflection\Types\Resource_; use phpDocumentor\Reflection\Types\Scalar; use phpDocumentor\Reflection\Types\Self_; use phpDocumentor\Reflection\Types\Static_; use phpDocumentor\Reflection\Types\String_; use phpDocumentor\Reflection\Types\This; use phpDocumentor\Reflection\Types\Void_; use PHPUnit\Framework\TestCase; use RuntimeException; use stdClass; use function get_class; class TypeResolverTest extends TestCase { use VerifyDeprecations; public function testResolvingKeywords(string $keyword, string $expectedClass) : void { $fixture = new TypeResolver(); $resolvedType = $fixture->resolve($keyword, new Context('')); $this->assertInstanceOf($expectedClass, $resolvedType); } public function testResolvingClassStrings(string $classString, bool $throwsException) : void { $fixture = new TypeResolver(); if ($throwsException) { $this->expectException(RuntimeException::class); } $resolvedType = $fixture->resolve($classString, new Context('')); $this->assertInstanceOf(ClassString::class, $resolvedType); } public function testResolvingInterfaceStrings(string $interfaceString, bool $throwsException) : void { $fixture = new TypeResolver(); if ($throwsException) { $this->expectException(RuntimeException::class); } $resolvedType = $fixture->resolve($interfaceString, new Context('')); $this->assertInstanceOf(InterfaceString::class, $resolvedType); } public function testResolvingFQSENs(string $fqsen) : void { $fixture = new TypeResolver(); $resolvedType = $fixture->resolve($fqsen, new Context('')); $this->assertInstanceOf(Object_::class, $resolvedType); $this->assertInstanceOf(Fqsen::class, $resolvedType->getFqsen()); $this->assertSame($fqsen, (string) $resolvedType); } public function testResolvingRelativeQSENsBasedOnNamespace() : void { $fixture = new TypeResolver(); $resolvedType = $fixture->resolve("\104\157\143\102\154\x6f\143\153", new Context("\160\150\x70\x44\x6f\x63\x75\x6d\145\x6e\x74\x6f\162\134\122\145\146\x6c\145\143\164\x69\x6f\156")); $this->assertInstanceOf(Object_::class, $resolvedType); $this->assertInstanceOf(Fqsen::class, $resolvedType->getFqsen()); $this->assertSame("\x5c\160\150\x70\104\157\x63\x75\155\145\x6e\164\157\x72\134\122\145\x66\154\145\143\164\151\157\x6e\134\104\157\143\x42\154\x6f\x63\x6b", (string) $resolvedType); } public function testResolvingRelativeQSENsBasedOnNamespaceAlias() : void { $fixture = new TypeResolver(); $resolvedType = $fixture->resolve("\x6d\x5c\x41\x72\162\x61\171\137", new Context("\160\x68\x70\x44\157\x63\x75\155\145\x6e\x74\x6f\x72\x5c\122\145\146\x6c\145\143\164\x69\157\x6e", array("\155" => "\x5c\160\x68\x70\x44\x6f\143\x75\155\145\156\x74\x6f\162\x5c\122\145\146\154\x65\x63\x74\151\x6f\156\134\124\171\x70\145\x73"))); $this->assertInstanceOf(Object_::class, $resolvedType); $this->assertInstanceOf(Fqsen::class, $resolvedType->getFqsen()); $this->assertSame("\134\160\x68\x70\104\x6f\143\x75\155\145\156\164\157\x72\134\x52\x65\146\x6c\x65\143\x74\151\x6f\x6e\134\124\x79\x70\x65\x73\x5c\101\x72\x72\x61\x79\137", (string) $resolvedType); } public function testResolvingTypedArrays() : void { $fixture = new TypeResolver(); $resolvedType = $fixture->resolve("\163\164\162\x69\x6e\147\x5b\x5d", new Context('')); $this->assertInstanceOf(Array_::class, $resolvedType); $this->assertSame("\x73\164\162\x69\156\x67\x5b\135", (string) $resolvedType); $this->assertInstanceOf(Compound::class, $resolvedType->getKeyType()); $this->assertInstanceOf(String_::class, $resolvedType->getValueType()); } public function testResolvingNullableTypes() : void { $fixture = new TypeResolver(); $resolvedType = $fixture->resolve("\x3f\x73\x74\x72\x69\156\x67", new Context('')); $this->assertInstanceOf(Nullable::class, $resolvedType); $this->assertInstanceOf(String_::class, $resolvedType->getActualType()); $this->assertSame("\77\163\164\162\x69\156\147", (string) $resolvedType); } public function testResolvingNestedTypedArrays() : void { $fixture = new TypeResolver(); $resolvedType = $fixture->resolve("\x73\164\162\151\156\x67\133\x5d\133\135", new Context('')); $childValueType = $resolvedType->getValueType(); $this->assertInstanceOf(Array_::class, $resolvedType); $this->assertSame("\x73\x74\x72\x69\x6e\x67\133\135\x5b\x5d", (string) $resolvedType); $this->assertInstanceOf(Compound::class, $resolvedType->getKeyType()); $this->assertInstanceOf(Array_::class, $childValueType); $this->assertSame("\x73\x74\x72\x69\x6e\x67\133\135", (string) $childValueType); $this->assertInstanceOf(Compound::class, $childValueType->getKeyType()); $this->assertInstanceOf(String_::class, $childValueType->getValueType()); } public function testResolvingCompoundTypes() : void { $fixture = new TypeResolver(); $resolvedType = $fixture->resolve("\x73\x74\x72\x69\156\x67\x7c\122\x65\146\x6c\x65\143\164\x69\157\156\x5c\104\x6f\143\x42\x6c\157\143\x6b", new Context("\160\x68\x70\x44\x6f\x63\165\x6d\145\156\x74\157\x72")); $this->assertInstanceOf(Compound::class, $resolvedType); $this->assertSame("\x73\x74\x72\151\x6e\x67\x7c\x5c\x70\x68\x70\104\157\143\165\155\145\x6e\x74\x6f\x72\134\122\x65\146\154\145\x63\x74\x69\157\156\x5c\104\x6f\143\x42\154\x6f\143\153", (string) $resolvedType); $firstType = $resolvedType->get(0); $secondType = $resolvedType->get(1); $this->assertInstanceOf(String_::class, $firstType); $this->assertInstanceOf(Object_::class, $secondType); $this->assertInstanceOf(Fqsen::class, $secondType->getFqsen()); } public function testResolvingAmpersandCompoundTypes() : void { $fixture = new TypeResolver(); $resolvedType = $fixture->resolve("\122\x65\146\x6c\x65\x63\x74\151\157\x6e\x5c\104\157\143\102\x6c\157\143\153\x26\x5c\120\110\x50\x55\x6e\x69\x74\134\106\x72\141\x6d\x65\x77\x6f\x72\153\134\x4d\x6f\x63\x6b\117\x62\x6a\x65\143\164\x5c\x4d\x6f\x63\153\117\x62\152\145\143\x74\x20", new Context("\x70\150\x70\104\x6f\x63\165\155\145\156\x74\157\162")); $this->assertInstanceOf(Intersection::class, $resolvedType); $this->assertSame("\x5c\x70\150\160\104\x6f\143\x75\155\145\x6e\164\x6f\x72\x5c\x52\x65\x66\x6c\145\143\x74\x69\157\156\x5c\104\x6f\143\102\x6c\157\x63\x6b\46\x5c\x50\110\120\x55\x6e\151\x74\134\x46\162\141\155\x65\x77\157\162\153\x5c\x4d\157\x63\x6b\117\x62\152\x65\143\164\x5c\x4d\x6f\x63\x6b\x4f\x62\152\x65\x63\164", (string) $resolvedType); $firstType = $resolvedType->get(0); $secondType = $resolvedType->get(1); $this->assertInstanceOf(Object_::class, $firstType); $this->assertInstanceOf(Fqsen::class, $firstType->getFqsen()); $this->assertInstanceOf(Object_::class, $secondType); $this->assertInstanceOf(Fqsen::class, $secondType->getFqsen()); } public function testResolvingMixedCompoundTypes() : void { $fixture = new TypeResolver(); $resolvedType = $fixture->resolve("\x28\122\x65\x66\x6c\x65\143\x74\x69\157\156\134\104\157\x63\102\x6c\157\x63\153\46\x5c\x50\110\x50\x55\156\x69\x74\134\x46\x72\x61\x6d\x65\167\x6f\162\153\x5c\x4d\x6f\143\x6b\x4f\x62\x6a\x65\x63\164\x5c\115\x6f\x63\153\x4f\x62\x6a\145\x63\x74\51\x7c\156\165\x6c\154", new Context("\160\150\160\x44\x6f\x63\x75\x6d\x65\156\x74\157\x72")); $this->assertInstanceOf(Compound::class, $resolvedType); $this->assertSame("\x28\134\x70\x68\x70\x44\x6f\x63\x75\x6d\145\156\164\x6f\x72\134\122\x65\146\x6c\x65\x63\x74\151\x6f\156\x5c\104\157\143\102\x6c\x6f\x63\153\x26\134\120\110\x50\125\x6e\x69\x74\134\x46\x72\x61\155\145\167\157\162\153\x5c\x4d\157\143\x6b\117\142\152\145\x63\164\x5c\115\157\143\x6b\x4f\142\152\x65\143\x74\x29\x7c\156\x75\x6c\154", (string) $resolvedType); $firstType = $resolvedType->get(0); $secondType = $resolvedType->get(1); $this->assertInstanceOf(Expression::class, $firstType); $this->assertSame("\x28\x5c\160\x68\x70\104\157\x63\165\155\145\156\164\x6f\x72\x5c\122\145\146\154\x65\x63\x74\151\157\156\x5c\104\x6f\x63\x42\x6c\x6f\143\153\46\134\120\110\x50\125\156\x69\x74\x5c\106\162\x61\x6d\145\167\157\162\x6b\134\115\157\x63\x6b\x4f\142\x6a\x65\x63\164\x5c\x4d\x6f\x63\x6b\x4f\x62\152\145\x63\x74\x29", (string) $firstType); $this->assertInstanceOf(Null_::class, $secondType); $resolvedType = $firstType->getValueType(); $firstSubType = $resolvedType->get(0); $secondSubType = $resolvedType->get(1); $this->assertInstanceOf(Object_::class, $firstSubType); $this->assertInstanceOf(Fqsen::class, $secondSubType->getFqsen()); $this->assertInstanceOf(Object_::class, $secondSubType); $this->assertInstanceOf(Fqsen::class, $secondSubType->getFqsen()); } public function testResolvingCompoundTypedArrayTypes() : void { $fixture = new TypeResolver(); $resolvedType = $fixture->resolve("\134\163\164\144\103\154\141\x73\x73\x5b\x5d\x7c\x52\x65\x66\x6c\145\143\x74\151\157\x6e\x5c\x44\157\143\102\154\157\x63\x6b\x5b\x5d", new Context("\160\x68\x70\104\157\143\x75\x6d\x65\x6e\x74\x6f\162")); $this->assertInstanceOf(Compound::class, $resolvedType); $this->assertSame("\134\163\164\x64\103\154\x61\163\163\x5b\135\x7c\134\x70\150\160\104\157\x63\x75\155\145\x6e\164\x6f\162\x5c\x52\145\x66\x6c\145\x63\164\151\157\x6e\x5c\104\x6f\143\102\154\157\143\153\133\x5d", (string) $resolvedType); $firstType = $resolvedType->get(0); $secondType = $resolvedType->get(1); $this->assertInstanceOf(Array_::class, $firstType); $this->assertInstanceOf(Array_::class, $secondType); $this->assertInstanceOf(Object_::class, $firstType->getValueType()); $this->assertInstanceOf(Object_::class, $secondType->getValueType()); } public function testResolvingArrayExpressionObjectsTypes() : void { $fixture = new TypeResolver(); $resolvedType = $fixture->resolve("\50\x5c\163\x74\x64\x43\x6c\x61\163\163\174\122\145\x66\154\x65\x63\164\151\x6f\156\134\104\x6f\143\102\154\x6f\143\x6b\x29\x5b\135", new Context("\160\150\160\104\157\x63\165\155\145\x6e\164\157\162")); $this->assertInstanceOf(Array_::class, $resolvedType); $this->assertSame("\50\134\x73\x74\x64\x43\154\141\163\x73\174\134\x70\150\x70\104\x6f\143\x75\x6d\x65\x6e\x74\157\162\x5c\x52\145\x66\x6c\145\x63\x74\x69\157\x6e\x5c\x44\157\143\102\x6c\157\x63\153\51\133\x5d", (string) $resolvedType); $valueType = $resolvedType->getValueType(); $this->assertInstanceOf(Compound::class, $valueType); $firstType = $valueType->get(0); $secondType = $valueType->get(1); $this->assertInstanceOf(Object_::class, $firstType); $this->assertInstanceOf(Object_::class, $secondType); } public function testResolvingArrayExpressionSimpleTypes() : void { $fixture = new TypeResolver(); $resolvedType = $fixture->resolve("\50\163\164\162\x69\x6e\147\x7c\134\163\x74\x64\x43\x6c\x61\x73\x73\174\142\157\x6f\x6c\145\x61\x6e\51\133\135", new Context('')); $this->assertInstanceOf(Array_::class, $resolvedType); $this->assertSame("\50\x73\x74\162\x69\x6e\x67\x7c\x5c\x73\x74\144\x43\x6c\x61\163\x73\x7c\142\157\x6f\x6c\51\133\135", (string) $resolvedType); $valueType = $resolvedType->getValueType(); $this->assertInstanceOf(Compound::class, $valueType); $firstType = $valueType->get(0); $secondType = $valueType->get(1); $thirdType = $valueType->get(2); $this->assertInstanceOf(String_::class, $firstType); $this->assertInstanceOf(Object_::class, $secondType); $this->assertInstanceOf(Boolean::class, $thirdType); } public function testResolvingArrayOfArrayExpressionTypes() : void { $fixture = new TypeResolver(); $resolvedType = $fixture->resolve("\x28\163\x74\162\151\156\147\x7c\x5c\163\164\x64\103\x6c\x61\163\163\x29\x5b\x5d\133\135", new Context('')); $this->assertInstanceOf(Array_::class, $resolvedType); $this->assertSame("\50\x73\x74\162\x69\x6e\147\x7c\x5c\163\x74\144\x43\x6c\x61\163\x73\x29\x5b\135\133\135", (string) $resolvedType); $parentArrayType = $resolvedType->getValueType(); $this->assertInstanceOf(Array_::class, $parentArrayType); $valueType = $parentArrayType->getValueType(); $this->assertInstanceOf(Compound::class, $valueType); $firstType = $valueType->get(0); $secondType = $valueType->get(1); $this->assertInstanceOf(String_::class, $firstType); $this->assertInstanceOf(Object_::class, $secondType); } public function testReturnEmptyCompoundOnAnUnclosedArrayExpressionType() : void { $this->expectException(RuntimeException::class); $fixture = new TypeResolver(); $fixture->resolve("\50\x73\x74\162\x69\x6e\147\x7c\134\163\x74\144\x43\x6c\141\x73\x73", new Context('')); } public function testResolvingArrayExpressionOrCompoundTypes() : void { $fixture = new TypeResolver(); $resolvedType = $fixture->resolve("\x5c\163\164\x64\x43\x6c\x61\163\x73\x7c\50\x73\164\x72\x69\x6e\x67\174\134\163\164\x64\103\x6c\x61\x73\163\51\133\x5d\x7c\x62\157\157\154", new Context('')); $this->assertInstanceOf(Compound::class, $resolvedType); $this->assertSame("\x5c\163\x74\x64\x43\154\141\163\x73\174\x28\163\164\x72\151\156\x67\174\x5c\163\164\144\103\x6c\x61\x73\163\x29\133\135\174\x62\x6f\157\x6c", (string) $resolvedType); $firstType = $resolvedType->get(0); $this->assertInstanceOf(Object_::class, $firstType); $secondType = $resolvedType->get(1); $this->assertInstanceOf(Array_::class, $secondType); $thirdType = $resolvedType->get(2); $this->assertInstanceOf(Boolean::class, $thirdType); $valueType = $secondType->getValueType(); $this->assertInstanceOf(Compound::class, $valueType); $firstArrayType = $valueType->get(0); $secondArrayType = $valueType->get(1); $this->assertInstanceOf(String_::class, $firstArrayType); $this->assertInstanceOf(Object_::class, $secondArrayType); } public function testResolvingIterableExpressionSimpleTypes() : void { $fixture = new TypeResolver(); $resolvedType = $fixture->resolve("\151\x74\x65\x72\141\x62\x6c\x65\74\163\164\162\151\x6e\x67\174\134\x73\x74\x64\103\154\x61\163\x73\x7c\142\x6f\x6f\x6c\145\x61\x6e\76", new Context('')); $this->assertInstanceOf(Iterable_::class, $resolvedType); $this->assertSame("\151\x74\145\x72\x61\x62\154\x65\74\x73\164\162\x69\x6e\147\174\x5c\163\x74\x64\103\154\x61\163\x73\x7c\x62\x6f\x6f\x6c\x3e", (string) $resolvedType); $valueType = $resolvedType->getValueType(); $this->assertInstanceOf(Compound::class, $valueType); $firstType = $valueType->get(0); $secondType = $valueType->get(1); $thirdType = $valueType->get(2); $this->assertInstanceOf(String_::class, $firstType); $this->assertInstanceOf(Object_::class, $secondType); $this->assertInstanceOf(Boolean::class, $thirdType); } public function testResolvingCompoundTypesWithTwoArrays() : void { $fixture = new TypeResolver(); $resolvedType = $fixture->resolve("\151\x6e\x74\145\147\145\x72\x5b\135\x7c\x73\164\162\151\156\147\133\135", new Context('')); $this->assertInstanceOf(Compound::class, $resolvedType); $this->assertSame("\151\156\x74\x5b\x5d\174\163\x74\x72\151\156\147\133\135", (string) $resolvedType); $firstType = $resolvedType->get(0); $secondType = $resolvedType->get(1); $this->assertInstanceOf(Array_::class, $firstType); $this->assertInstanceOf(Integer::class, $firstType->getValueType()); $this->assertInstanceOf(Array_::class, $secondType); $this->assertInstanceOf(String_::class, $secondType->getValueType()); } public function testAddingAKeyword() : void { $typeMock = self::createStub(Type::class); $fixture = new TypeResolver(); $fixture->addKeyword("\155\x6f\143\153", get_class($typeMock)); $result = $fixture->resolve("\155\x6f\143\x6b", new Context('')); $this->assertInstanceOf(get_class($typeMock), $result); $this->assertNotSame($typeMock, $result); } public function testAddingAKeywordFailsIfTypeClassDoesNotExist() : void { $this->expectException(InvalidArgumentException::class); $fixture = new TypeResolver(); $fixture->addKeyword("\155\157\x63\x6b", "\111\104\157\116\157\x74\105\x78\x69\163\x74"); } public function testAddingAKeywordFailsIfTypeClassDoesNotImplementTypeInterface() : void { $this->expectException(InvalidArgumentException::class); $fixture = new TypeResolver(); $fixture->addKeyword("\155\157\x63\x6b", stdClass::class); } public function testExceptionIsThrownIfTypeIsEmpty() : void { $this->expectException(InvalidArgumentException::class); $fixture = new TypeResolver(); $fixture->resolve("\40", new Context('')); } public function testInvalidArrayOperator() : void { $this->expectException(RuntimeException::class); $fixture = new TypeResolver(); $fixture->resolve("\133\x5d", new Context('')); } public function provideKeywords() : array { return array(array("\163\164\162\151\156\147", String_::class), array("\x63\x6c\x61\163\x73\x2d\x73\x74\162\151\x6e\147", ClassString::class), array("\150\164\155\x6c\x2d\x65\163\x63\141\160\145\x64\55\x73\164\x72\x69\x6e\x67", HtmlEscapedString::class), array("\154\157\167\145\162\143\x61\x73\145\x2d\163\164\162\x69\156\x67", LowercaseString::class), array("\156\157\156\x2d\x65\x6d\160\164\x79\55\x6c\x6f\167\145\x72\143\141\x73\145\55\x73\164\162\151\156\147", NonEmptyLowercaseString::class), array("\x6e\x6f\156\55\145\155\160\164\x79\x2d\163\x74\x72\151\x6e\x67", NonEmptyString::class), array("\156\165\x6d\145\162\x69\x63\55\x73\164\x72\x69\156\147", NumericString::class), array("\156\x75\155\x65\x72\151\x63", Numeric_::class), array("\164\x72\141\151\x74\55\163\x74\x72\x69\x6e\x67", TraitString::class), array("\151\156\x74", Integer::class), array("\x69\156\164\x65\147\x65\x72", Integer::class), array("\160\157\x73\x69\x74\151\166\x65\55\x69\156\x74", PositiveInteger::class), array("\x6e\x65\147\x61\x74\x69\x76\x65\x2d\151\x6e\164", NegativeInteger::class), array("\x66\x6c\x6f\141\x74", Float_::class), array("\x64\157\x75\142\154\145", Float_::class), array("\142\157\157\154", Boolean::class), array("\x62\x6f\157\154\x65\x61\x6e", Boolean::class), array("\164\162\165\145", Boolean::class), array("\x74\x72\x75\145", True_::class), array("\x66\141\x6c\163\145", Boolean::class), array("\146\141\154\x73\145", False_::class), array("\x72\145\163\x6f\x75\x72\x63\145", Resource_::class), array("\x6e\165\154\154", Null_::class), array("\x63\x61\154\x6c\x61\x62\x6c\145", Callable_::class), array("\143\x61\x6c\x6c\141\142\x6c\x65\55\163\164\162\151\x6e\147", CallableString::class), array("\143\141\154\154\142\x61\143\153", Callable_::class), array("\141\x72\162\x61\171", Array_::class), array("\141\162\x72\x61\171\x2d\153\x65\171", ArrayKey::class), array("\163\x63\141\154\141\162", Scalar::class), array("\x6f\x62\152\145\x63\x74", Object_::class), array("\x6d\x69\170\x65\144", Mixed_::class), array("\166\157\x69\144", Void_::class), array("\44\164\150\151\x73", This::class), array("\163\x74\141\x74\151\143", Static_::class), array("\163\145\154\146", Self_::class), array("\x70\x61\x72\x65\156\164", Parent_::class), array("\x69\x74\x65\x72\x61\142\x6c\145", Iterable_::class), array("\x6e\145\x76\145\x72", Never_::class), array("\x6c\x69\164\145\162\141\x6c\55\163\164\162\x69\156\147", LiteralString::class), array("\x6c\x69\x73\164", List_::class), array("\x6e\157\156\x2d\145\155\160\164\171\55\x6c\x69\x73\164", NonEmptyList::class), array("\156\x6f\x6e\x2d\x65\155\x70\x74\x79\x2d\x61\x72\162\x61\x79", NonEmptyArray::class)); } public function provideClassStrings() : array { return array(array("\143\154\141\163\163\55\x73\164\x72\x69\156\x67\x3c\x5c\160\150\160\104\157\143\x75\155\x65\x6e\164\x6f\x72\134\x52\x65\146\154\x65\143\x74\x69\x6f\156\x3e", false), array("\143\x6c\x61\x73\x73\55\163\164\x72\x69\x6e\x67\x3c\x5c\160\150\160\104\157\143\x75\x6d\145\x6e\x74\x6f\x72\x5c\x52\x65\x66\x6c\145\143\164\151\157\156\134\x44\x6f\x63\x42\x6c\157\x63\x6b\x3e", false), array("\143\154\141\x73\163\x2d\x73\x74\162\151\x6e\147\x3c\163\x74\x72\x69\x6e\147\x3e", true)); } public function provideInterfaceStrings() : array { return array(array("\151\156\164\x65\162\x66\x61\143\x65\55\163\164\162\151\156\147\x3c\134\160\x68\x70\104\x6f\x63\165\x6d\x65\156\x74\x6f\x72\134\122\145\x66\154\145\143\164\x69\157\156\x3e", false), array("\151\x6e\164\x65\x72\x66\141\x63\145\x2d\x73\x74\162\151\x6e\147\74\x5c\x70\150\x70\x44\157\143\165\x6d\x65\x6e\164\x6f\x72\x5c\122\x65\x66\x6c\x65\143\164\151\157\156\134\104\157\x63\x42\x6c\x6f\x63\x6b\x3e", false), array("\x69\x6e\x74\145\x72\x66\141\x63\145\55\x73\x74\162\x69\156\x67\x3c\163\x74\162\x69\156\x67\76", true)); } public function provideFqcn() : array { return array("\156\141\155\145\163\160\x61\x63\x65" => array("\134\160\150\x70\104\157\x63\165\x6d\x65\x6e\x74\157\162\134\x52\x65\146\154\145\x63\x74\151\157\x6e"), "\143\x6c\141\163\x73" => array("\x5c\x70\150\160\104\x6f\143\x75\155\145\x6e\164\x6f\162\x5c\x52\145\146\154\145\x63\164\151\x6f\156\x5c\104\157\143\x42\x6c\157\143\x6b"), "\143\154\141\x73\x73\x20\x77\x69\x74\x68\x20\x65\155\157\x6a\151" => array("\134\115\x79\360\x9f\x98\x81\103\154\x61\x73\x73")); } public function testArrayKeyValueSpecification() : void { $fixture = new TypeResolver(); $type = $fixture->resolve("\x61\162\x72\x61\x79\x3c\x73\x74\x72\151\156\147\x2c\141\162\x72\141\x79\74\x69\156\x74\x2c\163\164\x72\x69\156\147\x3e\76", new Context('')); $this->assertEquals(new Array_(new Array_(new String_(), new Integer()), new String_()), $type); } public function testTypeBuilding(string $type, Type $expected, bool $deprecation = false) : void { if ($deprecation) { $this->expectDeprecationWithIdentifier("\x68\164\x74\x70\163\72\57\x2f\x67\x69\164\150\165\x62\x2e\x63\x6f\x6d\57\160\x68\160\x44\x6f\143\165\155\145\x6e\164\157\162\57\124\171\x70\145\x52\145\x73\x6f\154\x76\145\162\x2f\151\163\163\165\145\x73\57\x31\x38\x34"); } else { $this->expectNoDeprecationWithIdentifier("\x68\x74\164\160\x73\x3a\57\x2f\147\151\164\150\165\142\x2e\x63\x6f\x6d\57\x70\150\160\x44\157\143\x75\155\145\x6e\x74\157\162\57\124\171\x70\145\x52\145\x73\157\154\166\145\162\x2f\151\x73\x73\165\x65\x73\57\61\x38\64"); } $fixture = new TypeResolver(); $actual = $fixture->resolve($type, new Context("\x70\x68\160\104\x6f\x63\165\155\x65\156\x74\x6f\x72")); self::assertEquals($expected, $actual); } public function typeProvider() : array { return array(array("\x73\x74\162\x69\x6e\x67", new String_()), array("\x28\40\x73\164\x72\x69\x6e\147\x20\51", new String_()), array("\134\x46\x6f\157\134\102\141\x72\x5c\102\x61\172", new Object_(new Fqsen("\x5c\x46\157\157\x5c\x42\141\162\134\x42\141\x7a"))), array("\163\x74\162\x69\x6e\147\174\151\156\x74", new Compound(array(new String_(), new Integer()))), array("\163\164\162\151\156\x67\46\x69\x6e\164", new Intersection(array(new String_(), new Integer()))), array("\163\x74\162\151\156\x67\40\x26\40\x28\x69\x6e\164\40\x7c\40\x66\154\157\141\x74\51", new Intersection(array(new String_(), new Expression(new Compound(array(new Integer(), new Float_())))))), array("\x73\x74\162\151\x6e\x67\133\x5d", new Array_(new String_())), array("\x24\164\x68\151\x73", new This()), array("\x3f\151\x6e\164", new Nullable(new Integer())), array("\x73\145\x6c\146", new Self_())); } public function genericsProvider() : array { return array(array("\141\162\x72\x61\171\x3c\151\156\164\x2c\x20\106\x6f\157\134\x42\141\162\x3e", new Array_(new Object_(new Fqsen("\x5c\x70\150\x70\x44\x6f\143\x75\155\145\x6e\x74\x6f\162\x5c\x46\157\157\x5c\102\141\x72")), new Integer())), array("\141\162\162\x61\171\74\163\164\x72\151\156\x67\174\x69\x6e\x74\x2c\40\106\157\x6f\x5c\102\141\x72\76", new Array_(new Object_(new Fqsen("\134\x70\x68\160\104\x6f\143\x75\155\x65\x6e\164\157\162\x5c\x46\157\157\134\102\141\x72")), new Compound(array(new String_(), new Integer())))), array("\103\x6f\154\x6c\x65\143\x74\151\157\156\74\141\x72\x72\x61\171\x2d\153\145\x79\54\x20\151\x6e\x74\x3e\x5b\x5d", new Array_(new Collection(new Fqsen("\x5c\160\x68\x70\x44\x6f\143\165\x6d\145\x6e\164\157\x72\x5c\x43\x6f\x6c\x6c\x65\143\x74\151\157\x6e"), new Integer(), new ArrayKey()))), array("\143\x6c\x61\x73\163\55\x73\164\x72\x69\x6e\147", new ClassString(null)), array("\x63\x6c\141\x73\163\x2d\x73\164\x72\151\x6e\147\74\x46\x6f\x6f\76", new ClassString(new Fqsen("\x5c\x70\150\x70\x44\x6f\x63\x75\x6d\x65\156\164\x6f\162\x5c\x46\157\157"))), array("\x69\x6e\164\x65\162\x66\x61\143\145\x2d\x73\164\x72\x69\x6e\x67\74\106\157\157\x3e", new InterfaceString(new Fqsen("\x5c\x70\150\160\104\157\x63\165\155\x65\x6e\164\157\x72\x5c\106\x6f\x6f"))), array("\x4c\151\163\x74\74\x46\x6f\157\x3e", new List_(new Object_(new Fqsen("\134\160\x68\160\x44\157\x63\x75\x6d\145\x6e\164\157\x72\134\x46\x6f\157")))), array("\151\156\164\74\61\54\40\61\60\60\x3e", new IntegerRange("\61", "\x31\x30\60"))); } public function callableProvider() : array { return array(array("\x63\x61\x6c\x6c\141\142\154\145", new Callable_()), array("\143\x61\x6c\154\141\x62\154\145\x28\x29", new Callable_()), array("\x63\x61\x6c\x6c\x61\142\154\145\x28\51\72\x20\106\x6f\157", new Callable_(array(), new Object_(new Fqsen("\134\x70\150\x70\x44\157\143\165\x6d\x65\156\x74\157\x72\x5c\106\157\157")))), array("\143\x61\154\x6c\x61\x62\154\x65\50\51\72\40\50\x46\x6f\x6f\x26\x42\x61\162\51", new Callable_(array(), new Intersection(array(new Object_(new Fqsen("\x5c\160\150\x70\104\x6f\143\x75\155\x65\x6e\164\x6f\162\134\106\x6f\157")), new Object_(new Fqsen("\134\x70\150\x70\x44\x6f\x63\x75\x6d\x65\x6e\164\157\x72\x5c\102\141\162")))))), array("\143\x61\154\x6c\141\142\x6c\145\x28\x41\x26\56\56\56\x24\141\x3d\x2c\x20\x42\x26\56\56\x2e\x3d\54\x20\103\x29\72\x20\x46\x6f\x6f", new Callable_(array(new CallableParameter(new Object_(new Fqsen("\x5c\x70\x68\160\104\157\x63\x75\x6d\x65\x6e\x74\157\x72\134\x41")), "\x61", true, true, true), new CallableParameter(new Object_(new Fqsen("\x5c\160\150\x70\x44\157\143\x75\x6d\x65\156\164\157\162\x5c\x42")), null, true, true, true), new CallableParameter(new Object_(new Fqsen("\x5c\x70\150\x70\x44\157\143\165\155\145\x6e\x74\x6f\162\134\103")), null, false, false, false)), new Object_(new Fqsen("\x5c\x70\150\160\104\x6f\143\165\155\145\156\164\x6f\162\x5c\x46\x6f\157"))))); } public function constExpressions() : array { return array(array("\61\x32\63", new IntegerValue(123)), array("\x74\162\165\x65", new True_()), array("\x31\x32\63\x2e\x32", new FloatValue(123.2)), array("\x22\x62\x61\x72\42", new StringValue("\142\141\162")), array("\106\x6f\x6f\72\72\x46\117\x4f\137\x43\x4f\116\123\x54\x41\116\124", new ConstExpression(new Object_(new Fqsen("\134\160\x68\x70\x44\157\x63\165\x6d\x65\x6e\x74\157\162\x5c\106\x6f\157")), "\106\117\x4f\x5f\x43\x4f\x4e\123\x54\x41\x4e\x54")), array("\106\157\x6f\x3a\72\106\117\x4f\x5f\52", new ConstExpression(new Object_(new Fqsen("\x5c\x70\150\160\x44\x6f\143\x75\x6d\145\x6e\164\157\162\x5c\x46\157\157")), "\106\x4f\x4f\x5f\52")), array("\163\x65\x6c\x66\x3a\72\x2a\174\x6e\165\154\154", new Compound(array(new ConstExpression(new Self_(), "\52"), new Null_())))); } public function shapeStructures() : array { return array(array("\141\162\162\x61\171\x7b\x66\157\157\x3a\x20\x73\164\x72\151\156\147\54\x20\142\x61\x72\x3a\x20\x69\x6e\164\x7d", new ArrayShape(new ArrayShapeItem("\146\x6f\157", new String_(), false), new ArrayShapeItem("\142\141\162", new Integer(), false))), array("\141\x72\x72\141\x79\173\146\x6f\x6f\x3f\72\x20\163\x74\x72\x69\156\147\54\x20\142\x61\x72\72\40\x69\156\x74\x7d", new ArrayShape(new ArrayShapeItem("\146\157\x6f", new String_(), true), new ArrayShapeItem("\142\x61\x72", new Integer(), false))), array("\x6f\142\152\145\x63\x74\x7b\x66\157\x6f\72\x20\x73\164\x72\151\156\147\x2c\x20\142\x61\162\72\x20\151\x6e\164\x7d", new ObjectShape(new ObjectShapeItem("\146\157\x6f", new String_(), false), new ObjectShapeItem("\142\141\x72", new Integer(), false))), array("\154\x69\163\x74\x7b\61\x7d", new ListShape(new ListShapeItem(null, new IntegerValue(1), false)))); } public function illegalLegacyFormatProvider() : array { return array(array("\77\x73\164\162\151\156\x67\x20\x7c\x62\x6f\157\x6c", new Compound(array(new Nullable(new String_()), new Boolean())), true), array("\77\x73\x74\x72\151\156\x67\x7c\x3f\142\x6f\x6f\154", new Compound(array(new Nullable(new String_()), new Nullable(new Boolean()))), true), array("\77\163\x74\162\151\x6e\147\x7c\77\142\x6f\x6f\x6c\x7c\x6e\x75\x6c\x6c", new Compound(array(new Nullable(new String_()), new Nullable(new Boolean()), new Null_())), true), array("\x3f\x73\164\x72\151\x6e\x67\174\142\157\x6f\x6c\174\106\x6f\157", new Compound(array(new Nullable(new String_()), new Boolean(), new Object_(new Fqsen("\134\x70\150\160\104\157\143\x75\155\145\156\x74\157\x72\134\x46\157\157")))), true), array("\77\x73\164\x72\151\156\x67\x26\142\157\x6f\154", new Intersection(array(new Nullable(new String_()), new Boolean())), true), array("\x3f\163\164\x72\x69\156\x67\x26\142\x6f\x6f\x6c\x7c\106\157\x6f", new Intersection(array(new Nullable(new String_()), new Compound(array(new Boolean(), new Object_(new Fqsen("\134\160\150\160\104\x6f\x63\x75\x6d\x65\156\164\x6f\x72\x5c\106\x6f\x6f")))))), true), array("\77\163\x74\162\151\156\147\x26\77\142\x6f\x6f\154\x7c\156\x75\x6c\x6c", new Compound(array(new Intersection(array(new Nullable(new String_()), new Nullable(new Boolean()))), new Null_())), true)); } }
Function Calls
| None |
Stats
| MD5 | c932e647a7aebd5fb0553de65749bfb5 |
| Eval Count | 0 |
| Decode Time | 104 ms |