From 1e36395b039a44a4b58fa56012dabc8276cc0de7 Mon Sep 17 00:00:00 2001 From: Jaapio Date: Mon, 24 Apr 2017 21:49:13 +0200 Subject: [PATCH] Improves code style Adds missing @throws blocks Adds usage of ::class --- src/FqsenResolver.php | 1 + src/TypeResolver.php | 43 +++--- src/Types/Array_.php | 1 - src/Types/Compound.php | 3 +- src/Types/Context.php | 4 +- src/Types/ContextFactory.php | 2 +- src/Types/Object_.php | 1 + tests/unit/TypeResolverTest.php | 189 ++++++++++++------------ tests/unit/Types/ContextFactoryTest.php | 22 +-- tests/unit/Types/ContextTest.php | 2 - 10 files changed, 135 insertions(+), 133 deletions(-) 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 633e8af..7236d81 100644 --- a/src/TypeResolver.php +++ b/src/TypeResolver.php @@ -28,27 +28,27 @@ 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_', + '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, 'iterable' => Iterable_::class, ); @@ -239,6 +239,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 85002a2..6d55b06 100644 --- a/tests/unit/TypeResolverTest.php +++ b/tests/unit/TypeResolverTest.php @@ -18,6 +18,7 @@ use phpDocumentor\Reflection\Types\Context; use phpDocumentor\Reflection\Types\Iterable_; use phpDocumentor\Reflection\Types\Object_; +use Mockery\MockInterface; /** * @coversDefaultClass phpDocumentor\Reflection\TypeResolver @@ -32,9 +33,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 */ @@ -54,10 +55,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 */ @@ -68,8 +69,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); } @@ -78,10 +79,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() { @@ -90,8 +91,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); } @@ -100,10 +101,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() { @@ -112,11 +113,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); } @@ -125,9 +126,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() { @@ -136,10 +137,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()); } /** @@ -147,9 +148,9 @@ public function testResolvingTypedArrays() * @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 testResolvingNestedTypedArrays() { @@ -161,15 +162,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()); } /** @@ -177,12 +178,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() { @@ -191,7 +192,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 */ @@ -200,9 +201,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()); } /** @@ -210,12 +211,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() { @@ -224,7 +225,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 */ @@ -233,10 +234,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()); } /** @@ -251,11 +252,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() { @@ -264,7 +265,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 */ @@ -273,18 +274,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() { @@ -304,7 +305,7 @@ public function testAddingAKeyword() /** * @covers ::__construct * @covers ::addKeyword - * @uses phpDocumentor\Reflection\Types\Context + * @uses \phpDocumentor\Reflection\Types\Context * @expectedException \InvalidArgumentException */ public function testAddingAKeywordFailsIfTypeClassDoesNotExist() @@ -316,19 +317,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 */ @@ -341,7 +342,7 @@ public function testExceptionIsThrownIfTypeIsEmpty() /** * @covers ::__construct * @covers ::resolve - * @uses phpDocumentor\Reflection\Types\Context + * @uses \phpDocumentor\Reflection\Types\Context * * @expectedException \InvalidArgumentException */ @@ -359,25 +360,25 @@ 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_'], + ['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], ['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 */