diff --git a/src/FqsenResolver.php b/src/FqsenResolver.php index a0e0041..9aa6ba3 100644 --- a/src/FqsenResolver.php +++ b/src/FqsenResolver.php @@ -52,6 +52,7 @@ private function isFqsen($type) * @param Context $context * * @return Fqsen + * @throws \InvalidArgumentException when type is not a valid FQSEN. */ private function resolvePartialStructuralElementName($type, Context $context) { diff --git a/src/TypeResolver.php b/src/TypeResolver.php index 4f003da..9df65b6 100644 --- a/src/TypeResolver.php +++ b/src/TypeResolver.php @@ -29,28 +29,28 @@ final class TypeResolver /** @var string[] List of recognized keywords and unto which Value Object they map */ private $keywords = array( - 'string' => 'phpDocumentor\Reflection\Types\String_', - 'int' => 'phpDocumentor\Reflection\Types\Integer', - 'integer' => 'phpDocumentor\Reflection\Types\Integer', - 'bool' => 'phpDocumentor\Reflection\Types\Boolean', - 'boolean' => 'phpDocumentor\Reflection\Types\Boolean', - 'float' => 'phpDocumentor\Reflection\Types\Float_', - 'double' => 'phpDocumentor\Reflection\Types\Float_', - 'object' => 'phpDocumentor\Reflection\Types\Object_', - 'mixed' => 'phpDocumentor\Reflection\Types\Mixed', - 'array' => 'phpDocumentor\Reflection\Types\Array_', - 'resource' => 'phpDocumentor\Reflection\Types\Resource', - 'void' => 'phpDocumentor\Reflection\Types\Void_', - 'null' => 'phpDocumentor\Reflection\Types\Null_', - 'scalar' => 'phpDocumentor\Reflection\Types\Scalar', - 'callback' => 'phpDocumentor\Reflection\Types\Callable_', - 'callable' => 'phpDocumentor\Reflection\Types\Callable_', - 'false' => 'phpDocumentor\Reflection\Types\Boolean', - 'true' => 'phpDocumentor\Reflection\Types\Boolean', - 'self' => 'phpDocumentor\Reflection\Types\Self_', - '$this' => 'phpDocumentor\Reflection\Types\This', - 'static' => 'phpDocumentor\Reflection\Types\Static_', - 'parent' => 'phpDocumentor\Reflection\Types\Parent_', + 'string' => Types\String_::class, + 'int' => Types\Integer::class, + 'integer' => Types\Integer::class, + 'bool' => Types\Boolean::class, + 'boolean' => Types\Boolean::class, + 'float' => Types\Float_::class, + 'double' => Types\Float_::class, + 'object' => Object_::class, + 'mixed' => Types\Mixed::class, + 'array' => Array_::class, + 'resource' => Types\Resource::class, + 'void' => Types\Void_::class, + 'null' => Types\Null_::class, + 'scalar' => Types\Scalar::class, + 'callback' => Types\Callable_::class, + 'callable' => Types\Callable_::class, + 'false' => Types\Boolean::class, + 'true' => Types\Boolean::class, + 'self' => Types\Self_::class, + '$this' => Types\This::class, + 'static' => Types\Static_::class, + 'parent' => Types\Parent_::class, 'iterable' => Iterable_::class, ); @@ -255,6 +255,7 @@ private function resolveKeyword($type) * Resolves the given FQSEN string into an FQSEN object. * * @param string $type + * @param Context|null $context * * @return Object_ */ diff --git a/src/Types/Array_.php b/src/Types/Array_.php index 45276c6..b699b10 100644 --- a/src/Types/Array_.php +++ b/src/Types/Array_.php @@ -12,7 +12,6 @@ namespace phpDocumentor\Reflection\Types; -use phpDocumentor\Reflection\Fqsen; use phpDocumentor\Reflection\Type; /** diff --git a/src/Types/Compound.php b/src/Types/Compound.php index 3e5ebb5..be99718 100644 --- a/src/Types/Compound.php +++ b/src/Types/Compound.php @@ -24,12 +24,13 @@ final class Compound implements Type { /** @var Type[] */ - private $types = []; + private $types; /** * Initializes a compound type (i.e. `string|int`) and tests if the provided types all implement the Type interface. * * @param Type[] $types + * @throws \InvalidArgumentException when types are not all instance of Type */ public function __construct(array $types) { diff --git a/src/Types/Context.php b/src/Types/Context.php index cc95342..4e9ce5a 100644 --- a/src/Types/Context.php +++ b/src/Types/Context.php @@ -29,10 +29,10 @@ final class Context { /** @var string The current namespace. */ - private $namespace = ''; + private $namespace; /** @var array List of namespace aliases => Fully Qualified Namespace. */ - private $namespaceAliases = []; + private $namespaceAliases; /** * Initializes the new context and normalizes all passed namespaces to be in Qualified Namespace Name (QNN) diff --git a/src/Types/ContextFactory.php b/src/Types/ContextFactory.php index 147df69..30936a3 100644 --- a/src/Types/ContextFactory.php +++ b/src/Types/ContextFactory.php @@ -32,7 +32,7 @@ final class ContextFactory /** * Build a Context given a Class Reflection. * - * @param \ReflectionClass $reflector + * @param \Reflector $reflector * * @see Context for more information on Contexts. * diff --git a/src/Types/Object_.php b/src/Types/Object_.php index b337c71..389f7c7 100644 --- a/src/Types/Object_.php +++ b/src/Types/Object_.php @@ -31,6 +31,7 @@ final class Object_ implements Type * Initializes this object with an optional FQSEN, if not provided this object is considered 'untyped'. * * @param Fqsen $fqsen + * @throws \InvalidArgumentException when provided $fqsen is not a valid type. */ public function __construct(Fqsen $fqsen = null) { diff --git a/tests/unit/TypeResolverTest.php b/tests/unit/TypeResolverTest.php index 634777f..3063514 100644 --- a/tests/unit/TypeResolverTest.php +++ b/tests/unit/TypeResolverTest.php @@ -19,6 +19,7 @@ use phpDocumentor\Reflection\Types\Iterable_; use phpDocumentor\Reflection\Types\Nullable; use phpDocumentor\Reflection\Types\Object_; +use Mockery\MockInterface; use phpDocumentor\Reflection\Types\String_; /** @@ -34,9 +35,9 @@ class TypeResolverTest extends \PHPUnit_Framework_TestCase * @covers ::resolve * @covers :: * - * @uses phpDocumentor\Reflection\Types\Context - * @uses phpDocumentor\Reflection\Types\Array_ - * @uses phpDocumentor\Reflection\Types\Object_ + * @uses \phpDocumentor\Reflection\Types\Context + * @uses \phpDocumentor\Reflection\Types\Array_ + * @uses \phpDocumentor\Reflection\Types\Object_ * * @dataProvider provideKeywords */ @@ -56,10 +57,10 @@ public function testResolvingKeywords($keyword, $expectedClass) * @covers ::resolve * @covers :: * - * @uses phpDocumentor\Reflection\Types\Context - * @uses phpDocumentor\Reflection\Types\Object_ - * @uses phpDocumentor\Reflection\Fqsen - * @uses phpDocumentor\Reflection\FqsenResolver + * @uses \phpDocumentor\Reflection\Types\Context + * @uses \phpDocumentor\Reflection\Types\Object_ + * @uses \phpDocumentor\Reflection\Fqsen + * @uses \phpDocumentor\Reflection\FqsenResolver * * @dataProvider provideFqcn */ @@ -70,8 +71,8 @@ public function testResolvingFQSENs($fqsen) /** @var Object_ $resolvedType */ $resolvedType = $fixture->resolve($fqsen, new Context('')); - $this->assertInstanceOf('phpDocumentor\Reflection\Types\Object_', $resolvedType); - $this->assertInstanceOf('phpDocumentor\Reflection\Fqsen', $resolvedType->getFqsen()); + $this->assertInstanceOf(Object_::class, $resolvedType); + $this->assertInstanceOf(Fqsen::class, $resolvedType->getFqsen()); $this->assertSame($fqsen, (string)$resolvedType); } @@ -80,10 +81,10 @@ public function testResolvingFQSENs($fqsen) * @covers ::resolve * @covers :: * - * @uses phpDocumentor\Reflection\Types\Context - * @uses phpDocumentor\Reflection\Types\Object_ - * @uses phpDocumentor\Reflection\Fqsen - * @uses phpDocumentor\Reflection\FqsenResolver + * @uses \phpDocumentor\Reflection\Types\Context + * @uses \phpDocumentor\Reflection\Types\Object_ + * @uses \phpDocumentor\Reflection\Fqsen + * @uses \phpDocumentor\Reflection\FqsenResolver */ public function testResolvingRelativeQSENsBasedOnNamespace() { @@ -92,8 +93,8 @@ public function testResolvingRelativeQSENsBasedOnNamespace() /** @var Object_ $resolvedType */ $resolvedType = $fixture->resolve('DocBlock', new Context('phpDocumentor\Reflection')); - $this->assertInstanceOf('phpDocumentor\Reflection\Types\Object_', $resolvedType); - $this->assertInstanceOf('phpDocumentor\Reflection\Fqsen', $resolvedType->getFqsen()); + $this->assertInstanceOf(Object_::class, $resolvedType); + $this->assertInstanceOf(Fqsen::class, $resolvedType->getFqsen()); $this->assertSame('\phpDocumentor\Reflection\DocBlock', (string)$resolvedType); } @@ -102,10 +103,10 @@ public function testResolvingRelativeQSENsBasedOnNamespace() * @covers ::resolve * @covers :: * - * @uses phpDocumentor\Reflection\Types\Context - * @uses phpDocumentor\Reflection\Types\Object_ - * @uses phpDocumentor\Reflection\Fqsen - * @uses phpDocumentor\Reflection\FqsenResolver + * @uses \phpDocumentor\Reflection\Types\Context + * @uses \phpDocumentor\Reflection\Types\Object_ + * @uses \phpDocumentor\Reflection\Fqsen + * @uses \phpDocumentor\Reflection\FqsenResolver */ public function testResolvingRelativeQSENsBasedOnNamespaceAlias() { @@ -114,11 +115,11 @@ public function testResolvingRelativeQSENsBasedOnNamespaceAlias() /** @var Object_ $resolvedType */ $resolvedType = $fixture->resolve( 'm\MockInterface', - new Context('phpDocumentor\Reflection', ['m' => '\Mockery']) + new Context('phpDocumentor\Reflection', ['m' => m::class]) ); - $this->assertInstanceOf('phpDocumentor\Reflection\Types\Object_', $resolvedType); - $this->assertInstanceOf('phpDocumentor\Reflection\Fqsen', $resolvedType->getFqsen()); + $this->assertInstanceOf(Object_::class, $resolvedType); + $this->assertInstanceOf(Fqsen::class, $resolvedType->getFqsen()); $this->assertSame('\Mockery\MockInterface', (string)$resolvedType); } @@ -127,9 +128,9 @@ public function testResolvingRelativeQSENsBasedOnNamespaceAlias() * @covers ::resolve * @covers :: * - * @uses phpDocumentor\Reflection\Types\Context - * @uses phpDocumentor\Reflection\Types\Array_ - * @uses phpDocumentor\Reflection\Types\String_ + * @uses \phpDocumentor\Reflection\Types\Context + * @uses \phpDocumentor\Reflection\Types\Array_ + * @uses \phpDocumentor\Reflection\Types\String_ */ public function testResolvingTypedArrays() { @@ -138,10 +139,10 @@ public function testResolvingTypedArrays() /** @var Array_ $resolvedType */ $resolvedType = $fixture->resolve('string[]', new Context('')); - $this->assertInstanceOf('phpDocumentor\Reflection\Types\Array_', $resolvedType); + $this->assertInstanceOf(Array_::class, $resolvedType); $this->assertSame('string[]', (string)$resolvedType); - $this->assertInstanceOf('phpDocumentor\Reflection\Types\Compound', $resolvedType->getKeyType()); - $this->assertInstanceOf('phpDocumentor\Reflection\Types\String_', $resolvedType->getValueType()); + $this->assertInstanceOf(Compound::class, $resolvedType->getKeyType()); + $this->assertInstanceOf(Types\String_::class, $resolvedType->getValueType()); } /** @@ -184,15 +185,15 @@ public function testResolvingNestedTypedArrays() /** @var Array_ $childValueType */ $childValueType = $resolvedType->getValueType(); - $this->assertInstanceOf('phpDocumentor\Reflection\Types\Array_', $resolvedType); + $this->assertInstanceOf(Array_::class, $resolvedType); $this->assertSame('string[][]', (string)$resolvedType); - $this->assertInstanceOf('phpDocumentor\Reflection\Types\Compound', $resolvedType->getKeyType()); - $this->assertInstanceOf('phpDocumentor\Reflection\Types\Array_', $childValueType); + $this->assertInstanceOf(Compound::class, $resolvedType->getKeyType()); + $this->assertInstanceOf(Array_::class, $childValueType); $this->assertSame('string[]', (string)$childValueType); - $this->assertInstanceOf('phpDocumentor\Reflection\Types\Compound', $childValueType->getKeyType()); - $this->assertInstanceOf('phpDocumentor\Reflection\Types\String_', $childValueType->getValueType()); + $this->assertInstanceOf(Compound::class, $childValueType->getKeyType()); + $this->assertInstanceOf(Types\String_::class, $childValueType->getValueType()); } /** @@ -200,12 +201,12 @@ public function testResolvingNestedTypedArrays() * @covers ::resolve * @covers :: * - * @uses phpDocumentor\Reflection\Types\Context - * @uses phpDocumentor\Reflection\Types\Compound - * @uses phpDocumentor\Reflection\Types\String_ - * @uses phpDocumentor\Reflection\Types\Object_ - * @uses phpDocumentor\Reflection\Fqsen - * @uses phpDocumentor\Reflection\FqsenResolver + * @uses \phpDocumentor\Reflection\Types\Context + * @uses \phpDocumentor\Reflection\Types\Compound + * @uses \phpDocumentor\Reflection\Types\String_ + * @uses \phpDocumentor\Reflection\Types\Object_ + * @uses \phpDocumentor\Reflection\Fqsen + * @uses \phpDocumentor\Reflection\FqsenResolver */ public function testResolvingCompoundTypes() { @@ -214,7 +215,7 @@ public function testResolvingCompoundTypes() /** @var Compound $resolvedType */ $resolvedType = $fixture->resolve('string|Reflection\DocBlock', new Context('phpDocumentor')); - $this->assertInstanceOf('phpDocumentor\Reflection\Types\Compound', $resolvedType); + $this->assertInstanceOf(Compound::class, $resolvedType); $this->assertSame('string|\phpDocumentor\Reflection\DocBlock', (string)$resolvedType); /** @var String $secondType */ @@ -223,9 +224,9 @@ public function testResolvingCompoundTypes() /** @var Object_ $secondType */ $secondType = $resolvedType->get(1); - $this->assertInstanceOf('phpDocumentor\Reflection\Types\String_', $firstType); - $this->assertInstanceOf('phpDocumentor\Reflection\Types\Object_', $secondType); - $this->assertInstanceOf('phpDocumentor\Reflection\Fqsen', $secondType->getFqsen()); + $this->assertInstanceOf(Types\String_::class, $firstType); + $this->assertInstanceOf(Object_::class, $secondType); + $this->assertInstanceOf(Fqsen::class, $secondType->getFqsen()); } /** @@ -233,12 +234,12 @@ public function testResolvingCompoundTypes() * @covers ::resolve * @covers :: * - * @uses phpDocumentor\Reflection\Types\Context - * @uses phpDocumentor\Reflection\Types\Compound - * @uses phpDocumentor\Reflection\Types\Array_ - * @uses phpDocumentor\Reflection\Types\Object_ - * @uses phpDocumentor\Reflection\Fqsen - * @uses phpDocumentor\Reflection\FqsenResolver + * @uses \phpDocumentor\Reflection\Types\Context + * @uses \phpDocumentor\Reflection\Types\Compound + * @uses \phpDocumentor\Reflection\Types\Array_ + * @uses \phpDocumentor\Reflection\Types\Object_ + * @uses \phpDocumentor\Reflection\Fqsen + * @uses \phpDocumentor\Reflection\FqsenResolver */ public function testResolvingCompoundTypedArrayTypes() { @@ -247,7 +248,7 @@ public function testResolvingCompoundTypedArrayTypes() /** @var Compound $resolvedType */ $resolvedType = $fixture->resolve('\stdClass[]|Reflection\DocBlock[]', new Context('phpDocumentor')); - $this->assertInstanceOf('phpDocumentor\Reflection\Types\Compound', $resolvedType); + $this->assertInstanceOf(Compound::class, $resolvedType); $this->assertSame('\stdClass[]|\phpDocumentor\Reflection\DocBlock[]', (string)$resolvedType); /** @var Array_ $secondType */ @@ -256,10 +257,10 @@ public function testResolvingCompoundTypedArrayTypes() /** @var Array_ $secondType */ $secondType = $resolvedType->get(1); - $this->assertInstanceOf('phpDocumentor\Reflection\Types\Array_', $firstType); - $this->assertInstanceOf('phpDocumentor\Reflection\Types\Array_', $secondType); - $this->assertInstanceOf('phpDocumentor\Reflection\Types\Object_', $firstType->getValueType()); - $this->assertInstanceOf('phpDocumentor\Reflection\Types\Object_', $secondType->getValueType()); + $this->assertInstanceOf(Array_::class, $firstType); + $this->assertInstanceOf(Array_::class, $secondType); + $this->assertInstanceOf(Object_::class, $firstType->getValueType()); + $this->assertInstanceOf(Object_::class, $secondType->getValueType()); } /** @@ -274,11 +275,11 @@ public function testResolvingCompoundTypedArrayTypes() * @covers ::resolve * @covers :: * - * @uses phpDocumentor\Reflection\Types\Context - * @uses phpDocumentor\Reflection\Types\Compound - * @uses phpDocumentor\Reflection\Types\Array_ - * @uses phpDocumentor\Reflection\Types\Integer - * @uses phpDocumentor\Reflection\Types\String_ + * @uses \phpDocumentor\Reflection\Types\Context + * @uses \phpDocumentor\Reflection\Types\Compound + * @uses \phpDocumentor\Reflection\Types\Array_ + * @uses \phpDocumentor\Reflection\Types\Integer + * @uses \phpDocumentor\Reflection\Types\String_ */ public function testResolvingCompoundTypesWithTwoArrays() { @@ -287,7 +288,7 @@ public function testResolvingCompoundTypesWithTwoArrays() /** @var Compound $resolvedType */ $resolvedType = $fixture->resolve('integer[]|string[]', new Context('')); - $this->assertInstanceOf('phpDocumentor\Reflection\Types\Compound', $resolvedType); + $this->assertInstanceOf(Compound::class, $resolvedType); $this->assertSame('int[]|string[]', (string)$resolvedType); /** @var Array_ $firstType */ @@ -296,18 +297,18 @@ public function testResolvingCompoundTypesWithTwoArrays() /** @var Array_ $secondType */ $secondType = $resolvedType->get(1); - $this->assertInstanceOf('phpDocumentor\Reflection\Types\Array_', $firstType); - $this->assertInstanceOf('phpDocumentor\Reflection\Types\Integer', $firstType->getValueType()); - $this->assertInstanceOf('phpDocumentor\Reflection\Types\Array_', $secondType); - $this->assertInstanceOf('phpDocumentor\Reflection\Types\String_', $secondType->getValueType()); + $this->assertInstanceOf(Array_::class, $firstType); + $this->assertInstanceOf(Types\Integer::class, $firstType->getValueType()); + $this->assertInstanceOf(Array_::class, $secondType); + $this->assertInstanceOf(Types\String_::class, $secondType->getValueType()); } /** * @covers ::__construct * @covers ::addKeyword - * @uses phpDocumentor\Reflection\TypeResolver::resolve - * @uses phpDocumentor\Reflection\TypeResolver:: - * @uses phpDocumentor\Reflection\Types\Context + * @uses \phpDocumentor\Reflection\TypeResolver::resolve + * @uses \phpDocumentor\Reflection\TypeResolver:: + * @uses \phpDocumentor\Reflection\Types\Context */ public function testAddingAKeyword() { @@ -327,7 +328,7 @@ public function testAddingAKeyword() /** * @covers ::__construct * @covers ::addKeyword - * @uses phpDocumentor\Reflection\Types\Context + * @uses \phpDocumentor\Reflection\Types\Context * @expectedException \InvalidArgumentException */ public function testAddingAKeywordFailsIfTypeClassDoesNotExist() @@ -339,19 +340,19 @@ public function testAddingAKeywordFailsIfTypeClassDoesNotExist() /** * @covers ::__construct * @covers ::addKeyword - * @uses phpDocumentor\Reflection\Types\Context + * @uses \phpDocumentor\Reflection\Types\Context * @expectedException \InvalidArgumentException */ public function testAddingAKeywordFailsIfTypeClassDoesNotImplementTypeInterface() { $fixture = new TypeResolver(); - $fixture->addKeyword('mock', 'stdClass'); + $fixture->addKeyword('mock', \stdClass::class); } /** * @covers ::__construct * @covers ::resolve - * @uses phpDocumentor\Reflection\Types\Context + * @uses \phpDocumentor\Reflection\Types\Context * * @expectedException \InvalidArgumentException */ @@ -364,7 +365,7 @@ public function testExceptionIsThrownIfTypeIsEmpty() /** * @covers ::__construct * @covers ::resolve - * @uses phpDocumentor\Reflection\Types\Context + * @uses \phpDocumentor\Reflection\Types\Context * * @expectedException \InvalidArgumentException */ @@ -382,26 +383,26 @@ public function testExceptionIsThrownIfTypeIsNotAString() public function provideKeywords() { return [ - ['string', 'phpDocumentor\Reflection\Types\String_'], - ['int', 'phpDocumentor\Reflection\Types\Integer'], - ['integer', 'phpDocumentor\Reflection\Types\Integer'], - ['float', 'phpDocumentor\Reflection\Types\Float_'], - ['double', 'phpDocumentor\Reflection\Types\Float_'], - ['bool', 'phpDocumentor\Reflection\Types\Boolean'], - ['boolean', 'phpDocumentor\Reflection\Types\Boolean'], - ['resource', 'phpDocumentor\Reflection\Types\Resource'], - ['null', 'phpDocumentor\Reflection\Types\Null_'], - ['callable', 'phpDocumentor\Reflection\Types\Callable_'], - ['callback', 'phpDocumentor\Reflection\Types\Callable_'], - ['array', 'phpDocumentor\Reflection\Types\Array_'], - ['scalar', 'phpDocumentor\Reflection\Types\Scalar'], - ['object', 'phpDocumentor\Reflection\Types\Object_'], - ['mixed', 'phpDocumentor\Reflection\Types\Mixed'], - ['void', 'phpDocumentor\Reflection\Types\Void_'], - ['$this', 'phpDocumentor\Reflection\Types\This'], - ['static', 'phpDocumentor\Reflection\Types\Static_'], - ['self', 'phpDocumentor\Reflection\Types\Self_'], - ['parent', 'phpDocumentor\Reflection\Types\Parent_'], + ['string', Types\String_::class], + ['int', Types\Integer::class], + ['integer', Types\Integer::class], + ['float', Types\Float_::class], + ['double', Types\Float_::class], + ['bool', Types\Boolean::class], + ['boolean', Types\Boolean::class], + ['resource', Types\Resource::class], + ['null', Types\Null_::class], + ['callable', Types\Callable_::class], + ['callback', Types\Callable_::class], + ['array', Array_::class], + ['scalar', Types\Scalar::class], + ['object', Object_::class], + ['mixed', Types\Mixed::class], + ['void', Types\Void_::class], + ['$this', Types\This::class], + ['static', Types\Static_::class], + ['self', Types\Self_::class], + ['parent', Types\Parent_::class], ['iterable', Iterable_::class], ]; } diff --git a/tests/unit/Types/ContextFactoryTest.php b/tests/unit/Types/ContextFactoryTest.php index 20d63c9..dd6b5ab 100644 --- a/tests/unit/Types/ContextFactoryTest.php +++ b/tests/unit/Types/ContextFactoryTest.php @@ -47,11 +47,11 @@ public function testReadsAliasesFromClassReflection() { $fixture = new ContextFactory(); $expected = [ - 'm' => 'Mockery', - 'DocBlock' => 'phpDocumentor\Reflection\DocBlock', - 'Tag' => 'phpDocumentor\Reflection\DocBlock\Tag', + 'm' => m::class, + 'DocBlock' => DocBlock::class, + 'Tag' => Tag::class, 'phpDocumentor' => 'phpDocumentor', - 'ReflectionClass' => 'ReflectionClass' + ReflectionClass::class => ReflectionClass::class ]; $context = $fixture->createFromReflector(new ReflectionClass($this)); @@ -78,11 +78,11 @@ public function testReadsAliasesFromProvidedNamespaceAndContent() { $fixture = new ContextFactory(); $expected = [ - 'm' => 'Mockery', - 'DocBlock' => 'phpDocumentor\Reflection\DocBlock', - 'Tag' => 'phpDocumentor\Reflection\DocBlock\Tag', + 'm' => m::class, + 'DocBlock' => DocBlock::class, + 'Tag' => Tag::class, 'phpDocumentor' => 'phpDocumentor', - 'ReflectionClass' => 'ReflectionClass' + ReflectionClass::class => ReflectionClass::class ]; $context = $fixture->createForNamespace(__NAMESPACE__, file_get_contents(__FILE__)); @@ -95,7 +95,7 @@ public function testReadsAliasesFromProvidedNamespaceAndContent() */ public function testTraitUseIsNotDetectedAsNamespaceUse() { - $php = "createForNamespace('Foo', $php); @@ -156,7 +156,7 @@ public function bar() public function testEmptyFileName() { $fixture = new ContextFactory(); - $context = $fixture->createFromReflector(new \ReflectionClass('stdClass')); + $context = $fixture->createFromReflector(new \ReflectionClass(\stdClass::class)); $this->assertSame([], $context->getNamespaceAliases()); } diff --git a/tests/unit/Types/ContextTest.php b/tests/unit/Types/ContextTest.php index 165f415..677c5d1 100644 --- a/tests/unit/Types/ContextTest.php +++ b/tests/unit/Types/ContextTest.php @@ -12,8 +12,6 @@ namespace phpDocumentor\Reflection\Types; -use Mockery as m; - /** * @coversDefaultClass \phpDocumentor\Reflection\Types\Context */