diff --git a/.phpunit.result.cache b/.phpunit.result.cache
new file mode 100644
index 00000000..386df0f0
--- /dev/null
+++ b/.phpunit.result.cache
@@ -0,0 +1 @@
+C:37:"PHPUnit\Runner\DefaultTestResultCache":16457:{a:2:{s:7:"defects";a:6:{s:54:"phpDocumentor\Reflection\Php\ArgumentTest::testGetName";i:4;s:80:"phpDocumentor\Reflection\Php\Factory\DocBlockTest::testCreateWithNullReturnsNull";i:4;s:76:"phpDocumentor\Reflection\Php\Factory\Function_Test::testCreateWithParameters";i:4;s:73:"phpDocumentor\Reflection\Php\Factory\MethodTest::testCreateWithParameters";i:4;s:59:"phpDocumentor\Reflection\Php\ProjectFactoryTest::testCreate";i:4;s:93:"phpDocumentor\Reflection\Php\ProjectFactoryTest::testErrorScenarioWhenFileStrategyReturnsNull";i:4;}s:5:"times";a:191:{s:60:"phpDocumentor\Reflection\File\LocalFileTest::testGetContents";d:0;s:52:"phpDocumentor\Reflection\File\LocalFileTest::testMd5";d:0;s:79:"phpDocumentor\Reflection\File\LocalFileTest::testNotExistingFileThrowsException";d:0;s:53:"phpDocumentor\Reflection\File\LocalFileTest::testPath";d:0;s:90:"phpDocumentor\Reflection\NodeVisitor\ElementNameResolverTest::testFunctionWithoutNamespace";d:0.001;s:75:"phpDocumentor\Reflection\NodeVisitor\ElementNameResolverTest::testWithClass";d:0;s:92:"phpDocumentor\Reflection\NodeVisitor\ElementNameResolverTest::testDoesNotEnterAnonymousClass";d:0;s:95:"phpDocumentor\Reflection\NodeVisitor\ElementNameResolverTest::testAnonymousClassDoesNotPopParts";d:0;s:79:"phpDocumentor\Reflection\NodeVisitor\ElementNameResolverTest::testClassConstant";d:0;s:84:"phpDocumentor\Reflection\NodeVisitor\ElementNameResolverTest::testNamespacedConstant";d:0;s:55:"phpDocumentor\Reflection\Php\ArgumentTest::testGetTypes";d:0;s:54:"phpDocumentor\Reflection\Php\ArgumentTest::testGetName";d:0;s:57:"phpDocumentor\Reflection\Php\ArgumentTest::testGetDefault";d:0;s:84:"phpDocumentor\Reflection\Php\ArgumentTest::testGetWhetherArgumentIsPassedByReference";d:0;s:75:"phpDocumentor\Reflection\Php\ArgumentTest::testGetWhetherArgumentisVariadic";d:0;s:58:"phpDocumentor\Reflection\Php\Class_Test::testGettingParent";d:0.002;s:68:"phpDocumentor\Reflection\Php\Class_Test::testAddAndGettingInterfaces";d:0;s:67:"phpDocumentor\Reflection\Php\Class_Test::testAddAndGettingConstants";d:0;s:68:"phpDocumentor\Reflection\Php\Class_Test::testAddAndGettingProperties";d:0;s:65:"phpDocumentor\Reflection\Php\Class_Test::testAddAndGettingMethods";d:0;s:67:"phpDocumentor\Reflection\Php\Class_Test::testAddAndGettingUsedTrait";d:0;s:74:"phpDocumentor\Reflection\Php\Class_Test::testGettingWhetherClassIsAbstract";d:0;s:71:"phpDocumentor\Reflection\Php\Class_Test::testGettingWhetherClassIsFinal";d:0;s:55:"phpDocumentor\Reflection\Php\ConstantTest::testGetValue";d:0;s:55:"phpDocumentor\Reflection\Php\ConstantTest::testGetFqsen";d:0;s:58:"phpDocumentor\Reflection\Php\ConstantTest::testGetDocblock";d:0;s:62:"phpDocumentor\Reflection\Php\Factory\ArgumentTest::testMatches";d:0.008;s:61:"phpDocumentor\Reflection\Php\Factory\ArgumentTest::testCreate";d:0;s:76:"phpDocumentor\Reflection\Php\Factory\ArgumentTest::testCreateThrowsException";d:0.001;s:80:"phpDocumentor\Reflection\Php\Factory\ClassConstantIteratorTest::testIterateProps";d:0;s:71:"phpDocumentor\Reflection\Php\Factory\ClassConstantIteratorTest::testKey";d:0.001;s:80:"phpDocumentor\Reflection\Php\Factory\ClassConstantIteratorTest::testProxyMethods";d:0.001;s:90:"phpDocumentor\Reflection\Php\Factory\ClassConstantIteratorTest::testGetDocCommentPropFirst";d:0.002;s:81:"phpDocumentor\Reflection\Php\Factory\ClassConstantIteratorTest::testGetDocComment";d:0;s:60:"phpDocumentor\Reflection\Php\Factory\Class_Test::testMatches";d:0.002;s:65:"phpDocumentor\Reflection\Php\Factory\Class_Test::testSimpleCreate";d:0;s:68:"phpDocumentor\Reflection\Php\Factory\Class_Test::testClassWithParent";d:0;s:79:"phpDocumentor\Reflection\Php\Factory\Class_Test::testClassImplementingInterface";d:0;s:70:"phpDocumentor\Reflection\Php\Factory\Class_Test::testWithMethodMembers";d:0.001;s:72:"phpDocumentor\Reflection\Php\Factory\Class_Test::testWithPropertyMembers";d:0.001;s:67:"phpDocumentor\Reflection\Php\Factory\Class_Test::testWithUsedTraits";d:0;s:66:"phpDocumentor\Reflection\Php\Factory\Class_Test::testWithConstants";d:0;s:71:"phpDocumentor\Reflection\Php\Factory\Class_Test::testCreateWithDocBlock";d:0.001;s:74:"phpDocumentor\Reflection\Php\Factory\Class_Test::testCreateThrowsException";d:0;s:62:"phpDocumentor\Reflection\Php\Factory\DocBlockTest::testMatches";d:0.001;s:80:"phpDocumentor\Reflection\Php\Factory\DocBlockTest::testCreateWithNullReturnsNull";d:0;s:73:"phpDocumentor\Reflection\Php\Factory\DocBlockTest::testCreateCallsFactory";d:0;s:76:"phpDocumentor\Reflection\Php\Factory\DocBlockTest::testCreateThrowsException";d:0;s:72:"phpDocumentor\Reflection\Php\Factory\File\CreateCommandTest::testGetFile";d:0;s:78:"phpDocumentor\Reflection\Php\Factory\File\CreateCommandTest::testGetStrategies";d:0;s:58:"phpDocumentor\Reflection\Php\Factory\FileTest::testMatches";d:0.002;s:67:"phpDocumentor\Reflection\Php\Factory\FileTest::testFileWithFunction";d:0.001;s:64:"phpDocumentor\Reflection\Php\Factory\FileTest::testFileWithClass";d:0;s:68:"phpDocumentor\Reflection\Php\Factory\FileTest::testFileWithNamespace";d:0;s:68:"phpDocumentor\Reflection\Php\Factory\FileTest::testFileWithInterface";d:0.001;s:64:"phpDocumentor\Reflection\Php\Factory\FileTest::testFileWithTrait";d:0.001;s:71:"phpDocumentor\Reflection\Php\Factory\FileTest::testMiddlewareIsExecuted";d:0.001;s:70:"phpDocumentor\Reflection\Php\Factory\FileTest::testMiddlewareIsChecked";d:0;s:76:"phpDocumentor\Reflection\Php\Factory\FileTest::testFileDocBlockWithNamespace";d:0.001;s:72:"phpDocumentor\Reflection\Php\Factory\FileTest::testFileDocBlockWithClass";d:0;s:75:"phpDocumentor\Reflection\Php\Factory\FileTest::testFileDocBlockWithComments";d:0;s:72:"phpDocumentor\Reflection\Php\Factory\FileTest::testCreateThrowsException";d:0;s:63:"phpDocumentor\Reflection\Php\Factory\Function_Test::testMatches";d:0.002;s:79:"phpDocumentor\Reflection\Php\Factory\Function_Test::testCreateWithoutParameters";d:0;s:76:"phpDocumentor\Reflection\Php\Factory\Function_Test::testCreateWithParameters";d:0;s:75:"phpDocumentor\Reflection\Php\Factory\Function_Test::testReturnTypeResolving";d:0.001;s:83:"phpDocumentor\Reflection\Php\Factory\Function_Test::testReturnTypeNullableResolving";d:0;s:74:"phpDocumentor\Reflection\Php\Factory\Function_Test::testCreateWithDocBlock";d:0;s:77:"phpDocumentor\Reflection\Php\Factory\Function_Test::testCreateThrowsException";d:0;s:64:"phpDocumentor\Reflection\Php\Factory\Interface_Test::testMatches";d:0.002;s:69:"phpDocumentor\Reflection\Php\Factory\Interface_Test::testSimpleCreate";d:0;s:75:"phpDocumentor\Reflection\Php\Factory\Interface_Test::testCreateWithDocBlock";d:0;s:74:"phpDocumentor\Reflection\Php\Factory\Interface_Test::testWithMethodMembers";d:0;s:70:"phpDocumentor\Reflection\Php\Factory\Interface_Test::testWithConstants";d:0;s:78:"phpDocumentor\Reflection\Php\Factory\Interface_Test::testCreateThrowsException";d:0;s:60:"phpDocumentor\Reflection\Php\Factory\MethodTest::testMatches";d:0.002;s:76:"phpDocumentor\Reflection\Php\Factory\MethodTest::testCreateWithoutParameters";d:0;s:74:"phpDocumentor\Reflection\Php\Factory\MethodTest::testCreateProtectedMethod";d:0;s:73:"phpDocumentor\Reflection\Php\Factory\MethodTest::testCreateWithParameters";d:0;s:72:"phpDocumentor\Reflection\Php\Factory\MethodTest::testReturnTypeResolving";d:0;s:80:"phpDocumentor\Reflection\Php\Factory\MethodTest::testReturnTypeNullableResolving";d:0;s:71:"phpDocumentor\Reflection\Php\Factory\MethodTest::testCreateWithDocBlock";d:0;s:74:"phpDocumentor\Reflection\Php\Factory\MethodTest::testCreateThrowsException";d:0;s:75:"phpDocumentor\Reflection\Php\Factory\PropertyIteratorTest::testIterateProps";d:0;s:66:"phpDocumentor\Reflection\Php\Factory\PropertyIteratorTest::testKey";d:0.002;s:75:"phpDocumentor\Reflection\Php\Factory\PropertyIteratorTest::testProxyMethods";d:0;s:73:"phpDocumentor\Reflection\Php\Factory\PropertyIteratorTest::testGetDefault";d:0.002;s:85:"phpDocumentor\Reflection\Php\Factory\PropertyIteratorTest::testGetDocCommentPropFirst";d:0;s:76:"phpDocumentor\Reflection\Php\Factory\PropertyIteratorTest::testGetDocComment";d:0;s:62:"phpDocumentor\Reflection\Php\Factory\PropertyTest::testMatches";d:0;s:68:"phpDocumentor\Reflection\Php\Factory\PropertyTest::testPrivateCreate";d:0;s:70:"phpDocumentor\Reflection\Php\Factory\PropertyTest::testProtectedCreate";d:0;s:67:"phpDocumentor\Reflection\Php\Factory\PropertyTest::testCreatePublic";d:0;s:73:"phpDocumentor\Reflection\Php\Factory\PropertyTest::testCreateWithDocBlock";d:0;s:76:"phpDocumentor\Reflection\Php\Factory\PropertyTest::testCreateThrowsException";d:0;s:60:"phpDocumentor\Reflection\Php\Factory\Trait_Test::testMatches";d:0.002;s:65:"phpDocumentor\Reflection\Php\Factory\Trait_Test::testSimpleCreate";d:0;s:71:"phpDocumentor\Reflection\Php\Factory\Trait_Test::testCreateWithDocBlock";d:0;s:72:"phpDocumentor\Reflection\Php\Factory\Trait_Test::testWithPropertyMembers";d:0;s:70:"phpDocumentor\Reflection\Php\Factory\Trait_Test::testWithMethodMembers";d:0;s:67:"phpDocumentor\Reflection\Php\Factory\Trait_Test::testWithUsedTraits";d:0;s:74:"phpDocumentor\Reflection\Php\Factory\Trait_Test::testCreateThrowsException";d:0;s:59:"phpDocumentor\Reflection\Php\FileTest::testAddAndGetClasses";d:0;s:61:"phpDocumentor\Reflection\Php\FileTest::testAddAndGetConstants";d:0;s:61:"phpDocumentor\Reflection\Php\FileTest::testAddAndGetFunctions";d:0;s:62:"phpDocumentor\Reflection\Php\FileTest::testAddAndGetInterfaces";d:0;s:58:"phpDocumentor\Reflection\Php\FileTest::testAddAndGetTraits";d:0;s:54:"phpDocumentor\Reflection\Php\FileTest::testGetDocBlock";d:0;s:50:"phpDocumentor\Reflection\Php\FileTest::testGetHash";d:0;s:56:"phpDocumentor\Reflection\Php\FileTest::testSetAndGetPath";d:0;s:58:"phpDocumentor\Reflection\Php\FileTest::testSetAndGetSource";d:0;s:68:"phpDocumentor\Reflection\Php\FileTest::testSetAndGetNamespaceAliases";d:0;s:60:"phpDocumentor\Reflection\Php\FileTest::testAddAndGetIncludes";d:0;s:55:"phpDocumentor\Reflection\Php\Function_Test::testGetName";d:0;s:66:"phpDocumentor\Reflection\Php\Function_Test::testAddAndGetArguments";d:0;s:56:"phpDocumentor\Reflection\Php\Function_Test::testGetFqsen";d:0;s:59:"phpDocumentor\Reflection\Php\Function_Test::testGetDocblock";d:0;s:68:"phpDocumentor\Reflection\Php\Function_Test::testGetDefaultReturnType";d:0;s:76:"phpDocumentor\Reflection\Php\Function_Test::testGetReturnTypeFromConstructor";d:0;s:57:"phpDocumentor\Reflection\Php\Interface_Test::testGetFqsen";d:0;s:60:"phpDocumentor\Reflection\Php\Interface_Test::testGetDocblock";d:0;s:75:"phpDocumentor\Reflection\Php\Interface_Test::testSettingAndGettingConstants";d:0;s:73:"phpDocumentor\Reflection\Php\Interface_Test::testSettingAndGettingMethods";d:0;s:63:"phpDocumentor\Reflection\Php\MethodTest::testGetFqsenAndGetName";d:0;s:56:"phpDocumentor\Reflection\Php\MethodTest::testGetDocBlock";d:0;s:70:"phpDocumentor\Reflection\Php\MethodTest::testAddingAndGettingArguments";d:0;s:75:"phpDocumentor\Reflection\Php\MethodTest::testGettingWhetherMethodIsAbstract";d:0;s:72:"phpDocumentor\Reflection\Php\MethodTest::testGettingWhetherMethodIsFinal";d:0;s:73:"phpDocumentor\Reflection\Php\MethodTest::testGettingWhetherMethodIsStatic";d:0;s:62:"phpDocumentor\Reflection\Php\MethodTest::testGettingVisibility";d:0;s:65:"phpDocumentor\Reflection\Php\MethodTest::testGetDefaultVisibility";d:0;s:65:"phpDocumentor\Reflection\Php\MethodTest::testGetDefaultReturnType";d:0;s:73:"phpDocumentor\Reflection\Php\MethodTest::testGetReturnTypeFromConstructor";d:0;s:65:"phpDocumentor\Reflection\Php\Namespace_Test::testAddAndGetClasses";d:0;s:67:"phpDocumentor\Reflection\Php\Namespace_Test::testAddAndGetConstants";d:0;s:67:"phpDocumentor\Reflection\Php\Namespace_Test::testAddAndGetFunctions";d:0;s:68:"phpDocumentor\Reflection\Php\Namespace_Test::testAddAndGetInterfaces";d:0;s:64:"phpDocumentor\Reflection\Php\Namespace_Test::testAddAndGetTraits";d:0;s:57:"phpDocumentor\Reflection\Php\Namespace_Test::testGetFqsen";d:0;s:83:"phpDocumentor\Reflection\Php\ProjectFactoryStrategiesTest::testStrategiesAreChecked";d:0;s:75:"phpDocumentor\Reflection\Php\ProjectFactoryStrategiesTest::testFindMatching";d:0;s:104:"phpDocumentor\Reflection\Php\ProjectFactoryStrategiesTest::testCreateThrowsExceptionWhenStrategyNotFound";d:0;s:73:"phpDocumentor\Reflection\Php\ProjectFactoryTest::testStrategiesAreChecked";d:0;s:59:"phpDocumentor\Reflection\Php\ProjectFactoryTest::testCreate";d:0;s:94:"phpDocumentor\Reflection\Php\ProjectFactoryTest::testCreateThrowsExceptionWhenStrategyNotFound";d:0;s:93:"phpDocumentor\Reflection\Php\ProjectFactoryTest::testCreateProjectFromFileWithNamespacedClass";d:0;s:76:"phpDocumentor\Reflection\Php\ProjectFactoryTest::testWithNamespacedInterface";d:0;s:75:"phpDocumentor\Reflection\Php\ProjectFactoryTest::testWithNamespacedFunction";d:0;s:75:"phpDocumentor\Reflection\Php\ProjectFactoryTest::testWithNamespacedConstant";d:0;s:72:"phpDocumentor\Reflection\Php\ProjectFactoryTest::testWithNamespacedTrait";d:0;s:85:"phpDocumentor\Reflection\Php\ProjectFactoryTest::testNamespaceSpreadOverMultipleFiles";d:0;s:81:"phpDocumentor\Reflection\Php\ProjectFactoryTest::testSingleFileMultipleNamespaces";d:0;s:93:"phpDocumentor\Reflection\Php\ProjectFactoryTest::testErrorScenarioWhenFileStrategyReturnsNull";d:0;s:56:"phpDocumentor\Reflection\Php\ProjectTest::testGetSetName";d:0;s:57:"phpDocumentor\Reflection\Php\ProjectTest::testGetAddFiles";d:0;s:62:"phpDocumentor\Reflection\Php\ProjectTest::testGetRootNamespace";d:0;s:61:"phpDocumentor\Reflection\Php\ProjectTest::testGetAddNamespace";d:0;s:65:"phpDocumentor\Reflection\Php\PropertyTest::testGetFqsenAndGetName";d:0;s:77:"phpDocumentor\Reflection\Php\PropertyTest::testGettingWhetherPropertyIsStatic";d:0;s:64:"phpDocumentor\Reflection\Php\PropertyTest::testGettingVisibility";d:0;s:61:"phpDocumentor\Reflection\Php\PropertyTest::testSetAndGetTypes";d:0;s:57:"phpDocumentor\Reflection\Php\PropertyTest::testGetDefault";d:0;s:58:"phpDocumentor\Reflection\Php\PropertyTest::testGetDocBlock";d:0;s:63:"phpDocumentor\Reflection\Php\Trait_Test::testGetFqsenAndGetName";d:0;s:68:"phpDocumentor\Reflection\Php\Trait_Test::testAddAndGettingProperties";d:0;s:65:"phpDocumentor\Reflection\Php\Trait_Test::testAddAndGettingMethods";d:0;s:67:"phpDocumentor\Reflection\Php\Trait_Test::testAddAndGettingUsedTrait";d:0;s:56:"phpDocumentor\Reflection\Php\Trait_Test::testGetDocblock";d:0;s:76:"phpDocumentor\Reflection\Php\VisibilityTest::testVisibility with data set #0";d:0;s:76:"phpDocumentor\Reflection\Php\VisibilityTest::testVisibility with data set #1";d:0;s:76:"phpDocumentor\Reflection\Php\VisibilityTest::testVisibility with data set #2";d:0;s:76:"phpDocumentor\Reflection\Php\VisibilityTest::testVisibility with data set #3";d:0;s:70:"phpDocumentor\Reflection\Php\VisibilityTest::testVisibilityChecksInput";d:0;s:68:"phpDocumentor\Reflection\PrettyPrinterTest::testScalarStringPrinting";d:0;s:102:"phpDocumentor\Reflection\Types\NamespaceNodeToContextTest::testConversion with data set "No namespace"";d:0;s:105:"phpDocumentor\Reflection\Types\NamespaceNodeToContextTest::testConversion with data set "Empty namespace"";d:0;s:106:"phpDocumentor\Reflection\Types\NamespaceNodeToContextTest::testConversion with data set "Actual namespace"";d:0;s:122:"phpDocumentor\Reflection\Types\NamespaceNodeToContextTest::testConversion with data set "Actual namespace prefixed with \"";d:0;s:111:"phpDocumentor\Reflection\Types\NamespaceNodeToContextTest::testConversion with data set "Complex use statement"";d:0;s:76:"phpDocumentor\Reflection\ProjectCreationTest::testCreateProjectWithFunctions";d:0.018;s:72:"phpDocumentor\Reflection\ProjectCreationTest::testCreateProjectWithClass";d:0.002;s:66:"phpDocumentor\Reflection\ProjectCreationTest::testFileWithDocBlock";d:0.001;s:69:"phpDocumentor\Reflection\ProjectCreationTest::testWithNamespacedClass";d:0.005;s:77:"phpDocumentor\Reflection\ProjectCreationTest::testDocblockOfMethodIsProcessed";d:0.003;s:64:"phpDocumentor\Reflection\ProjectCreationTest::testWithUsedParent";d:0.001;s:63:"phpDocumentor\Reflection\ProjectCreationTest::testWithInterface";d:0.001;s:59:"phpDocumentor\Reflection\ProjectCreationTest::testWithTrait";d:0.001;s:66:"phpDocumentor\Reflection\ProjectCreationTest::testInterfaceExtends";d:0.001;s:66:"phpDocumentor\Reflection\ProjectCreationTest::testMethodReturnType";d:0.001;s:62:"phpDocumentor\Reflection\ProjectCreationTest::testFileDocblock";d:0.001;s:70:"phpDocumentor\Reflection\ProjectNamespaceTest::testWithNamespacedClass";d:0.003;}}}
\ No newline at end of file
diff --git a/Makefile b/Makefile
new file mode 100644
index 00000000..b83dd98b
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,32 @@
+.PHONY: install-phive
+install-phive:
+ mkdir tools; \
+ wget -O tools/phive.phar https://phar.io/releases/phive.phar; \
+ wget -O tools/phive.phar.asc https://phar.io/releases/phive.phar.asc; \
+ gpg --keyserver pool.sks-keyservers.net --recv-keys 0x9D8A98B29B2D5D79; \
+ gpg --verify tools/phive.phar.asc tools/phive.phar; \
+ chmod +x tools/phive.phar
+
+.PHONY: setup
+setup: install-phive
+ docker run -it --rm -v${PWD}:/opt/project -w /opt/project phpdoc/phar-ga:latest php tools/phive.phar install --force-accept-unsigned
+
+.PHONY: phpcs
+phpcs:
+ docker run -it --rm -v${PWD}:/opt/project -w /opt/project phpdoc/phpcs-ga:latest -d memory_limit=1024M
+
+.PHONY: phpstan
+phpstan:
+ docker run -it --rm -v${PWD}:/opt/project -w /opt/project phpdoc/phpstan-ga:latest analyse src --no-progress --level max --configuration phpstan.neon
+
+.PHONY: psaml
+psalm:
+ docker run -it --rm -v${PWD}:/opt/project -w /opt/project mickaelandrieu/psalm-ga
+
+.PHONY: test
+test:
+ docker run -it --rm -v${PWD}:/opt/project -w /opt/project php:7.2 tools/phpunit
+
+.PHONY: pre-commit-test
+pre-commit-test: test phpcs phpstan psalm
+
diff --git a/composer.json b/composer.json
index a4a443ae..711a3397 100644
--- a/composer.json
+++ b/composer.json
@@ -20,7 +20,7 @@
},
"minimum-stability": "alpha",
"require": {
- "php": ">=7.1",
+ "php": "^7.2",
"psr/log": "~1.0",
"nikic/php-parser": "^4.0",
"phpdocumentor/reflection-docblock": "^5"
diff --git a/composer.lock b/composer.lock
index 6b1bee98..3b396e24 100644
--- a/composer.lock
+++ b/composer.lock
@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
- "content-hash": "ae7e684c7c19ad6defcfa2c3b7dd8847",
+ "content-hash": "32c8e6a1a2e596454e877e4409559aeb",
"packages": [
{
"name": "nikic/php-parser",
@@ -526,7 +526,7 @@
"prefer-stable": false,
"prefer-lowest": false,
"platform": {
- "php": ">=7.1"
+ "php": "^7.2"
},
"platform-dev": []
}
diff --git a/phive.xml b/phive.xml
index ce69c2f9..5782466d 100644
--- a/phive.xml
+++ b/phive.xml
@@ -1,6 +1,6 @@
-
-
+
+
diff --git a/phpcs.xml.dist b/phpcs.xml.dist
new file mode 100644
index 00000000..c030e8de
--- /dev/null
+++ b/phpcs.xml.dist
@@ -0,0 +1,30 @@
+
+
+ The coding standard for phpDocumentor.
+
+ src
+ tests/unit
+ */tests/unit/Types/ContextFactoryTest.php
+
+
+ *\.php
+
+
+
+
+
+
+
+ */src/*_.php
+
+
+
+ */src/*/Abstract*.php
+
+
+
+
+
+
+
+
diff --git a/phpunit.xml.dist b/phpunit.xml.dist
index 751d4fd1..75351dc5 100644
--- a/phpunit.xml.dist
+++ b/phpunit.xml.dist
@@ -1,11 +1,16 @@
@@ -22,15 +27,11 @@
-
+
- * @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
*/
@@ -17,8 +16,6 @@
/**
* An exception specifically originating from the Reflection component.
*
- * @author Mike van Riel
- * @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
*/
class Exception extends \Exception
diff --git a/src/phpDocumentor/Reflection/File/LocalFile.php b/src/phpDocumentor/Reflection/File/LocalFile.php
index facf4f73..69480a82 100644
--- a/src/phpDocumentor/Reflection/File/LocalFile.php
+++ b/src/phpDocumentor/Reflection/File/LocalFile.php
@@ -1,4 +1,5 @@
- * @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
*/
namespace phpDocumentor\Reflection\File;
+use InvalidArgumentException;
use phpDocumentor\Reflection\File;
+use function file_exists;
+use function file_get_contents;
+use function md5_file;
+use function sprintf;
/**
* Represents a local file on the file system.
@@ -23,17 +27,15 @@ final class LocalFile implements File
{
/**
* Path to the file.
+ *
* @var string
*/
private $path;
- /**
- * LocalFile constructor.
- */
public function __construct(string $path)
{
if (!file_exists($path)) {
- throw new \InvalidArgumentException(sprintf('File "%s" does not exist', $path));
+ throw new InvalidArgumentException(sprintf('File "%s" does not exist', $path));
}
$this->path = $path;
@@ -42,7 +44,7 @@ public function __construct(string $path)
/**
* Returns the content of the file as a string.
*/
- public function getContents(): string
+ public function getContents() : string
{
return (string) file_get_contents($this->path);
}
@@ -50,7 +52,7 @@ public function getContents(): string
/**
* Returns md5 hash of the file.
*/
- public function md5(): string
+ public function md5() : string
{
return md5_file($this->path);
}
@@ -58,7 +60,7 @@ public function md5(): string
/**
* Returns an relative path to the file.
*/
- public function path(): string
+ public function path() : string
{
return $this->path;
}
diff --git a/src/phpDocumentor/Reflection/Middleware/ChainFactory.php b/src/phpDocumentor/Reflection/Middleware/ChainFactory.php
index b6d8d158..98e12d48 100644
--- a/src/phpDocumentor/Reflection/Middleware/ChainFactory.php
+++ b/src/phpDocumentor/Reflection/Middleware/ChainFactory.php
@@ -1,4 +1,5 @@
execute($command, $lastCallable);
};
}
diff --git a/src/phpDocumentor/Reflection/Middleware/Command.php b/src/phpDocumentor/Reflection/Middleware/Command.php
index d5d625e3..cbba91bf 100644
--- a/src/phpDocumentor/Reflection/Middleware/Command.php
+++ b/src/phpDocumentor/Reflection/Middleware/Command.php
@@ -1,4 +1,5 @@
- * @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
*/
diff --git a/src/phpDocumentor/Reflection/Middleware/Middleware.php b/src/phpDocumentor/Reflection/Middleware/Middleware.php
index dd50f4e5..1a46cbbf 100644
--- a/src/phpDocumentor/Reflection/Middleware/Middleware.php
+++ b/src/phpDocumentor/Reflection/Middleware/Middleware.php
@@ -1,4 +1,5 @@
- * @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
*/
@@ -21,8 +20,6 @@ interface Middleware
{
/**
* Executes this middle ware class.
- *
- * @return object
*/
- public function execute(Command $command, callable $next);
+ public function execute(Command $command, callable $next) : object;
}
diff --git a/src/phpDocumentor/Reflection/NodeVisitor/ElementNameResolver.php b/src/phpDocumentor/Reflection/NodeVisitor/ElementNameResolver.php
index cd0de69d..44147fba 100644
--- a/src/phpDocumentor/Reflection/NodeVisitor/ElementNameResolver.php
+++ b/src/phpDocumentor/Reflection/NodeVisitor/ElementNameResolver.php
@@ -1,4 +1,5 @@
- * @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
*/
@@ -28,18 +27,18 @@
use PhpParser\NodeTraverser;
use PhpParser\NodeVisitorAbstract;
use SplDoublyLinkedList;
+use function get_class;
+use function rtrim;
final class ElementNameResolver extends NodeVisitorAbstract
{
- /**
- * @var SplDoublyLinkedList
- */
+ /** @var SplDoublyLinkedList */
private $parts = null;
/**
* Resets the object to a known state before start processing.
*/
- public function beforeTraverse(array $nodes)
+ public function beforeTraverse(array $nodes) : void
{
$this->resetState('\\');
}
@@ -47,7 +46,7 @@ public function beforeTraverse(array $nodes)
/**
* Performs a reset of the added element when needed.
*/
- public function leaveNode(Node $node)
+ public function leaveNode(Node $node) : void
{
switch (get_class($node)) {
case Namespace_::class:
@@ -75,7 +74,7 @@ public function leaveNode(Node $node)
* that should clear up the PHPSTAN errors about
* "access to an undefined property ::$fqsen".
*/
- public function enterNode(Node $node): ?int
+ public function enterNode(Node $node) : ?int
{
switch (get_class($node)) {
case Namespace_::class:
@@ -89,7 +88,7 @@ public function enterNode(Node $node): ?int
return NodeTraverser::DONT_TRAVERSE_CHILDREN;
}
- $this->parts->push((string)$node->name);
+ $this->parts->push((string) $node->name);
$node->fqsen = new Fqsen($this->buildName());
break;
case Function_::class:
@@ -119,7 +118,7 @@ public function enterNode(Node $node): ?int
/**
* Resets the state of the object to an empty state.
*/
- private function resetState(?string $namespace = null): void
+ private function resetState(?string $namespace = null) : void
{
$this->parts = new SplDoublyLinkedList();
$this->parts->push($namespace);
@@ -128,7 +127,7 @@ private function resetState(?string $namespace = null): void
/**
* Builds the name of the current node using the parts that are pushed to the parts list.
*/
- private function buildName(): string
+ private function buildName() : string
{
$name = null;
foreach ($this->parts as $part) {
diff --git a/src/phpDocumentor/Reflection/Php/Argument.php b/src/phpDocumentor/Reflection/Php/Argument.php
index ce82e5b1..f5fc473c 100644
--- a/src/phpDocumentor/Reflection/Php/Argument.php
+++ b/src/phpDocumentor/Reflection/Php/Argument.php
@@ -1,4 +1,5 @@
- * @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
*/
@@ -22,29 +21,19 @@
*/
final class Argument
{
- /**
- * @var string name of the Argument
- */
+ /** @var string name of the Argument */
private $name;
- /**
- * @var Type a normalized type that should be in this Argument
- */
+ /** @var Type a normalized type that should be in this Argument */
private $type;
- /**
- * @var string|null the default value for an argument or null if none is provided
- */
+ /** @var string|null the default value for an argument or null if none is provided */
private $default;
- /**
- * @var bool whether the argument passes the parameter by reference instead of by value
- */
+ /** @var bool whether the argument passes the parameter by reference instead of by value */
private $byReference;
- /**
- * @var boolean Determines if this Argument represents a variadic argument
- */
+ /** @var bool Determines if this Argument represents a variadic argument */
private $isVariadic;
/**
@@ -52,10 +41,10 @@ final class Argument
*/
public function __construct(string $name, ?Type $type = null, ?string $default = null, bool $byReference = false, bool $isVariadic = false)
{
- $this->name = $name;
- $this->default = $default;
+ $this->name = $name;
+ $this->default = $default;
$this->byReference = $byReference;
- $this->isVariadic = $isVariadic;
+ $this->isVariadic = $isVariadic;
if ($type === null) {
$type = new Mixed_();
}
@@ -66,27 +55,27 @@ public function __construct(string $name, ?Type $type = null, ?string $default =
/**
* Returns the name of this argument.
*/
- public function getName(): string
+ public function getName() : string
{
return $this->name;
}
- public function getType(): ?Type
+ public function getType() : ?Type
{
return $this->type;
}
- public function getDefault(): ?string
+ public function getDefault() : ?string
{
return $this->default;
}
- public function isByReference(): bool
+ public function isByReference() : bool
{
return $this->byReference;
}
- public function isVariadic(): bool
+ public function isVariadic() : bool
{
return $this->isVariadic;
}
diff --git a/src/phpDocumentor/Reflection/Php/Class_.php b/src/phpDocumentor/Reflection/Php/Class_.php
index dd310a75..02a8d1d0 100644
--- a/src/phpDocumentor/Reflection/Php/Class_.php
+++ b/src/phpDocumentor/Reflection/Php/Class_.php
@@ -1,4 +1,5 @@
- * @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
*/
@@ -26,59 +25,37 @@
final class Class_ implements Element
// @codingStandardsIgnoreEnd
{
- /**
- * @var Fqsen Full Qualified Structural Element Name
- */
+ /** @var Fqsen Full Qualified Structural Element Name */
private $fqsen;
- /**
- * @var DocBlock|null
- */
+ /** @var DocBlock|null */
private $docBlock = null;
- /**
- * @var boolean Whether this is an abstract class.
- */
+ /** @var bool Whether this is an abstract class. */
private $abstract = false;
- /**
- * @var boolean Whether this class is marked as final and can't be subclassed.
- */
+ /** @var bool Whether this class is marked as final and can't be subclassed. */
private $final = false;
- /**
- * @var null|Fqsen The class this class is extending.
- */
+ /** @var Fqsen|null The class this class is extending. */
private $parent = null;
- /**
- * @var Fqsen[] References to interfaces that are implemented by this class.
- */
+ /** @var Fqsen[] References to interfaces that are implemented by this class. */
private $implements = [];
- /**
- * @var Constant[] References to constants defined in this class.
- */
+ /** @var Constant[] References to constants defined in this class. */
private $constants = [];
- /**
- * @var Property[] References to properties defined in this class.
- */
+ /** @var Property[] References to properties defined in this class. */
private $properties = [];
- /**
- * @var Method[] References to methods defined in this class.
- */
+ /** @var Method[] References to methods defined in this class. */
private $methods = [];
- /**
- * @var Fqsen[] References to traits consumed by this class
- */
+ /** @var Fqsen[] References to traits consumed by this class */
private $usedTraits = [];
- /**
- * @var Location
- */
+ /** @var Location */
private $location;
/**
@@ -96,18 +73,18 @@ public function __construct(
$location = new Location(-1);
}
- $this->fqsen = $fqsen;
- $this->parent = $parent;
+ $this->fqsen = $fqsen;
+ $this->parent = $parent;
$this->docBlock = $docBlock;
$this->abstract = $abstract;
- $this->final = $final;
+ $this->final = $final;
$this->location = $location;
}
/**
* Returns true when this class is final. Otherwise returns false.
*/
- public function isFinal(): bool
+ public function isFinal() : bool
{
return $this->final;
}
@@ -115,7 +92,7 @@ public function isFinal(): bool
/**
* Returns true when this class is abstract. Otherwise returns false.
*/
- public function isAbstract(): bool
+ public function isAbstract() : bool
{
return $this->abstract;
}
@@ -123,7 +100,7 @@ public function isAbstract(): bool
/**
* Returns the superclass this class is extending if available.
*/
- public function getParent(): ?Fqsen
+ public function getParent() : ?Fqsen
{
return $this->parent;
}
@@ -133,7 +110,7 @@ public function getParent(): ?Fqsen
*
* @return Fqsen[]
*/
- public function getInterfaces(): array
+ public function getInterfaces() : array
{
return $this->implements;
}
@@ -141,7 +118,7 @@ public function getInterfaces(): array
/**
* Add a interface Fqsen this class is implementing.
*/
- public function addInterface(Fqsen $interface): void
+ public function addInterface(Fqsen $interface) : void
{
$this->implements[(string) $interface] = $interface;
}
@@ -151,7 +128,7 @@ public function addInterface(Fqsen $interface): void
*
* @return Constant[]
*/
- public function getConstants(): array
+ public function getConstants() : array
{
return $this->constants;
}
@@ -159,7 +136,7 @@ public function getConstants(): array
/**
* Add Constant to this class.
*/
- public function addConstant(Constant $constant): void
+ public function addConstant(Constant $constant) : void
{
$this->constants[(string) $constant->getFqsen()] = $constant;
}
@@ -169,7 +146,7 @@ public function addConstant(Constant $constant): void
*
* @return Method[]
*/
- public function getMethods(): array
+ public function getMethods() : array
{
return $this->methods;
}
@@ -177,7 +154,7 @@ public function getMethods(): array
/**
* Add a method to this class.
*/
- public function addMethod(Method $method): void
+ public function addMethod(Method $method) : void
{
$this->methods[(string) $method->getFqsen()] = $method;
}
@@ -187,7 +164,7 @@ public function addMethod(Method $method): void
*
* @return Property[]
*/
- public function getProperties(): array
+ public function getProperties() : array
{
return $this->properties;
}
@@ -195,7 +172,7 @@ public function getProperties(): array
/**
* Add a property to this class.
*/
- public function addProperty(Property $property): void
+ public function addProperty(Property $property) : void
{
$this->properties[(string) $property->getFqsen()] = $property;
}
@@ -205,7 +182,7 @@ public function addProperty(Property $property): void
*
* @return Fqsen[]
*/
- public function getUsedTraits(): array
+ public function getUsedTraits() : array
{
return $this->usedTraits;
}
@@ -213,7 +190,7 @@ public function getUsedTraits(): array
/**
* Add trait fqsen used by this class.
*/
- public function addUsedTrait(Fqsen $fqsen): void
+ public function addUsedTrait(Fqsen $fqsen) : void
{
$this->usedTraits[(string) $fqsen] = $fqsen;
}
@@ -221,7 +198,7 @@ public function addUsedTrait(Fqsen $fqsen): void
/**
* Returns the Fqsen of the element.
*/
- public function getFqsen(): Fqsen
+ public function getFqsen() : Fqsen
{
return $this->fqsen;
}
@@ -229,17 +206,17 @@ public function getFqsen(): Fqsen
/**
* Returns the name of the element.
*/
- public function getName(): string
+ public function getName() : string
{
return $this->fqsen->getName();
}
- public function getDocBlock(): ?DocBlock
+ public function getDocBlock() : ?DocBlock
{
return $this->docBlock;
}
- public function getLocation(): Location
+ public function getLocation() : Location
{
return $this->location;
}
diff --git a/src/phpDocumentor/Reflection/Php/Constant.php b/src/phpDocumentor/Reflection/Php/Constant.php
index 9ac9d8ec..846a2775 100644
--- a/src/phpDocumentor/Reflection/Php/Constant.php
+++ b/src/phpDocumentor/Reflection/Php/Constant.php
@@ -1,4 +1,5 @@
- * @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
*/
@@ -24,36 +23,26 @@
*/
final class Constant implements Element
{
- /**
- * @var Fqsen
- */
+ /** @var Fqsen */
private $fqsen;
- /**
- * @var null|DocBlock
- */
+ /** @var DocBlock|null */
private $docBlock;
- /** @var null|string $value */
+ /** @var string|null $value */
private $value;
- /**
- * @var Location
- */
+ /** @var Location */
private $location;
/**
* Initializes the object.
- *
- * @param DocBlock|null $docBlock
- * @param null|string $value
- * @param Location|null $location
*/
public function __construct(Fqsen $fqsen, ?DocBlock $docBlock = null, ?string $value = null, ?Location $location = null)
{
- $this->fqsen = $fqsen;
+ $this->fqsen = $fqsen;
$this->docBlock = $docBlock;
- $this->value = $value;
+ $this->value = $value;
if ($location === null) {
$location = new Location(-1);
@@ -65,7 +54,7 @@ public function __construct(Fqsen $fqsen, ?DocBlock $docBlock = null, ?string $v
/**
* Returns the value of this constant.
*/
- public function getValue(): ?string
+ public function getValue() : ?string
{
return $this->value;
}
@@ -73,7 +62,7 @@ public function getValue(): ?string
/**
* Returns the Fqsen of the element.
*/
- public function getFqsen(): Fqsen
+ public function getFqsen() : Fqsen
{
return $this->fqsen;
}
@@ -81,7 +70,7 @@ public function getFqsen(): Fqsen
/**
* Returns the name of the element.
*/
- public function getName(): string
+ public function getName() : string
{
return $this->fqsen->getName();
}
@@ -89,12 +78,12 @@ public function getName(): string
/**
* Returns DocBlock of this constant if available.
*/
- public function getDocBlock(): ?DocBlock
+ public function getDocBlock() : ?DocBlock
{
return $this->docBlock;
}
- public function getLocation(): Location
+ public function getLocation() : Location
{
return $this->location;
}
diff --git a/src/phpDocumentor/Reflection/Php/Factory/AbstractFactory.php b/src/phpDocumentor/Reflection/Php/Factory/AbstractFactory.php
index 1f9d4205..ddf1fcda 100644
--- a/src/phpDocumentor/Reflection/Php/Factory/AbstractFactory.php
+++ b/src/phpDocumentor/Reflection/Php/Factory/AbstractFactory.php
@@ -1,14 +1,21 @@
matches($object)) {
- throw new \InvalidArgumentException(
+ throw new InvalidArgumentException(
sprintf(
'%s cannot handle objects with the type %s',
- __CLASS__,
+ self::class,
is_object($object) ? get_class($object) : gettype($object)
)
);
@@ -38,6 +45,7 @@ abstract protected function doCreate($object, StrategyContainer $strategies, ?Co
/**
* @param Node|PropertyIterator|ClassConstantIterator|Doc $stmt
+ *
* @return mixed a child of Element
*/
protected function createMember($stmt, StrategyContainer $strategies, ?Context $context = null)
@@ -46,10 +54,7 @@ protected function createMember($stmt, StrategyContainer $strategies, ?Context $
return $strategy->create($stmt, $strategies, $context);
}
- /**
- * @return null|DocBlockInstance
- */
- protected function createDocBlock(?StrategyContainer $strategies = null, ?Doc $docBlock = null, ?Context $context = null)
+ protected function createDocBlock(?StrategyContainer $strategies = null, ?Doc $docBlock = null, ?Context $context = null) : ?DocBlockInstance
{
if ($docBlock === null || $strategies === null) {
return null;
diff --git a/src/phpDocumentor/Reflection/Php/Factory/Argument.php b/src/phpDocumentor/Reflection/Php/Factory/Argument.php
index 4c4be3bd..c5008e68 100644
--- a/src/phpDocumentor/Reflection/Php/Factory/Argument.php
+++ b/src/phpDocumentor/Reflection/Php/Factory/Argument.php
@@ -1,4 +1,5 @@
- * @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
*/
@@ -34,9 +33,7 @@
*/
final class Argument extends AbstractFactory implements ProjectFactoryStrategy
{
- /**
- * @var PrettyPrinter
- */
+ /** @var PrettyPrinter */
private $valueConverter;
/**
@@ -47,7 +44,7 @@ public function __construct(PrettyPrinter $prettyPrinter)
$this->valueConverter = $prettyPrinter;
}
- public function matches($object): bool
+ public function matches($object) : bool
{
return $object instanceof Param;
}
@@ -57,9 +54,9 @@ public function matches($object): bool
* Since an object might contain other objects that need to be converted the $factory is passed so it can be
* used to create nested Elements.
*
- * @param Param $object object to convert to an Element
+ * @param Param $object object to convert to an Element
* @param StrategyContainer $strategies used to convert nested objects.
- * @param Context $context of the created object
+ * @param Context $context of the created object
* @return ArgumentDescriptor
*/
protected function doCreate($object, StrategyContainer $strategies, ?Context $context = null)
@@ -79,7 +76,7 @@ protected function doCreate($object, StrategyContainer $strategies, ?Context $co
return new ArgumentDescriptor((string) $object->var->name, $type, $default, $object->byRef, $object->variadic);
}
- private function createType(Param $arg, ?Context $context = null): Type
+ private function createType(Param $arg, ?Context $context = null) : Type
{
$typeResolver = new TypeResolver();
if ($arg->type instanceof NullableType) {
diff --git a/src/phpDocumentor/Reflection/Php/Factory/ClassConstantIterator.php b/src/phpDocumentor/Reflection/Php/Factory/ClassConstantIterator.php
index 3849bfce..e871979c 100644
--- a/src/phpDocumentor/Reflection/Php/Factory/ClassConstantIterator.php
+++ b/src/phpDocumentor/Reflection/Php/Factory/ClassConstantIterator.php
@@ -1,4 +1,5 @@
- * @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
*/
@@ -25,14 +24,10 @@
*/
final class ClassConstantIterator implements Iterator
{
- /**
- * @var ClassConst
- */
+ /** @var ClassConst */
private $classConstants;
- /**
- * @var int index of the current ClassConst to use
- */
+ /** @var int index of the current ClassConst to use */
private $index = 0;
/**
@@ -48,7 +43,7 @@ public function __construct(ClassConst $classConst)
*
* @return int Line
*/
- public function getLine(): int
+ public function getLine() : int
{
return $this->classConstants->getLine();
}
@@ -56,7 +51,7 @@ public function getLine(): int
/**
* Returns the name of the current constant.
*/
- public function getName(): string
+ public function getName() : string
{
return (string) $this->classConstants->consts[$this->index]->name;
}
@@ -64,7 +59,7 @@ public function getName(): string
/**
* Returns the fqsen of the current constant.
*/
- public function getFqsen(): Fqsen
+ public function getFqsen() : Fqsen
{
return $this->classConstants->consts[$this->index]->fqsen;
}
@@ -74,7 +69,7 @@ public function getFqsen(): Fqsen
*
* The doc comment has to be the last comment associated with the node.
*/
- public function getDocComment(): ?Doc
+ public function getDocComment() : ?Doc
{
$docComment = $this->classConstants->consts[$this->index]->getDocComment();
if ($docComment === null) {
@@ -92,7 +87,7 @@ public function getValue()
/**
* @link http://php.net/manual/en/iterator.current.php
*/
- public function current(): self
+ public function current() : self
{
return $this;
}
@@ -100,7 +95,7 @@ public function current(): self
/**
* @link http://php.net/manual/en/iterator.next.php
*/
- public function next(): void
+ public function next() : void
{
++$this->index;
}
@@ -108,7 +103,7 @@ public function next(): void
/**
* @link http://php.net/manual/en/iterator.key.php
*/
- public function key(): ?int
+ public function key() : ?int
{
return $this->index;
}
@@ -116,7 +111,7 @@ public function key(): ?int
/**
* @link http://php.net/manual/en/iterator.valid.php
*/
- public function valid(): bool
+ public function valid() : bool
{
return isset($this->classConstants->consts[$this->index]);
}
@@ -124,7 +119,7 @@ public function valid(): bool
/**
* @link http://php.net/manual/en/iterator.rewind.php
*/
- public function rewind(): void
+ public function rewind() : void
{
$this->index = 0;
}
diff --git a/src/phpDocumentor/Reflection/Php/Factory/Class_.php b/src/phpDocumentor/Reflection/Php/Factory/Class_.php
index 508d2078..6430b397 100644
--- a/src/phpDocumentor/Reflection/Php/Factory/Class_.php
+++ b/src/phpDocumentor/Reflection/Php/Factory/Class_.php
@@ -1,4 +1,5 @@
- * @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
*/
@@ -25,6 +24,7 @@
use PhpParser\Node\Stmt\ClassMethod;
use PhpParser\Node\Stmt\Property as PropertyNode;
use PhpParser\Node\Stmt\TraitUse;
+use function get_class;
/**
* Strategy to create a ClassElement including all sub elements.
@@ -33,7 +33,7 @@
final class Class_ extends AbstractFactory implements ProjectFactoryStrategy
// @codingStandardsIgnoreEnd
{
- public function matches($object): bool
+ public function matches($object) : bool
{
return $object instanceof ClassNode;
}
@@ -43,9 +43,9 @@ public function matches($object): bool
* Since an object might contain other objects that need to be converted the $factory is passed so it can be
* used to create nested Elements.
*
- * @param ClassNode $object object to convert to an Element
+ * @param ClassNode $object object to convert to an Element
* @param StrategyContainer $strategies used to convert nested objects.
- * @param Context $context of the created object
+ * @param Context $context of the created object
* @return ClassElement
*/
protected function doCreate($object, StrategyContainer $strategies, ?Context $context = null)
diff --git a/src/phpDocumentor/Reflection/Php/Factory/Constant.php b/src/phpDocumentor/Reflection/Php/Factory/Constant.php
index 75586f1b..39075293 100644
--- a/src/phpDocumentor/Reflection/Php/Factory/Constant.php
+++ b/src/phpDocumentor/Reflection/Php/Factory/Constant.php
@@ -1,4 +1,5 @@
- * @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
*/
@@ -28,9 +27,7 @@
*/
final class Constant extends AbstractFactory
{
- /**
- * @var PrettyPrinter
- */
+ /** @var PrettyPrinter */
private $valueConverter;
/**
@@ -41,7 +38,7 @@ public function __construct(PrettyPrinter $prettyPrinter)
$this->valueConverter = $prettyPrinter;
}
- public function matches($object): bool
+ public function matches($object) : bool
{
return $object instanceof ClassConstantIterator;
}
@@ -51,15 +48,15 @@ public function matches($object): bool
* Since an object might contain other objects that need to be converted the $factory is passed so it can be
* used to create nested Elements.
*
- * @param ClassConstantIterator $object object to convert to an Element
- * @param StrategyContainer $strategies used to convert nested objects.
- * @param Context $context of the created object
+ * @param ClassConstantIterator $object object to convert to an Element
+ * @param StrategyContainer $strategies used to convert nested objects.
+ * @param Context $context of the created object
* @return ConstantElement
*/
protected function doCreate($object, StrategyContainer $strategies, ?Context $context = null)
{
$docBlock = $this->createDocBlock($strategies, $object->getDocComment(), $context);
- $default = null;
+ $default = null;
if ($object->getValue() !== null) {
$default = $this->valueConverter->prettyPrintExpr($object->getValue());
}
diff --git a/src/phpDocumentor/Reflection/Php/Factory/DocBlock.php b/src/phpDocumentor/Reflection/Php/Factory/DocBlock.php
index 3585e057..405eab74 100644
--- a/src/phpDocumentor/Reflection/Php/Factory/DocBlock.php
+++ b/src/phpDocumentor/Reflection/Php/Factory/DocBlock.php
@@ -1,4 +1,5 @@
- * @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
*/
@@ -22,9 +21,14 @@
use phpDocumentor\Reflection\Php\StrategyContainer;
use phpDocumentor\Reflection\Types\Context;
use PhpParser\Comment\Doc;
+use function get_class;
+use function gettype;
+use function is_object;
+use function sprintf;
/**
* Strategy as wrapper around the DocBlockFactoryInterface.
+ *
* @see DocBlockFactoryInterface
* @see DocBlockDescriptor
*/
@@ -32,6 +36,7 @@ final class DocBlock implements ProjectFactoryStrategy
{
/**
* Wrapped DocBlock factory
+ *
* @var DocBlockFactoryInterface
*/
private $docblockFactory;
@@ -44,7 +49,7 @@ public function __construct(DocBlockFactoryInterface $docBlockFactory)
$this->docblockFactory = $docBlockFactory;
}
- public function matches($object): bool
+ public function matches($object) : bool
{
return $object instanceof Doc;
}
@@ -54,12 +59,12 @@ public function matches($object): bool
* Since an object might contain other objects that need to be converted the $factory is passed so it can be
* used to create nested Elements.
*
- * @param Doc $object object to convert to an Element
+ * @param Doc $object object to convert to an Element
* @param StrategyContainer $strategies used to convert nested objects.
- * @param Context $context of the created object
+ * @param Context $context of the created object
* @return null|DocBlockDescriptor
*/
- public function create($object, StrategyContainer $strategies, ?Context $context = null): ?DocBlockDescriptor
+ public function create($object, StrategyContainer $strategies, ?Context $context = null)
{
if ($object === null) {
return null;
@@ -69,7 +74,7 @@ public function create($object, StrategyContainer $strategies, ?Context $context
throw new InvalidArgumentException(
sprintf(
'%s cannot handle objects with the type %s',
- __CLASS__,
+ self::class,
is_object($object) ? get_class($object) : gettype($object)
)
);
diff --git a/src/phpDocumentor/Reflection/Php/Factory/File.php b/src/phpDocumentor/Reflection/Php/Factory/File.php
index adf9283b..032a30b6 100644
--- a/src/phpDocumentor/Reflection/Php/Factory/File.php
+++ b/src/phpDocumentor/Reflection/Php/Factory/File.php
@@ -1,4 +1,5 @@
- * @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
*/
@@ -16,7 +15,6 @@
use phpDocumentor\Reflection\DocBlock as DocBlockInstance;
use phpDocumentor\Reflection\File as FileSystemFile;
-use phpDocumentor\Reflection\Fqsen;
use phpDocumentor\Reflection\Middleware\ChainFactory;
use phpDocumentor\Reflection\Middleware\Middleware;
use phpDocumentor\Reflection\Php\Factory\File\CreateCommand;
@@ -25,7 +23,6 @@
use phpDocumentor\Reflection\Php\ProjectFactoryStrategy;
use phpDocumentor\Reflection\Php\StrategyContainer;
use phpDocumentor\Reflection\Types\Context;
-use phpDocumentor\Reflection\Types\ContextFactory;
use phpDocumentor\Reflection\Types\NamespaceNodeToContext;
use PhpParser\Comment\Doc;
use PhpParser\Node;
@@ -34,21 +31,20 @@
use PhpParser\Node\Stmt\Interface_ as InterfaceNode;
use PhpParser\Node\Stmt\Namespace_ as NamespaceNode;
use PhpParser\Node\Stmt\Trait_ as TraitNode;
+use function current;
+use function get_class;
+use function is_array;
/**
* Strategy to create File element from the provided filename.
* This class supports extra middle wares to add extra steps to the creation process.
*/
-final class File extends AbstractFactory implements ProjectFactoryStrategy
+final class File extends AbstractFactory
{
- /**
- * @var NodesFactory
- */
+ /** @var NodesFactory */
private $nodesFactory;
- /**
- * @var callable
- */
+ /** @var callable */
private $middlewareChain;
/**
@@ -67,7 +63,7 @@ public function __construct(NodesFactory $nodesFactory, $middleware = [])
$this->middlewareChain = ChainFactory::createExecutionChain($middleware, $lastCallable);
}
- public function matches($file): bool
+ public function matches($file) : bool
{
return $file instanceof FileSystemFile;
}
@@ -78,25 +74,22 @@ public function matches($file): bool
* Since an object might contain other objects that need to be converted the $factory is passed so it can be
* used to create nested Elements.
*
- * @param FileSystemFile $object path to the file to convert to an File object.
+ * @param FileSystemFile $object path to the file to convert to an File object.
* @param StrategyContainer $strategies used to convert nested objects.
* @return File
*/
protected function doCreate($object, StrategyContainer $strategies, ?Context $context = null)
{
- $command = new CreateCommand($object, $strategies);
+ $command = new CreateCommand($object, $strategies);
$middlewareChain = $this->middlewareChain;
return $middlewareChain($command);
}
- /**
- * @return FileElement
- */
- private function createFile(CreateCommand $command)
+ private function createFile(CreateCommand $command) : FileElement
{
- $file = $command->getFile();
- $code = $file->getContents();
+ $file = $command->getFile();
+ $code = $file->getContents();
$nodes = $this->nodesFactory->create($code);
$docBlock = $this->createFileDocBlock(null, $command->getStrategies(), null, $nodes);
@@ -121,12 +114,12 @@ private function createElements(
FileElement $file,
StrategyContainer $strategies,
?Context $context
- ): void {
+ ) : void {
foreach ($nodes as $node) {
switch (get_class($node)) {
case ClassNode::class:
$strategy = $strategies->findMatching($node);
- $class = $strategy->create($node, $strategies, $context);
+ $class = $strategy->create($node, $strategies, $context);
$file->addClass($class);
break;
case FunctionNode::class:
@@ -135,7 +128,7 @@ private function createElements(
$file->addFunction($function);
break;
case InterfaceNode::class:
- $strategy = $strategies->findMatching($node);
+ $strategy = $strategies->findMatching($node);
$interface = $strategy->create($node, $strategies, $context);
$file->addInterface($interface);
break;
@@ -146,7 +139,7 @@ private function createElements(
break;
case TraitNode::class:
$strategy = $strategies->findMatching($node);
- $trait = $strategy->create($node, $strategies, $context);
+ $trait = $strategy->create($node, $strategies, $context);
$file->addTrait($trait);
break;
}
@@ -161,7 +154,7 @@ protected function createFileDocBlock(
?StrategyContainer $strategies = null,
?Context $context = null,
array $nodes = []
- ): ?DocBlockInstance {
+ ) : ?DocBlockInstance {
$node = current($nodes);
if (!$node instanceof Node) {
return null;
@@ -172,7 +165,7 @@ protected function createFileDocBlock(
return null;
}
- $found = 0;
+ $found = 0;
$firstDocBlock = null;
foreach ($comments as $comment) {
if (!$comment instanceof Doc) {
diff --git a/src/phpDocumentor/Reflection/Php/Factory/File/CreateCommand.php b/src/phpDocumentor/Reflection/Php/Factory/File/CreateCommand.php
index 2de96663..c9b34f2e 100644
--- a/src/phpDocumentor/Reflection/Php/Factory/File/CreateCommand.php
+++ b/src/phpDocumentor/Reflection/Php/Factory/File/CreateCommand.php
@@ -1,4 +1,5 @@
file = $file;
+ $this->file = $file;
$this->strategies = $strategies;
}
/**
* Returns the strategyContainer in this command context.
*/
- public function getStrategies(): StrategyContainer
+ public function getStrategies() : StrategyContainer
{
return $this->strategies;
}
- public function getFile(): File
+ public function getFile() : File
{
return $this->file;
}
diff --git a/src/phpDocumentor/Reflection/Php/Factory/Function_.php b/src/phpDocumentor/Reflection/Php/Factory/Function_.php
index a097d884..4983ed38 100644
--- a/src/phpDocumentor/Reflection/Php/Factory/Function_.php
+++ b/src/phpDocumentor/Reflection/Php/Factory/Function_.php
@@ -1,4 +1,5 @@
- * @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
*/
@@ -33,7 +32,7 @@
final class Function_ extends AbstractFactory implements ProjectFactoryStrategy
// @codingStandardsIgnoreEnd
{
- public function matches($object): bool
+ public function matches($object) : bool
{
return $object instanceof FunctionNode;
}
@@ -41,9 +40,9 @@ public function matches($object): bool
/**
* Creates an FunctionDescriptor out of the given object including its child elements.
*
- * @param \PhpParser\Node\Stmt\Function_ $object object to convert to an Element
- * @param StrategyContainer $strategies used to convert nested objects.
- * @param Context $context of the created object
+ * @param \PhpParser\Node\Stmt\Function_ $object object to convert to an Element
+ * @param StrategyContainer $strategies used to convert nested objects.
+ * @param Context $context of the created object
* @return FunctionDescriptor
*/
protected function doCreate($object, StrategyContainer $strategies, ?Context $context = null)
diff --git a/src/phpDocumentor/Reflection/Php/Factory/Interface_.php b/src/phpDocumentor/Reflection/Php/Factory/Interface_.php
index b3c19d89..afa13acd 100644
--- a/src/phpDocumentor/Reflection/Php/Factory/Interface_.php
+++ b/src/phpDocumentor/Reflection/Php/Factory/Interface_.php
@@ -1,4 +1,5 @@
- * @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
*/
@@ -23,6 +22,7 @@
use PhpParser\Node\Stmt\ClassConst;
use PhpParser\Node\Stmt\ClassMethod;
use PhpParser\Node\Stmt\Interface_ as InterfaceNode;
+use function get_class;
/**
* Strategy to create a InterfaceElement including all sub elements.
@@ -31,7 +31,7 @@
final class Interface_ extends AbstractFactory implements ProjectFactoryStrategy
// @codingStandardsIgnoreEnd
{
- public function matches($object): bool
+ public function matches($object) : bool
{
return $object instanceof InterfaceNode;
}
@@ -41,15 +41,14 @@ public function matches($object): bool
* Since an object might contain other objects that need to be converted the $factory is passed so it can be
* used to create nested Elements.
*
- * @param InterfaceNode $object object to convert to an Element
+ * @param InterfaceNode $object object to convert to an Element
* @param StrategyContainer $strategies used to convert nested objects.
- * @param Context $context of the created object
- * @return InterfaceElement
+ * @param Context $context of the created object
*/
protected function doCreate($object, StrategyContainer $strategies, ?Context $context = null)
{
$docBlock = $this->createDocBlock($strategies, $object->getDocComment(), $context);
- $parents = [];
+ $parents = [];
foreach ($object->extends as $extend) {
$parents['\\' . (string) $extend] = new Fqsen('\\' . (string) $extend);
}
diff --git a/src/phpDocumentor/Reflection/Php/Factory/Method.php b/src/phpDocumentor/Reflection/Php/Factory/Method.php
index 96dfdc56..ff7309a5 100644
--- a/src/phpDocumentor/Reflection/Php/Factory/Method.php
+++ b/src/phpDocumentor/Reflection/Php/Factory/Method.php
@@ -1,4 +1,5 @@
- * @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
*/
@@ -29,7 +28,7 @@
*/
final class Method extends AbstractFactory implements ProjectFactoryStrategy
{
- public function matches($object): bool
+ public function matches($object) : bool
{
return $object instanceof ClassMethod;
}
@@ -37,9 +36,9 @@ public function matches($object): bool
/**
* Creates an MethodDescriptor out of the given object including its child elements.
*
- * @param ClassMethod $object object to convert to an MethodDescriptor
+ * @param ClassMethod $object object to convert to an MethodDescriptor
* @param StrategyContainer $strategies used to convert nested objects.
- * @param Context $context of the created object
+ * @param Context $context of the created object
* @return MethodDescriptor
*/
protected function doCreate($object, StrategyContainer $strategies, ?Context $context = null)
@@ -79,7 +78,7 @@ protected function doCreate($object, StrategyContainer $strategies, ?Context $co
/**
* Converts the visibility of the method to a valid Visibility object.
*/
- private function buildVisibility(ClassMethod $node): Visibility
+ private function buildVisibility(ClassMethod $node) : Visibility
{
if ($node->isPrivate()) {
return new Visibility(Visibility::PRIVATE_);
diff --git a/src/phpDocumentor/Reflection/Php/Factory/Property.php b/src/phpDocumentor/Reflection/Php/Factory/Property.php
index 24a4997e..879e3153 100644
--- a/src/phpDocumentor/Reflection/Php/Factory/Property.php
+++ b/src/phpDocumentor/Reflection/Php/Factory/Property.php
@@ -1,4 +1,5 @@
- * @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
*/
@@ -30,9 +29,7 @@
*/
final class Property extends AbstractFactory implements ProjectFactoryStrategy
{
- /**
- * @var PrettyPrinter
- */
+ /** @var PrettyPrinter */
private $valueConverter;
/**
@@ -43,7 +40,7 @@ public function __construct(PrettyPrinter $prettyPrinter)
$this->valueConverter = $prettyPrinter;
}
- public function matches($object): bool
+ public function matches($object) : bool
{
return $object instanceof PropertyIterator;
}
@@ -54,14 +51,14 @@ public function matches($object): bool
* Since an object might contain other objects that need to be converted the $factory is passed so it can be
* used to create nested Elements.
*
- * @param PropertyIterator $object object to convert to an PropertyDescriptor
+ * @param PropertyIterator $object object to convert to an PropertyDescriptor
* @param StrategyContainer $strategies used to convert nested objects.
* @return PropertyDescriptor
*/
protected function doCreate($object, StrategyContainer $strategies, ?Context $context = null)
{
$visibility = $this->buildVisibility($object);
- $default = null;
+ $default = null;
if ($object->getDefault() !== null) {
$default = $this->valueConverter->prettyPrintExpr($object->getDefault());
}
@@ -81,7 +78,7 @@ protected function doCreate($object, StrategyContainer $strategies, ?Context $co
/**
* Converts the visibility of the property to a valid Visibility object.
*/
- private function buildVisibility(PropertyIterator $node): Visibility
+ private function buildVisibility(PropertyIterator $node) : Visibility
{
if ($node->isPrivate()) {
return new Visibility(Visibility::PRIVATE_);
diff --git a/src/phpDocumentor/Reflection/Php/Factory/PropertyIterator.php b/src/phpDocumentor/Reflection/Php/Factory/PropertyIterator.php
index 3a654791..027dcf62 100644
--- a/src/phpDocumentor/Reflection/Php/Factory/PropertyIterator.php
+++ b/src/phpDocumentor/Reflection/Php/Factory/PropertyIterator.php
@@ -1,4 +1,5 @@
- * @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
*/
@@ -26,14 +25,10 @@
*/
final class PropertyIterator implements Iterator
{
- /**
- * @var PropertyNode
- */
+ /** @var PropertyNode */
private $property;
- /**
- * @var int index of the current propertyProperty to use
- */
+ /** @var int index of the current propertyProperty to use */
private $index = 0;
/**
@@ -47,7 +42,7 @@ public function __construct(PropertyNode $property)
/**
* returns true when the current property is public.
*/
- public function isPublic(): bool
+ public function isPublic() : bool
{
return $this->property->isPublic();
}
@@ -55,7 +50,7 @@ public function isPublic(): bool
/**
* returns true when the current property is protected.
*/
- public function isProtected(): bool
+ public function isProtected() : bool
{
return $this->property->isProtected();
}
@@ -63,7 +58,7 @@ public function isProtected(): bool
/**
* returns true when the current property is private.
*/
- public function isPrivate(): bool
+ public function isPrivate() : bool
{
return $this->property->isPrivate();
}
@@ -71,7 +66,7 @@ public function isPrivate(): bool
/**
* returns true when the current property is static.
*/
- public function isStatic(): bool
+ public function isStatic() : bool
{
return $this->property->isStatic();
}
@@ -79,7 +74,7 @@ public function isStatic(): bool
/**
* Gets line the node started in.
*/
- public function getLine(): int
+ public function getLine() : int
{
return $this->property->getLine();
}
@@ -89,7 +84,7 @@ public function getLine(): int
*
* The doc comment has to be the last comment associated with the node.
*/
- public function getDocComment(): ?Doc
+ public function getDocComment() : ?Doc
{
$docComment = $this->property->props[$this->index]->getDocComment();
if ($docComment === null) {
@@ -102,7 +97,7 @@ public function getDocComment(): ?Doc
/**
* returns the name of the current property.
*/
- public function getName(): string
+ public function getName() : string
{
return (string) $this->property->props[$this->index]->name;
}
@@ -110,7 +105,7 @@ public function getName(): string
/**
* returns the default value of the current property.
*
- * @return null|string|Expr
+ * @return string|Expr|null
*/
public function getDefault()
{
@@ -120,7 +115,7 @@ public function getDefault()
/**
* Returns the fqsen of the current property.
*/
- public function getFqsen(): Fqsen
+ public function getFqsen() : Fqsen
{
return $this->property->props[$this->index]->fqsen;
}
@@ -128,7 +123,7 @@ public function getFqsen(): Fqsen
/**
* @link http://php.net/manual/en/iterator.current.php
*/
- public function current(): self
+ public function current() : self
{
return $this;
}
@@ -136,7 +131,7 @@ public function current(): self
/**
* @link http://php.net/manual/en/iterator.next.php
*/
- public function next(): void
+ public function next() : void
{
++$this->index;
}
@@ -144,7 +139,7 @@ public function next(): void
/**
* @link http://php.net/manual/en/iterator.key.php
*/
- public function key(): ?int
+ public function key() : ?int
{
return $this->index;
}
@@ -152,7 +147,7 @@ public function key(): ?int
/**
* @link http://php.net/manual/en/iterator.valid.php
*/
- public function valid(): bool
+ public function valid() : bool
{
return isset($this->property->props[$this->index]);
}
@@ -160,7 +155,7 @@ public function valid(): bool
/**
* @link http://php.net/manual/en/iterator.rewind.php
*/
- public function rewind(): void
+ public function rewind() : void
{
$this->index = 0;
}
diff --git a/src/phpDocumentor/Reflection/Php/Factory/Trait_.php b/src/phpDocumentor/Reflection/Php/Factory/Trait_.php
index 102ce919..b5b85776 100644
--- a/src/phpDocumentor/Reflection/Php/Factory/Trait_.php
+++ b/src/phpDocumentor/Reflection/Php/Factory/Trait_.php
@@ -1,4 +1,5 @@
- * @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
*/
@@ -24,12 +23,13 @@
use PhpParser\Node\Stmt\Property as PropertyNode;
use PhpParser\Node\Stmt\Trait_ as TraitNode;
use PhpParser\Node\Stmt\TraitUse;
+use function get_class;
// @codingStandardsIgnoreStart
final class Trait_ extends AbstractFactory implements ProjectFactoryStrategy
// @codingStandardsIgnoreEnd
{
- public function matches($object): bool
+ public function matches($object) : bool
{
return $object instanceof TraitNode;
}
@@ -40,7 +40,7 @@ public function matches($object): bool
* Since an object might contain other objects that need to be converted the $factory is passed so it can be
* used to create nested Elements.
*
- * @param TraitNode $object object to convert to an TraitElement
+ * @param TraitNode $object object to convert to an TraitElement
* @param StrategyContainer $strategies used to convert nested objects.
* @return TraitElement
*/
diff --git a/src/phpDocumentor/Reflection/Php/File.php b/src/phpDocumentor/Reflection/Php/File.php
index 1f14ec6a..4d459547 100644
--- a/src/phpDocumentor/Reflection/Php/File.php
+++ b/src/phpDocumentor/Reflection/Php/File.php
@@ -1,4 +1,5 @@
- * @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
*/
@@ -16,70 +15,47 @@
use phpDocumentor\Reflection\DocBlock;
use phpDocumentor\Reflection\Fqsen;
+use function basename;
/**
* Represents a file in the project.
*/
final class File
{
- /**
- * @var DocBlock|null
- */
+ /** @var DocBlock|null */
private $docBlock = null;
- /**
- * @var string
- */
+ /** @var string */
private $hash;
- /**
- * @var string
- */
+ /** @var string */
private $name = null;
- /**
- * @var string
- */
+ /** @var string */
private $path = null;
- /**
- * @var string
- */
+ /** @var string */
private $source = null;
- /**
- * @var Fqsen[]
- */
+ /** @var Fqsen[] */
private $namespaces = [];
- /**
- * @var string[]
- */
+ /** @var string[] */
private $includes = [];
- /**
- * @var Function_[]
- */
+ /** @var Function_[] */
private $functions = [];
- /**
- * @var Constant[]
- */
+ /** @var Constant[] */
private $constants = [];
- /**
- * @var Class_[]
- */
+ /** @var Class_[] */
private $classes = [];
- /**
- * @var Interface_[]
- */
+ /** @var Interface_[] */
private $interfaces = [];
- /**
- * @var Trait_[]
- */
+ /** @var Trait_[] */
private $traits = [];
/**
@@ -89,17 +65,17 @@ final class File
*/
public function __construct(string $hash, string $path, string $source = '', ?DocBlock $docBlock = null)
{
- $this->hash = $hash;
- $this->path = $path;
- $this->name = basename($path);
- $this->source = $source;
+ $this->hash = $hash;
+ $this->path = $path;
+ $this->name = basename($path);
+ $this->source = $source;
$this->docBlock = $docBlock;
}
/**
* Returns the hash of the contents for this file.
*/
- public function getHash(): string
+ public function getHash() : string
{
return $this->hash;
}
@@ -107,7 +83,7 @@ public function getHash(): string
/**
* Retrieves the contents of this file.
*/
- public function getSource(): string
+ public function getSource() : string
{
return $this->source;
}
@@ -117,7 +93,7 @@ public function getSource(): string
*
* @return Fqsen[]
*/
- public function getNamespaces(): array
+ public function getNamespaces() : array
{
return $this->namespaces;
}
@@ -125,7 +101,7 @@ public function getNamespaces(): array
/**
* Add namespace to file
*/
- public function addNamespace(Fqsen $fqsen): void
+ public function addNamespace(Fqsen $fqsen) : void
{
$this->namespaces[(string) $fqsen] = $fqsen;
}
@@ -135,12 +111,12 @@ public function addNamespace(Fqsen $fqsen): void
*
* @return string[]
*/
- public function getIncludes(): array
+ public function getIncludes() : array
{
return $this->includes;
}
- public function addInclude(string $include): void
+ public function addInclude(string $include) : void
{
$this->includes[$include] = $include;
}
@@ -150,7 +126,7 @@ public function addInclude(string $include): void
*
* @return Constant[]
*/
- public function getConstants(): array
+ public function getConstants() : array
{
return $this->constants;
}
@@ -158,7 +134,7 @@ public function getConstants(): array
/**
* Add constant to this file.
*/
- public function addConstant(Constant $constant): void
+ public function addConstant(Constant $constant) : void
{
$this->constants[(string) $constant->getFqsen()] = $constant;
}
@@ -168,7 +144,7 @@ public function addConstant(Constant $constant): void
*
* @return Function_[]
*/
- public function getFunctions(): array
+ public function getFunctions() : array
{
return $this->functions;
}
@@ -176,7 +152,7 @@ public function getFunctions(): array
/**
* Add function to this file.
*/
- public function addFunction(Function_ $function): void
+ public function addFunction(Function_ $function) : void
{
$this->functions[(string) $function->getFqsen()] = $function;
}
@@ -186,7 +162,7 @@ public function addFunction(Function_ $function): void
*
* @return Class_[]
*/
- public function getClasses(): array
+ public function getClasses() : array
{
return $this->classes;
}
@@ -194,7 +170,7 @@ public function getClasses(): array
/**
* Add Class to this file.
*/
- public function addClass(Class_ $class): void
+ public function addClass(Class_ $class) : void
{
$this->classes[(string) $class->getFqsen()] = $class;
}
@@ -204,7 +180,7 @@ public function addClass(Class_ $class): void
*
* @return Interface_[]
*/
- public function getInterfaces(): array
+ public function getInterfaces() : array
{
return $this->interfaces;
}
@@ -212,7 +188,7 @@ public function getInterfaces(): array
/**
* Add interface to this file.
*/
- public function addInterface(Interface_ $interface): void
+ public function addInterface(Interface_ $interface) : void
{
$this->interfaces[(string) $interface->getFqsen()] = $interface;
}
@@ -222,7 +198,7 @@ public function addInterface(Interface_ $interface): void
*
* @return Trait_[]
*/
- public function getTraits(): array
+ public function getTraits() : array
{
return $this->traits;
}
@@ -230,7 +206,7 @@ public function getTraits(): array
/**
* Add trait to this file.
*/
- public function addTrait(Trait_ $trait): void
+ public function addTrait(Trait_ $trait) : void
{
$this->traits[(string) $trait->getFqsen()] = $trait;
}
@@ -238,7 +214,7 @@ public function addTrait(Trait_ $trait): void
/**
* Returns the file path relative to the project's root.
*/
- public function getPath(): string
+ public function getPath() : string
{
return $this->path;
}
@@ -246,7 +222,7 @@ public function getPath(): string
/**
* Returns the DocBlock of the element if available
*/
- public function getDocBlock(): ?DocBlock
+ public function getDocBlock() : ?DocBlock
{
return $this->docBlock;
}
@@ -254,7 +230,7 @@ public function getDocBlock(): ?DocBlock
/**
* Returns the full name of this file
*/
- public function getName(): string
+ public function getName() : string
{
return $this->name;
}
diff --git a/src/phpDocumentor/Reflection/Php/Function_.php b/src/phpDocumentor/Reflection/Php/Function_.php
index f7397969..9caf4a45 100644
--- a/src/phpDocumentor/Reflection/Php/Function_.php
+++ b/src/phpDocumentor/Reflection/Php/Function_.php
@@ -1,4 +1,5 @@
- * @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
*/
@@ -28,37 +27,23 @@
final class Function_ implements Element
// // @codingStandardsIgnoreEnd
{
- /**
- * @var Fqsen Full Qualified Structural Element Name
- */
+ /** @var Fqsen Full Qualified Structural Element Name */
private $fqsen;
- /**
- * @var Argument[]
- */
+ /** @var Argument[] */
private $arguments = [];
- /**
- * @var DocBlock|null
- */
+ /** @var DocBlock|null */
private $docBlock;
- /**
- * @var Location
- */
+ /** @var Location */
private $location;
- /**
- * @var Type
- */
+ /** @var Type */
private $returnType;
/**
* Initializes the object.
- *
- * @param DocBlock|null $docBlock
- * @param Location|null $location
- * @param Type|null $returnType
*/
public function __construct(
Fqsen $fqsen,
@@ -74,9 +59,9 @@ public function __construct(
$returnType = new Mixed_();
}
- $this->fqsen = $fqsen;
- $this->docBlock = $docBlock;
- $this->location = $location;
+ $this->fqsen = $fqsen;
+ $this->docBlock = $docBlock;
+ $this->location = $location;
$this->returnType = $returnType;
}
@@ -85,7 +70,7 @@ public function __construct(
*
* @return Argument[]
*/
- public function getArguments(): array
+ public function getArguments() : array
{
return $this->arguments;
}
@@ -93,7 +78,7 @@ public function getArguments(): array
/**
* Add an argument to the function.
*/
- public function addArgument(Argument $argument): void
+ public function addArgument(Argument $argument) : void
{
$this->arguments[] = $argument;
}
@@ -101,7 +86,7 @@ public function addArgument(Argument $argument): void
/**
* Returns the Fqsen of the element.
*/
- public function getFqsen(): Fqsen
+ public function getFqsen() : Fqsen
{
return $this->fqsen;
}
@@ -109,7 +94,7 @@ public function getFqsen(): Fqsen
/**
* Returns the name of the element.
*/
- public function getName(): string
+ public function getName() : string
{
return $this->fqsen->getName();
}
@@ -117,17 +102,17 @@ public function getName(): string
/**
* Returns the DocBlock of the element if available
*/
- public function getDocBlock(): ?DocBlock
+ public function getDocBlock() : ?DocBlock
{
return $this->docBlock;
}
- public function getLocation(): Location
+ public function getLocation() : Location
{
return $this->location;
}
- public function getReturnType(): Type
+ public function getReturnType() : Type
{
return $this->returnType;
}
diff --git a/src/phpDocumentor/Reflection/Php/Interface_.php b/src/phpDocumentor/Reflection/Php/Interface_.php
index 1d7adfbd..36599313 100644
--- a/src/phpDocumentor/Reflection/Php/Interface_.php
+++ b/src/phpDocumentor/Reflection/Php/Interface_.php
@@ -1,4 +1,5 @@
- * @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
*/
@@ -26,34 +25,22 @@
final class Interface_ implements Element
// @codingStandardsIgnoreEnd
{
- /**
- * @var Fqsen Full Qualified Structural Element Name
- */
+ /** @var Fqsen Full Qualified Structural Element Name */
private $fqsen;
- /**
- * @var DocBlock|null
- */
+ /** @var DocBlock|null */
private $docBlock;
- /**
- * @var Constant[]
- */
+ /** @var Constant[] */
private $constants = [];
- /**
- * @var Method[]
- */
+ /** @var Method[] */
private $methods = [];
- /**
- * @var Fqsen[]
- */
+ /** @var Fqsen[] */
private $parents = [];
- /**
- * @var Location
- */
+ /** @var Location */
private $location;
/**
@@ -71,9 +58,9 @@ public function __construct(
$location = new Location(-1);
}
- $this->fqsen = $fqsen;
+ $this->fqsen = $fqsen;
$this->docBlock = $docBlock;
- $this->parents = $parents;
+ $this->parents = $parents;
$this->location = $location;
}
@@ -82,7 +69,7 @@ public function __construct(
*
* @return Constant[]
*/
- public function getConstants(): array
+ public function getConstants() : array
{
return $this->constants;
}
@@ -90,7 +77,7 @@ public function getConstants(): array
/**
* Add constant to this interface.
*/
- public function addConstant(Constant $constant): void
+ public function addConstant(Constant $constant) : void
{
$this->constants[(string) $constant->getFqsen()] = $constant;
}
@@ -100,7 +87,7 @@ public function addConstant(Constant $constant): void
*
* @return Method[]
*/
- public function getMethods(): array
+ public function getMethods() : array
{
return $this->methods;
}
@@ -108,7 +95,7 @@ public function getMethods(): array
/**
* Add method to this interface.
*/
- public function addMethod(Method $method): void
+ public function addMethod(Method $method) : void
{
$this->methods[(string) $method->getFqsen()] = $method;
}
@@ -116,7 +103,7 @@ public function addMethod(Method $method): void
/**
* Returns the Fqsen of the element.
*/
- public function getFqsen(): Fqsen
+ public function getFqsen() : Fqsen
{
return $this->fqsen;
}
@@ -124,7 +111,7 @@ public function getFqsen(): Fqsen
/**
* Returns the name of the element.
*/
- public function getName(): string
+ public function getName() : string
{
return $this->fqsen->getName();
}
@@ -132,7 +119,7 @@ public function getName(): string
/**
* Returns the DocBlock of this interface if available.
*/
- public function getDocBlock(): ?DocBlock
+ public function getDocBlock() : ?DocBlock
{
return $this->docBlock;
}
@@ -142,12 +129,12 @@ public function getDocBlock(): ?DocBlock
*
* @return Fqsen[]
*/
- public function getParents(): array
+ public function getParents() : array
{
return $this->parents;
}
- public function getLocation(): Location
+ public function getLocation() : Location
{
return $this->location;
}
diff --git a/src/phpDocumentor/Reflection/Php/Method.php b/src/phpDocumentor/Reflection/Php/Method.php
index cf846b28..392b2b5f 100644
--- a/src/phpDocumentor/Reflection/Php/Method.php
+++ b/src/phpDocumentor/Reflection/Php/Method.php
@@ -1,4 +1,5 @@
- * @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
*/
@@ -26,49 +25,31 @@
*/
final class Method implements Element
{
- /**
- * @var DocBlock|null documentation of this method.
- */
+ /** @var DocBlock|null documentation of this method. */
private $docBlock = null;
- /**
- * @var Fqsen Full Qualified Structural Element Name
- */
+ /** @var Fqsen Full Qualified Structural Element Name */
private $fqsen;
- /**
- * @var bool
- */
+ /** @var bool */
private $abstract = false;
- /**
- * @var bool
- */
+ /** @var bool */
private $final = false;
- /**
- * @var bool
- */
+ /** @var bool */
private $static = false;
- /**
- * @var null|Visibility visibility of this method
- */
+ /** @var Visibility|null visibility of this method */
private $visibility = null;
- /**
- * @var Argument[]
- */
+ /** @var Argument[] */
private $arguments = [];
- /**
- * @var Location
- */
+ /** @var Location */
private $location;
- /**
- * @var Type
- */
+ /** @var Type */
private $returnType;
/**
@@ -86,9 +67,9 @@ public function __construct(
?Location $location = null,
?Type $returnType = null
) {
- $this->fqsen = $fqsen;
+ $this->fqsen = $fqsen;
$this->visibility = $visibility;
- $this->docBlock = $docBlock;
+ $this->docBlock = $docBlock;
if ($this->visibility === null) {
$this->visibility = new Visibility('public');
@@ -102,17 +83,17 @@ public function __construct(
$returnType = new Mixed_();
}
- $this->abstract = $abstract;
- $this->static = $static;
- $this->final = $final;
- $this->location = $location;
+ $this->abstract = $abstract;
+ $this->static = $static;
+ $this->final = $final;
+ $this->location = $location;
$this->returnType = $returnType;
}
/**
* Returns true when this method is abstract. Otherwise returns false.
*/
- public function isAbstract(): bool
+ public function isAbstract() : bool
{
return $this->abstract;
}
@@ -120,7 +101,7 @@ public function isAbstract(): bool
/**
* Returns true when this method is final. Otherwise returns false.
*/
- public function isFinal(): bool
+ public function isFinal() : bool
{
return $this->final;
}
@@ -128,7 +109,7 @@ public function isFinal(): bool
/**
* Returns true when this method is static. Otherwise returns false.
*/
- public function isStatic(): bool
+ public function isStatic() : bool
{
return $this->static;
}
@@ -136,7 +117,7 @@ public function isStatic(): bool
/**
* Returns the Visibility of this method.
*/
- public function getVisibility(): ?Visibility
+ public function getVisibility() : ?Visibility
{
return $this->visibility;
}
@@ -146,7 +127,7 @@ public function getVisibility(): ?Visibility
*
* @return Argument[]
*/
- public function getArguments(): array
+ public function getArguments() : array
{
return $this->arguments;
}
@@ -154,7 +135,7 @@ public function getArguments(): array
/**
* Add new argument to this method.
*/
- public function addArgument(Argument $argument): void
+ public function addArgument(Argument $argument) : void
{
$this->arguments[] = $argument;
}
@@ -162,7 +143,7 @@ public function addArgument(Argument $argument): void
/**
* Returns the Fqsen of the element.
*/
- public function getFqsen(): Fqsen
+ public function getFqsen() : Fqsen
{
return $this->fqsen;
}
@@ -170,7 +151,7 @@ public function getFqsen(): Fqsen
/**
* Returns the name of the element.
*/
- public function getName(): string
+ public function getName() : string
{
return $this->fqsen->getName();
}
@@ -180,12 +161,12 @@ public function getName(): string
*
* @returns null|DocBlock
*/
- public function getDocBlock(): ?DocBlock
+ public function getDocBlock() : ?DocBlock
{
return $this->docBlock;
}
- public function getLocation(): Location
+ public function getLocation() : Location
{
return $this->location;
}
@@ -197,7 +178,7 @@ public function getLocation(): Location
* return type defined this method will return Mixed_ by default. The return value of this
* method is not affected by the return tag in your docblock.
*/
- public function getReturnType(): Type
+ public function getReturnType() : Type
{
return $this->returnType;
}
diff --git a/src/phpDocumentor/Reflection/Php/Namespace_.php b/src/phpDocumentor/Reflection/Php/Namespace_.php
index 09c80e40..7ca566b0 100644
--- a/src/phpDocumentor/Reflection/Php/Namespace_.php
+++ b/src/phpDocumentor/Reflection/Php/Namespace_.php
@@ -1,4 +1,5 @@
- * @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
*/
diff --git a/src/phpDocumentor/Reflection/Php/NodesFactory.php b/src/phpDocumentor/Reflection/Php/NodesFactory.php
index ec47f8e8..9a9c80be 100644
--- a/src/phpDocumentor/Reflection/Php/NodesFactory.php
+++ b/src/phpDocumentor/Reflection/Php/NodesFactory.php
@@ -1,4 +1,5 @@
- * @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
*/
@@ -44,12 +43,12 @@ class NodesFactory
/**
* Initializes the object.
*
- * @param Parser $parser used to parse the code
+ * @param Parser $parser used to parse the code
* @param NodeTraverser $traverser used to do some post processing on the nodes
*/
public function __construct(Parser $parser, NodeTraverser $traverser)
{
- $this->parser = $parser;
+ $this->parser = $parser;
$this->traverser = $traverser;
}
@@ -58,11 +57,12 @@ public function __construct(Parser $parser, NodeTraverser $traverser)
*
* @param int $kind One of ParserFactory::PREFER_PHP7,
* ParserFactory::PREFER_PHP5, ParserFactory::ONLY_PHP7 or ParserFactory::ONLY_PHP5
+ *
* @return static
*/
- public static function createInstance($kind = ParserFactory::PREFER_PHP7): self
+ public static function createInstance(int $kind = ParserFactory::PREFER_PHP7) : self
{
- $parser = (new ParserFactory())->create($kind);
+ $parser = (new ParserFactory())->create($kind);
$traverser = new NodeTraverser();
$traverser->addVisitor(new NameResolver());
$traverser->addVisitor(new ElementNameResolver());
@@ -73,9 +73,10 @@ public static function createInstance($kind = ParserFactory::PREFER_PHP7): self
* Will convert the provided code to nodes.
*
* @param string $code code to process.
+ *
* @return Node[]
*/
- public function create(string $code): array
+ public function create(string $code) : array
{
$stmt = $this->parser->parse($code);
return $this->traverser->traverse($stmt);
diff --git a/src/phpDocumentor/Reflection/Php/Project.php b/src/phpDocumentor/Reflection/Php/Project.php
index 4589dc57..c5f3fe79 100644
--- a/src/phpDocumentor/Reflection/Php/Project.php
+++ b/src/phpDocumentor/Reflection/Php/Project.php
@@ -1,4 +1,5 @@
- * @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
*/
@@ -22,45 +21,39 @@
*/
final class Project implements ProjectInterface
{
- /**
- * @var string
- */
+ /** @var string */
private $name = '';
- /**
- * @var Namespace_|null
- */
+ /** @var Namespace_|null */
private $rootNamespace;
- /**
- * @var File[]
- */
+ /** @var File[] */
private $files = [];
- /**
- * @var Namespace_[]
- */
+ /** @var Namespace_[] */
private $namespaces = [];
/**
* Initializes this descriptor.
*
- * @param string $name Name of the current project.
- * @param null|Namespace_ $namespace Root namespace of the project.
+ * @param string $name Name of the current project.
+ * @param Namespace_|null $namespace Root namespace of the project.
*/
public function __construct(string $name, ?Namespace_ $namespace = null)
{
- $this->name = $name;
+ $this->name = $name;
$this->rootNamespace = $namespace;
- if ($this->rootNamespace === null) {
- $this->rootNamespace = new Namespace_(new Fqsen('\\'));
+ if ($this->rootNamespace !== null) {
+ return;
}
+
+ $this->rootNamespace = new Namespace_(new Fqsen('\\'));
}
/**
* Returns the name of this project.
*/
- public function getName(): string
+ public function getName() : string
{
return $this->name;
}
@@ -70,7 +63,7 @@ public function getName(): string
*
* @return File[]
*/
- public function getFiles(): array
+ public function getFiles() : array
{
return $this->files;
}
@@ -78,7 +71,7 @@ public function getFiles(): array
/**
* Add a file to this project.
*/
- public function addFile(File $file): void
+ public function addFile(File $file) : void
{
$this->files[$file->getPath()] = $file;
}
@@ -88,7 +81,7 @@ public function addFile(File $file): void
*
* @return Namespace_[]
*/
- public function getNamespaces(): array
+ public function getNamespaces() : array
{
return $this->namespaces;
}
@@ -96,7 +89,7 @@ public function getNamespaces(): array
/**
* Add a namespace to the project.
*/
- public function addNamespace(Namespace_ $namespace): void
+ public function addNamespace(Namespace_ $namespace) : void
{
$this->namespaces[(string) $namespace->getFqsen()] = $namespace;
}
@@ -104,7 +97,7 @@ public function addNamespace(Namespace_ $namespace): void
/**
* Returns the root (global) namespace.
*/
- public function getRootNamespace(): ?Namespace_
+ public function getRootNamespace() : ?Namespace_
{
return $this->rootNamespace;
}
diff --git a/src/phpDocumentor/Reflection/Php/ProjectFactory.php b/src/phpDocumentor/Reflection/Php/ProjectFactory.php
index c50ebae6..694005fa 100644
--- a/src/phpDocumentor/Reflection/Php/ProjectFactory.php
+++ b/src/phpDocumentor/Reflection/Php/ProjectFactory.php
@@ -1,4 +1,5 @@
- * @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
*/
@@ -27,9 +26,7 @@
*/
final class ProjectFactory implements ProjectFactoryInterface
{
- /**
- * @var ProjectFactoryStrategies
- */
+ /** @var ProjectFactoryStrategies */
private $strategies;
/**
@@ -45,7 +42,7 @@ public function __construct(array $strategies)
/**
* Creates a new instance of this factory. With all default strategies.
*/
- public static function createInstance(): self
+ public static function createInstance() : self
{
return new static(
[
@@ -66,20 +63,22 @@ public static function createInstance(): self
/**
* Creates a project from the set of files.
*
- * @param string $name
* @param SourceFile[] $files
+ *
* @throws Exception when no matching strategy was found.
*/
- public function create($name, array $files): ProjectInterface
+ public function create($name, array $files) : ProjectInterface
{
$project = new Project($name);
foreach ($files as $filePath) {
$strategy = $this->strategies->findMatching($filePath);
- $file = $strategy->create($filePath, $this->strategies);
- if ($file !== null) {
- $project->addFile($file);
+ $file = $strategy->create($filePath, $this->strategies);
+ if ($file === null) {
+ continue;
}
+
+ $project->addFile($file);
}
$this->buildNamespaces($project);
@@ -90,7 +89,7 @@ public function create($name, array $files): ProjectInterface
/**
* Builds the namespace tree with all elements in the project.
*/
- private function buildNamespaces(Project $project): void
+ private function buildNamespaces(Project $project) : void
{
foreach ($project->getFiles() as $file) {
foreach ($file->getNamespaces() as $namespaceFqsen) {
@@ -103,7 +102,7 @@ private function buildNamespaces(Project $project): void
/**
* Gets Namespace from the project if it exists, otherwise returns a new namepace
*/
- private function getNamespaceByName(Project $project, $name): Namespace_
+ private function getNamespaceByName(Project $project, $name) : Namespace_
{
$existingNamespaces = $project->getNamespaces();
@@ -119,36 +118,46 @@ private function getNamespaceByName(Project $project, $name): Namespace_
/**
* Adds all elements belonging to the namespace to the namespace.
*/
- private function buildNamespace(File $file, Namespace_ $namespace): void
+ private function buildNamespace(File $file, Namespace_ $namespace) : void
{
foreach ($file->getClasses() as $class) {
- if ($namespace->getFqsen() . '\\' . $class->getName() === (string) $class->getFqsen()) {
- $namespace->addClass($class->getFqsen());
+ if ($namespace->getFqsen() . '\\' . $class->getName() !== (string) $class->getFqsen()) {
+ continue;
}
+
+ $namespace->addClass($class->getFqsen());
}
foreach ($file->getInterfaces() as $interface) {
- if ($namespace->getFqsen() . '\\' . $interface->getName() === (string) $interface->getFqsen()) {
- $namespace->addInterface($interface->getFqsen());
+ if ($namespace->getFqsen() . '\\' . $interface->getName() !== (string) $interface->getFqsen()) {
+ continue;
}
+
+ $namespace->addInterface($interface->getFqsen());
}
foreach ($file->getFunctions() as $function) {
- if ($namespace->getFqsen() . '\\' . $function->getName() . '()' === (string) $function->getFqsen()) {
- $namespace->addFunction($function->getFqsen());
+ if ($namespace->getFqsen() . '\\' . $function->getName() . '()' !== (string) $function->getFqsen()) {
+ continue;
}
+
+ $namespace->addFunction($function->getFqsen());
}
foreach ($file->getConstants() as $constant) {
- if ($namespace->getFqsen() . '::' . $constant->getName() === (string) $constant->getFqsen()) {
- $namespace->addConstant($constant->getFqsen());
+ if ($namespace->getFqsen() . '::' . $constant->getName() !== (string) $constant->getFqsen()) {
+ continue;
}
+
+ $namespace->addConstant($constant->getFqsen());
}
foreach ($file->getTraits() as $trait) {
- if ($namespace->getFqsen() . '\\' . $trait->getName() === (string) $trait->getFqsen()) {
- $namespace->addTrait($trait->getFqsen());
+ if ($namespace->getFqsen() . '\\' . $trait->getName() !== (string) $trait->getFqsen()) {
+ continue;
}
+
+ $namespace->addTrait($trait->getFqsen());
}
}
}
diff --git a/src/phpDocumentor/Reflection/Php/ProjectFactoryStrategies.php b/src/phpDocumentor/Reflection/Php/ProjectFactoryStrategies.php
index 24c90237..7d2d790e 100644
--- a/src/phpDocumentor/Reflection/Php/ProjectFactoryStrategies.php
+++ b/src/phpDocumentor/Reflection/Php/ProjectFactoryStrategies.php
@@ -1,4 +1,5 @@
- * @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
*/
namespace phpDocumentor\Reflection\Php;
use OutOfBoundsException;
+use function get_class;
+use function is_object;
+use function print_r;
+use function sprintf;
final class ProjectFactoryStrategies implements StrategyContainer
{
- /**
- * @var ProjectFactoryStrategy[]
- */
+ /** @var ProjectFactoryStrategy[] */
private $strategies;
/**
@@ -40,11 +41,11 @@ public function __construct(array $strategies)
/**
* Find the ProjectFactoryStrategy that matches $object.
*
- *
* @param mixed $object
- * @throws OutOfBoundsException when no matching strategy was found.
+ *
+ * @throws OutOfBoundsException When no matching strategy was found.
*/
- public function findMatching($object): ProjectFactoryStrategy
+ public function findMatching($object) : ProjectFactoryStrategy
{
foreach ($this->strategies as $strategy) {
if ($strategy->matches($object)) {
@@ -63,7 +64,7 @@ public function findMatching($object): ProjectFactoryStrategy
/**
* Add a strategy to this container.
*/
- public function addStrategy(ProjectFactoryStrategy $strategy): void
+ public function addStrategy(ProjectFactoryStrategy $strategy) : void
{
$this->strategies[] = $strategy;
}
diff --git a/src/phpDocumentor/Reflection/Php/ProjectFactoryStrategy.php b/src/phpDocumentor/Reflection/Php/ProjectFactoryStrategy.php
index 43342ca7..36df796c 100644
--- a/src/phpDocumentor/Reflection/Php/ProjectFactoryStrategy.php
+++ b/src/phpDocumentor/Reflection/Php/ProjectFactoryStrategy.php
@@ -1,4 +1,5 @@
- * @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
*/
namespace phpDocumentor\Reflection\Php;
+use phpDocumentor\Reflection\DocBlock;
use phpDocumentor\Reflection\Element;
use phpDocumentor\Reflection\Types\Context;
@@ -26,19 +26,18 @@ interface ProjectFactoryStrategy
* Returns true when the strategy is able to handle the object.
*
* @param mixed $object object to check.
- * @return boolean
*/
- public function matches($object): bool;
+ public function matches($object) : bool;
/**
* Creates an Element out of the given object.
* Since an object might contain other objects that need to be converted the $factory is passed so it can be
* used to create nested Elements.
*
- * @param object $object object to convert to an Element
+ * @param object $object object to convert to an Element
* @param StrategyContainer $strategies used to convert nested objects.
- * @param Context $context
- * @return Element
+ *
+ * @return Element|DocBlock
*/
public function create($object, StrategyContainer $strategies, ?Context $context = null);
}
diff --git a/src/phpDocumentor/Reflection/Php/Property.php b/src/phpDocumentor/Reflection/Php/Property.php
index 07cc5457..3baafc50 100644
--- a/src/phpDocumentor/Reflection/Php/Property.php
+++ b/src/phpDocumentor/Reflection/Php/Property.php
@@ -1,4 +1,5 @@
- * @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
*/
@@ -24,38 +23,29 @@
*/
final class Property implements Element
{
- /**
- * @var Fqsen
- */
+ /** @var Fqsen */
private $fqsen;
- /**
- * @var DocBlock|null
- */
+ /** @var DocBlock|null */
private $docBlock;
/** @var string[] $types */
private $types = [];
- /** @var null|string $default */
+ /** @var string|null $default */
private $default = null;
/** @var bool $static */
private $static = false;
- /** @var null|Visibility $visibility */
+ /** @var Visibility|null $visibility */
private $visibility = null;
- /**
- * @var Location
- */
+ /** @var Location */
private $location;
/**
* @param Visibility|null $visibility when null is provided a default 'public' is set.
- * @param DocBlock|null $docBlock
- * @param null|string $default
- * @param Location|null $location
*/
public function __construct(
Fqsen $fqsen,
@@ -69,22 +59,24 @@ public function __construct(
$location = new Location(-1);
}
- $this->fqsen = $fqsen;
+ $this->fqsen = $fqsen;
$this->visibility = $visibility;
- $this->docBlock = $docBlock;
- $this->default = $default;
- $this->static = $static;
- $this->location = $location;
+ $this->docBlock = $docBlock;
+ $this->default = $default;
+ $this->static = $static;
+ $this->location = $location;
- if ($this->visibility === null) {
- $this->visibility = new Visibility('public');
+ if ($this->visibility !== null) {
+ return;
}
+
+ $this->visibility = new Visibility('public');
}
/**
* returns the default value of this property.
*/
- public function getDefault(): ?string
+ public function getDefault() : ?string
{
return $this->default;
}
@@ -92,7 +84,7 @@ public function getDefault(): ?string
/**
* Returns true when this method is static. Otherwise returns false.
*/
- public function isStatic(): bool
+ public function isStatic() : bool
{
return $this->static;
}
@@ -102,7 +94,7 @@ public function isStatic(): bool
*
* @return string[]
*/
- public function getTypes(): array
+ public function getTypes() : array
{
return $this->types;
}
@@ -110,7 +102,7 @@ public function getTypes(): array
/**
* Add a type to this property
*/
- public function addType(string $type): void
+ public function addType(string $type) : void
{
$this->types[] = $type;
}
@@ -118,7 +110,7 @@ public function addType(string $type): void
/**
* Return visibility of the property.
*/
- public function getVisibility(): ?Visibility
+ public function getVisibility() : ?Visibility
{
return $this->visibility;
}
@@ -126,7 +118,7 @@ public function getVisibility(): ?Visibility
/**
* Returns the Fqsen of the element.
*/
- public function getFqsen(): Fqsen
+ public function getFqsen() : Fqsen
{
return $this->fqsen;
}
@@ -134,7 +126,7 @@ public function getFqsen(): Fqsen
/**
* Returns the name of the element.
*/
- public function getName(): string
+ public function getName() : string
{
return $this->fqsen->getName();
}
@@ -142,12 +134,12 @@ public function getName(): string
/**
* Returns the DocBlock of this property.
*/
- public function getDocBlock(): ?DocBlock
+ public function getDocBlock() : ?DocBlock
{
return $this->docBlock;
}
- public function getLocation(): Location
+ public function getLocation() : Location
{
return $this->location;
}
diff --git a/src/phpDocumentor/Reflection/Php/StrategyContainer.php b/src/phpDocumentor/Reflection/Php/StrategyContainer.php
index de0981b3..17481dc5 100644
--- a/src/phpDocumentor/Reflection/Php/StrategyContainer.php
+++ b/src/phpDocumentor/Reflection/Php/StrategyContainer.php
@@ -1,4 +1,5 @@
- * @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
*/
@@ -25,8 +24,8 @@ interface StrategyContainer
* Find the ProjectFactoryStrategy that matches $object.
*
* @param mixed $object
- * @return ProjectFactoryStrategy
+ *
* @throws Exception when no matching strategy was found.
*/
- public function findMatching($object): ProjectFactoryStrategy;
+ public function findMatching($object) : ProjectFactoryStrategy;
}
diff --git a/src/phpDocumentor/Reflection/Php/Trait_.php b/src/phpDocumentor/Reflection/Php/Trait_.php
index a71b3cb5..56bbaea9 100644
--- a/src/phpDocumentor/Reflection/Php/Trait_.php
+++ b/src/phpDocumentor/Reflection/Php/Trait_.php
@@ -1,4 +1,5 @@
- * @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
*/
@@ -26,14 +25,10 @@
final class Trait_ implements Element
// @codingStandardsIgnoreEnd
{
- /**
- * @var Fqsen Full Qualified Structural Element Name
- */
+ /** @var Fqsen Full Qualified Structural Element Name */
private $fqsen;
- /**
- * @var DocBlock|null
- */
+ /** @var DocBlock|null */
private $docBlock;
/** @var Property[] $properties */
@@ -45,9 +40,7 @@ final class Trait_ implements Element
/** @var Fqsen[] $usedTraits References to traits consumed by this trait */
private $usedTraits = [];
- /**
- * @var Location
- */
+ /** @var Location */
private $location;
/**
@@ -59,7 +52,7 @@ public function __construct(Fqsen $fqsen, ?DocBlock $docBlock = null, ?Location
$location = new Location(-1);
}
- $this->fqsen = $fqsen;
+ $this->fqsen = $fqsen;
$this->docBlock = $docBlock;
$this->location = $location;
}
@@ -69,7 +62,7 @@ public function __construct(Fqsen $fqsen, ?DocBlock $docBlock = null, ?Location
*
* @return Method[]
*/
- public function getMethods(): array
+ public function getMethods() : array
{
return $this->methods;
}
@@ -77,7 +70,7 @@ public function getMethods(): array
/**
* Add a method to this Trait
*/
- public function addMethod(Method $method): void
+ public function addMethod(Method $method) : void
{
$this->methods[(string) $method->getFqsen()] = $method;
}
@@ -87,7 +80,7 @@ public function addMethod(Method $method): void
*
* @return Property[]
*/
- public function getProperties(): array
+ public function getProperties() : array
{
return $this->properties;
}
@@ -95,7 +88,7 @@ public function getProperties(): array
/**
* Add a property to this Trait.
*/
- public function addProperty(Property $property): void
+ public function addProperty(Property $property) : void
{
$this->properties[(string) $property->getFqsen()] = $property;
}
@@ -103,7 +96,7 @@ public function addProperty(Property $property): void
/**
* Returns the Fqsen of the element.
*/
- public function getFqsen(): Fqsen
+ public function getFqsen() : Fqsen
{
return $this->fqsen;
}
@@ -111,12 +104,12 @@ public function getFqsen(): Fqsen
/**
* Returns the name of the element.
*/
- public function getName(): string
+ public function getName() : string
{
return $this->fqsen->getName();
}
- public function getDocBlock(): ?DocBlock
+ public function getDocBlock() : ?DocBlock
{
return $this->docBlock;
}
@@ -126,7 +119,7 @@ public function getDocBlock(): ?DocBlock
*
* @return Fqsen[]
*/
- public function getUsedTraits(): array
+ public function getUsedTraits() : array
{
return $this->usedTraits;
}
@@ -134,12 +127,12 @@ public function getUsedTraits(): array
/**
* Add reference to trait used by this trait.
*/
- public function addUsedTrait(Fqsen $fqsen): void
+ public function addUsedTrait(Fqsen $fqsen) : void
{
$this->usedTraits[(string) $fqsen] = $fqsen;
}
- public function getLocation(): Location
+ public function getLocation() : Location
{
return $this->location;
}
diff --git a/src/phpDocumentor/Reflection/Php/Visibility.php b/src/phpDocumentor/Reflection/Php/Visibility.php
index 6d4bcba4..3fd77ff6 100644
--- a/src/phpDocumentor/Reflection/Php/Visibility.php
+++ b/src/phpDocumentor/Reflection/Php/Visibility.php
@@ -1,4 +1,5 @@
- * @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
*/
namespace phpDocumentor\Reflection\Php;
use InvalidArgumentException;
+use function sprintf;
+use function strtolower;
/**
* Value object for visibility values of classes, properties, ect.
@@ -24,21 +25,19 @@ final class Visibility
/**
* constant for protected visibility
*/
- const PUBLIC_ = 'public';
+ public const PUBLIC_ = 'public';
/**
* constant for protected visibility
*/
- const PROTECTED_ = 'protected';
+ public const PROTECTED_ = 'protected';
/**
* constant for private visibility
*/
- const PRIVATE_ = 'private';
+ public const PRIVATE_ = 'private';
- /**
- * @var string value can be public, protected or private
- */
+ /** @var string value can be public, protected or private */
private $visibility;
/**
@@ -62,7 +61,7 @@ public function __construct(string $visibility)
/**
* Will return a string representation of visibility.
*/
- public function __toString(): string
+ public function __toString() : string
{
return $this->visibility;
}
diff --git a/src/phpDocumentor/Reflection/PrettyPrinter.php b/src/phpDocumentor/Reflection/PrettyPrinter.php
index 4f162b5c..a7f0235a 100644
--- a/src/phpDocumentor/Reflection/PrettyPrinter.php
+++ b/src/phpDocumentor/Reflection/PrettyPrinter.php
@@ -1,4 +1,5 @@
- * @copyright 2010-2018 Mike van Riel / Naenius (http://www.naenius.com)
- * @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
*/
@@ -28,8 +26,6 @@
* If the interpreted version was to be used then the XML interpretation would
* fail because of special characters.
*
- * @author Mike van Riel
- * @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
*/
class PrettyPrinter extends Standard
@@ -43,11 +39,9 @@ class PrettyPrinter extends Standard
* Since we do not want such conversions we take the original that is
* injected by our own custom Lexer.
*
- * @param String_ $node The node to return a string representation of.
- *
* @see Lexer where the originalValue is injected.
*
- * @return string
+ * @param String_ $node The node to return a string representation of.
*/
// @codingStandardsIgnoreStart
public function pScalar_String(String_ $node): string
diff --git a/src/phpDocumentor/Reflection/Types/NamespaceNodeToContext.php b/src/phpDocumentor/Reflection/Types/NamespaceNodeToContext.php
index 8d18622e..8c002403 100644
--- a/src/phpDocumentor/Reflection/Types/NamespaceNodeToContext.php
+++ b/src/phpDocumentor/Reflection/Types/NamespaceNodeToContext.php
@@ -1,4 +1,5 @@
getAlias() => $use->prefix->toString() . '\\' . $useUse->name->toString()];
+ return [
+ (string) $useUse->getAlias() => $use->prefix->toString() . '\\' . $useUse->name->toString(),
+ ];
}
return [(string) $useUse->getAlias() => $useUse->name->toString()];
@@ -44,19 +50,17 @@ private function aliasesToFullyQualifiedNames(Namespace_ $namespace) : array
}
/**
- * @param Namespace_ $namespace
- *
* @return Use_[]|GroupUse[]
*/
private function classAlikeUses(Namespace_ $namespace) : array
{
- return \array_filter(
+ return array_filter(
$namespace->stmts ?? [],
- function (Node $node) : bool {
+ static function (Node $node) : bool {
return (
$node instanceof Use_
|| $node instanceof GroupUse
- ) && \in_array($node->type, [Use_::TYPE_UNKNOWN, Use_::TYPE_NORMAL], true);
+ ) && in_array($node->type, [Use_::TYPE_UNKNOWN, Use_::TYPE_NORMAL], true);
}
);
}
diff --git a/tests/component/ProjectCreationTest.php b/tests/component/ProjectCreationTest.php
index 0e61a3bd..c426e5f2 100644
--- a/tests/component/ProjectCreationTest.php
+++ b/tests/component/ProjectCreationTest.php
@@ -32,12 +32,12 @@ class ProjectCreationTest extends TestCase
*/
private $fixture;
- protected function setUp()
+ protected function setUp() : void
{
$this->fixture = ProjectFactory::createInstance();
}
- protected function tearDown()
+ protected function tearDown() : void
{
m::close();
}
@@ -57,7 +57,7 @@ public function testCreateProjectWithFunctions()
public function testCreateProjectWithClass()
{
$fileName = __DIR__ . '/project/Pizza.php';
- $project = $this->fixture->create('MyProject', [
+ $project = $this->fixture->create('MyProject', [
new LocalFile($fileName),
]);
@@ -75,7 +75,7 @@ public function testCreateProjectWithClass()
public function testFileWithDocBlock()
{
$fileName = __DIR__ . '/project/Pizza.php';
- $project = $this->fixture->create('MyProject', [
+ $project = $this->fixture->create('MyProject', [
new LocalFile($fileName),
]);
@@ -86,7 +86,7 @@ public function testFileWithDocBlock()
public function testWithNamespacedClass()
{
$fileName = __DIR__ . '/project/Luigi/Pizza.php';
- $project = $this->fixture->create('MyProject', [
+ $project = $this->fixture->create('MyProject', [
new LocalFile($fileName),
]);
@@ -111,7 +111,7 @@ public function testWithNamespacedClass()
public function testDocblockOfMethodIsProcessed()
{
$fileName = __DIR__ . '/project/Luigi/Pizza.php';
- $project = $this->fixture->create('MyProject', [
+ $project = $this->fixture->create('MyProject', [
new LocalFile($fileName),
]);
@@ -136,7 +136,7 @@ public function testDocblockOfMethodIsProcessed()
public function testWithUsedParent()
{
$fileName = __DIR__ . '/project/Luigi/StyleFactory.php';
- $project = $this->fixture->create('MyProject', [
+ $project = $this->fixture->create('MyProject', [
new LocalFile($fileName),
]);
@@ -151,7 +151,7 @@ public function testWithUsedParent()
public function testWithInterface()
{
$fileName = __DIR__ . '/project/Luigi/Valued.php';
- $project = $this->fixture->create('MyProject', [
+ $project = $this->fixture->create('MyProject', [
new LocalFile($fileName),
]);
@@ -161,7 +161,7 @@ public function testWithInterface()
public function testWithTrait()
{
$fileName = __DIR__ . '/project/Luigi/ExampleNestedTrait.php';
- $project = $this->fixture->create('MyProject', [
+ $project = $this->fixture->create('MyProject', [
new LocalFile($fileName),
]);
@@ -171,7 +171,7 @@ public function testWithTrait()
public function testInterfaceExtends()
{
$fileName = __DIR__ . '/project/Luigi/Packing.php';
- $project = $this->fixture->create('MyProject', [
+ $project = $this->fixture->create('MyProject', [
new LocalFile($fileName),
]);
@@ -184,7 +184,7 @@ public function testInterfaceExtends()
public function testMethodReturnType()
{
$fileName = __DIR__ . '/project/Packing.php';
- $project = $this->fixture->create('MyProject', [
+ $project = $this->fixture->create('MyProject', [
new LocalFile($fileName),
]);
@@ -197,7 +197,7 @@ public function testMethodReturnType()
public function testFileDocblock()
{
$fileName = __DIR__ . '/project/empty.php';
- $project = $this->fixture->create('MyProject', [
+ $project = $this->fixture->create('MyProject', [
new LocalFile($fileName),
]);
diff --git a/tests/component/ProjectNamespaceTest.php b/tests/component/ProjectNamespaceTest.php
index cce9b512..72d139ce 100644
--- a/tests/component/ProjectNamespaceTest.php
+++ b/tests/component/ProjectNamespaceTest.php
@@ -30,20 +30,20 @@ class ProjectNamespaceTest extends TestCase
*/
private $fixture;
- protected function setUp()
+ protected function setUp() : void
{
$this->fixture = $this->fixture = ProjectFactory::createInstance();
}
- protected function tearDown()
+ protected function tearDown() : void
{
m::close();
}
- public function testWithNamespacedClass()
+ public function testWithNamespacedClass() : void
{
$fileName = __DIR__ . '/project/Luigi/Pizza.php';
- $project = $this->fixture->create('My Project', [
+ $project = $this->fixture->create('My Project', [
new LocalFile($fileName),
]);
diff --git a/tests/unit/phpDocumentor/Reflection/File/LocalFileTest.php b/tests/unit/phpDocumentor/Reflection/File/LocalFileTest.php
index 35dbc839..88e0d05b 100644
--- a/tests/unit/phpDocumentor/Reflection/File/LocalFileTest.php
+++ b/tests/unit/phpDocumentor/Reflection/File/LocalFileTest.php
@@ -1,18 +1,20 @@
- * @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
*/
namespace phpDocumentor\Reflection\File;
use PHPUnit\Framework\TestCase;
+use function md5_file;
/**
* @coversDefaultClass phpDocumentor\Reflection\File\LocalFile
@@ -23,7 +25,7 @@ class LocalFileTest extends TestCase
/**
* @covers ::getContents
*/
- public function testGetContents()
+ public function testGetContents() : void
{
$file = new LocalFile(__FILE__);
$this->assertStringEqualsFile(__FILE__, $file->getContents());
@@ -32,7 +34,7 @@ public function testGetContents()
/**
* @covers ::md5
*/
- public function testMd5()
+ public function testMd5() : void
{
$file = new LocalFile(__FILE__);
$this->assertEquals(md5_file(__FILE__), $file->md5());
@@ -40,17 +42,17 @@ public function testMd5()
/**
* @covers ::__construct
- * @expectedException \InvalidArgumentException
*/
- public function testNotExistingFileThrowsException()
+ public function testNotExistingFileThrowsException() : void
{
+ $this->expectException('InvalidArgumentException');
new LocalFile('aa');
}
/**
* @covers ::path
*/
- public function testPath()
+ public function testPath() : void
{
$file = new LocalFile(__FILE__);
$this->assertEquals(__FILE__, $file->path());
diff --git a/tests/unit/phpDocumentor/Reflection/NodeVisitor/ElementNameResolverTest.php b/tests/unit/phpDocumentor/Reflection/NodeVisitor/ElementNameResolverTest.php
index ea4bd36a..228a8fec 100644
--- a/tests/unit/phpDocumentor/Reflection/NodeVisitor/ElementNameResolverTest.php
+++ b/tests/unit/phpDocumentor/Reflection/NodeVisitor/ElementNameResolverTest.php
@@ -1,12 +1,13 @@
- * @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
*/
@@ -25,17 +26,16 @@
/**
* Testcase for FqsenResolver
+ *
* @coversDefaultClass phpDocumentor\Reflection\NodeVisitor\ElementNameResolver
* @covers ::
*/
class ElementNameResolverTest extends TestCase
{
- /**
- * @var ElementNameResolver
- */
+ /** @var ElementNameResolver */
private $fixture;
- protected function setUp()
+ protected function setUp() : void
{
$this->fixture = new ElementNameResolver();
$this->fixture->beforeTraverse([]);
@@ -44,7 +44,7 @@ protected function setUp()
/**
* @covers ::enterNode
*/
- public function testFunctionWithoutNamespace()
+ public function testFunctionWithoutNamespace() : void
{
$function = new Function_('myFunction');
$this->fixture->enterNode($function);
@@ -55,7 +55,7 @@ public function testFunctionWithoutNamespace()
/**
* @covers ::enterNode
*/
- public function testWithClass()
+ public function testWithClass() : void
{
$class = new Class_('myClass');
$this->fixture->enterNode($class);
@@ -69,7 +69,7 @@ public function testWithClass()
*
* @covers ::enterNode
*/
- public function testDoesNotEnterAnonymousClass()
+ public function testDoesNotEnterAnonymousClass() : void
{
$class = new Class_(null);
$this->assertEquals(
@@ -80,10 +80,11 @@ public function testDoesNotEnterAnonymousClass()
/**
* @link https://github.com/phpDocumentor/Reflection/issues/103
+ *
* @covers ::enterNode
* @covers ::leaveNode
*/
- public function testAnonymousClassDoesNotPopParts()
+ public function testAnonymousClassDoesNotPopParts() : void
{
$anonymousClass = new Class_(null);
@@ -104,11 +105,11 @@ public function testAnonymousClassDoesNotPopParts()
/**
* @covers ::enterNode
*/
- public function testClassConstant()
+ public function testClassConstant() : void
{
- $const = new Const_('MY_CLASS', new String_('value'));
+ $const = new Const_('MY_CLASS', new String_('value'));
$classConst = new ClassConst([$const]);
- $class = new Class_('myClass');
+ $class = new Class_('myClass');
$this->fixture->enterNode($class);
$this->fixture->enterNode($classConst);
@@ -120,9 +121,9 @@ public function testClassConstant()
/**
* @covers ::enterNode
*/
- public function testNamespacedConstant()
+ public function testNamespacedConstant() : void
{
- $const = new Const_('MY_CLASS', new String_('value'));
+ $const = new Const_('MY_CLASS', new String_('value'));
$namespace = new Namespace_(new Name('name'));
$this->fixture->enterNode($namespace);
diff --git a/tests/unit/phpDocumentor/Reflection/Php/ArgumentTest.php b/tests/unit/phpDocumentor/Reflection/Php/ArgumentTest.php
index c4e17b1d..2a92d3eb 100644
--- a/tests/unit/phpDocumentor/Reflection/Php/ArgumentTest.php
+++ b/tests/unit/phpDocumentor/Reflection/Php/ArgumentTest.php
@@ -1,12 +1,13 @@
- * @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
*/
@@ -18,6 +19,7 @@
/**
* Tests the functionality for the Argument class.
+ *
* @coversDefaultClass \phpDocumentor\Reflection\Php\Argument
*/
class ArgumentTest extends TestCase
@@ -25,7 +27,7 @@ class ArgumentTest extends TestCase
/**
* @covers ::getType
*/
- public function testGetTypes()
+ public function testGetTypes() : void
{
$argument = new Argument('myArgument', null, 'myDefaultValue', true, true);
$this->assertInstanceOf(Mixed_::class, $argument->getType());
@@ -44,9 +46,9 @@ public function testGetTypes()
* @covers ::__construct
* @covers ::getName
*/
- public function testGetName()
+ public function testGetName() : void
{
- $argument = new Argument('myArgument', null, true, true);
+ $argument = new Argument('myArgument', null, 'myDefault', true, true);
$this->assertEquals('myArgument', $argument->getName());
}
@@ -54,7 +56,7 @@ public function testGetName()
* @covers ::__construct
* @covers ::getDefault
*/
- public function testGetDefault()
+ public function testGetDefault() : void
{
$argument = new Argument('myArgument', null, 'myDefaultValue', true, true);
$this->assertEquals('myDefaultValue', $argument->getDefault());
@@ -67,7 +69,7 @@ public function testGetDefault()
* @covers ::__construct
* @covers ::isByReference
*/
- public function testGetWhetherArgumentIsPassedByReference()
+ public function testGetWhetherArgumentIsPassedByReference() : void
{
$argument = new Argument('myArgument', null, 'myDefaultValue', true, true);
$this->assertTrue($argument->isByReference());
@@ -80,7 +82,7 @@ public function testGetWhetherArgumentIsPassedByReference()
* @covers ::__construct
* @covers ::isVariadic
*/
- public function testGetWhetherArgumentisVariadic()
+ public function testGetWhetherArgumentisVariadic() : void
{
$argument = new Argument('myArgument', null, 'myDefaultValue', true, true);
$this->assertTrue($argument->isVariadic());
diff --git a/tests/unit/phpDocumentor/Reflection/Php/Class_Test.php b/tests/unit/phpDocumentor/Reflection/Php/Class_Test.php
index 92cbfcb9..830bc898 100644
--- a/tests/unit/phpDocumentor/Reflection/Php/Class_Test.php
+++ b/tests/unit/phpDocumentor/Reflection/Php/Class_Test.php
@@ -1,12 +1,13 @@
- * @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
*/
@@ -20,45 +21,38 @@
/**
* Tests the functionality for the Class_ class.
+ *
* @coversDefaultClass phpDocumentor\Reflection\Php\Class_
*/
// @codingStandardsIgnoreStart
class Class_Test extends TestCase
// @codingStandardsIgnoreEnd
{
- /**
- * @var Class_
- */
+ /** @var Class_ */
private $fixture;
- /**
- * @var Fqsen
- */
+ /** @var Fqsen */
private $parent;
- /**
- * @var Fqsen
- */
+ /** @var Fqsen */
private $fqsen;
- /**
- * @var DocBlock
- */
+ /** @var DocBlock */
private $docBlock;
/**
* Creates a new (emoty) fixture object.
*/
- protected function setUp()
+ protected function setUp() : void
{
- $this->parent = new Fqsen('\MyParentClass');
- $this->fqsen = new Fqsen('\MyClass');
+ $this->parent = new Fqsen('\MyParentClass');
+ $this->fqsen = new Fqsen('\MyClass');
$this->docBlock = new DocBlock('');
$this->fixture = new Class_($this->fqsen, $this->docBlock, null, false, false, new Location(1));
}
- protected function tearDown()
+ protected function tearDown() : void
{
m::close();
}
@@ -67,7 +61,7 @@ protected function tearDown()
* @covers ::getParent
* @covers ::__construct
*/
- public function testGettingParent()
+ public function testGettingParent() : void
{
$class = new Class_($this->fqsen, $this->docBlock, null, false, false, null);
$this->assertNull($class->getParent());
@@ -80,7 +74,7 @@ public function testGettingParent()
* @covers ::getInterfaces
* @covers ::AddInterface
*/
- public function testAddAndGettingInterfaces()
+ public function testAddAndGettingInterfaces() : void
{
$this->assertEmpty($this->fixture->getInterfaces());
@@ -95,7 +89,7 @@ public function testAddAndGettingInterfaces()
* @covers ::getConstants
* @covers ::addConstant
*/
- public function testAddAndGettingConstants()
+ public function testAddAndGettingConstants() : void
{
$this->assertEmpty($this->fixture->getConstants());
@@ -110,7 +104,7 @@ public function testAddAndGettingConstants()
* @covers ::addProperty
* @covers ::getProperties
*/
- public function testAddAndGettingProperties()
+ public function testAddAndGettingProperties() : void
{
$this->assertEmpty($this->fixture->getProperties());
@@ -125,7 +119,7 @@ public function testAddAndGettingProperties()
* @covers ::addMethod
* @covers ::getMethods
*/
- public function testAddAndGettingMethods()
+ public function testAddAndGettingMethods() : void
{
$this->assertEmpty($this->fixture->getMethods());
@@ -140,7 +134,7 @@ public function testAddAndGettingMethods()
* @covers ::getUsedTraits
* @covers ::AddUsedTrait
*/
- public function testAddAndGettingUsedTrait()
+ public function testAddAndGettingUsedTrait() : void
{
$this->assertEmpty($this->fixture->getUsedTraits());
@@ -155,7 +149,7 @@ public function testAddAndGettingUsedTrait()
* @covers ::isAbstract
* @covers ::__construct
*/
- public function testGettingWhetherClassIsAbstract()
+ public function testGettingWhetherClassIsAbstract() : void
{
$class = new Class_($this->fqsen, $this->docBlock, null, false, false);
$this->assertFalse($class->isAbstract());
@@ -168,7 +162,7 @@ public function testGettingWhetherClassIsAbstract()
* @covers ::isFinal
* @covers ::__construct
*/
- public function testGettingWhetherClassIsFinal()
+ public function testGettingWhetherClassIsFinal() : void
{
$class = new Class_($this->fqsen, $this->docBlock, null, false, false);
$this->assertFalse($class->isFinal());
diff --git a/tests/unit/phpDocumentor/Reflection/Php/ConstantTest.php b/tests/unit/phpDocumentor/Reflection/Php/ConstantTest.php
index 53e3db7e..4ac1f9d9 100644
--- a/tests/unit/phpDocumentor/Reflection/Php/ConstantTest.php
+++ b/tests/unit/phpDocumentor/Reflection/Php/ConstantTest.php
@@ -1,12 +1,13 @@
- * @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
*/
@@ -18,6 +19,7 @@
/**
* Tests the functionality for the Constant class.
+ *
* @coversDefaultClass phpDocumentor\Reflection\Php\Constant
*/
class ConstantTest extends TestCase
@@ -25,36 +27,30 @@ class ConstantTest extends TestCase
/** @var Constant $fixture */
protected $fixture;
- /**
- * @var Fqsen
- */
+ /** @var Fqsen */
private $fqsen;
- /**
- * @var DocBlock
- */
+ /** @var DocBlock */
private $docBlock;
- /**
- * @var string
- */
+ /** @var string */
private $value = 'Value';
/**
* Creates a new (empty) fixture object.
*/
- protected function setUp()
+ protected function setUp() : void
{
- $this->fqsen = new Fqsen('\MySpace\CONSTANT');
+ $this->fqsen = new Fqsen('\MySpace\CONSTANT');
$this->docBlock = new DocBlock('');
- $this->fixture = new Constant($this->fqsen, $this->docBlock, $this->value);
+ $this->fixture = new Constant($this->fqsen, $this->docBlock, $this->value);
}
/**
* @covers ::getValue
* @covers ::__construct
*/
- public function testGetValue()
+ public function testGetValue() : void
{
$this->assertSame($this->value, $this->fixture->getValue());
}
@@ -64,7 +60,7 @@ public function testGetValue()
* @covers ::getFqsen
* @covers ::getName
*/
- public function testGetFqsen()
+ public function testGetFqsen() : void
{
$this->assertSame($this->fqsen, $this->fixture->getFqsen());
$this->assertSame($this->fqsen->getName(), $this->fixture->getName());
@@ -74,7 +70,7 @@ public function testGetFqsen()
* @covers ::__construct
* @covers ::getDocBlock
*/
- public function testGetDocblock()
+ public function testGetDocblock() : void
{
$this->assertSame($this->docBlock, $this->fixture->getDocBlock());
}
diff --git a/tests/unit/phpDocumentor/Reflection/Php/Factory/ArgumentTest.php b/tests/unit/phpDocumentor/Reflection/Php/Factory/ArgumentTest.php
index 14b39b1b..0e4033eb 100644
--- a/tests/unit/phpDocumentor/Reflection/Php/Factory/ArgumentTest.php
+++ b/tests/unit/phpDocumentor/Reflection/Php/Factory/ArgumentTest.php
@@ -1,11 +1,12 @@
*/
class ArgumentTest extends TestCase
{
- protected function setUp()
+ protected function setUp() : void
{
$this->fixture = new Argument(new PrettyPrinter());
}
- protected function tearDown()
+ protected function tearDown() : void
{
m::close();
}
@@ -40,7 +43,7 @@ protected function tearDown()
/**
* @covers ::matches
*/
- public function testMatches()
+ public function testMatches() : void
{
$this->assertFalse($this->fixture->matches(new stdClass()));
$this->assertTrue($this->fixture->matches(m::mock(Param::class)));
@@ -49,14 +52,14 @@ public function testMatches()
/**
* @covers ::create
*/
- public function testCreate()
+ public function testCreate() : void
{
$factory = new ProjectFactoryStrategies([]);
- $argMock = m::mock(Param::class);
- $argMock->var = new \PhpParser\Node\Expr\Variable('myArgument');
- $argMock->default = new String_('MyDefault');
- $argMock->byRef = true;
+ $argMock = m::mock(Param::class);
+ $argMock->var = new Variable('myArgument');
+ $argMock->default = new String_('MyDefault');
+ $argMock->byRef = true;
$argMock->variadic = true;
$argument = $this->fixture->create($argMock, $factory);
diff --git a/tests/unit/phpDocumentor/Reflection/Php/Factory/ClassConstantIteratorTest.php b/tests/unit/phpDocumentor/Reflection/Php/Factory/ClassConstantIteratorTest.php
index 995bd88a..a946d96e 100644
--- a/tests/unit/phpDocumentor/Reflection/Php/Factory/ClassConstantIteratorTest.php
+++ b/tests/unit/phpDocumentor/Reflection/Php/Factory/ClassConstantIteratorTest.php
@@ -1,12 +1,13 @@
- * @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
*/
@@ -22,11 +23,12 @@
/**
* Class PropertyIteratorTest
+ *
* @coversDefaultClass \phpDocumentor\Reflection\Php\Factory\ClassConstantIterator
*/
class ClassConstantIteratorTest extends TestCase
{
- protected function tearDown()
+ protected function tearDown() : void
{
m::close();
}
@@ -39,11 +41,11 @@ protected function tearDown()
* @covers ::getName()
* @covers ::getFqsen()
*/
- public function testIterateProps()
+ public function testIterateProps() : void
{
- $const1 = new Const_('\Space\MyClass::MY_CONST1', new Variable('a'));
+ $const1 = new Const_('\Space\MyClass::MY_CONST1', new Variable('a'));
$const1->fqsen = new Fqsen((string) $const1->name);
- $const2 = new Const_('\Space\MyClass::MY_CONST2', new Variable('b'));
+ $const2 = new Const_('\Space\MyClass::MY_CONST2', new Variable('b'));
$const2->fqsen = new Fqsen((string) $const2->name);
$classConstantNode = new ClassConst([$const1, $const2]);
@@ -61,7 +63,7 @@ public function testIterateProps()
* @covers ::key()
* @covers ::next()
*/
- public function testKey()
+ public function testKey() : void
{
$propertyMock = m::mock(ClassConst::class);
@@ -76,7 +78,7 @@ public function testKey()
* @covers ::__construct
* @covers ::getLine
*/
- public function testProxyMethods()
+ public function testProxyMethods() : void
{
$propertyMock = m::mock(ClassConst::class);
$propertyMock->shouldReceive('getLine')->once()->andReturn(10);
@@ -89,10 +91,10 @@ public function testProxyMethods()
/**
* @covers ::getDocComment
*/
- public function testGetDocCommentPropFirst()
+ public function testGetDocCommentPropFirst() : void
{
- $const = m::mock(Const_::class);
- $classConstants = m::mock(ClassConst::class);
+ $const = m::mock(Const_::class);
+ $classConstants = m::mock(ClassConst::class);
$classConstants->consts = [$const];
$const->shouldReceive('getDocComment')->once()->andReturn(new Doc('test'));
@@ -106,10 +108,10 @@ public function testGetDocCommentPropFirst()
/**
* @covers ::getDocComment
*/
- public function testGetDocComment()
+ public function testGetDocComment() : void
{
- $const = m::mock(Const_::class);
- $classConstants = m::mock(ClassConst::class);
+ $const = m::mock(Const_::class);
+ $classConstants = m::mock(ClassConst::class);
$classConstants->consts = [$const];
$const->shouldReceive('getDocComment')->once()->andReturnNull();
diff --git a/tests/unit/phpDocumentor/Reflection/Php/Factory/Class_Test.php b/tests/unit/phpDocumentor/Reflection/Php/Factory/Class_Test.php
index 9fa98b37..05df26d4 100644
--- a/tests/unit/phpDocumentor/Reflection/Php/Factory/Class_Test.php
+++ b/tests/unit/phpDocumentor/Reflection/Php/Factory/Class_Test.php
@@ -1,12 +1,13 @@
- * @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
*/
@@ -31,9 +32,11 @@
use PhpParser\Node\Stmt\Property as PropertyNode;
use PhpParser\Node\Stmt\PropertyProperty;
use PhpParser\Node\Stmt\TraitUse;
+use stdClass;
/**
* Class Class_Test
+ *
* @coversDefaultClass phpDocumentor\Reflection\Php\Factory\Class_
* @covers ::
*/
@@ -41,7 +44,7 @@
class Class_Test extends TestCase
// @codingStandardsIgnoreEnd
{
- protected function setUp()
+ protected function setUp() : void
{
$this->fixture = new Class_();
}
@@ -49,19 +52,19 @@ protected function setUp()
/**
* @covers ::matches
*/
- public function testMatches()
+ public function testMatches() : void
{
- $this->assertFalse($this->fixture->matches(new \stdClass()));
+ $this->assertFalse($this->fixture->matches(new stdClass()));
$this->assertTrue($this->fixture->matches(m::mock(ClassNode::class)));
}
/**
* @covers ::create
*/
- public function testSimpleCreate()
+ public function testSimpleCreate() : void
{
$containerMock = m::mock(StrategyContainer::class);
- $classMock = $this->buildClassMock();
+ $classMock = $this->buildClassMock();
$classMock->shouldReceive('getDocComment')->andReturnNull();
/** @var ClassElement $class */
@@ -77,10 +80,10 @@ public function testSimpleCreate()
/**
* @covers ::create
*/
- public function testClassWithParent()
+ public function testClassWithParent() : void
{
$containerMock = m::mock(StrategyContainer::class);
- $classMock = $this->buildClassMock();
+ $classMock = $this->buildClassMock();
$classMock->shouldReceive('getDocComment')->andReturnNull();
$classMock->extends = 'Space\MyParent';
@@ -95,12 +98,12 @@ public function testClassWithParent()
/**
* @covers ::create
*/
- public function testClassImplementingInterface()
+ public function testClassImplementingInterface() : void
{
$containerMock = m::mock(StrategyContainer::class);
- $classMock = $this->buildClassMock();
+ $classMock = $this->buildClassMock();
$classMock->shouldReceive('getDocComment')->andReturnNull();
- $classMock->extends = 'Space\MyParent';
+ $classMock->extends = 'Space\MyParent';
$classMock->implements = [
new Name('MyInterface'),
];
@@ -120,17 +123,15 @@ public function testClassImplementingInterface()
/**
* @covers ::create
*/
- public function testWithMethodMembers()
+ public function testWithMethodMembers() : void
{
- $method1 = new ClassMethod('MyClass::method1');
+ $method1 = new ClassMethod('MyClass::method1');
$method1Descriptor = new MethodElement(new Fqsen('\MyClass::method1'));
- $strategyMock = m::mock(ProjectFactoryStrategy::class);
- $containerMock = m::mock(StrategyContainer::class);
- $classMock = $this->buildClassMock();
+ $strategyMock = m::mock(ProjectFactoryStrategy::class);
+ $containerMock = m::mock(StrategyContainer::class);
+ $classMock = $this->buildClassMock();
$classMock->shouldReceive('getDocComment')->andReturnNull();
- $classMock->stmts = [
- $method1,
- ];
+ $classMock->stmts = [$method1];
$strategyMock->shouldReceive('create')
->with($method1, $containerMock, null)
@@ -154,18 +155,16 @@ public function testWithMethodMembers()
/**
* @covers ::create
*/
- public function testWithPropertyMembers()
+ public function testWithPropertyMembers() : void
{
- $propertyProperty = new PropertyProperty('\MyClass::$property');
- $property = new PropertyNode(1, [$propertyProperty]);
+ $propertyProperty = new PropertyProperty('\MyClass::$property');
+ $property = new PropertyNode(1, [$propertyProperty]);
$propertyDescriptor = new PropertyElement(new Fqsen('\MyClass::$property'));
- $strategyMock = m::mock(ProjectFactoryStrategy::class);
- $containerMock = m::mock(StrategyContainer::class);
- $classMock = $this->buildClassMock();
+ $strategyMock = m::mock(ProjectFactoryStrategy::class);
+ $containerMock = m::mock(StrategyContainer::class);
+ $classMock = $this->buildClassMock();
$classMock->shouldReceive('getDocComment')->andReturnNull();
- $classMock->stmts = [
- $property,
- ];
+ $classMock->stmts = [$property];
$strategyMock->shouldReceive('create')
->with(m::type(PropertyIterator::class), $containerMock, null)
@@ -189,16 +188,14 @@ public function testWithPropertyMembers()
/**
* @covers ::create
*/
- public function testWithUsedTraits()
+ public function testWithUsedTraits() : void
{
- $trait = new TraitUse([new Name('MyTrait'), new Name('OtherTrait')]);
+ $trait = new TraitUse([new Name('MyTrait'), new Name('OtherTrait')]);
$containerMock = m::mock(StrategyContainer::class);
$containerMock->shouldReceive('findMatching')->never();
$classMock = $this->buildClassMock();
$classMock->shouldReceive('getDocComment')->andReturnNull();
- $classMock->stmts = [
- $trait,
- ];
+ $classMock->stmts = [$trait];
/** @var ClassElement $class */
$class = $this->fixture->create($classMock, $containerMock);
@@ -215,13 +212,13 @@ public function testWithUsedTraits()
/**
* @covers ::create
*/
- public function testWithConstants()
+ public function testWithConstants() : void
{
- $const = new Const_('\Space\MyClass::MY_CONST', new Variable('a'));
+ $const = new Const_('\Space\MyClass::MY_CONST', new Variable('a'));
$constant = new ClassConst([$const]);
- $result = new ConstantElement(new Fqsen('\Space\MyClass::MY_CONST'));
- $strategyMock = m::mock(ProjectFactoryStrategy::class);
+ $result = new ConstantElement(new Fqsen('\Space\MyClass::MY_CONST'));
+ $strategyMock = m::mock(ProjectFactoryStrategy::class);
$containerMock = m::mock(StrategyContainer::class);
$strategyMock->shouldReceive('create')
@@ -234,17 +231,13 @@ public function testWithConstants()
$classMock = $this->buildClassMock();
$classMock->shouldReceive('getDocComment')->andReturnNull();
- $classMock->stmts = [
- $constant,
- ];
+ $classMock->stmts = [$constant];
/** @var ClassElement $class */
$class = $this->fixture->create($classMock, $containerMock);
$this->assertEquals(
- [
- '\Space\MyClass::MY_CONST' => $result,
- ],
+ ['\Space\MyClass::MY_CONST' => $result],
$class->getConstants()
);
}
@@ -252,15 +245,15 @@ public function testWithConstants()
/**
* @covers ::create
*/
- public function testCreateWithDocBlock()
+ public function testCreateWithDocBlock() : void
{
- $doc = m::mock(Doc::class);
+ $doc = m::mock(Doc::class);
$classMock = $this->buildClassMock();
$classMock->shouldReceive('getDocComment')->andReturn($doc);
$docBlock = new DocBlockElement('');
- $strategyMock = m::mock(ProjectFactoryStrategy::class);
+ $strategyMock = m::mock(ProjectFactoryStrategy::class);
$containerMock = m::mock(StrategyContainer::class);
$strategyMock->shouldReceive('create')
@@ -282,7 +275,7 @@ public function testCreateWithDocBlock()
*/
private function buildClassMock()
{
- $classMock = m::mock(ClassNode::class);
+ $classMock = m::mock(ClassNode::class);
$classMock->fqsen = new Fqsen('\Space\MyClass');
$classMock->shouldReceive('isFinal')->andReturn(true);
$classMock->shouldReceive('isAbstract')->andReturn(true);
diff --git a/tests/unit/phpDocumentor/Reflection/Php/Factory/DocBlockTest.php b/tests/unit/phpDocumentor/Reflection/Php/Factory/DocBlockTest.php
index 2937101c..86f05cd8 100644
--- a/tests/unit/phpDocumentor/Reflection/Php/Factory/DocBlockTest.php
+++ b/tests/unit/phpDocumentor/Reflection/Php/Factory/DocBlockTest.php
@@ -1,12 +1,13 @@
- * @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
*/
@@ -17,40 +18,41 @@
use phpDocumentor\Reflection\DocBlockFactoryInterface;
use phpDocumentor\Reflection\Php\StrategyContainer;
use PhpParser\Comment\Doc;
+use stdClass;
/**
* Test case for \phpDocumentor\Reflection\Php\Factory\DocBlock
+ *
* @coversDefaultClass \phpDocumentor\Reflection\Php\Factory\DocBlock
*/
class DocBlockTest extends TestCase
{
- /**
- * @var m\MockInterface
- */
+ /** @var m\MockInterface|DocBlockFactoryInterface */
private $factoryMock;
+ /** @var m\MockInterface|StrategyContainer */
private $strategiesMock;
- protected function setUp()
+ protected function setUp() : void
{
- $this->factoryMock = m::mock(DocBlockFactoryInterface::class);
+ $this->factoryMock = m::mock(DocBlockFactoryInterface::class);
$this->strategiesMock = m::mock(StrategyContainer::class);
- $this->fixture = new DocBlock($this->factoryMock);
+ $this->fixture = new DocBlock($this->factoryMock);
}
/**
* @covers ::matches
*/
- public function testMatches()
+ public function testMatches() : void
{
- $this->assertFalse($this->fixture->matches(new \stdClass()));
+ $this->assertFalse($this->fixture->matches(new stdClass()));
$this->assertTrue($this->fixture->matches(m::mock(Doc::class)));
}
/**
* @covers ::create
*/
- public function testCreateWithNullReturnsNull()
+ public function testCreateWithNullReturnsNull() : void
{
$this->assertNull($this->fixture->create(null, $this->strategiesMock));
}
@@ -59,7 +61,7 @@ public function testCreateWithNullReturnsNull()
* @covers ::__construct
* @covers ::create
*/
- public function testCreateCallsFactory()
+ public function testCreateCallsFactory() : void
{
$expected = new DocblockDescriptor('');
$this->factoryMock->shouldReceive('create')->once()->andReturn($expected);
diff --git a/tests/unit/phpDocumentor/Reflection/Php/Factory/DummyFactoryStrategy.php b/tests/unit/phpDocumentor/Reflection/Php/Factory/DummyFactoryStrategy.php
index 6f2c35f9..edbe07ff 100644
--- a/tests/unit/phpDocumentor/Reflection/Php/Factory/DummyFactoryStrategy.php
+++ b/tests/unit/phpDocumentor/Reflection/Php/Factory/DummyFactoryStrategy.php
@@ -1,4 +1,5 @@
- * @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
*/
@@ -17,16 +18,15 @@
use PHPUnit\Framework\TestCase;
/**
- * @coversDefaultClass phpDocumentor\Reflection\Php\Factory\File\CreateCommand
- * @covers ::__construct
* @uses phpDocumentor\Reflection\File\LocalFile
* @uses phpDocumentor\Reflection\Php\ProjectFactoryStrategies
+ *
+ * @coversDefaultClass phpDocumentor\Reflection\Php\Factory\File\CreateCommand
+ * @covers ::__construct
*/
class CreateCommandTest extends TestCase
{
- /**
- * @var CreateCommand
- */
+ /** @var CreateCommand */
private $fixture;
/** @var LocalFile */
@@ -35,17 +35,17 @@ class CreateCommandTest extends TestCase
/** @var ProjectFactoryStrategies */
private $strategies;
- protected function setUp()
+ protected function setUp() : void
{
- $this->file = new LocalFile(__FILE__);
+ $this->file = new LocalFile(__FILE__);
$this->strategies = new ProjectFactoryStrategies([]);
- $this->fixture = new CreateCommand($this->file, $this->strategies);
+ $this->fixture = new CreateCommand($this->file, $this->strategies);
}
/**
* @covers ::getFile
*/
- public function testGetFile()
+ public function testGetFile() : void
{
$this->assertSame($this->file, $this->fixture->getFile());
}
@@ -53,7 +53,7 @@ public function testGetFile()
/**
* @covers ::getStrategies
*/
- public function testGetStrategies()
+ public function testGetStrategies() : void
{
$this->assertSame($this->strategies, $this->fixture->getStrategies());
}
diff --git a/tests/unit/phpDocumentor/Reflection/Php/Factory/FileTest.php b/tests/unit/phpDocumentor/Reflection/Php/Factory/FileTest.php
index f4780116..698fcc77 100644
--- a/tests/unit/phpDocumentor/Reflection/Php/Factory/FileTest.php
+++ b/tests/unit/phpDocumentor/Reflection/Php/Factory/FileTest.php
@@ -1,12 +1,13 @@
- * @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
*/
@@ -33,49 +34,48 @@
use PhpParser\Node\Stmt\Interface_ as InterfaceNode;
use PhpParser\Node\Stmt\Namespace_ as NamespaceNode;
use PhpParser\Node\Stmt\Trait_ as TraitNode;
+use stdClass;
+use function file_get_contents;
/**
* Test case for \phpDocumentor\Reflection\Php\Factory\File
+ *
* @coversDefaultClass \phpDocumentor\Reflection\Php\Factory\File
* @covers ::
* @covers ::__construct
*/
class FileTest extends TestCase
{
- /**
- * @var m\MockInterface
- */
+ /** @var m\MockInterface */
private $nodesFactoryMock;
- protected function setUp()
+ protected function setUp() : void
{
$this->nodesFactoryMock = m::mock(NodesFactory::class);
- $this->fixture = new File($this->nodesFactoryMock);
+ $this->fixture = new File($this->nodesFactoryMock);
}
/**
* @covers ::matches
*/
- public function testMatches()
+ public function testMatches() : void
{
- $this->assertFalse($this->fixture->matches(new \stdClass()));
+ $this->assertFalse($this->fixture->matches(new stdClass()));
$this->assertTrue($this->fixture->matches(m::mock(SourceFile::class)));
}
/**
* @covers ::create
*/
- public function testFileWithFunction()
+ public function testFileWithFunction() : void
{
$functionNode = new FunctionNode('myFunction');
$this->nodesFactoryMock->shouldReceive('create')
->with(file_get_contents(__FILE__))
->andReturn(
- [
- $functionNode,
- ]
+ [$functionNode]
);
- $strategyMock = m::mock(ProjectFactoryStrategy::class);
+ $strategyMock = m::mock(ProjectFactoryStrategy::class);
$containerMock = m::mock(StrategyContainer::class);
$strategyMock->shouldReceive('create')
@@ -96,17 +96,15 @@ public function testFileWithFunction()
/**
* @covers ::create
*/
- public function testFileWithClass()
+ public function testFileWithClass() : void
{
$classNode = new ClassNode('myClass');
$this->nodesFactoryMock->shouldReceive('create')
->with(file_get_contents(__FILE__))
->andReturn(
- [
- $classNode,
- ]
+ [$classNode]
);
- $strategyMock = m::mock(ProjectFactoryStrategy::class);
+ $strategyMock = m::mock(ProjectFactoryStrategy::class);
$containerMock = m::mock(StrategyContainer::class);
$strategyMock->shouldReceive('create')
@@ -127,16 +125,14 @@ public function testFileWithClass()
/**
* @covers ::create
*/
- public function testFileWithNamespace()
+ public function testFileWithNamespace() : void
{
- $namespaceNode = new NamespaceNode(new Name('mySpace'));
+ $namespaceNode = new NamespaceNode(new Name('mySpace'));
$namespaceNode->fqsen = new Fqsen('\mySpace');
$this->nodesFactoryMock->shouldReceive('create')
->with(file_get_contents(__FILE__))
->andReturn(
- [
- $namespaceNode,
- ]
+ [$namespaceNode]
);
$containerMock = m::mock(StrategyContainer::class);
@@ -151,17 +147,15 @@ public function testFileWithNamespace()
/**
* @covers ::create
*/
- public function testFileWithInterface()
+ public function testFileWithInterface() : void
{
$interfaceNode = new InterfaceNode('myInterface');
$this->nodesFactoryMock->shouldReceive('create')
->with(file_get_contents(__FILE__))
->andReturn(
- [
- $interfaceNode,
- ]
+ [$interfaceNode]
);
- $strategyMock = m::mock(ProjectFactoryStrategy::class);
+ $strategyMock = m::mock(ProjectFactoryStrategy::class);
$containerMock = m::mock(StrategyContainer::class);
$strategyMock->shouldReceive('create')
@@ -182,17 +176,15 @@ public function testFileWithInterface()
/**
* @covers ::create
*/
- public function testFileWithTrait()
+ public function testFileWithTrait() : void
{
$traitNode = new TraitNode('\myTrait');
$this->nodesFactoryMock->shouldReceive('create')
->with(file_get_contents(__FILE__))
->andReturn(
- [
- $traitNode,
- ]
+ [$traitNode]
);
- $strategyMock = m::mock(ProjectFactoryStrategy::class);
+ $strategyMock = m::mock(ProjectFactoryStrategy::class);
$containerMock = m::mock(StrategyContainer::class);
$strategyMock->shouldReceive('create')
@@ -213,7 +205,7 @@ public function testFileWithTrait()
/**
* @covers ::create
*/
- public function testMiddlewareIsExecuted()
+ public function testMiddlewareIsExecuted() : void
{
$file = new FileElement('aa', __FILE__);
$this->nodesFactoryMock->shouldReceive('create')
@@ -227,28 +219,26 @@ public function testMiddlewareIsExecuted()
$fixture = new File($this->nodesFactoryMock, [$middleware]);
$containerMock = m::mock(StrategyContainer::class);
- $result = $fixture->create(new SourceFile\LocalFile(__FILE__), $containerMock);
+ $result = $fixture->create(new SourceFile\LocalFile(__FILE__), $containerMock);
$this->assertSame($result, $file);
}
- /**
- * @expectedException \InvalidArgumentException
- */
- public function testMiddlewareIsChecked()
+ public function testMiddlewareIsChecked() : void
{
- new File($this->nodesFactoryMock, [new \stdClass()]);
+ $this->expectException('InvalidArgumentException');
+ new File($this->nodesFactoryMock, [new stdClass()]);
}
/**
* @covers ::create
*/
- public function testFileDocBlockWithNamespace()
+ public function testFileDocBlockWithNamespace() : void
{
- $docBlockNode = new DocBlockNode('');
+ $docBlockNode = new DocBlockNode('');
$docBlockDescriptor = new DocBlockDescriptor('');
- $namespaceNode = new NamespaceNode(new Name('mySpace'));
+ $namespaceNode = new NamespaceNode(new Name('mySpace'));
$namespaceNode->fqsen = new Fqsen('\mySpace');
$namespaceNode->setAttribute('comments', [$docBlockNode]);
@@ -256,7 +246,7 @@ public function testFileDocBlockWithNamespace()
->with(file_get_contents(__FILE__))
->andReturn([$namespaceNode]);
- $strategyMock = m::mock(ProjectFactoryStrategy::class);
+ $strategyMock = m::mock(ProjectFactoryStrategy::class);
$containerMock = m::mock(StrategyContainer::class);
$strategyMock->shouldReceive('create')
@@ -276,9 +266,9 @@ public function testFileDocBlockWithNamespace()
/**
* @covers ::create
*/
- public function testFileDocBlockWithClass()
+ public function testFileDocBlockWithClass() : void
{
- $docBlockNode = new DocBlockNode('');
+ $docBlockNode = new DocBlockNode('');
$docBlockDescriptor = new DocBlockDescriptor('');
$classNode = new ClassNode('myClass');
@@ -288,7 +278,7 @@ public function testFileDocBlockWithClass()
->with(file_get_contents(__FILE__))
->andReturn([$classNode]);
- $strategyMock = m::mock(ProjectFactoryStrategy::class);
+ $strategyMock = m::mock(ProjectFactoryStrategy::class);
$containerMock = m::mock(StrategyContainer::class);
$strategyMock->shouldReceive('create')
@@ -316,12 +306,12 @@ public function testFileDocBlockWithClass()
/**
* @covers ::create
*/
- public function testFileDocBlockWithComments()
+ public function testFileDocBlockWithComments() : void
{
- $docBlockNode = new DocBlockNode('');
+ $docBlockNode = new DocBlockNode('');
$docBlockDescriptor = new DocBlockDescriptor('');
- $namespaceNode = new NamespaceNode(new Name('mySpace'));
+ $namespaceNode = new NamespaceNode(new Name('mySpace'));
$namespaceNode->fqsen = new Fqsen('\mySpace');
$namespaceNode->setAttribute('comments', [new CommentNode('@codingStandardsIgnoreStart'), $docBlockNode]);
@@ -329,7 +319,7 @@ public function testFileDocBlockWithComments()
->with(file_get_contents(__FILE__))
->andReturn([$namespaceNode]);
- $strategyMock = m::mock(ProjectFactoryStrategy::class);
+ $strategyMock = m::mock(ProjectFactoryStrategy::class);
$containerMock = m::mock(StrategyContainer::class);
$strategyMock->shouldReceive('create')
diff --git a/tests/unit/phpDocumentor/Reflection/Php/Factory/Function_Test.php b/tests/unit/phpDocumentor/Reflection/Php/Factory/Function_Test.php
index 2b81e94c..5992d736 100644
--- a/tests/unit/phpDocumentor/Reflection/Php/Factory/Function_Test.php
+++ b/tests/unit/phpDocumentor/Reflection/Php/Factory/Function_Test.php
@@ -1,11 +1,12 @@
*/
@@ -32,7 +35,7 @@
class Function_Test extends TestCase
// @codingStandardsIgnoreEnd
{
- protected function setUp()
+ protected function setUp() : void
{
$this->fixture = new Function_();
}
@@ -40,19 +43,19 @@ protected function setUp()
/**
* @covers ::matches
*/
- public function testMatches()
+ public function testMatches() : void
{
- $this->assertFalse($this->fixture->matches(new \stdClass()));
+ $this->assertFalse($this->fixture->matches(new stdClass()));
$this->assertTrue($this->fixture->matches(m::mock(\PhpParser\Node\Stmt\Function_::class)));
}
/**
* @covers ::create
*/
- public function testCreateWithoutParameters()
+ public function testCreateWithoutParameters() : void
{
- $functionMock = m::mock(\PhpParser\Node\Stmt\Function_::class);
- $functionMock->fqsen = new Fqsen('\SomeSpace::function()');
+ $functionMock = m::mock(\PhpParser\Node\Stmt\Function_::class);
+ $functionMock->fqsen = new Fqsen('\SomeSpace::function()');
$functionMock->params = [];
$functionMock->shouldReceive('getDocComment')->andReturnNull();
$functionMock->shouldReceive('getLine')->andReturn(1);
@@ -70,16 +73,16 @@ public function testCreateWithoutParameters()
/**
* @covers ::create
*/
- public function testCreateWithParameters()
+ public function testCreateWithParameters() : void
{
- $functionMock = m::mock(\PhpParser\Node\Stmt\Function_::class);
- $functionMock->fqsen = new Fqsen('\SomeSpace::function()');
+ $functionMock = m::mock(\PhpParser\Node\Stmt\Function_::class);
+ $functionMock->fqsen = new Fqsen('\SomeSpace::function()');
$functionMock->params = ['param1'];
$functionMock->shouldReceive('getDocComment')->andReturnNull();
$functionMock->shouldReceive('getLine')->andReturn(1);
$functionMock->shouldReceive('getReturnType')->andReturnNull();
- $strategyMock = m::mock(ProjectFactoryStrategy::class);
+ $strategyMock = m::mock(ProjectFactoryStrategy::class);
$containerMock = m::mock(StrategyContainer::class);
$strategyMock->shouldReceive('create')
@@ -99,10 +102,10 @@ public function testCreateWithParameters()
/**
* @covers ::create
*/
- public function testReturnTypeResolving()
+ public function testReturnTypeResolving() : void
{
- $functionMock = m::mock(\PhpParser\Node\Stmt\Function_::class);
- $functionMock->fqsen = new Fqsen('\SomeSpace::function()');
+ $functionMock = m::mock(\PhpParser\Node\Stmt\Function_::class);
+ $functionMock->fqsen = new Fqsen('\SomeSpace::function()');
$functionMock->params = [];
$functionMock->shouldReceive('getDocComment')->andReturnNull();
$functionMock->shouldReceive('getLine')->andReturn(1);
@@ -120,10 +123,10 @@ public function testReturnTypeResolving()
/**
* @covers ::create
*/
- public function testReturnTypeNullableResolving()
+ public function testReturnTypeNullableResolving() : void
{
- $functionMock = m::mock(\PhpParser\Node\Stmt\Function_::class);
- $functionMock->fqsen = new Fqsen('\SomeSpace::function()');
+ $functionMock = m::mock(\PhpParser\Node\Stmt\Function_::class);
+ $functionMock->fqsen = new Fqsen('\SomeSpace::function()');
$functionMock->params = [];
$functionMock->shouldReceive('getDocComment')->andReturnNull();
$functionMock->shouldReceive('getLine')->andReturn(1);
@@ -141,18 +144,18 @@ public function testReturnTypeNullableResolving()
/**
* @covers ::create
*/
- public function testCreateWithDocBlock()
+ public function testCreateWithDocBlock() : void
{
- $doc = m::mock(Doc::class);
- $functionMock = m::mock(\PhpParser\Node\Stmt\Function_::class);
- $functionMock->fqsen = new Fqsen('\SomeSpace::function()');
+ $doc = m::mock(Doc::class);
+ $functionMock = m::mock(\PhpParser\Node\Stmt\Function_::class);
+ $functionMock->fqsen = new Fqsen('\SomeSpace::function()');
$functionMock->params = [];
$functionMock->shouldReceive('getDocComment')->andReturn($doc);
$functionMock->shouldReceive('getLine')->andReturn(1);
$functionMock->shouldReceive('getReturnType')->andReturnNull();
- $docBlock = new DocBlockDescriptor('');
- $strategyMock = m::mock(ProjectFactoryStrategy::class);
+ $docBlock = new DocBlockDescriptor('');
+ $strategyMock = m::mock(ProjectFactoryStrategy::class);
$containerMock = m::mock(StrategyContainer::class);
$strategyMock->shouldReceive('create')
diff --git a/tests/unit/phpDocumentor/Reflection/Php/Factory/Interface_Test.php b/tests/unit/phpDocumentor/Reflection/Php/Factory/Interface_Test.php
index 6d2df77e..e4afc5cd 100644
--- a/tests/unit/phpDocumentor/Reflection/Php/Factory/Interface_Test.php
+++ b/tests/unit/phpDocumentor/Reflection/Php/Factory/Interface_Test.php
@@ -1,12 +1,13 @@
- * @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
*/
@@ -26,9 +27,11 @@
use PhpParser\Node\Stmt\ClassConst;
use PhpParser\Node\Stmt\ClassMethod;
use PhpParser\Node\Stmt\Interface_ as InterfaceNode;
+use stdClass;
/**
* Test case for Interface_
+ *
* @coversDefaultClass phpDocumentor\Reflection\Php\Factory\Interface_
* @covers ::
*/
@@ -36,7 +39,7 @@
class Interface_Test extends TestCase
// @codingStandardsIgnoreEnd
{
- protected function setUp()
+ protected function setUp() : void
{
$this->fixture = new Interface_();
}
@@ -44,16 +47,16 @@ protected function setUp()
/**
* @covers ::matches
*/
- public function testMatches()
+ public function testMatches() : void
{
- $this->assertFalse($this->fixture->matches(new \stdClass()));
+ $this->assertFalse($this->fixture->matches(new stdClass()));
$this->assertTrue($this->fixture->matches(m::mock(InterfaceNode::class)));
}
/**
* @covers ::create
*/
- public function testSimpleCreate()
+ public function testSimpleCreate() : void
{
$containerMock = m::mock(StrategyContainer::class);
$interfaceMock = $this->buildClassMock();
@@ -69,14 +72,14 @@ public function testSimpleCreate()
/**
* @covers ::create
*/
- public function testCreateWithDocBlock()
+ public function testCreateWithDocBlock() : void
{
- $doc = m::mock(Doc::class);
+ $doc = m::mock(Doc::class);
$interfaceMock = $this->buildClassMock();
$interfaceMock->shouldReceive('getDocComment')->andReturn($doc);
- $docBlock = new DocBlockElement('');
- $strategyMock = m::mock(ProjectFactoryStrategy::class);
+ $docBlock = new DocBlockElement('');
+ $strategyMock = m::mock(ProjectFactoryStrategy::class);
$containerMock = m::mock(StrategyContainer::class);
$strategyMock->shouldReceive('create')
@@ -96,17 +99,15 @@ public function testCreateWithDocBlock()
/**
* @covers ::create
*/
- public function testWithMethodMembers()
+ public function testWithMethodMembers() : void
{
- $method1 = new ClassMethod('\Space\MyInterface::method1');
+ $method1 = new ClassMethod('\Space\MyInterface::method1');
$method1Descriptor = new MethodElement(new Fqsen('\Space\MyInterface::method1'));
- $strategyMock = m::mock(ProjectFactoryStrategy::class);
- $containerMock = m::mock(StrategyContainer::class);
- $interfaceMock = $this->buildClassMock();
+ $strategyMock = m::mock(ProjectFactoryStrategy::class);
+ $containerMock = m::mock(StrategyContainer::class);
+ $interfaceMock = $this->buildClassMock();
$interfaceMock->shouldReceive('getDocComment')->andReturnNull();
- $interfaceMock->stmts = [
- $method1,
- ];
+ $interfaceMock->stmts = [$method1];
$strategyMock->shouldReceive('create')
->with($method1, $containerMock, null)
@@ -132,13 +133,13 @@ public function testWithMethodMembers()
/**
* @covers ::create
*/
- public function testWithConstants()
+ public function testWithConstants() : void
{
- $const = new Const_('\Space\MyClass::MY_CONST', new Variable('a'));
+ $const = new Const_('\Space\MyClass::MY_CONST', new Variable('a'));
$constant = new ClassConst([$const]);
- $result = new ConstantElement(new Fqsen('\Space\MyClass::MY_CONST'));
- $strategyMock = m::mock(ProjectFactoryStrategy::class);
+ $result = new ConstantElement(new Fqsen('\Space\MyClass::MY_CONST'));
+ $strategyMock = m::mock(ProjectFactoryStrategy::class);
$containerMock = m::mock(StrategyContainer::class);
$strategyMock->shouldReceive('create')
@@ -151,17 +152,13 @@ public function testWithConstants()
$classMock = $this->buildClassMock();
$classMock->shouldReceive('getDocComment')->andReturnNull();
- $classMock->stmts = [
- $constant,
- ];
+ $classMock->stmts = [$constant];
/** @var ClassElement $class */
$class = $this->fixture->create($classMock, $containerMock);
$this->assertEquals(
- [
- '\Space\MyClass::MY_CONST' => $result,
- ],
+ ['\Space\MyClass::MY_CONST' => $result],
$class->getConstants()
);
}
@@ -171,8 +168,8 @@ public function testWithConstants()
*/
private function buildClassMock()
{
- $interfaceMock = m::mock(InterfaceNode::class);
- $interfaceMock->fqsen = new Fqsen('\Space\MyInterface');
+ $interfaceMock = m::mock(InterfaceNode::class);
+ $interfaceMock->fqsen = new Fqsen('\Space\MyInterface');
$interfaceMock->extends = [];
$interfaceMock->shouldReceive('getLine')->andReturn(1);
return $interfaceMock;
diff --git a/tests/unit/phpDocumentor/Reflection/Php/Factory/MethodTest.php b/tests/unit/phpDocumentor/Reflection/Php/Factory/MethodTest.php
index d767e9db..71d1899e 100644
--- a/tests/unit/phpDocumentor/Reflection/Php/Factory/MethodTest.php
+++ b/tests/unit/phpDocumentor/Reflection/Php/Factory/MethodTest.php
@@ -1,17 +1,19 @@
*/
class MethodTest extends TestCase
{
- protected function setUp()
+ protected function setUp() : void
{
$this->fixture = new Method();
}
@@ -39,18 +43,18 @@ protected function setUp()
/**
* @covers ::matches
*/
- public function testMatches()
+ public function testMatches() : void
{
- $this->assertFalse($this->fixture->matches(new \stdClass()));
+ $this->assertFalse($this->fixture->matches(new stdClass()));
$this->assertTrue($this->fixture->matches(m::mock(ClassMethod::class)));
}
/**
* @covers ::create
*/
- public function testCreateWithoutParameters()
+ public function testCreateWithoutParameters() : void
{
- $classMethodMock = $this->buildClassMethodMock();
+ $classMethodMock = $this->buildClassMethodMock();
$classMethodMock->params = [];
$classMethodMock->shouldReceive('isPrivate')->once()->andReturn(false);
$classMethodMock->shouldReceive('isProtected')->once()->andReturn(false);
@@ -67,9 +71,9 @@ public function testCreateWithoutParameters()
$this->assertEquals('public', (string) $method->getVisibility());
}
- public function testCreateProtectedMethod()
+ public function testCreateProtectedMethod() : void
{
- $classMethodMock = $this->buildClassMethodMock();
+ $classMethodMock = $this->buildClassMethodMock();
$classMethodMock->params = [];
$classMethodMock->shouldReceive('isPrivate')->once()->andReturn(false);
$classMethodMock->shouldReceive('isProtected')->once()->andReturn(true);
@@ -89,15 +93,15 @@ public function testCreateProtectedMethod()
/**
* @covers ::create
*/
- public function testCreateWithParameters()
+ public function testCreateWithParameters() : void
{
- $classMethodMock = $this->buildClassMethodMock();
+ $classMethodMock = $this->buildClassMethodMock();
$classMethodMock->params = ['param1'];
$classMethodMock->shouldReceive('isPrivate')->once()->andReturn(true);
$classMethodMock->shouldReceive('getDocComment')->once()->andReturnNull();
$classMethodMock->shouldReceive('getReturnType')->once()->andReturn(null);
- $strategyMock = m::mock(ProjectFactoryStrategy::class);
+ $strategyMock = m::mock(ProjectFactoryStrategy::class);
$containerMock = m::mock(StrategyContainer::class);
$strategyMock->shouldReceive('create')
@@ -121,9 +125,9 @@ public function testCreateWithParameters()
/**
* @covers ::create
*/
- public function testReturnTypeResolving()
+ public function testReturnTypeResolving() : void
{
- $classMethodMock = $this->buildClassMethodMock();
+ $classMethodMock = $this->buildClassMethodMock();
$classMethodMock->params = [];
$classMethodMock->shouldReceive('isPrivate')->once()->andReturn(true);
$classMethodMock->shouldReceive('getDocComment')->once()->andReturnNull();
@@ -141,9 +145,9 @@ public function testReturnTypeResolving()
/**
* @covers ::create
*/
- public function testReturnTypeNullableResolving()
+ public function testReturnTypeNullableResolving() : void
{
- $classMethodMock = $this->buildClassMethodMock();
+ $classMethodMock = $this->buildClassMethodMock();
$classMethodMock->params = [];
$classMethodMock->shouldReceive('isPrivate')->once()->andReturn(true);
$classMethodMock->shouldReceive('getDocComment')->once()->andReturnNull();
@@ -161,17 +165,17 @@ public function testReturnTypeNullableResolving()
/**
* @covers ::create
*/
- public function testCreateWithDocBlock()
+ public function testCreateWithDocBlock() : void
{
- $doc = m::mock(Doc::class);
- $classMethodMock = $this->buildClassMethodMock();
+ $doc = m::mock(Doc::class);
+ $classMethodMock = $this->buildClassMethodMock();
$classMethodMock->params = [];
$classMethodMock->shouldReceive('isPrivate')->once()->andReturn(true);
$classMethodMock->shouldReceive('getDocComment')->andReturn($doc);
$classMethodMock->shouldReceive('getReturnType')->once()->andReturn(null);
- $docBlock = new DocBlockDescriptor('');
- $strategyMock = m::mock(ProjectFactoryStrategy::class);
+ $docBlock = new DocBlockDescriptor('');
+ $strategyMock = m::mock(ProjectFactoryStrategy::class);
$containerMock = m::mock(StrategyContainer::class);
$strategyMock->shouldReceive('create')
@@ -189,10 +193,13 @@ public function testCreateWithDocBlock()
$this->assertSame($docBlock, $method->getDocBlock());
}
- private function buildClassMethodMock()
+ /**
+ * @return MockInterface|ClassMethod
+ */
+ private function buildClassMethodMock() : MockInterface
{
- $methodMock = m::mock(ClassMethod::class);
- $methodMock->name = 'function';
+ $methodMock = m::mock(ClassMethod::class);
+ $methodMock->name = 'function';
$methodMock->fqsen = new Fqsen('\SomeSpace\Class::function()');
$methodMock->shouldReceive('isStatic')->once()->andReturn(true);
diff --git a/tests/unit/phpDocumentor/Reflection/Php/Factory/PropertyIteratorTest.php b/tests/unit/phpDocumentor/Reflection/Php/Factory/PropertyIteratorTest.php
index cf88e015..565d74cd 100644
--- a/tests/unit/phpDocumentor/Reflection/Php/Factory/PropertyIteratorTest.php
+++ b/tests/unit/phpDocumentor/Reflection/Php/Factory/PropertyIteratorTest.php
@@ -1,12 +1,13 @@
- * @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
*/
@@ -20,11 +21,12 @@
/**
* Class PropertyIteratorTest
+ *
* @coversDefaultClass \phpDocumentor\Reflection\Php\Factory\PropertyIterator
*/
class PropertyIteratorTest extends TestCase
{
- protected function tearDown()
+ protected function tearDown() : void
{
m::close();
}
@@ -36,7 +38,7 @@ protected function tearDown()
* @covers ::rewind()
* @covers ::getName()
*/
- public function testIterateProps()
+ public function testIterateProps() : void
{
$prop1 = new PropertyProperty('prop1');
$prop2 = new PropertyProperty('prop2');
@@ -54,7 +56,7 @@ public function testIterateProps()
* @covers ::key()
* @covers ::next()
*/
- public function testKey()
+ public function testKey() : void
{
$propertyMock = m::mock(PropertyNode::class);
@@ -73,7 +75,7 @@ public function testKey()
* @covers ::isStatic
* @covers ::getLine
*/
- public function testProxyMethods()
+ public function testProxyMethods() : void
{
$propertyMock = m::mock(PropertyNode::class);
$propertyMock->shouldReceive('isPublic')->once()->andReturn(true);
@@ -95,11 +97,11 @@ public function testProxyMethods()
* @covers ::__construct
* @covers ::getDefault
*/
- public function testGetDefault()
+ public function testGetDefault() : void
{
- $prop = m::mock(PropertyProperty::class);
+ $prop = m::mock(PropertyProperty::class);
$prop->default = 'myDefault';
- $property = new PropertyNode(1, [$prop]);
+ $property = new PropertyNode(1, [$prop]);
$fixture = new PropertyIterator($property);
@@ -109,10 +111,10 @@ public function testGetDefault()
/**
* @covers ::getDocComment
*/
- public function testGetDocCommentPropFirst()
+ public function testGetDocCommentPropFirst() : void
{
- $prop = m::mock(PropertyProperty::class);
- $propertyNode = m::mock(PropertyNode::class);
+ $prop = m::mock(PropertyProperty::class);
+ $propertyNode = m::mock(PropertyNode::class);
$propertyNode->props = [$prop];
$prop->shouldReceive('getDocComment')->once()->andReturn(new Doc('test'));
@@ -126,10 +128,10 @@ public function testGetDocCommentPropFirst()
/**
* @covers ::getDocComment
*/
- public function testGetDocComment()
+ public function testGetDocComment() : void
{
- $prop = m::mock(PropertyProperty::class);
- $propertyNode = m::mock(PropertyNode::class);
+ $prop = m::mock(PropertyProperty::class);
+ $propertyNode = m::mock(PropertyNode::class);
$propertyNode->props = [$prop];
$prop->shouldReceive('getDocComment')->once()->andReturnNull();
diff --git a/tests/unit/phpDocumentor/Reflection/Php/Factory/PropertyTest.php b/tests/unit/phpDocumentor/Reflection/Php/Factory/PropertyTest.php
index 2701d990..ec881832 100644
--- a/tests/unit/phpDocumentor/Reflection/Php/Factory/PropertyTest.php
+++ b/tests/unit/phpDocumentor/Reflection/Php/Factory/PropertyTest.php
@@ -1,11 +1,12 @@
* @covers ::__construct
*/
class PropertyTest extends TestCase
{
- protected function setUp()
+ protected function setUp() : void
{
$this->fixture = new Property(new PrettyPrinter());
}
@@ -41,16 +44,16 @@ protected function setUp()
/**
* @covers ::matches
*/
- public function testMatches()
+ public function testMatches() : void
{
- $this->assertFalse($this->fixture->matches(new \stdClass()));
+ $this->assertFalse($this->fixture->matches(new stdClass()));
$this->assertTrue($this->fixture->matches(new PropertyIterator(new PropertyNode(1, []))));
}
/**
* @covers ::create
*/
- public function testPrivateCreate()
+ public function testPrivateCreate() : void
{
$factory = new ProjectFactoryStrategies([]);
@@ -65,7 +68,7 @@ public function testPrivateCreate()
/**
* @covers ::create
*/
- public function testProtectedCreate()
+ public function testProtectedCreate() : void
{
$factory = new ProjectFactoryStrategies([]);
@@ -80,7 +83,7 @@ public function testProtectedCreate()
/**
* @covers ::create
*/
- public function testCreatePublic()
+ public function testCreatePublic() : void
{
$factory = new ProjectFactoryStrategies([]);
@@ -95,17 +98,17 @@ public function testCreatePublic()
/**
* @covers ::create
*/
- public function testCreateWithDocBlock()
+ public function testCreateWithDocBlock() : void
{
- $doc = m::mock(Doc::class);
+ $doc = m::mock(Doc::class);
$docBlock = new DocBlockDescriptor('');
- $property = new PropertyProperty('property', new String_('MyDefault'), ['comments' => [$doc]]);
+ $property = new PropertyProperty('property', new String_('MyDefault'), ['comments' => [$doc]]);
$property->fqsen = new Fqsen('\myClass::$property');
- $node = new PropertyNode(ClassNode::MODIFIER_PRIVATE | ClassNode::MODIFIER_STATIC, [$property]);
+ $node = new PropertyNode(ClassNode::MODIFIER_PRIVATE | ClassNode::MODIFIER_STATIC, [$property]);
- $propertyMock = new PropertyIterator($node);
- $strategyMock = m::mock(ProjectFactoryStrategy::class);
+ $propertyMock = new PropertyIterator($node);
+ $strategyMock = m::mock(ProjectFactoryStrategy::class);
$containerMock = m::mock(StrategyContainer::class);
$strategyMock->shouldReceive('create')
@@ -123,23 +126,14 @@ public function testCreateWithDocBlock()
$this->assertSame($docBlock, $property->getDocBlock());
}
- /**
- * @return PropertyIterator
- */
- private function buildPropertyMock($modifier)
+ private function buildPropertyMock(int $modifier) : PropertyIterator
{
- $property = new PropertyProperty('property', new String_('MyDefault'));
+ $property = new PropertyProperty('property', new String_('MyDefault'));
$property->fqsen = new Fqsen('\myClass::$property');
- $propertyMock = new PropertyIterator(new PropertyNode($modifier | ClassNode::MODIFIER_STATIC, [$property]));
-
- return $propertyMock;
+ return new PropertyIterator(new PropertyNode($modifier | ClassNode::MODIFIER_STATIC, [$property]));
}
- /**
- * @param PropertyDescriptor $property
- * @param string $visibility
- */
- private function assertProperty($property, $visibility)
+ private function assertProperty(PropertyDescriptor $property, string $visibility) : void
{
$this->assertInstanceOf(PropertyDescriptor::class, $property);
$this->assertEquals('\myClass::$property', (string) $property->getFqsen());
diff --git a/tests/unit/phpDocumentor/Reflection/Php/Factory/TestCase.php b/tests/unit/phpDocumentor/Reflection/Php/Factory/TestCase.php
index 43aa0400..6447436b 100644
--- a/tests/unit/phpDocumentor/Reflection/Php/Factory/TestCase.php
+++ b/tests/unit/phpDocumentor/Reflection/Php/Factory/TestCase.php
@@ -1,12 +1,13 @@
- * @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
*/
@@ -16,29 +17,27 @@
use phpDocumentor\Reflection\Php\ProjectFactoryStrategy;
use phpDocumentor\Reflection\Php\StrategyContainer;
use PHPUnit\Framework\TestCase as BaseTestCase;
+use stdClass;
/**
* Base test case for all strategies, to be sure that they check if the can handle objects before handeling them.
*/
abstract class TestCase extends BaseTestCase
{
- /**
- * @var ProjectFactoryStrategy
- */
+ /** @var ProjectFactoryStrategy */
protected $fixture;
- protected function tearDown()
+ protected function tearDown() : void
{
m::close();
}
/**
* @covers ::create
- *
- * @expectedException \InvalidArgumentException
*/
- public function testCreateThrowsException()
+ public function testCreateThrowsException() : void
{
- $this->fixture->create(new \stdClass(), m::mock(StrategyContainer::class));
+ $this->expectException('InvalidArgumentException');
+ $this->fixture->create(new stdClass(), m::mock(StrategyContainer::class));
}
}
diff --git a/tests/unit/phpDocumentor/Reflection/Php/Factory/Trait_Test.php b/tests/unit/phpDocumentor/Reflection/Php/Factory/Trait_Test.php
index eb7f1c55..6eb593b2 100644
--- a/tests/unit/phpDocumentor/Reflection/Php/Factory/Trait_Test.php
+++ b/tests/unit/phpDocumentor/Reflection/Php/Factory/Trait_Test.php
@@ -1,12 +1,13 @@
- * @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
*/
@@ -27,9 +28,11 @@
use PhpParser\Node\Stmt\PropertyProperty;
use PhpParser\Node\Stmt\Trait_ as TraitNode;
use PhpParser\Node\Stmt\TraitUse;
+use stdClass;
/**
* Test case for Trait_
+ *
* @coversDefaultClass phpDocumentor\Reflection\Php\Factory\Trait_
* @covers ::
*/
@@ -37,7 +40,7 @@
class Trait_Test extends TestCase
// @codingStandardsIgnoreEnd
{
- protected function setUp()
+ protected function setUp() : void
{
$this->fixture = new Trait_();
}
@@ -45,16 +48,16 @@ protected function setUp()
/**
* @covers ::matches
*/
- public function testMatches()
+ public function testMatches() : void
{
- $this->assertFalse($this->fixture->matches(new \stdClass()));
+ $this->assertFalse($this->fixture->matches(new stdClass()));
$this->assertTrue($this->fixture->matches(m::mock(TraitNode::class)));
}
/**
* @covers ::create
*/
- public function testSimpleCreate()
+ public function testSimpleCreate() : void
{
$containerMock = m::mock(StrategyContainer::class);
$interfaceMock = $this->buildTraitMock();
@@ -70,15 +73,15 @@ public function testSimpleCreate()
/**
* @covers ::create
*/
- public function testCreateWithDocBlock()
+ public function testCreateWithDocBlock() : void
{
- $doc = m::mock(Doc::class);
+ $doc = m::mock(Doc::class);
$interfaceMock = $this->buildTraitMock();
$interfaceMock->shouldReceive('getDocComment')->andReturn($doc);
$docBlock = new DocBlockElement('');
- $strategyMock = m::mock(ProjectFactoryStrategy::class);
+ $strategyMock = m::mock(ProjectFactoryStrategy::class);
$containerMock = m::mock(StrategyContainer::class);
$strategyMock->shouldReceive('create')
@@ -98,18 +101,16 @@ public function testCreateWithDocBlock()
/**
* @covers ::create
*/
- public function testWithPropertyMembers()
+ public function testWithPropertyMembers() : void
{
- $propertyProperty = new PropertyProperty('\Space\MyTrait::$property');
- $property = new PropertyNode(1, [$propertyProperty]);
+ $propertyProperty = new PropertyProperty('\Space\MyTrait::$property');
+ $property = new PropertyNode(1, [$propertyProperty]);
$propertyDescriptor = new PropertyElement(new Fqsen('\Space\MyTrait::$property'));
- $strategyMock = m::mock(ProjectFactoryStrategy::class);
- $containerMock = m::mock(StrategyContainer::class);
- $traitMock = $this->buildTraitMock();
+ $strategyMock = m::mock(ProjectFactoryStrategy::class);
+ $containerMock = m::mock(StrategyContainer::class);
+ $traitMock = $this->buildTraitMock();
$traitMock->shouldReceive('getDocComment')->andReturnNull();
- $traitMock->stmts = [
- $property,
- ];
+ $traitMock->stmts = [$property];
$strategyMock->shouldReceive('create')
->with(m::type(PropertyIterator::class), $containerMock, null)
@@ -133,17 +134,15 @@ public function testWithPropertyMembers()
/**
* @covers ::create
*/
- public function testWithMethodMembers()
+ public function testWithMethodMembers() : void
{
- $method1 = new ClassMethod('MyTrait::method1');
+ $method1 = new ClassMethod('MyTrait::method1');
$method1Descriptor = new MethodElement(new Fqsen('\MyTrait::method1'));
- $strategyMock = m::mock(ProjectFactoryStrategy::class);
- $containerMock = m::mock(StrategyContainer::class);
- $traitMock = $this->buildTraitMock();
+ $strategyMock = m::mock(ProjectFactoryStrategy::class);
+ $containerMock = m::mock(StrategyContainer::class);
+ $traitMock = $this->buildTraitMock();
$traitMock->shouldReceive('getDocComment')->andReturnNull();
- $traitMock->stmts = [
- $method1,
- ];
+ $traitMock->stmts = [$method1];
$strategyMock->shouldReceive('create')
->with($method1, $containerMock, null)
@@ -167,16 +166,14 @@ public function testWithMethodMembers()
/**
* @covers ::create
*/
- public function testWithUsedTraits()
+ public function testWithUsedTraits() : void
{
- $trait = new TraitUse([new Name('MyTrait')]);
+ $trait = new TraitUse([new Name('MyTrait')]);
$containerMock = m::mock(StrategyContainer::class);
$containerMock->shouldReceive('findMatching')->never();
$traitMock = $this->buildTraitMock();
$traitMock->shouldReceive('getDocComment')->andReturnNull();
- $traitMock->stmts = [
- $trait,
- ];
+ $traitMock->stmts = [$trait];
/** @var TraitElement $trait */
$trait = $this->fixture->create($traitMock, $containerMock);
@@ -194,7 +191,7 @@ public function testWithUsedTraits()
*/
private function buildTraitMock()
{
- $mock = m::mock(TraitNode::class);
+ $mock = m::mock(TraitNode::class);
$mock->fqsen = new Fqsen('\Space\MyTrait');
$mock->shouldReceive('getLine')->andReturn(1);
return $mock;
diff --git a/tests/unit/phpDocumentor/Reflection/Php/FileTest.php b/tests/unit/phpDocumentor/Reflection/Php/FileTest.php
index 11493152..06909226 100644
--- a/tests/unit/phpDocumentor/Reflection/Php/FileTest.php
+++ b/tests/unit/phpDocumentor/Reflection/Php/FileTest.php
@@ -1,18 +1,19 @@
- * @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
*/
namespace phpDocumentor\Reflection\Php;
-use \Mockery as m;
+use Mockery as m;
use phpDocumentor\Reflection\DocBlock;
use phpDocumentor\Reflection\Fqsen;
use PHPUnit\Framework\TestCase;
@@ -24,31 +25,29 @@
*/
class FileTest extends TestCase
{
- const EXAMPLE_HASH = 'a-hash-string';
+ public const EXAMPLE_HASH = 'a-hash-string';
- const EXAMPLE_PATH = 'a-path-string';
+ public const EXAMPLE_PATH = 'a-path-string';
- const EXAMPLE_SOURCE = 'a-source-string';
+ public const EXAMPLE_SOURCE = 'a-source-string';
/** @var File $fixture */
protected $fixture;
- /**
- * @var DocBlock
- */
+ /** @var DocBlock */
private $docBlock;
/**
* Creates a new (emoty) fixture object.
*/
- protected function setUp()
+ protected function setUp() : void
{
$this->docBlock = new DocBlock('');
$this->fixture = new File(static::EXAMPLE_HASH, static::EXAMPLE_PATH, static::EXAMPLE_SOURCE, $this->docBlock);
}
- protected function tearDown()
+ protected function tearDown() : void
{
m::close();
}
@@ -58,7 +57,7 @@ protected function tearDown()
* @covers ::getClasses
* @covers ::AddClass
*/
- public function testAddAndGetClasses()
+ public function testAddAndGetClasses() : void
{
$this->assertEmpty($this->fixture->getClasses());
@@ -73,7 +72,7 @@ public function testAddAndGetClasses()
* @covers ::getConstants
* @covers ::addConstant
*/
- public function testAddAndGetConstants()
+ public function testAddAndGetConstants() : void
{
$this->assertEmpty($this->fixture->getConstants());
@@ -88,7 +87,7 @@ public function testAddAndGetConstants()
* @covers ::getFunctions
* @covers ::addFunction
*/
- public function testAddAndGetFunctions()
+ public function testAddAndGetFunctions() : void
{
$this->assertEmpty($this->fixture->getFunctions());
@@ -103,7 +102,7 @@ public function testAddAndGetFunctions()
* @covers ::getInterfaces
* @covers ::addInterface
*/
- public function testAddAndGetInterfaces()
+ public function testAddAndGetInterfaces() : void
{
$this->assertEmpty($this->fixture->getInterfaces());
@@ -118,7 +117,7 @@ public function testAddAndGetInterfaces()
* @covers ::getTraits
* @covers ::addTrait
*/
- public function testAddAndGetTraits()
+ public function testAddAndGetTraits() : void
{
$this->assertEmpty($this->fixture->getTraits());
@@ -132,7 +131,7 @@ public function testAddAndGetTraits()
* @covers ::__construct
* @covers ::getDocBlock
*/
- public function testGetDocBlock()
+ public function testGetDocBlock() : void
{
$this->assertSame($this->docBlock, $this->fixture->getDocBlock());
}
@@ -141,7 +140,7 @@ public function testGetDocBlock()
* @covers ::__construct
* @covers ::getHash
*/
- public function testGetHash()
+ public function testGetHash() : void
{
$this->assertSame(self::EXAMPLE_HASH, $this->fixture->getHash());
}
@@ -149,7 +148,7 @@ public function testGetHash()
/**
* @covers ::getPath
*/
- public function testSetAndGetPath()
+ public function testSetAndGetPath() : void
{
$this->assertSame(self::EXAMPLE_PATH, $this->fixture->getPath());
}
@@ -157,7 +156,7 @@ public function testSetAndGetPath()
/**
* @covers ::getSource
*/
- public function testSetAndGetSource()
+ public function testSetAndGetSource() : void
{
$this->assertSame(self::EXAMPLE_SOURCE, $this->fixture->getSource());
}
@@ -166,7 +165,7 @@ public function testSetAndGetSource()
* @covers ::addNamespace
* @covers ::getNamespaces
*/
- public function testSetAndGetNamespaceAliases()
+ public function testSetAndGetNamespaceAliases() : void
{
$this->assertEmpty($this->fixture->getNamespaces());
@@ -179,7 +178,7 @@ public function testSetAndGetNamespaceAliases()
* @covers ::getIncludes
* @covers ::addInclude
*/
- public function testAddAndGetIncludes()
+ public function testAddAndGetIncludes() : void
{
$this->assertEmpty($this->fixture->getIncludes());
diff --git a/tests/unit/phpDocumentor/Reflection/Php/Function_Test.php b/tests/unit/phpDocumentor/Reflection/Php/Function_Test.php
index dca21213..aebd0060 100644
--- a/tests/unit/phpDocumentor/Reflection/Php/Function_Test.php
+++ b/tests/unit/phpDocumentor/Reflection/Php/Function_Test.php
@@ -1,18 +1,19 @@
- * @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
*/
namespace phpDocumentor\Reflection\Php;
-use \Mockery as m;
+use Mockery as m;
use phpDocumentor\Reflection\DocBlock;
use phpDocumentor\Reflection\Fqsen;
use phpDocumentor\Reflection\Types\Mixed_;
@@ -21,6 +22,7 @@
/**
* Tests the functionality for the Function_ class.
+ *
* @coversDefaultClass phpDocumentor\Reflection\Php\Function_
*/
// @codingStandardsIgnoreStart
@@ -39,14 +41,14 @@ class Function_Test extends TestCase
/**
* Creates a new (emoty) fixture object.
*/
- protected function setUp()
+ protected function setUp() : void
{
- $this->fqsen = new Fqsen('\space\MyFunction()');
+ $this->fqsen = new Fqsen('\space\MyFunction()');
$this->docBlock = new DocBlock('aa');
- $this->fixture = new Function_($this->fqsen, $this->docBlock);
+ $this->fixture = new Function_($this->fqsen, $this->docBlock);
}
- protected function tearDown()
+ protected function tearDown() : void
{
m::close();
}
@@ -55,7 +57,7 @@ protected function tearDown()
* @covers ::__construct
* @covers ::getName
*/
- public function testGetName()
+ public function testGetName() : void
{
$this->assertEquals('MyFunction', $this->fixture->getName());
}
@@ -64,7 +66,7 @@ public function testGetName()
* @covers ::addArgument
* @covers ::getArguments
*/
- public function testAddAndGetArguments()
+ public function testAddAndGetArguments() : void
{
$argument = new Argument('firstArgument');
$this->fixture->addArgument($argument);
@@ -76,7 +78,7 @@ public function testAddAndGetArguments()
* @covers ::__construct
* @covers ::getFqsen
*/
- public function testGetFqsen()
+ public function testGetFqsen() : void
{
$this->assertSame($this->fqsen, $this->fixture->getFqsen());
}
@@ -85,7 +87,7 @@ public function testGetFqsen()
* @covers ::__construct
* @covers ::getDocBlock
*/
- public function testGetDocblock()
+ public function testGetDocblock() : void
{
$this->assertSame($this->docBlock, $this->fixture->getDocBlock());
}
@@ -94,7 +96,7 @@ public function testGetDocblock()
* @covers ::getReturnType
* @covers ::__construct
*/
- public function testGetDefaultReturnType()
+ public function testGetDefaultReturnType() : void
{
$method = new Function_($this->fqsen);
$this->assertEquals(new Mixed_(), $method->getReturnType());
@@ -104,10 +106,10 @@ public function testGetDefaultReturnType()
* @covers ::getReturnType
* @covers ::__construct
*/
- public function testGetReturnTypeFromConstructor()
+ public function testGetReturnTypeFromConstructor() : void
{
$returnType = new String_();
- $method = new Function_(
+ $method = new Function_(
$this->fqsen,
null,
null,
diff --git a/tests/unit/phpDocumentor/Reflection/Php/Interface_Test.php b/tests/unit/phpDocumentor/Reflection/Php/Interface_Test.php
index 4e8109c7..8b26afcb 100644
--- a/tests/unit/phpDocumentor/Reflection/Php/Interface_Test.php
+++ b/tests/unit/phpDocumentor/Reflection/Php/Interface_Test.php
@@ -1,12 +1,13 @@
- * @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
*/
@@ -19,6 +20,7 @@
/**
* Tests the functionality for the Interface_ class.
+ *
* @coversDefaultClass phpDocumentor\Reflection\Php\Interface_
*/
// @codingStandardsIgnoreStart
@@ -28,27 +30,23 @@ class Interface_Test extends TestCase
/** @var Interface_ $fixture */
private $fixture;
- /**
- * @var Fqsen
- */
+ /** @var Fqsen */
private $fqsen;
- /**
- * @var DocBlock
- */
+ /** @var DocBlock */
private $docBlock;
/**
* Creates a new (empty) fixture object.
*/
- protected function setUp()
+ protected function setUp() : void
{
- $this->fqsen = new Fqsen('\MySpace\MyInterface');
+ $this->fqsen = new Fqsen('\MySpace\MyInterface');
$this->docBlock = new DocBlock('');
- $this->fixture = new Interface_($this->fqsen, [], $this->docBlock);
+ $this->fixture = new Interface_($this->fqsen, [], $this->docBlock);
}
- protected function tearDown()
+ protected function tearDown() : void
{
m::close();
}
@@ -57,7 +55,7 @@ protected function tearDown()
* @covers ::__construct
* @covers ::getFqsen
*/
- public function testGetFqsen()
+ public function testGetFqsen() : void
{
$this->assertSame($this->fqsen, $this->fixture->getFqsen());
}
@@ -66,7 +64,7 @@ public function testGetFqsen()
* @covers ::__construct
* @covers ::getDocBlock
*/
- public function testGetDocblock()
+ public function testGetDocblock() : void
{
$this->assertSame($this->docBlock, $this->fixture->getDocBlock());
}
@@ -75,7 +73,7 @@ public function testGetDocblock()
* @covers ::addConstant
* @covers ::getConstants
*/
- public function testSettingAndGettingConstants()
+ public function testSettingAndGettingConstants() : void
{
$this->assertEquals([], $this->fixture->getConstants());
@@ -90,7 +88,7 @@ public function testSettingAndGettingConstants()
* @covers ::addMethod
* @covers ::getMethods
*/
- public function testSettingAndGettingMethods()
+ public function testSettingAndGettingMethods() : void
{
$this->assertEquals([], $this->fixture->getMethods());
diff --git a/tests/unit/phpDocumentor/Reflection/Php/MethodTest.php b/tests/unit/phpDocumentor/Reflection/Php/MethodTest.php
index e1d48d04..0d8bd500 100644
--- a/tests/unit/phpDocumentor/Reflection/Php/MethodTest.php
+++ b/tests/unit/phpDocumentor/Reflection/Php/MethodTest.php
@@ -1,18 +1,19 @@
- * @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
*/
namespace phpDocumentor\Reflection\Php;
-use \Mockery as m;
+use Mockery as m;
use phpDocumentor\Reflection\DocBlock;
use phpDocumentor\Reflection\Fqsen;
use phpDocumentor\Reflection\Types\Mixed_;
@@ -21,6 +22,7 @@
/**
* Tests the functionality for the Method class.
+ *
* @coversDefaultClass phpDocumentor\Reflection\Php\Method
*/
class MethodTest extends TestCase
@@ -28,20 +30,23 @@ class MethodTest extends TestCase
/** @var Method $fixture */
protected $fixture;
+ /** @var Fqsen */
private $fqsen;
+ /** @var Visibility */
private $visibility;
+ /** @var DocBlock */
private $docblock;
- protected function setUp()
+ protected function setUp() : void
{
- $this->fqsen = new Fqsen('\My\Space::MyMethod()');
+ $this->fqsen = new Fqsen('\My\Space::MyMethod()');
$this->visibility = new Visibility('private');
- $this->docblock = new DocBlock('');
+ $this->docblock = new DocBlock('');
}
- protected function tearDown()
+ protected function tearDown() : void
{
m::close();
}
@@ -51,7 +56,7 @@ protected function tearDown()
* @covers ::getName
* @covers ::__construct
*/
- public function testGetFqsenAndGetName()
+ public function testGetFqsenAndGetName() : void
{
$method = new Method($this->fqsen);
@@ -63,7 +68,7 @@ public function testGetFqsenAndGetName()
* @covers ::getDocblock
* @covers ::__construct
*/
- public function testGetDocBlock()
+ public function testGetDocBlock() : void
{
$method = new Method($this->fqsen, $this->visibility, $this->docblock);
@@ -74,7 +79,7 @@ public function testGetDocBlock()
* @covers ::getArguments
* @covers ::addArgument
*/
- public function testAddingAndGettingArguments()
+ public function testAddingAndGettingArguments() : void
{
$method = new Method($this->fqsen);
$this->assertEquals([], $method->getArguments());
@@ -89,7 +94,7 @@ public function testAddingAndGettingArguments()
* @covers ::isAbstract
* @covers ::__construct
*/
- public function testGettingWhetherMethodIsAbstract()
+ public function testGettingWhetherMethodIsAbstract() : void
{
$method = new Method($this->fqsen, $this->visibility, $this->docblock, false);
$this->assertFalse($method->isAbstract());
@@ -102,7 +107,7 @@ public function testGettingWhetherMethodIsAbstract()
* @covers ::isFinal
* @covers ::__construct
*/
- public function testGettingWhetherMethodIsFinal()
+ public function testGettingWhetherMethodIsFinal() : void
{
$method = new Method($this->fqsen, $this->visibility, $this->docblock, false, false, false);
$this->assertFalse($method->isFinal());
@@ -115,7 +120,7 @@ public function testGettingWhetherMethodIsFinal()
* @covers ::isStatic
* @covers ::__construct
*/
- public function testGettingWhetherMethodIsStatic()
+ public function testGettingWhetherMethodIsStatic() : void
{
$method = new Method($this->fqsen, $this->visibility, $this->docblock, false, false, false);
$this->assertFalse($method->isStatic());
@@ -128,7 +133,7 @@ public function testGettingWhetherMethodIsStatic()
* @covers ::getVisibility
* @covers ::__construct
*/
- public function testGettingVisibility()
+ public function testGettingVisibility() : void
{
$method = new Method($this->fqsen, $this->visibility, $this->docblock, false, false, false);
$this->assertSame($this->visibility, $method->getVisibility());
@@ -138,7 +143,7 @@ public function testGettingVisibility()
* @covers ::getVisibility
* @covers ::__construct
*/
- public function testGetDefaultVisibility()
+ public function testGetDefaultVisibility() : void
{
$method = new Method($this->fqsen);
$this->assertEquals(new Visibility('public'), $method->getVisibility());
@@ -148,7 +153,7 @@ public function testGetDefaultVisibility()
* @covers ::getReturnType
* @covers ::__construct
*/
- public function testGetDefaultReturnType()
+ public function testGetDefaultReturnType() : void
{
$method = new Method($this->fqsen);
$this->assertEquals(new Mixed_(), $method->getReturnType());
@@ -158,10 +163,10 @@ public function testGetDefaultReturnType()
* @covers ::getReturnType
* @covers ::__construct
*/
- public function testGetReturnTypeFromConstructor()
+ public function testGetReturnTypeFromConstructor() : void
{
$returnType = new String_();
- $method = new Method(
+ $method = new Method(
$this->fqsen,
new Visibility('public'),
null,
diff --git a/tests/unit/phpDocumentor/Reflection/Php/Namespace_Test.php b/tests/unit/phpDocumentor/Reflection/Php/Namespace_Test.php
index 7d39b21e..a945cb9a 100644
--- a/tests/unit/phpDocumentor/Reflection/Php/Namespace_Test.php
+++ b/tests/unit/phpDocumentor/Reflection/Php/Namespace_Test.php
@@ -1,12 +1,13 @@
- * @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
*/
@@ -28,22 +29,18 @@ class Namespace_Test extends TestCase
/** @var Namespace_ $fixture */
protected $fixture;
- /**
- * @var Fqsen
- */
+ /** @var Fqsen */
private $fqsen;
- /**
- * @var DocBlock
- */
+ /** @var DocBlock */
private $docBlock;
/**
* Creates a new (emoty) fixture object.
*/
- protected function setUp()
+ protected function setUp() : void
{
- $this->fqsen = new Fqsen('\MySpace');
+ $this->fqsen = new Fqsen('\MySpace');
$this->docBlock = new DocBlock('');
$this->fixture = new Namespace_($this->fqsen, $this->docBlock);
@@ -54,7 +51,7 @@ protected function setUp()
* @covers ::getClasses
* @covers ::AddClass
*/
- public function testAddAndGetClasses()
+ public function testAddAndGetClasses() : void
{
$this->assertEmpty($this->fixture->getClasses());
@@ -69,7 +66,7 @@ public function testAddAndGetClasses()
* @covers ::getConstants
* @covers ::addConstant
*/
- public function testAddAndGetConstants()
+ public function testAddAndGetConstants() : void
{
$this->assertEmpty($this->fixture->getConstants());
@@ -84,7 +81,7 @@ public function testAddAndGetConstants()
* @covers ::getFunctions
* @covers ::addFunction
*/
- public function testAddAndGetFunctions()
+ public function testAddAndGetFunctions() : void
{
$this->assertEmpty($this->fixture->getFunctions());
@@ -99,7 +96,7 @@ public function testAddAndGetFunctions()
* @covers ::getInterfaces
* @covers ::addInterface
*/
- public function testAddAndGetInterfaces()
+ public function testAddAndGetInterfaces() : void
{
$this->assertEmpty($this->fixture->getInterfaces());
@@ -114,7 +111,7 @@ public function testAddAndGetInterfaces()
* @covers ::getTraits
* @covers ::addTrait
*/
- public function testAddAndGetTraits()
+ public function testAddAndGetTraits() : void
{
$this->assertEmpty($this->fixture->getTraits());
@@ -129,7 +126,7 @@ public function testAddAndGetTraits()
* @covers ::getFqsen
* @covers ::getName
*/
- public function testGetFqsen()
+ public function testGetFqsen() : void
{
$this->assertSame($this->fqsen, $this->fixture->getFqsen());
$this->assertEquals($this->fqsen->getName(), $this->fixture->getName());
diff --git a/tests/unit/phpDocumentor/Reflection/Php/ProjectFactoryStrategiesTest.php b/tests/unit/phpDocumentor/Reflection/Php/ProjectFactoryStrategiesTest.php
index 5082e95a..a59e6891 100644
--- a/tests/unit/phpDocumentor/Reflection/Php/ProjectFactoryStrategiesTest.php
+++ b/tests/unit/phpDocumentor/Reflection/Php/ProjectFactoryStrategiesTest.php
@@ -1,12 +1,13 @@
- * @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
*/
@@ -26,7 +27,7 @@ class ProjectFactoryStrategiesTest extends TestCase
* @covers ::__construct
* @covers ::addStrategy
*/
- public function testStrategiesAreChecked()
+ public function testStrategiesAreChecked() : void
{
new ProjectFactoryStrategies([new DummyFactoryStrategy()]);
$this->assertTrue(true);
@@ -36,11 +37,11 @@ public function testStrategiesAreChecked()
* @covers ::findMatching
* @covers ::
*/
- public function testFindMatching()
+ public function testFindMatching() : void
{
- $strategy = new DummyFactoryStrategy();
+ $strategy = new DummyFactoryStrategy();
$container = new ProjectFactoryStrategies([$strategy]);
- $actual = $container->findMatching(['aa']);
+ $actual = $container->findMatching(['aa']);
$this->assertSame($strategy, $actual);
}
@@ -48,11 +49,10 @@ public function testFindMatching()
/**
* @covers ::findMatching
* @covers ::
- *
- * @expectedException \OutOfBoundsException
*/
- public function testCreateThrowsExceptionWhenStrategyNotFound()
+ public function testCreateThrowsExceptionWhenStrategyNotFound() : void
{
+ $this->expectException('OutOfBoundsException');
$container = new ProjectFactoryStrategies([]);
$container->findMatching(['aa']);
}
diff --git a/tests/unit/phpDocumentor/Reflection/Php/ProjectFactoryTest.php b/tests/unit/phpDocumentor/Reflection/Php/ProjectFactoryTest.php
index 026f5f84..e75aa625 100644
--- a/tests/unit/phpDocumentor/Reflection/Php/ProjectFactoryTest.php
+++ b/tests/unit/phpDocumentor/Reflection/Php/ProjectFactoryTest.php
@@ -1,32 +1,39 @@
- * @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
*/
namespace phpDocumentor\Reflection\Php;
use Mockery as m;
+use phpDocumentor\Reflection\Exception;
use phpDocumentor\Reflection\Fqsen;
use phpDocumentor\Reflection\Php\Factory\DummyFactoryStrategy;
use PHPUnit\Framework\TestCase;
+use function array_keys;
+use function count;
+use function current;
+use function key;
+use function md5;
/**
* Test case for ProjectFactory
*
- * @coversDefaultClass phpDocumentor\Reflection\Php\ProjectFactory
+ * @coversDefaultClass \phpDocumentor\Reflection\Php\ProjectFactory
* @covers ::create
* @covers ::
*/
class ProjectFactoryTest extends TestCase
{
- protected function tearDown()
+ protected function tearDown() : void
{
m::close();
}
@@ -34,13 +41,13 @@ protected function tearDown()
/**
* @covers ::__construct
*/
- public function testStrategiesAreChecked()
+ public function testStrategiesAreChecked() : void
{
new ProjectFactory([new DummyFactoryStrategy()]);
$this->assertTrue(true);
}
- public function testCreate()
+ public function testCreate() : void
{
$someOtherStrategy = m::mock(ProjectFactoryStrategy::class);
$someOtherStrategy->shouldReceive('matches')->twice()->andReturn(false);
@@ -59,7 +66,7 @@ public function testCreate()
$projectFactory = new ProjectFactory([$someOtherStrategy, $fileStrategyMock]);
- $files = ['some/file.php', 'some/other.php'];
+ $files = ['some/file.php', 'some/other.php'];
$project = $projectFactory->create('MyProject', $files);
$this->assertInstanceOf(Project::class, $project);
@@ -68,16 +75,14 @@ public function testCreate()
$this->assertEquals($files, $projectFilePaths);
}
- /**
- * @expectedException \OutOfBoundsException
- */
- public function testCreateThrowsExceptionWhenStrategyNotFound()
+ public function testCreateThrowsExceptionWhenStrategyNotFound() : void
{
+ $this->expectException('OutOfBoundsException');
$projectFactory = new ProjectFactory([]);
$projectFactory->create('MyProject', ['aa']);
}
- public function testCreateProjectFromFileWithNamespacedClass()
+ public function testCreateProjectFromFileWithNamespacedClass() : void
{
$file = new File(md5('some/file.php'), 'some/file.php');
$file->addNamespace(new Fqsen('\mySpace'));
@@ -94,7 +99,7 @@ public function testCreateProjectFromFileWithNamespacedClass()
$this->assertEquals('\mySpace\MyClass', key($mySpace->getClasses()));
}
- public function testWithNamespacedInterface()
+ public function testWithNamespacedInterface() : void
{
$file = new File(md5('some/file.php'), 'some/file.php');
$file->addNamespace(new Fqsen('\mySpace'));
@@ -109,7 +114,7 @@ public function testWithNamespacedInterface()
$this->assertEquals('\mySpace\MyInterface', key($mySpace->getInterfaces()));
}
- public function testWithNamespacedFunction()
+ public function testWithNamespacedFunction() : void
{
$file = new File(md5('some/file.php'), 'some/file.php');
$file->addNamespace(new Fqsen('\mySpace'));
@@ -124,7 +129,7 @@ public function testWithNamespacedFunction()
$this->assertEquals('\mySpace\function()', key($mySpace->getFunctions()));
}
- public function testWithNamespacedConstant()
+ public function testWithNamespacedConstant() : void
{
$file = new File(md5('some/file.php'), 'some/file.php');
$file->addNamespace(new Fqsen('\mySpace'));
@@ -139,7 +144,7 @@ public function testWithNamespacedConstant()
$this->assertEquals('\mySpace::MY_CONST', key($mySpace->getConstants()));
}
- public function testWithNamespacedTrait()
+ public function testWithNamespacedTrait() : void
{
$file = new File(md5('some/file.php'), 'some/file.php');
$file->addNamespace(new Fqsen('\mySpace'));
@@ -154,7 +159,7 @@ public function testWithNamespacedTrait()
$this->assertEquals('\mySpace\MyTrait', key($mySpace->getTraits()));
}
- public function testNamespaceSpreadOverMultipleFiles()
+ public function testNamespaceSpreadOverMultipleFiles() : void
{
$someFile = new File(md5('some/file.php'), 'some/file.php');
$someFile->addNamespace(new Fqsen('\mySpace'));
@@ -170,7 +175,7 @@ public function testNamespaceSpreadOverMultipleFiles()
$this->assertCount(2, current($namespaces)->getClasses());
}
- public function testSingleFileMultipleNamespaces()
+ public function testSingleFileMultipleNamespaces() : void
{
$someFile = new File(md5('some/file.php'), 'some/file.php');
$someFile->addNamespace(new Fqsen('\mySpace'));
@@ -187,7 +192,7 @@ public function testSingleFileMultipleNamespaces()
$this->assertCount(1, $namespaces['\mySpace']->getClasses());
}
- public function testErrorScenarioWhenFileStrategyReturnsNull()
+ public function testErrorScenarioWhenFileStrategyReturnsNull() : void
{
$fileStrategyMock = m::mock(ProjectFactoryStrategy::class);
$fileStrategyMock->shouldReceive('matches')->twice()->andReturn(true);
@@ -202,7 +207,7 @@ public function testErrorScenarioWhenFileStrategyReturnsNull()
$projectFactory = new ProjectFactory([$fileStrategyMock]);
- $files = ['some/file.php', 'some/other.php'];
+ $files = ['some/file.php', 'some/other.php'];
$project = $projectFactory->create('MyProject', $files);
$this->assertInstanceOf(Project::class, $project);
@@ -215,8 +220,10 @@ public function testErrorScenarioWhenFileStrategyReturnsNull()
* Uses the ProjectFactory to create a Project and returns the namespaces created by the factory.
*
* @return Namespace_[] Namespaces of the project
+ *
+ * @throws Exception
*/
- private function fetchNamespacesFromSingleFile(File $file)
+ private function fetchNamespacesFromSingleFile(File $file) : array
{
return $this->fetchNamespacesFromMultipleFiles([$file]);
}
@@ -225,9 +232,12 @@ private function fetchNamespacesFromSingleFile(File $file)
* Uses the ProjectFactory to create a Project and returns the namespaces created by the factory.
*
* @param File[] $files
+ *
* @return Namespace_[] Namespaces of the project
+ *
+ * @throws Exception
*/
- private function fetchNamespacesFromMultipleFiles($files)
+ private function fetchNamespacesFromMultipleFiles(array $files) : array
{
$fileStrategyMock = m::mock(ProjectFactoryStrategy::class);
$fileStrategyMock->shouldReceive('matches')->times(count($files))->andReturn(true);
@@ -238,7 +248,7 @@ private function fetchNamespacesFromMultipleFiles($files)
);
$projectFactory = new ProjectFactory([$fileStrategyMock]);
- $project = $projectFactory->create('My Project', $files);
+ $project = $projectFactory->create('My Project', $files);
return $project->getNamespaces();
}
diff --git a/tests/unit/phpDocumentor/Reflection/Php/ProjectTest.php b/tests/unit/phpDocumentor/Reflection/Php/ProjectTest.php
index da0c8459..e67a77b6 100644
--- a/tests/unit/phpDocumentor/Reflection/Php/ProjectTest.php
+++ b/tests/unit/phpDocumentor/Reflection/Php/ProjectTest.php
@@ -1,12 +1,13 @@
- * @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
*/
@@ -22,7 +23,7 @@
*/
class ProjectTest extends TestCase
{
- const EXAMPLE_NAME = 'Initial name';
+ public const EXAMPLE_NAME = 'Initial name';
/** @var Project */
private $fixture;
@@ -30,7 +31,7 @@ class ProjectTest extends TestCase
/**
* Initializes the fixture object.
*/
- protected function setUp()
+ protected function setUp() : void
{
$this->fixture = new Project(self::EXAMPLE_NAME);
}
@@ -39,7 +40,7 @@ protected function setUp()
* @covers ::__construct
* @covers ::getName
*/
- public function testGetSetName()
+ public function testGetSetName() : void
{
$this->assertEquals(self::EXAMPLE_NAME, $this->fixture->getName());
}
@@ -48,7 +49,7 @@ public function testGetSetName()
* @covers ::getFiles
* @covers ::addFile
*/
- public function testGetAddFiles()
+ public function testGetAddFiles() : void
{
$this->assertEmpty($this->fixture->getFiles());
@@ -62,12 +63,12 @@ public function testGetAddFiles()
* @covers ::__construct
* @covers ::getRootNamespace
*/
- public function testGetRootNamespace()
+ public function testGetRootNamespace() : void
{
$this->assertInstanceOf(Namespace_::class, $this->fixture->getRootNamespace());
$namespaceDescriptor = new Namespace_(new Fqsen('\MySpace'));
- $project = new Project(self::EXAMPLE_NAME, $namespaceDescriptor);
+ $project = new Project(self::EXAMPLE_NAME, $namespaceDescriptor);
$this->assertSame($namespaceDescriptor, $project->getRootNamespace());
}
@@ -76,7 +77,7 @@ public function testGetRootNamespace()
* @covers ::getNamespaces
* @covers ::addNamespace
*/
- public function testGetAddNamespace()
+ public function testGetAddNamespace() : void
{
$this->assertEmpty($this->fixture->getNamespaces());
diff --git a/tests/unit/phpDocumentor/Reflection/Php/PropertyTest.php b/tests/unit/phpDocumentor/Reflection/Php/PropertyTest.php
index d31ffba1..8c94248a 100644
--- a/tests/unit/phpDocumentor/Reflection/Php/PropertyTest.php
+++ b/tests/unit/phpDocumentor/Reflection/Php/PropertyTest.php
@@ -1,18 +1,19 @@
- * @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
*/
namespace phpDocumentor\Reflection\Php;
-use \Mockery as m;
+use Mockery as m;
use phpDocumentor\Reflection\DocBlock;
use phpDocumentor\Reflection\Fqsen;
use PHPUnit\Framework\TestCase;
@@ -24,29 +25,23 @@
*/
class PropertyTest extends TestCase
{
- /**
- * @var Fqsen
- */
+ /** @var Fqsen */
private $fqsen;
- /**
- * @var Visibility
- */
+ /** @var Visibility */
private $visibility;
- /**
- * @var DocBlock
- */
+ /** @var DocBlock */
private $docBlock;
- protected function setUp()
+ protected function setUp() : void
{
- $this->fqsen = new Fqsen('\My\Class::$property');
+ $this->fqsen = new Fqsen('\My\Class::$property');
$this->visibility = new Visibility('private');
- $this->docBlock = new DocBlock('');
+ $this->docBlock = new DocBlock('');
}
- protected function tearDown()
+ protected function tearDown() : void
{
m::close();
}
@@ -56,7 +51,7 @@ protected function tearDown()
* @covers ::getName
* @covers ::__construct
*/
- public function testGetFqsenAndGetName()
+ public function testGetFqsenAndGetName() : void
{
$property = new Property($this->fqsen);
@@ -68,7 +63,7 @@ public function testGetFqsenAndGetName()
* @covers ::isStatic
* @covers ::__construct
*/
- public function testGettingWhetherPropertyIsStatic()
+ public function testGettingWhetherPropertyIsStatic() : void
{
$property = new Property($this->fqsen, $this->visibility, $this->docBlock, null, false);
$this->assertFalse($property->isStatic());
@@ -81,7 +76,7 @@ public function testGettingWhetherPropertyIsStatic()
* @covers ::getVisibility
* @covers ::__construct
*/
- public function testGettingVisibility()
+ public function testGettingVisibility() : void
{
$property = new Property($this->fqsen, $this->visibility, $this->docBlock, null, true);
@@ -92,7 +87,7 @@ public function testGettingVisibility()
* @covers ::getTypes
* @covers ::addType
*/
- public function testSetAndGetTypes()
+ public function testSetAndGetTypes() : void
{
$property = new Property($this->fqsen, $this->visibility, $this->docBlock, null, true);
$this->assertEquals([], $property->getTypes());
@@ -105,7 +100,7 @@ public function testSetAndGetTypes()
* @covers ::getDefault
* @covers ::__construct
*/
- public function testGetDefault()
+ public function testGetDefault() : void
{
$property = new Property($this->fqsen, $this->visibility, $this->docBlock, null, false);
$this->assertNull($property->getDefault());
@@ -118,7 +113,7 @@ public function testGetDefault()
* @covers ::getDocBlock
* @covers ::__construct
*/
- public function testGetDocBlock()
+ public function testGetDocBlock() : void
{
$property = new Property($this->fqsen, $this->visibility, $this->docBlock, null, false);
$this->assertSame($this->docBlock, $property->getDocBlock());
diff --git a/tests/unit/phpDocumentor/Reflection/Php/Trait_Test.php b/tests/unit/phpDocumentor/Reflection/Php/Trait_Test.php
index cdb69de1..3e189e49 100644
--- a/tests/unit/phpDocumentor/Reflection/Php/Trait_Test.php
+++ b/tests/unit/phpDocumentor/Reflection/Php/Trait_Test.php
@@ -1,24 +1,26 @@
- * @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
*/
namespace phpDocumentor\Reflection\Php;
-use \Mockery as m;
+use Mockery as m;
use phpDocumentor\Reflection\DocBlock;
use phpDocumentor\Reflection\Fqsen;
use PHPUnit\Framework\TestCase;
/**
* Tests the functionality for the Trait_ class.
+ *
* @coversDefaultClass phpDocumentor\Reflection\Php\Trait_
*/
// @codingStandardsIgnoreStart
@@ -28,27 +30,23 @@ class Trait_Test extends TestCase
/** @var Trait_ $fixture */
protected $fixture;
- /**
- * @var Fqsen
- */
+ /** @var Fqsen */
private $fqsen;
- /**
- * @var DocBlock
- */
+ /** @var DocBlock */
private $docBlock;
/**
* Creates a new (empty) fixture object.
*/
- protected function setUp()
+ protected function setUp() : void
{
- $this->fqsen = new Fqsen('\MyTrait');
+ $this->fqsen = new Fqsen('\MyTrait');
$this->docBlock = new DocBlock('');
- $this->fixture = new Trait_($this->fqsen, $this->docBlock);
+ $this->fixture = new Trait_($this->fqsen, $this->docBlock);
}
- protected function tearDown()
+ protected function tearDown() : void
{
m::close();
}
@@ -58,7 +56,7 @@ protected function tearDown()
* @covers ::getName
* @covers ::__construct
*/
- public function testGetFqsenAndGetName()
+ public function testGetFqsenAndGetName() : void
{
$this->assertSame($this->fqsen, $this->fixture->getFqsen());
$this->assertEquals($this->fqsen->getName(), $this->fixture->getName());
@@ -68,7 +66,7 @@ public function testGetFqsenAndGetName()
* @covers ::addProperty
* @covers ::getProperties
*/
- public function testAddAndGettingProperties()
+ public function testAddAndGettingProperties() : void
{
$this->assertEquals([], $this->fixture->getProperties());
@@ -83,7 +81,7 @@ public function testAddAndGettingProperties()
* @covers ::addMethod
* @covers ::getMethods
*/
- public function testAddAndGettingMethods()
+ public function testAddAndGettingMethods() : void
{
$this->assertEquals([], $this->fixture->getMethods());
@@ -98,7 +96,7 @@ public function testAddAndGettingMethods()
* @covers ::getUsedTraits
* @covers ::AddUsedTrait
*/
- public function testAddAndGettingUsedTrait()
+ public function testAddAndGettingUsedTrait() : void
{
$this->assertEmpty($this->fixture->getUsedTraits());
@@ -113,7 +111,7 @@ public function testAddAndGettingUsedTrait()
* @covers ::__construct
* @covers ::getDocBlock
*/
- public function testGetDocblock()
+ public function testGetDocblock() : void
{
$this->assertSame($this->docBlock, $this->fixture->getDocBlock());
}
diff --git a/tests/unit/phpDocumentor/Reflection/Php/VisibilityTest.php b/tests/unit/phpDocumentor/Reflection/Php/VisibilityTest.php
index a121484b..ee68f74c 100644
--- a/tests/unit/phpDocumentor/Reflection/Php/VisibilityTest.php
+++ b/tests/unit/phpDocumentor/Reflection/Php/VisibilityTest.php
@@ -1,12 +1,13 @@
- * @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
*/
@@ -16,7 +17,8 @@
/**
* Test case for Visibility
- * @coversDefaultClass phpDocumentor\Reflection\Php\Visibility
+ *
+ * @coversDefaultClass \phpDocumentor\Reflection\Php\Visibility
*/
class VisibilityTest extends TestCase
{
@@ -25,14 +27,14 @@ class VisibilityTest extends TestCase
* @covers ::__construct
* @covers ::__toString
*/
- public function testVisibility($input, $expected)
+ public function testVisibility($input, $expected) : void
{
$visibility = new Visibility($input);
$this->assertEquals($expected, (string) $visibility);
}
- public function visibilityProvider()
+ public function visibilityProvider() : array
{
return [
['public', 'public'],
@@ -43,11 +45,11 @@ public function visibilityProvider()
}
/**
- * @expectedException \InvalidArgumentException
* @covers ::__construct
*/
- public function testVisibilityChecksInput()
+ public function testVisibilityChecksInput() : void
{
+ $this->expectException('InvalidArgumentException');
new Visibility('fooBar');
}
}
diff --git a/tests/unit/phpDocumentor/Reflection/PrettyPrinterTest.php b/tests/unit/phpDocumentor/Reflection/PrettyPrinterTest.php
index 60236b39..05df85d9 100644
--- a/tests/unit/phpDocumentor/Reflection/PrettyPrinterTest.php
+++ b/tests/unit/phpDocumentor/Reflection/PrettyPrinterTest.php
@@ -1,12 +1,13 @@
- * @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
*/
@@ -18,9 +19,6 @@
/**
* Class for testing the PrettyPrinter.
*
- * @author Vasil Rangelov
- * @copyright 2010-2018 Mike van Riel / Naenius (http://www.naenius.com)
- * @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
*/
class PrettyPrinterTest extends TestCase
@@ -28,7 +26,7 @@ class PrettyPrinterTest extends TestCase
/**
* @covers \phpDocumentor\Reflection\PrettyPrinter::pScalar_String
*/
- public function testScalarStringPrinting()
+ public function testScalarStringPrinting() : void
{
$object = new PrettyPrinter();
$this->assertEquals(
diff --git a/tests/unit/phpDocumentor/Reflection/Types/NamespaceNodeToContextTest.php b/tests/unit/phpDocumentor/Reflection/Types/NamespaceNodeToContextTest.php
index f7a9146f..30f2b1fa 100644
--- a/tests/unit/phpDocumentor/Reflection/Types/NamespaceNodeToContextTest.php
+++ b/tests/unit/phpDocumentor/Reflection/Types/NamespaceNodeToContextTest.php
@@ -1,4 +1,5 @@
__invoke($namespace));
}
@@ -28,29 +29,29 @@ public function testConversion(?Namespace_ $namespace, Context $expectedContext)
public function expectedContextsProvider()
{
$namespaceWithImports = new Namespace_(
- new Name('With\\Imports'),
- [
- (new Use_('ClassName', UseStatement::TYPE_NORMAL))->getNode(),
- (new Use_('ConstantName', UseStatement::TYPE_CONSTANT))->getNode(),
- (new Use_('FunctionName', UseStatement::TYPE_FUNCTION))->getNode(),
- (new Use_('UnknownName', UseStatement::TYPE_UNKNOWN))->getNode(),
- (new Use_('AAA\\BBB', UseStatement::TYPE_NORMAL))->getNode(),
- (new Use_('BBB\\CCC\\DDD', UseStatement::TYPE_NORMAL))->getNode(),
- (new Use_('Foo\\EEE\\FFF', UseStatement::TYPE_NORMAL))->getNode(),
- (new Use_('Foo', UseStatement::TYPE_NORMAL))->getNode(),
- (new Use_('GGG', UseStatement::TYPE_NORMAL))->as('HHH')->getNode(),
- (new Use_('III', UseStatement::TYPE_NORMAL))->as('JJJ')->getNode(),
- new GroupUse(
- new Name('LLL'),
- [
- new UseUse(new Name('MMM')),
- new UseUse(new Name('NNN'), 'OOO'),
- ]
- ),
- (new Use_('\\PPP', UseStatement::TYPE_NORMAL))->getNode(),
- new Class_('ClassNode'), // class node, should be ignored
- ]
- );
+ new Name('With\\Imports'),
+ [
+ (new Use_('ClassName', UseStatement::TYPE_NORMAL))->getNode(),
+ (new Use_('ConstantName', UseStatement::TYPE_CONSTANT))->getNode(),
+ (new Use_('FunctionName', UseStatement::TYPE_FUNCTION))->getNode(),
+ (new Use_('UnknownName', UseStatement::TYPE_UNKNOWN))->getNode(),
+ (new Use_('AAA\\BBB', UseStatement::TYPE_NORMAL))->getNode(),
+ (new Use_('BBB\\CCC\\DDD', UseStatement::TYPE_NORMAL))->getNode(),
+ (new Use_('Foo\\EEE\\FFF', UseStatement::TYPE_NORMAL))->getNode(),
+ (new Use_('Foo', UseStatement::TYPE_NORMAL))->getNode(),
+ (new Use_('GGG', UseStatement::TYPE_NORMAL))->as('HHH')->getNode(),
+ (new Use_('III', UseStatement::TYPE_NORMAL))->as('JJJ')->getNode(),
+ new GroupUse(
+ new Name('LLL'),
+ [
+ new UseUse(new Name('MMM')),
+ new UseUse(new Name('NNN'), 'OOO'),
+ ]
+ ),
+ (new Use_('\\PPP', UseStatement::TYPE_NORMAL))->getNode(),
+ new Class_('ClassNode'), // class node, should be ignored
+ ]
+ );
return [
'No namespace' => [