diff --git a/.github/workflows/integrate.yaml b/.github/workflows/integrate.yaml
index f7795d24..e92557d6 100644
--- a/.github/workflows/integrate.yaml
+++ b/.github/workflows/integrate.yaml
@@ -5,7 +5,7 @@ name: "Integrate"
on: # yamllint disable-line rule:truthy
push:
branches:
- - "5.x"
+ - "6.x"
pull_request: null
# Allow manually triggering the workflow.
workflow_dispatch: null
@@ -13,35 +13,59 @@ on: # yamllint disable-line rule:truthy
jobs:
code-coverage:
name: "Code Coverage"
- uses: "phpDocumentor/.github/.github/workflows/code-coverage.yml@v0.4.0"
+ uses: "phpDocumentor/.github/.github/workflows/code-coverage.yml@v0.5.0"
+ with:
+ php-version: "8.2"
coding-standards:
name: "Coding Standards"
- uses: "phpDocumentor/.github/.github/workflows/coding-standards.yml@v0.4.0"
+ runs-on: "ubuntu-22.04"
+ steps:
+ - name: "Checkout"
+ uses: "actions/checkout@v4"
+
+ - name: "Install PHP"
+ uses: "shivammathur/setup-php@v2"
+ with:
+ coverage: "none"
+ php-version: "8.2"
+ tools: "cs2pr"
+
+ - name: "Install dependencies with Composer"
+ uses: "ramsey/composer-install@v2"
+ with:
+ dependency-versions: "locked"
+
+ - name: "Run PHP_CodeSniffer"
+ run: "vendor/bin/phpcs -q --no-colors --report=checkstyle | cs2pr"
dependency-analysis:
name: "Dependency analysis"
- uses: "phpDocumentor/.github/.github/workflows/dependency-analysis.yml@v0.4.0"
+ uses: "phpDocumentor/.github/.github/workflows/dependency-analysis.yml@v0.5.0"
+ with:
+ php-version: "8.2"
lint-root:
name: "Lint root"
- uses: "phpDocumentor/.github/.github/workflows/lint.yml@v0.4.0"
+ uses: "phpDocumentor/.github/.github/workflows/lint.yml@v0.5.0"
with:
+ php-version: "8.2"
composer-options: "--no-check-publish --ansi"
static-analysis:
name: "Static analysis"
- uses: "phpDocumentor/.github/.github/workflows/static-analysis.yml@v0.4.0"
+ uses: "phpDocumentor/.github/.github/workflows/static-analysis.yml@v0.5.0"
with:
+ php-version: "8.2"
php-extensions: "none, ctype, dom, json, mbstring, phar, simplexml, tokenizer, xml, xmlwriter, fileinfo, pcntl, posix"
unit-tests:
name: "Unit test"
- uses: "phpDocumentor/.github/.github/workflows/continuous-integration.yml@v0.4.0"
+ uses: "phpDocumentor/.github/.github/workflows/continuous-integration.yml@v0.5.0"
integration-tests:
name: "Integration test"
- uses: "phpDocumentor/.github/.github/workflows/continuous-integration.yml@v0.4.0"
+ uses: "phpDocumentor/.github/.github/workflows/continuous-integration.yml@v0.5.0"
needs: "unit-tests"
with:
test-suite: "integration"
diff --git a/Makefile b/Makefile
index 1aab96f2..31d69963 100644
--- a/Makefile
+++ b/Makefile
@@ -4,32 +4,32 @@ help: ## Displays this list of targets with descriptions
.PHONY: code-style
code-style:
- docker run -it --rm -v${PWD}:/opt/project -w /opt/project phpdoc/phpcs-ga:latest -d memory_limit=1024M -s
+ docker run -it --rm -v${PWD}:/opt/project -w /opt/project php:8.1-cli vendor/bin/phpcs
.PHONY: fix-code-style
fix-code-style:
- docker run -it --rm -v${PWD}:/opt/project -w /opt/project phpdoc/phpcs-ga:latest phpcbf
+ docker run -it --rm -v${PWD}:/opt/project -w /opt/project php:8.1-cli vendor/bin/phpcbf
.PHONY: static-code-analysis
static-code-analysis: vendor ## Runs a static code analysis with phpstan/phpstan and vimeo/psalm
- docker run -it --rm -v${PWD}:/opt/project -w /opt/project php:7.4 vendor/bin/phpstan --configuration=phpstan.neon
- docker run -it --rm -v${PWD}:/opt/project -w /opt/project php:7.4 vendor/bin/psalm
+ docker run -it --rm -v${PWD}:/opt/project -w /opt/project php:8.1-cli vendor/bin/phpstan --configuration=phpstan.neon
+ docker run -it --rm -v${PWD}:/opt/project -w /opt/project php:8.1-cli vendor/bin/psalm
.PHONY: test
test: test-unit test-functional ## Runs all test suites with phpunit/phpunit
- docker run -it --rm -v${PWD}:/opt/project -w /opt/project php:7.4 vendor/bin/phpunit
+ docker run -it --rm -v${PWD}:/opt/project -w /opt/project php:8.1-cli vendor/bin/phpunit
.PHONY: test-unit
test-unit: ## Runs unit tests with phpunit/phpunit
- docker run -it --rm -v${PWD}:/opt/project -w /opt/project php:7.4 vendor/bin/phpunit --testsuite=unit
+ docker run -it --rm -v${PWD}:/opt/project -w /opt/project php:8.1-cli vendor/bin/phpunit --testsuite=unit
.PHONY: test-functional
test-functional: ## Runs unit tests with phpunit/phpunit
- docker run -it --rm -v${PWD}:/opt/project -w /opt/project php:7.4 vendor/bin/phpunit --testsuite=functional
+ docker run -it --rm -v${PWD}:/opt/project -w /opt/project php:8.1-cli vendor/bin/phpunit --testsuite=functional
.PHONY: dependency-analysis
dependency-analysis: vendor ## Runs a dependency analysis with maglnet/composer-require-checker
- docker run -it --rm -v${PWD}:/opt/project -w /opt/project php:7.4 .phive/composer-require-checker check --config-file=/opt/project/composer-require-checker.json
+ docker run -it --rm -v${PWD}:/opt/project -w /opt/project php:8.1-cli .phive/composer-require-checker check --config-file=/opt/project/composer-require-checker.json
vendor: composer.json composer.lock
composer validate --no-check-publish
@@ -37,11 +37,11 @@ vendor: composer.json composer.lock
.PHONY: benchmark
benchmark:
- docker run -it --rm -v${CURDIR}:/opt/project -w /opt/project php:7.4-cli tools/phpbench run
+ docker run -it --rm -v${CURDIR}:/opt/project -w /opt/project php:8.1-cli tools/phpbench run
.PHONY: rector
rector: ## Refactor code using rector
- docker run -it --rm -v${PWD}:/opt/project -w /opt/project php:7.4 vendor/bin/rector process
+ docker run -it --rm -v${PWD}:/opt/project -w /opt/project php:8.1-cli vendor/bin/rector process
.PHONY: pre-commit-test
pre-commit-test: fix-code-style test code-style static-code-analysis
diff --git a/composer.json b/composer.json
index 95cfe38c..5c526d6b 100644
--- a/composer.json
+++ b/composer.json
@@ -19,7 +19,7 @@
}
},
"require": {
- "php": "^7.4|8.0.*|8.1.*|8.2.*|8.3.*",
+ "php": "8.1.*|8.2.*|8.3.*",
"nikic/php-parser": "~4.14",
"phpdocumentor/reflection-common": "^2.1",
"phpdocumentor/reflection-docblock": "^5",
@@ -28,6 +28,8 @@
"webmozart/assert": "^1.7"
},
"require-dev": {
+ "dealerdirect/phpcodesniffer-composer-installer": "^1.0",
+ "doctrine/coding-standard": "^12.0",
"mikey179/vfsstream": "~1.2",
"mockery/mockery": "~1.6.0",
"phpspec/prophecy-phpunit": "^2.0",
@@ -37,6 +39,7 @@
"phpstan/phpstan-webmozart-assert": "^1.2",
"phpunit/phpunit": "^9.5",
"rector/rector": "^0.18.0",
+ "squizlabs/php_codesniffer": "^3.8",
"vimeo/psalm": "^5.0"
},
"config": {
@@ -45,15 +48,17 @@
},
"sort-packages": true,
"platform": {
- "php": "7.4.0"
+ "php": "8.1.0"
},
"allow-plugins": {
- "phpstan/extension-installer": true
+ "phpstan/extension-installer": true,
+ "dealerdirect/phpcodesniffer-composer-installer": true
}
},
"extra": {
"branch-alias": {
- "dev-5.x": "5.3.x-dev"
+ "dev-5.x": "5.3.x-dev",
+ "dev-6.x": "6.0.x-dev"
}
}
}
diff --git a/composer.lock b/composer.lock
index 9bbfcfb5..c2707bec 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": "4adf8ccefab99393b246acaf903ad069",
+ "content-hash": "7ea9cf09961a8b3acc5887dae34ec992",
"packages": [
{
"name": "doctrine/deprecations",
@@ -851,6 +851,84 @@
],
"time": "2022-02-25T21:32:43+00:00"
},
+ {
+ "name": "dealerdirect/phpcodesniffer-composer-installer",
+ "version": "v1.0.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/PHPCSStandards/composer-installer.git",
+ "reference": "4be43904336affa5c2f70744a348312336afd0da"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/PHPCSStandards/composer-installer/zipball/4be43904336affa5c2f70744a348312336afd0da",
+ "reference": "4be43904336affa5c2f70744a348312336afd0da",
+ "shasum": ""
+ },
+ "require": {
+ "composer-plugin-api": "^1.0 || ^2.0",
+ "php": ">=5.4",
+ "squizlabs/php_codesniffer": "^2.0 || ^3.1.0 || ^4.0"
+ },
+ "require-dev": {
+ "composer/composer": "*",
+ "ext-json": "*",
+ "ext-zip": "*",
+ "php-parallel-lint/php-parallel-lint": "^1.3.1",
+ "phpcompatibility/php-compatibility": "^9.0",
+ "yoast/phpunit-polyfills": "^1.0"
+ },
+ "type": "composer-plugin",
+ "extra": {
+ "class": "PHPCSStandards\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\Plugin"
+ },
+ "autoload": {
+ "psr-4": {
+ "PHPCSStandards\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Franck Nijhof",
+ "email": "franck.nijhof@dealerdirect.com",
+ "homepage": "http://www.frenck.nl",
+ "role": "Developer / IT Manager"
+ },
+ {
+ "name": "Contributors",
+ "homepage": "https://github.com/PHPCSStandards/composer-installer/graphs/contributors"
+ }
+ ],
+ "description": "PHP_CodeSniffer Standards Composer Installer Plugin",
+ "homepage": "http://www.dealerdirect.com",
+ "keywords": [
+ "PHPCodeSniffer",
+ "PHP_CodeSniffer",
+ "code quality",
+ "codesniffer",
+ "composer",
+ "installer",
+ "phpcbf",
+ "phpcs",
+ "plugin",
+ "qa",
+ "quality",
+ "standard",
+ "standards",
+ "style guide",
+ "stylecheck",
+ "tests"
+ ],
+ "support": {
+ "issues": "https://github.com/PHPCSStandards/composer-installer/issues",
+ "source": "https://github.com/PHPCSStandards/composer-installer"
+ },
+ "time": "2023-01-05T11:28:13+00:00"
+ },
{
"name": "dnoegel/php-xdg-base-dir",
"version": "v0.1.1",
@@ -888,6 +966,62 @@
},
"time": "2019-12-04T15:06:13+00:00"
},
+ {
+ "name": "doctrine/coding-standard",
+ "version": "12.0.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/doctrine/coding-standard.git",
+ "reference": "1b2b7dc58c68833af481fb9325c25abd40681c79"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/doctrine/coding-standard/zipball/1b2b7dc58c68833af481fb9325c25abd40681c79",
+ "reference": "1b2b7dc58c68833af481fb9325c25abd40681c79",
+ "shasum": ""
+ },
+ "require": {
+ "dealerdirect/phpcodesniffer-composer-installer": "^0.6.2 || ^0.7 || ^1.0.0",
+ "php": "^7.2 || ^8.0",
+ "slevomat/coding-standard": "^8.11",
+ "squizlabs/php_codesniffer": "^3.7"
+ },
+ "type": "phpcodesniffer-standard",
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Benjamin Eberlei",
+ "email": "kontakt@beberlei.de"
+ },
+ {
+ "name": "Steve Müller",
+ "email": "st.mueller@dzh-online.de"
+ }
+ ],
+ "description": "The Doctrine Coding Standard is a set of PHPCS rules applied to all Doctrine projects.",
+ "homepage": "https://www.doctrine-project.org/projects/coding-standard.html",
+ "keywords": [
+ "checks",
+ "code",
+ "coding",
+ "cs",
+ "dev",
+ "doctrine",
+ "rules",
+ "sniffer",
+ "sniffs",
+ "standard",
+ "style"
+ ],
+ "support": {
+ "issues": "https://github.com/doctrine/coding-standard/issues",
+ "source": "https://github.com/doctrine/coding-standard/tree/12.0.0"
+ },
+ "time": "2023-04-24T17:43:28+00:00"
+ },
{
"name": "doctrine/instantiator",
"version": "1.5.0",
@@ -3397,6 +3531,71 @@
],
"time": "2020-09-28T06:39:44+00:00"
},
+ {
+ "name": "slevomat/coding-standard",
+ "version": "8.14.1",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/slevomat/coding-standard.git",
+ "reference": "fea1fd6f137cc84f9cba0ae30d549615dbc6a926"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/slevomat/coding-standard/zipball/fea1fd6f137cc84f9cba0ae30d549615dbc6a926",
+ "reference": "fea1fd6f137cc84f9cba0ae30d549615dbc6a926",
+ "shasum": ""
+ },
+ "require": {
+ "dealerdirect/phpcodesniffer-composer-installer": "^0.6.2 || ^0.7 || ^1.0",
+ "php": "^7.2 || ^8.0",
+ "phpstan/phpdoc-parser": "^1.23.1",
+ "squizlabs/php_codesniffer": "^3.7.1"
+ },
+ "require-dev": {
+ "phing/phing": "2.17.4",
+ "php-parallel-lint/php-parallel-lint": "1.3.2",
+ "phpstan/phpstan": "1.10.37",
+ "phpstan/phpstan-deprecation-rules": "1.1.4",
+ "phpstan/phpstan-phpunit": "1.3.14",
+ "phpstan/phpstan-strict-rules": "1.5.1",
+ "phpunit/phpunit": "8.5.21|9.6.8|10.3.5"
+ },
+ "type": "phpcodesniffer-standard",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "8.x-dev"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "SlevomatCodingStandard\\": "SlevomatCodingStandard/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "description": "Slevomat Coding Standard for PHP_CodeSniffer complements Consistence Coding Standard by providing sniffs with additional checks.",
+ "keywords": [
+ "dev",
+ "phpcs"
+ ],
+ "support": {
+ "issues": "https://github.com/slevomat/coding-standard/issues",
+ "source": "https://github.com/slevomat/coding-standard/tree/8.14.1"
+ },
+ "funding": [
+ {
+ "url": "https://github.com/kukulich",
+ "type": "github"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/slevomat/coding-standard",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2023-10-08T07:28:08+00:00"
+ },
{
"name": "spatie/array-to-xml",
"version": "2.17.1",
@@ -3461,6 +3660,86 @@
],
"time": "2022-12-26T08:22:07+00:00"
},
+ {
+ "name": "squizlabs/php_codesniffer",
+ "version": "3.8.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/PHPCSStandards/PHP_CodeSniffer.git",
+ "reference": "5805f7a4e4958dbb5e944ef1e6edae0a303765e7"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/5805f7a4e4958dbb5e944ef1e6edae0a303765e7",
+ "reference": "5805f7a4e4958dbb5e944ef1e6edae0a303765e7",
+ "shasum": ""
+ },
+ "require": {
+ "ext-simplexml": "*",
+ "ext-tokenizer": "*",
+ "ext-xmlwriter": "*",
+ "php": ">=5.4.0"
+ },
+ "require-dev": {
+ "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0 || ^8.0 || ^9.0"
+ },
+ "bin": [
+ "bin/phpcs",
+ "bin/phpcbf"
+ ],
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "3.x-dev"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "BSD-3-Clause"
+ ],
+ "authors": [
+ {
+ "name": "Greg Sherwood",
+ "role": "Former lead"
+ },
+ {
+ "name": "Juliette Reinders Folmer",
+ "role": "Current lead"
+ },
+ {
+ "name": "Contributors",
+ "homepage": "https://github.com/PHPCSStandards/PHP_CodeSniffer/graphs/contributors"
+ }
+ ],
+ "description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.",
+ "homepage": "https://github.com/PHPCSStandards/PHP_CodeSniffer",
+ "keywords": [
+ "phpcs",
+ "standards",
+ "static analysis"
+ ],
+ "support": {
+ "issues": "https://github.com/PHPCSStandards/PHP_CodeSniffer/issues",
+ "security": "https://github.com/PHPCSStandards/PHP_CodeSniffer/security/policy",
+ "source": "https://github.com/PHPCSStandards/PHP_CodeSniffer",
+ "wiki": "https://github.com/PHPCSStandards/PHP_CodeSniffer/wiki"
+ },
+ "funding": [
+ {
+ "url": "https://github.com/PHPCSStandards",
+ "type": "github"
+ },
+ {
+ "url": "https://github.com/jrfnl",
+ "type": "github"
+ },
+ {
+ "url": "https://opencollective.com/php_codesniffer",
+ "type": "open_collective"
+ }
+ ],
+ "time": "2023-12-08T12:32:31+00:00"
+ },
{
"name": "symfony/console",
"version": "v5.4.28",
@@ -4435,11 +4714,11 @@
"prefer-stable": false,
"prefer-lowest": false,
"platform": {
- "php": "^7.4|8.0.*|8.1.*|8.2.*|8.3.*"
+ "php": "8.1.*|8.2.*|8.3.*"
},
"platform-dev": [],
"platform-overrides": {
- "php": "7.4.0"
+ "php": "8.1.0"
},
- "plugin-api-version": "2.3.0"
+ "plugin-api-version": "2.6.0"
}
diff --git a/phpcs.xml.dist b/phpcs.xml.dist
index ca43be0f..ba5c120c 100644
--- a/phpcs.xml.dist
+++ b/phpcs.xml.dist
@@ -9,18 +9,41 @@
-
+
-
-
-
+
+
+
+
+
+
+
+
+
-
- */src/*/Abstract*\.php
+
+
+
+
+
+
+
+ packages/guides/src/Setup/QuickStart.php
+
+
+
+
+
+
*/tests/unit/*
+
+
+ */tests/unit/*
+ */src/phpDocumentor/Reflection/Php/*
+
diff --git a/rector.php b/rector.php
index 095be69f..08b30620 100644
--- a/rector.php
+++ b/rector.php
@@ -19,6 +19,6 @@
// define sets of rules
$rectorConfig->sets([
- LevelSetList::UP_TO_PHP_74
+ LevelSetList::UP_TO_PHP_81,
]);
};
diff --git a/src/phpDocumentor/Reflection/File/LocalFile.php b/src/phpDocumentor/Reflection/File/LocalFile.php
index a7ddf2bb..cf8e58ab 100644
--- a/src/phpDocumentor/Reflection/File/LocalFile.php
+++ b/src/phpDocumentor/Reflection/File/LocalFile.php
@@ -29,7 +29,7 @@ final class LocalFile implements File
/**
* Path to the file.
*/
- private string $path;
+ private readonly string $path;
public function __construct(string $path)
{
diff --git a/src/phpDocumentor/Reflection/Middleware/ChainFactory.php b/src/phpDocumentor/Reflection/Middleware/ChainFactory.php
index 447edb63..08529722 100644
--- a/src/phpDocumentor/Reflection/Middleware/ChainFactory.php
+++ b/src/phpDocumentor/Reflection/Middleware/ChainFactory.php
@@ -16,16 +16,12 @@
use InvalidArgumentException;
use function array_pop;
-use function get_class;
-use function gettype;
-use function is_object;
+use function get_debug_type;
use function sprintf;
final class ChainFactory
{
- /**
- * @param Middleware[] $middlewareList
- */
+ /** @param Middleware[] $middlewareList */
public static function createExecutionChain(array $middlewareList, callable $lastCallable): callable
{
while ($middleware = array_pop($middlewareList)) {
@@ -34,8 +30,8 @@ public static function createExecutionChain(array $middlewareList, callable $las
sprintf(
'Middleware must be an instance of %s but %s was given',
Middleware::class,
- is_object($middleware) ? get_class($middleware) : gettype($middleware)
- )
+ get_debug_type($middleware),
+ ),
);
}
diff --git a/src/phpDocumentor/Reflection/NodeVisitor/ElementNameResolver.php b/src/phpDocumentor/Reflection/NodeVisitor/ElementNameResolver.php
index c168d8aa..0ea81f62 100644
--- a/src/phpDocumentor/Reflection/NodeVisitor/ElementNameResolver.php
+++ b/src/phpDocumentor/Reflection/NodeVisitor/ElementNameResolver.php
@@ -30,7 +30,6 @@
use PhpParser\NodeVisitorAbstract;
use SplDoublyLinkedList;
-use function get_class;
use function rtrim;
final class ElementNameResolver extends NodeVisitorAbstract
@@ -61,7 +60,7 @@ public function beforeTraverse(array $nodes)
*/
public function leaveNode(Node $node)
{
- switch (get_class($node)) {
+ switch ($node::class) {
case Namespace_::class:
case Class_::class:
case Enum_::class:
@@ -92,9 +91,9 @@ 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|null
{
- switch (get_class($node)) {
+ switch ($node::class) {
case Namespace_::class:
if ($node->name === null) {
break;
@@ -149,7 +148,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|null $namespace = null): void
{
$this->parts = new SplDoublyLinkedList();
$this->parts->push($namespace);
diff --git a/src/phpDocumentor/Reflection/Php/Argument.php b/src/phpDocumentor/Reflection/Php/Argument.php
index 8a0669cd..4706d240 100644
--- a/src/phpDocumentor/Reflection/Php/Argument.php
+++ b/src/phpDocumentor/Reflection/Php/Argument.php
@@ -21,35 +21,23 @@
*/
final class Argument
{
- /** @var string name of the Argument */
- private string $name;
-
/** @var Type a normalized type that should be in this Argument */
- private Type $type;
-
- /** @var string|null the default value for an argument or null if none is provided */
- private ?string $default;
-
- /** @var bool whether the argument passes the parameter by reference instead of by value */
- private bool $byReference;
-
- /** @var bool Determines if this Argument represents a variadic argument */
- private bool $isVariadic;
+ private readonly Type $type;
/**
* Initializes the object.
*/
public function __construct(
- string $name,
- ?Type $type = null,
- ?string $default = null,
- bool $byReference = false,
- bool $isVariadic = false
+ /** @var string name of the Argument */
+ private readonly string $name,
+ Type|null $type = null,
+ /** @var string|null the default value for an argument or null if none is provided */
+ private readonly string|null $default = null,
+ /** @var bool whether the argument passes the parameter by reference instead of by value */
+ private readonly bool $byReference = false,
+ /** @var bool Determines if this Argument represents a variadic argument */
+ private readonly bool $isVariadic = false,
) {
- $this->name = $name;
- $this->default = $default;
- $this->byReference = $byReference;
- $this->isVariadic = $isVariadic;
if ($type === null) {
$type = new Mixed_();
}
@@ -65,12 +53,12 @@ public function getName(): string
return $this->name;
}
- public function getType(): ?Type
+ public function getType(): Type|null
{
return $this->type;
}
- public function getDefault(): ?string
+ public function getDefault(): string|null
{
return $this->default;
}
diff --git a/src/phpDocumentor/Reflection/Php/Attribute.php b/src/phpDocumentor/Reflection/Php/Attribute.php
index e91e5b10..26ccf7e8 100644
--- a/src/phpDocumentor/Reflection/Php/Attribute.php
+++ b/src/phpDocumentor/Reflection/Php/Attribute.php
@@ -9,16 +9,9 @@
final class Attribute implements Element
{
- private Fqsen $fqsen;
-
- /** @var CallArgument[] */
- private array $arguments;
-
/** @param CallArgument[] $arguments */
- public function __construct(Fqsen $fqsen, array $arguments)
+ public function __construct(private readonly Fqsen $fqsen, private readonly array $arguments)
{
- $this->fqsen = $fqsen;
- $this->arguments = $arguments;
}
public function getFqsen(): Fqsen
diff --git a/src/phpDocumentor/Reflection/Php/CallArgument.php b/src/phpDocumentor/Reflection/Php/CallArgument.php
index 0e4e4310..e619d052 100644
--- a/src/phpDocumentor/Reflection/Php/CallArgument.php
+++ b/src/phpDocumentor/Reflection/Php/CallArgument.php
@@ -6,16 +6,8 @@
final class CallArgument
{
- private string $value;
-
- private ?string $name;
-
- public function __construct(
- string $value,
- ?string $name = null
- ) {
- $this->value = $value;
- $this->name = $name;
+ public function __construct(private readonly string $value, private readonly string|null $name = null)
+ {
}
public function getValue(): string
@@ -23,7 +15,7 @@ public function getValue(): string
return $this->value;
}
- public function getName(): ?string
+ public function getName(): string|null
{
return $this->name;
}
diff --git a/src/phpDocumentor/Reflection/Php/Class_.php b/src/phpDocumentor/Reflection/Php/Class_.php
index 72eba8dc..e6b44a1b 100644
--- a/src/phpDocumentor/Reflection/Php/Class_.php
+++ b/src/phpDocumentor/Reflection/Php/Class_.php
@@ -29,22 +29,6 @@ final class Class_ implements Element, MetaDataContainerInterface, AttributeCont
use MetadataContainer;
use HasAttributes;
- /** @var Fqsen Full Qualified Structural Element Name */
- private Fqsen $fqsen;
-
- private ?DocBlock $docBlock = null;
-
- private bool $readOnly = false;
-
- /** @var bool Whether this is an abstract class. */
- private bool $abstract = false;
-
- /** @var bool Whether this class is marked as final and can't be subclassed. */
- private bool $final = false;
-
- /** @var Fqsen|null The class this class is extending. */
- private ?Fqsen $parent = null;
-
/** @var Fqsen[] References to interfaces that are implemented by this class. */
private array $implements = [];
@@ -60,22 +44,26 @@ final class Class_ implements Element, MetaDataContainerInterface, AttributeCont
/** @var Fqsen[] References to traits consumed by this class */
private array $usedTraits = [];
- private Location $location;
+ private readonly Location $location;
- private Location $endLocation;
+ private readonly Location $endLocation;
/**
* Initializes a number of properties with the given values. Others are initialized by definition.
*/
public function __construct(
- Fqsen $fqsen,
- ?DocBlock $docBlock = null,
- ?Fqsen $parent = null,
- bool $abstract = false,
- bool $final = false,
- ?Location $location = null,
- ?Location $endLocation = null,
- bool $readOnly = false
+ /** @var Fqsen Full Qualified Structural Element Name */
+ private readonly Fqsen $fqsen,
+ private readonly DocBlock|null $docBlock = null,
+ /** @var Fqsen|null The class this class is extending. */
+ private readonly Fqsen|null $parent = null,
+ /** @var bool Whether this is an abstract class. */
+ private readonly bool $abstract = false,
+ /** @var bool Whether this class is marked as final and can't be subclassed. */
+ private readonly bool $final = false,
+ Location|null $location = null,
+ Location|null $endLocation = null,
+ private readonly bool $readOnly = false,
) {
if ($location === null) {
$location = new Location(-1);
@@ -85,14 +73,8 @@ public function __construct(
$endLocation = new Location(-1);
}
- $this->fqsen = $fqsen;
- $this->parent = $parent;
- $this->docBlock = $docBlock;
- $this->abstract = $abstract;
- $this->final = $final;
$this->location = $location;
$this->endLocation = $endLocation;
- $this->readOnly = $readOnly;
}
/**
@@ -122,7 +104,7 @@ public function isReadOnly(): bool
/**
* Returns the superclass this class is extending if available.
*/
- public function getParent(): ?Fqsen
+ public function getParent(): Fqsen|null
{
return $this->parent;
}
@@ -233,7 +215,7 @@ public function getName(): string
return $this->fqsen->getName();
}
- public function getDocBlock(): ?DocBlock
+ public function getDocBlock(): DocBlock|null
{
return $this->docBlock;
}
diff --git a/src/phpDocumentor/Reflection/Php/Constant.php b/src/phpDocumentor/Reflection/Php/Constant.php
index a4ad94a9..861957da 100644
--- a/src/phpDocumentor/Reflection/Php/Constant.php
+++ b/src/phpDocumentor/Reflection/Php/Constant.php
@@ -27,45 +27,33 @@ final class Constant implements Element, MetaDataContainerInterface, AttributeCo
use MetadataContainer;
use HasAttributes;
- private Fqsen $fqsen;
+ private readonly Location $location;
- private ?DocBlock $docBlock;
+ private readonly Location $endLocation;
- private ?string $value;
-
- private Location $location;
-
- private Location $endLocation;
-
- private Visibility $visibility;
-
- private bool $final;
+ private readonly Visibility $visibility;
/**
* Initializes the object.
*/
public function __construct(
- Fqsen $fqsen,
- ?DocBlock $docBlock = null,
- ?string $value = null,
- ?Location $location = null,
- ?Location $endLocation = null,
- ?Visibility $visibility = null,
- bool $final = false
+ private readonly Fqsen $fqsen,
+ private readonly DocBlock|null $docBlock = null,
+ private readonly string|null $value = null,
+ Location|null $location = null,
+ Location|null $endLocation = null,
+ Visibility|null $visibility = null,
+ private readonly bool $final = false,
) {
- $this->fqsen = $fqsen;
- $this->docBlock = $docBlock;
- $this->value = $value;
$this->location = $location ?: new Location(-1);
$this->endLocation = $endLocation ?: new Location(-1);
$this->visibility = $visibility ?: new Visibility(Visibility::PUBLIC_);
- $this->final = $final;
}
/**
* Returns the value of this constant.
*/
- public function getValue(): ?string
+ public function getValue(): string|null
{
return $this->value;
}
@@ -89,7 +77,7 @@ public function getName(): string
/**
* Returns DocBlock of this constant if available.
*/
- public function getDocBlock(): ?DocBlock
+ public function getDocBlock(): DocBlock|null
{
return $this->docBlock;
}
diff --git a/src/phpDocumentor/Reflection/Php/EnumCase.php b/src/phpDocumentor/Reflection/Php/EnumCase.php
index 3ddfc6ad..63393a80 100644
--- a/src/phpDocumentor/Reflection/Php/EnumCase.php
+++ b/src/phpDocumentor/Reflection/Php/EnumCase.php
@@ -15,22 +15,16 @@ final class EnumCase implements Element, MetaDataContainerInterface, AttributeCo
use MetadataContainer;
use HasAttributes;
- private Fqsen $fqsen;
+ private readonly Location $location;
- private ?DocBlock $docBlock;
-
- private Location $location;
-
- private Location $endLocation;
-
- private ?string $value;
+ private readonly Location $endLocation;
public function __construct(
- Fqsen $fqsen,
- ?DocBlock $docBlock,
- ?Location $location = null,
- ?Location $endLocation = null,
- ?string $value = null
+ private readonly Fqsen $fqsen,
+ private readonly DocBlock|null $docBlock,
+ Location|null $location = null,
+ Location|null $endLocation = null,
+ private readonly string|null $value = null,
) {
if ($location === null) {
$location = new Location(-1);
@@ -40,11 +34,8 @@ public function __construct(
$endLocation = new Location(-1);
}
- $this->fqsen = $fqsen;
- $this->docBlock = $docBlock;
$this->location = $location;
$this->endLocation = $endLocation;
- $this->value = $value;
}
public function getFqsen(): Fqsen
@@ -57,7 +48,7 @@ public function getName(): string
return $this->fqsen->getName();
}
- public function getDocBlock(): ?DocBlock
+ public function getDocBlock(): DocBlock|null
{
return $this->docBlock;
}
@@ -72,7 +63,7 @@ public function getEndLocation(): Location
return $this->endLocation;
}
- public function getValue(): ?string
+ public function getValue(): string|null
{
return $this->value;
}
diff --git a/src/phpDocumentor/Reflection/Php/Enum_.php b/src/phpDocumentor/Reflection/Php/Enum_.php
index 55b94dc9..30abc5da 100644
--- a/src/phpDocumentor/Reflection/Php/Enum_.php
+++ b/src/phpDocumentor/Reflection/Php/Enum_.php
@@ -25,14 +25,9 @@ final class Enum_ implements Element, MetaDataContainerInterface, AttributeConta
use MetadataContainer;
use HasAttributes;
- /** @var Fqsen Full Qualified Structural Element Name */
- private Fqsen $fqsen;
+ private readonly Location $location;
- private ?DocBlock $docBlock;
-
- private Location $location;
-
- private Location $endLocation;
+ private readonly Location $endLocation;
/** @var EnumCase[] */
private array $cases = [];
@@ -49,14 +44,13 @@ final class Enum_ implements Element, MetaDataContainerInterface, AttributeConta
/** @var array */
private array $usedTraits = [];
- private ?Type $backedType;
-
public function __construct(
- Fqsen $fqsen,
- ?Type $backedType,
- ?DocBlock $docBlock = null,
- ?Location $location = null,
- ?Location $endLocation = null
+ /** @var Fqsen Full Qualified Structural Element Name */
+ private readonly Fqsen $fqsen,
+ private readonly Type|null $backedType,
+ private readonly DocBlock|null $docBlock = null,
+ Location|null $location = null,
+ Location|null $endLocation = null,
) {
if ($location === null) {
$location = new Location(-1);
@@ -66,11 +60,8 @@ public function __construct(
$endLocation = new Location(-1);
}
- $this->fqsen = $fqsen;
- $this->docBlock = $docBlock;
$this->location = $location;
$this->endLocation = $endLocation;
- $this->backedType = $backedType;
}
public function getFqsen(): Fqsen
@@ -83,7 +74,7 @@ public function getName(): string
return $this->fqsen->getName();
}
- public function getDocBlock(): ?DocBlock
+ public function getDocBlock(): DocBlock|null
{
return $this->docBlock;
}
@@ -181,7 +172,7 @@ public function addUsedTrait(Fqsen $fqsen): void
$this->usedTraits[(string) $fqsen] = $fqsen;
}
- public function getBackedType(): ?Type
+ public function getBackedType(): Type|null
{
return $this->backedType;
}
diff --git a/src/phpDocumentor/Reflection/Php/Factory/AbstractFactory.php b/src/phpDocumentor/Reflection/Php/Factory/AbstractFactory.php
index a17783a3..84adce2e 100644
--- a/src/phpDocumentor/Reflection/Php/Factory/AbstractFactory.php
+++ b/src/phpDocumentor/Reflection/Php/Factory/AbstractFactory.php
@@ -23,23 +23,14 @@
use PhpParser\Comment\Doc;
use PhpParser\NodeAbstract;
-use function get_class;
-use function gettype;
-use function is_object;
+use function get_debug_type;
use function sprintf;
abstract class AbstractFactory implements ProjectFactoryStrategy
{
- private DocBlockFactoryInterface $docBlockFactory;
-
- /** @var iterable */
- private iterable $reducers;
-
- /** @param iterable $recuders */
- public function __construct(DocBlockFactoryInterface $docBlockFactory, iterable $recuders = [])
+ /** @param iterable $reducers */
+ public function __construct(private readonly DocBlockFactoryInterface $docBlockFactory, private readonly iterable $reducers = [])
{
- $this->docBlockFactory = $docBlockFactory;
- $this->reducers = $recuders;
}
/**
@@ -56,8 +47,8 @@ public function create(ContextStack $context, object $object, StrategyContainer
sprintf(
'%s cannot handle objects with the type %s',
self::class,
- is_object($object) ? get_class($object) : gettype($object)
- )
+ get_debug_type($object),
+ ),
);
}
@@ -75,9 +66,9 @@ public function create(ContextStack $context, object $object, StrategyContainer
*
* @param NodeAbstract|object $object object to convert to an Element
*/
- abstract protected function doCreate(ContextStack $context, object $object, StrategyContainer $strategies): ?object;
+ abstract protected function doCreate(ContextStack $context, object $object, StrategyContainer $strategies): object|null;
- protected function createDocBlock(?Doc $docBlock = null, ?Context $context = null): ?DocBlock
+ protected function createDocBlock(Doc|null $docBlock = null, Context|null $context = null): DocBlock|null
{
if ($docBlock === null) {
return null;
diff --git a/src/phpDocumentor/Reflection/Php/Factory/Argument.php b/src/phpDocumentor/Reflection/Php/Factory/Argument.php
index 44a2cd92..53ede8b6 100644
--- a/src/phpDocumentor/Reflection/Php/Factory/Argument.php
+++ b/src/phpDocumentor/Reflection/Php/Factory/Argument.php
@@ -31,14 +31,11 @@
*/
final class Argument implements ProjectFactoryStrategy
{
- private PrettyPrinter $valueConverter;
-
/**
* Initializes the object.
*/
- public function __construct(PrettyPrinter $prettyPrinter)
+ public function __construct(private readonly PrettyPrinter $valueConverter)
{
- $this->valueConverter = $prettyPrinter;
}
public function matches(ContextStack $context, object $object): bool
@@ -59,7 +56,7 @@ public function matches(ContextStack $context, object $object): bool
public function create(
ContextStack $context,
object $object,
- StrategyContainer $strategies
+ StrategyContainer $strategies,
): void {
Assert::isInstanceOf($object, Param::class);
Assert::isInstanceOf($object->var, Variable::class);
@@ -70,7 +67,7 @@ public function create(
[
Method::class,
Function_::class,
- ]
+ ],
);
$method->addArgument(
@@ -79,8 +76,8 @@ public function create(
(new Type())->fromPhpParser($object->type),
$object->default !== null ? $this->valueConverter->prettyPrintExpr($object->default) : null,
$object->byRef,
- $object->variadic
- )
+ $object->variadic,
+ ),
);
}
}
diff --git a/src/phpDocumentor/Reflection/Php/Factory/ClassConstant.php b/src/phpDocumentor/Reflection/Php/Factory/ClassConstant.php
index 72c8b71c..838b97fe 100644
--- a/src/phpDocumentor/Reflection/Php/Factory/ClassConstant.php
+++ b/src/phpDocumentor/Reflection/Php/Factory/ClassConstant.php
@@ -34,11 +34,8 @@
*/
final class ClassConstant extends AbstractFactory
{
- private PrettyPrinter $valueConverter;
-
- public function __construct(DocBlockFactoryInterface $blockFactory, PrettyPrinter $prettyPrinter)
+ public function __construct(DocBlockFactoryInterface $blockFactory, private readonly PrettyPrinter $valueConverter)
{
- $this->valueConverter = $prettyPrinter;
parent::__construct($blockFactory);
}
@@ -60,8 +57,8 @@ public function matches(ContextStack $context, object $object): bool
protected function doCreate(
ContextStack $context,
object $object,
- StrategyContainer $strategies
- ): ?object {
+ StrategyContainer $strategies,
+ ): object|null {
$constantContainer = $context->peek();
Assert::isInstanceOfAny(
$constantContainer,
@@ -70,7 +67,7 @@ protected function doCreate(
Enum_::class,
Interface_::class,
Trait_::class,
- ]
+ ],
);
$constants = new ClassConstantIterator($object);
@@ -83,7 +80,7 @@ protected function doCreate(
new Location($const->getLine()),
new Location($const->getEndLine()),
$this->buildVisibility($const),
- $const->isFinal()
+ $const->isFinal(),
));
}
diff --git a/src/phpDocumentor/Reflection/Php/Factory/ClassConstantIterator.php b/src/phpDocumentor/Reflection/Php/Factory/ClassConstantIterator.php
index 77051d7b..d365230b 100644
--- a/src/phpDocumentor/Reflection/Php/Factory/ClassConstantIterator.php
+++ b/src/phpDocumentor/Reflection/Php/Factory/ClassConstantIterator.php
@@ -27,17 +27,14 @@
*/
final class ClassConstantIterator implements Iterator
{
- private ClassConst $classConstants;
-
/** @var int index of the current ClassConst to use */
private int $index = 0;
/**
* Initializes the class with source data.
*/
- public function __construct(ClassConst $classConst)
+ public function __construct(private readonly ClassConst $classConstants)
{
- $this->classConstants = $classConst;
}
/**
@@ -105,7 +102,7 @@ public function isPrivate(): bool
*
* The doc comment has to be the last comment associated with the node.
*/
- public function getDocComment(): ?Doc
+ public function getDocComment(): Doc|null
{
$docComment = $this->classConstants->consts[$this->index]->getDocComment();
if ($docComment === null) {
@@ -125,41 +122,31 @@ public function isFinal(): bool
return $this->classConstants->isFinal();
}
- /**
- * @link http://php.net/manual/en/iterator.current.php
- */
+ /** @link http://php.net/manual/en/iterator.current.php */
public function current(): self
{
return $this;
}
- /**
- * @link http://php.net/manual/en/iterator.next.php
- */
+ /** @link http://php.net/manual/en/iterator.next.php */
public function next(): void
{
++$this->index;
}
- /**
- * @link http://php.net/manual/en/iterator.key.php
- */
- public function key(): ?int
+ /** @link http://php.net/manual/en/iterator.key.php */
+ public function key(): int|null
{
return $this->index;
}
- /**
- * @link http://php.net/manual/en/iterator.valid.php
- */
+ /** @link http://php.net/manual/en/iterator.valid.php */
public function valid(): bool
{
return isset($this->classConstants->consts[$this->index]);
}
- /**
- * @link http://php.net/manual/en/iterator.rewind.php
- */
+ /** @link http://php.net/manual/en/iterator.rewind.php */
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 3b093f62..531d7590 100644
--- a/src/phpDocumentor/Reflection/Php/Factory/Class_.php
+++ b/src/phpDocumentor/Reflection/Php/Factory/Class_.php
@@ -41,7 +41,7 @@ public function matches(ContextStack $context, object $object): bool
* @param ContextStack $context of the created object
* @param ClassNode $object
*/
- protected function doCreate(ContextStack $context, object $object, StrategyContainer $strategies): ?object
+ protected function doCreate(ContextStack $context, object $object, StrategyContainer $strategies): object|null
{
$docBlock = $this->createDocBlock($object->getDocComment(), $context->getTypeContext());
@@ -53,12 +53,12 @@ protected function doCreate(ContextStack $context, object $object, StrategyConta
$object->isFinal(),
new Location($object->getLine()),
new Location($object->getEndLine()),
- $object->isReadonly()
+ $object->isReadonly(),
);
foreach ($object->implements as $interfaceClassName) {
$classElement->addInterface(
- new Fqsen('\\' . $interfaceClassName->toString())
+ new Fqsen('\\' . $interfaceClassName->toString()),
);
}
diff --git a/src/phpDocumentor/Reflection/Php/Factory/ConstructorPromotion.php b/src/phpDocumentor/Reflection/Php/Factory/ConstructorPromotion.php
index a5ac2588..db055441 100644
--- a/src/phpDocumentor/Reflection/Php/Factory/ConstructorPromotion.php
+++ b/src/phpDocumentor/Reflection/Php/Factory/ConstructorPromotion.php
@@ -22,17 +22,12 @@
final class ConstructorPromotion extends AbstractFactory
{
- private PrettyPrinter $valueConverter;
- private ProjectFactoryStrategy $methodStrategy;
-
public function __construct(
- ProjectFactoryStrategy $methodStrategy,
+ private readonly ProjectFactoryStrategy $methodStrategy,
DocBlockFactoryInterface $docBlockFactory,
- PrettyPrinter $prettyPrinter
+ private readonly PrettyPrinter $valueConverter,
) {
parent::__construct($docBlockFactory);
- $this->valueConverter = $prettyPrinter;
- $this->methodStrategy = $methodStrategy;
}
public function matches(ContextStack $context, object $object): bool
@@ -41,15 +36,13 @@ public function matches(ContextStack $context, object $object): bool
return $context->peek() instanceof ClassElement &&
$object instanceof ClassMethod &&
(string) ($object->name) === '__construct';
- } catch (OutOfBoundsException $e) {
+ } catch (OutOfBoundsException) {
return false;
}
}
- /**
- * @param ClassMethod $object
- */
- protected function doCreate(ContextStack $context, object $object, StrategyContainer $strategies): ?object
+ /** @param ClassMethod $object */
+ protected function doCreate(ContextStack $context, object $object, StrategyContainer $strategies): object|null
{
$this->methodStrategy->create($context, $object, $strategies);
@@ -79,7 +72,7 @@ private function promoteParameterToProperty(ContextStack $context, Param $param)
new Location($param->getLine()),
new Location($param->getEndLine()),
(new Type())->fromPhpParser($param->type),
- $this->readOnly($param->flags)
+ $this->readOnly($param->flags),
);
$methodContainer->addProperty($property);
diff --git a/src/phpDocumentor/Reflection/Php/Factory/ContextStack.php b/src/phpDocumentor/Reflection/Php/Factory/ContextStack.php
index 28aefa0c..d4c17af7 100644
--- a/src/phpDocumentor/Reflection/Php/Factory/ContextStack.php
+++ b/src/phpDocumentor/Reflection/Php/Factory/ContextStack.php
@@ -18,17 +18,12 @@ final class ContextStack
/** @var (Element|FileElement)[] */
private array $elements = [];
- private ?TypeContext $typeContext;
- private Project $project;
-
- public function __construct(Project $project, ?TypeContext $typeContext = null)
+ public function __construct(private readonly Project $project, private readonly TypeContext|null $typeContext = null)
{
- $this->project = $project;
- $this->typeContext = $typeContext;
}
/** @param (Element|FileElement)[] $elements */
- private static function createFromSelf(Project $project, ?TypeContext $typeContext, array $elements): self
+ private static function createFromSelf(Project $project, TypeContext|null $typeContext, array $elements): self
{
$self = new self($project, $typeContext);
$self->elements = $elements;
@@ -36,8 +31,7 @@ private static function createFromSelf(Project $project, ?TypeContext $typeConte
return $self;
}
- /** @param Element|FileElement $element */
- public function push($element): self
+ public function push(Element|FileElement $element): self
{
$elements = $this->elements;
$elements[] = $element;
@@ -50,7 +44,7 @@ public function withTypeContext(TypeContext $typeContext): ContextStack
return self::createFromSelf($this->project, $typeContext, $this->elements);
}
- public function getTypeContext(): ?TypeContext
+ public function getTypeContext(): TypeContext|null
{
return $this->typeContext;
}
@@ -60,10 +54,7 @@ public function getProject(): Project
return $this->project;
}
- /**
- * @return Element|FileElement
- */
- public function peek()
+ public function peek(): Element|FileElement
{
$element = end($this->elements);
if ($element === false) {
@@ -80,10 +71,8 @@ public function peek()
* in the current stack.
*
* @param class-string $type
- *
- * @return Element|FileElement|null
*/
- public function search(string $type)
+ public function search(string $type): Element|FileElement|null
{
$reverseElements = array_reverse($this->elements);
foreach ($reverseElements as $element) {
diff --git a/src/phpDocumentor/Reflection/Php/Factory/Define.php b/src/phpDocumentor/Reflection/Php/Factory/Define.php
index d3d84a04..1d8b8692 100644
--- a/src/phpDocumentor/Reflection/Php/Factory/Define.php
+++ b/src/phpDocumentor/Reflection/Php/Factory/Define.php
@@ -31,6 +31,7 @@
use function assert;
use function sprintf;
+use function str_starts_with;
/**
* Strategy to convert `define` expressions to ConstantElement
@@ -40,21 +41,15 @@
*/
final class Define extends AbstractFactory
{
- private PrettyPrinter $valueConverter;
-
- private ConstantEvaluator $constantEvaluator;
-
/**
* Initializes the object.
*/
public function __construct(
DocBlockFactoryInterface $docBlockFactory,
- PrettyPrinter $prettyPrinter,
- ?ConstantEvaluator $constantEvaluator = null
+ private readonly PrettyPrinter $valueConverter,
+ private readonly ConstantEvaluator $constantEvaluator = new ConstantEvaluator(),
) {
parent::__construct($docBlockFactory);
- $this->valueConverter = $prettyPrinter;
- $this->constantEvaluator = $constantEvaluator ?? new ConstantEvaluator();
}
public function matches(ContextStack $context, object $object): bool
@@ -87,8 +82,8 @@ public function matches(ContextStack $context, object $object): bool
protected function doCreate(
ContextStack $context,
object $object,
- StrategyContainer $strategies
- ): ?object {
+ StrategyContainer $strategies,
+ ): object|null {
$expression = $object->expr;
assert($expression instanceof FuncCall);
@@ -112,7 +107,7 @@ protected function doCreate(
$this->createDocBlock($object->getDocComment(), $context->getTypeContext()),
$this->determineValue($value),
new Location($object->getLine()),
- new Location($object->getEndLine())
+ new Location($object->getEndLine()),
);
$file->addConstant($constant);
@@ -120,7 +115,7 @@ protected function doCreate(
return $constant;
}
- private function determineValue(?Arg $value): ?string
+ private function determineValue(Arg|null $value): string|null
{
if ($value === null) {
return null;
@@ -129,16 +124,16 @@ private function determineValue(?Arg $value): ?string
return $this->valueConverter->prettyPrintExpr($value->value);
}
- private function determineFqsen(Arg $name, ContextStack $context): ?Fqsen
+ private function determineFqsen(Arg $name, ContextStack $context): Fqsen|null
{
return $this->fqsenFromExpression($name->value, $context);
}
- private function fqsenFromExpression(Expr $nameString, ContextStack $context): ?Fqsen
+ private function fqsenFromExpression(Expr $nameString, ContextStack $context): Fqsen|null
{
try {
return $this->fqsenFromString($this->constantEvaluator->evaluate($nameString, $context));
- } catch (ConstExprEvaluationException $e) {
+ } catch (ConstExprEvaluationException) {
//Ignore any errors as we cannot evaluate all expressions
return null;
}
diff --git a/src/phpDocumentor/Reflection/Php/Factory/EnumCase.php b/src/phpDocumentor/Reflection/Php/Factory/EnumCase.php
index f2eb2cd7..bf05ae34 100644
--- a/src/phpDocumentor/Reflection/Php/Factory/EnumCase.php
+++ b/src/phpDocumentor/Reflection/Php/Factory/EnumCase.php
@@ -16,12 +16,9 @@
final class EnumCase extends AbstractFactory
{
- private PrettyPrinter $prettyPrinter;
-
- public function __construct(DocBlockFactoryInterface $docBlockFactory, PrettyPrinter $prettyPrinter)
+ public function __construct(DocBlockFactoryInterface $docBlockFactory, private readonly PrettyPrinter $prettyPrinter)
{
parent::__construct($docBlockFactory);
- $this->prettyPrinter = $prettyPrinter;
}
public function matches(ContextStack $context, object $object): bool
@@ -29,10 +26,8 @@ public function matches(ContextStack $context, object $object): bool
return $object instanceof EnumCaseNode;
}
- /**
- * @param EnumCaseNode $object
- */
- protected function doCreate(ContextStack $context, object $object, StrategyContainer $strategies): ?object
+ /** @param EnumCaseNode $object */
+ protected function doCreate(ContextStack $context, object $object, StrategyContainer $strategies): object|null
{
$docBlock = $this->createDocBlock($object->getDocComment(), $context->getTypeContext());
$enum = $context->peek();
@@ -43,7 +38,7 @@ protected function doCreate(ContextStack $context, object $object, StrategyConta
$docBlock,
new Location($object->getLine()),
new Location($object->getEndLine()),
- $object->expr !== null ? $this->prettyPrinter->prettyPrintExpr($object->expr) : null
+ $object->expr !== null ? $this->prettyPrinter->prettyPrintExpr($object->expr) : null,
);
$enum->addCase($case);
diff --git a/src/phpDocumentor/Reflection/Php/Factory/Enum_.php b/src/phpDocumentor/Reflection/Php/Factory/Enum_.php
index 1e8f8b1a..9abccfa7 100644
--- a/src/phpDocumentor/Reflection/Php/Factory/Enum_.php
+++ b/src/phpDocumentor/Reflection/Php/Factory/Enum_.php
@@ -29,7 +29,7 @@ public function matches(ContextStack $context, object $object): bool
}
/** @param EnumNode $object */
- protected function doCreate(ContextStack $context, object $object, StrategyContainer $strategies): ?object
+ protected function doCreate(ContextStack $context, object $object, StrategyContainer $strategies): object|null
{
$docBlock = $this->createDocBlock($object->getDocComment(), $context->getTypeContext());
@@ -38,12 +38,12 @@ protected function doCreate(ContextStack $context, object $object, StrategyConta
(new Type())->fromPhpParser($object->scalarType),
$docBlock,
new Location($object->getLine()),
- new Location($object->getEndLine())
+ new Location($object->getEndLine()),
);
foreach ($object->implements as $interfaceClassName) {
$enum->addInterface(
- new Fqsen('\\' . $interfaceClassName->toString())
+ new Fqsen('\\' . $interfaceClassName->toString()),
);
}
diff --git a/src/phpDocumentor/Reflection/Php/Factory/File.php b/src/phpDocumentor/Reflection/Php/Factory/File.php
index 467f19f9..f7d4d8fa 100644
--- a/src/phpDocumentor/Reflection/Php/Factory/File.php
+++ b/src/phpDocumentor/Reflection/Php/Factory/File.php
@@ -34,7 +34,6 @@
use PhpParser\Node\Stmt\Trait_ as TraitNode;
use function array_merge;
-use function get_class;
use function in_array;
/**
@@ -48,8 +47,6 @@ final class File extends AbstractFactory
InlineHTML::class,
];
- private NodesFactory $nodesFactory;
-
/** @var callable */
private $middlewareChain;
@@ -60,10 +57,9 @@ final class File extends AbstractFactory
*/
public function __construct(
DocBlockFactoryInterface $docBlockFactory,
- NodesFactory $nodesFactory,
- array $middleware = []
+ private readonly NodesFactory $nodesFactory,
+ array $middleware = [],
) {
- $this->nodesFactory = $nodesFactory;
parent::__construct($docBlockFactory);
$lastCallable = fn ($command): FileElement => $this->createFile($command);
@@ -86,7 +82,7 @@ public function matches(ContextStack $context, object $object): bool
* @param FileSystemFile $object path to the file to convert to an File object.
* @param StrategyContainer $strategies used to convert nested objects.
*/
- protected function doCreate(ContextStack $context, object $object, StrategyContainer $strategies): ?object
+ protected function doCreate(ContextStack $context, object $object, StrategyContainer $strategies): object|null
{
$command = new CreateCommand($context, $object, $strategies);
$middlewareChain = $this->middlewareChain;
@@ -113,7 +109,7 @@ private function createFile(CreateCommand $command): FileElement
$file->md5(),
$file->path(),
$code,
- $docBlock
+ $docBlock,
);
$this->createElements($command->getContext()->push($result), $nodes, $command->getStrategies());
@@ -121,13 +117,11 @@ private function createFile(CreateCommand $command): FileElement
return $result;
}
- /**
- * @param Node[] $nodes
- */
+ /** @param Node[] $nodes */
private function createElements(
ContextStack $contextStack,
array $nodes,
- StrategyContainer $strategies
+ StrategyContainer $strategies,
): void {
foreach ($nodes as $node) {
$strategy = $strategies->findMatching($contextStack, $node);
@@ -135,17 +129,15 @@ private function createElements(
}
}
- /**
- * @param Node[] $nodes
- */
+ /** @param Node[] $nodes */
protected function createFileDocBlock(
- ?Context $context = null,
- array $nodes = []
- ): ?DocBlockInstance {
+ Context|null $context = null,
+ array $nodes = [],
+ ): DocBlockInstance|null {
$node = null;
$comments = [];
foreach ($nodes as $n) {
- if (!in_array(get_class($n), self::SKIPPED_NODE_TYPES)) {
+ if (!in_array($n::class, self::SKIPPED_NODE_TYPES)) {
$node = $n;
break;
}
diff --git a/src/phpDocumentor/Reflection/Php/Factory/File/CreateCommand.php b/src/phpDocumentor/Reflection/Php/Factory/File/CreateCommand.php
index dc63a7a3..10ef2e3f 100644
--- a/src/phpDocumentor/Reflection/Php/Factory/File/CreateCommand.php
+++ b/src/phpDocumentor/Reflection/Php/Factory/File/CreateCommand.php
@@ -24,20 +24,11 @@
*/
final class CreateCommand implements Command
{
- private File $file;
-
- private StrategyContainer $strategies;
-
- private ContextStack $context;
-
/**
* Initializes this command.
*/
- public function __construct(ContextStack $context, File $file, StrategyContainer $strategies)
+ public function __construct(private readonly ContextStack $context, private readonly File $file, private readonly StrategyContainer $strategies)
{
- $this->file = $file;
- $this->strategies = $strategies;
- $this->context = $context;
}
/**
diff --git a/src/phpDocumentor/Reflection/Php/Factory/Function_.php b/src/phpDocumentor/Reflection/Php/Factory/Function_.php
index 0662d97a..7e2c136f 100644
--- a/src/phpDocumentor/Reflection/Php/Factory/Function_.php
+++ b/src/phpDocumentor/Reflection/Php/Factory/Function_.php
@@ -45,8 +45,8 @@ public function matches(ContextStack $context, object $object): bool
protected function doCreate(
ContextStack $context,
object $object,
- StrategyContainer $strategies
- ): ?object {
+ StrategyContainer $strategies,
+ ): object|null {
$file = $context->peek();
Assert::isInstanceOf($file, FileElement::class);
@@ -56,7 +56,7 @@ protected function doCreate(
new Location($object->getLine()),
new Location($object->getEndLine()),
(new Type())->fromPhpParser($object->getReturnType()),
- $object->byRef ?: false
+ $object->byRef ?: false,
);
$file->addFunction($function);
diff --git a/src/phpDocumentor/Reflection/Php/Factory/GlobalConstant.php b/src/phpDocumentor/Reflection/Php/Factory/GlobalConstant.php
index 79237e2f..ae352e11 100644
--- a/src/phpDocumentor/Reflection/Php/Factory/GlobalConstant.php
+++ b/src/phpDocumentor/Reflection/Php/Factory/GlobalConstant.php
@@ -30,14 +30,11 @@
*/
final class GlobalConstant extends AbstractFactory
{
- private PrettyPrinter $valueConverter;
-
/**
* Initializes the object.
*/
- public function __construct(DocBlockFactoryInterface $docBlockFactory, PrettyPrinter $prettyPrinter)
+ public function __construct(DocBlockFactoryInterface $docBlockFactory, private readonly PrettyPrinter $valueConverter)
{
- $this->valueConverter = $prettyPrinter;
parent::__construct($docBlockFactory);
}
@@ -59,8 +56,8 @@ public function matches(ContextStack $context, object $object): bool
protected function doCreate(
ContextStack $context,
object $object,
- StrategyContainer $strategies
- ): ?object {
+ StrategyContainer $strategies,
+ ): object|null {
$constants = new GlobalConstantIterator($object);
$file = $context->peek();
Assert::isInstanceOf($file, FileElement::class);
@@ -72,8 +69,8 @@ protected function doCreate(
$this->createDocBlock($const->getDocComment(), $context->getTypeContext()),
$const->getValue() !== null ? $this->valueConverter->prettyPrintExpr($const->getValue()) : null,
new Location($const->getLine()),
- new Location($const->getEndLine())
- )
+ new Location($const->getEndLine()),
+ ),
);
}
diff --git a/src/phpDocumentor/Reflection/Php/Factory/GlobalConstantIterator.php b/src/phpDocumentor/Reflection/Php/Factory/GlobalConstantIterator.php
index 4f0d59a9..11f5a6db 100644
--- a/src/phpDocumentor/Reflection/Php/Factory/GlobalConstantIterator.php
+++ b/src/phpDocumentor/Reflection/Php/Factory/GlobalConstantIterator.php
@@ -19,22 +19,17 @@
use PhpParser\Node\Expr;
use PhpParser\Node\Stmt\Const_;
-/**
- * @implements Iterator
- */
+/** @implements Iterator */
final class GlobalConstantIterator implements Iterator
{
- private Const_ $constant;
-
/** @var int index of the current constant to use */
private int $index = 0;
/**
* Initializes the class with source data.
*/
- public function __construct(Const_ $constant)
+ public function __construct(private readonly Const_ $constant)
{
- $this->constant = $constant;
}
/**
@@ -78,7 +73,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|null
{
$docComment = $this->constant->consts[$this->index]->getDocComment();
if ($docComment === null) {
@@ -93,41 +88,31 @@ public function getValue(): Expr
return $this->constant->consts[$this->index]->value;
}
- /**
- * @link http://php.net/manual/en/iterator.current.php
- */
+ /** @link http://php.net/manual/en/iterator.current.php */
public function current(): self
{
return $this;
}
- /**
- * @link http://php.net/manual/en/iterator.next.php
- */
+ /** @link http://php.net/manual/en/iterator.next.php */
public function next(): void
{
++$this->index;
}
- /**
- * @link http://php.net/manual/en/iterator.key.php
- */
- public function key(): ?int
+ /** @link http://php.net/manual/en/iterator.key.php */
+ public function key(): int|null
{
return $this->index;
}
- /**
- * @link http://php.net/manual/en/iterator.valid.php
- */
+ /** @link http://php.net/manual/en/iterator.valid.php */
public function valid(): bool
{
return isset($this->constant->consts[$this->index]);
}
- /**
- * @link http://php.net/manual/en/iterator.rewind.php
- */
+ /** @link http://php.net/manual/en/iterator.rewind.php */
public function rewind(): void
{
$this->index = 0;
diff --git a/src/phpDocumentor/Reflection/Php/Factory/IfStatement.php b/src/phpDocumentor/Reflection/Php/Factory/IfStatement.php
index 39cda07b..c108cc08 100644
--- a/src/phpDocumentor/Reflection/Php/Factory/IfStatement.php
+++ b/src/phpDocumentor/Reflection/Php/Factory/IfStatement.php
@@ -16,9 +16,7 @@ public function matches(ContextStack $context, object $object): bool
return $object instanceof If_;
}
- /**
- * @param If_ $object
- */
+ /** @param If_ $object */
public function create(ContextStack $context, object $object, StrategyContainer $strategies): void
{
foreach ($object->stmts as $stmt) {
diff --git a/src/phpDocumentor/Reflection/Php/Factory/Interface_.php b/src/phpDocumentor/Reflection/Php/Factory/Interface_.php
index 3eefcace..352b552a 100644
--- a/src/phpDocumentor/Reflection/Php/Factory/Interface_.php
+++ b/src/phpDocumentor/Reflection/Php/Factory/Interface_.php
@@ -45,8 +45,8 @@ public function matches(ContextStack $context, object $object): bool
protected function doCreate(
ContextStack $context,
object $object,
- StrategyContainer $strategies
- ): ?object {
+ StrategyContainer $strategies,
+ ): object|null {
$docBlock = $this->createDocBlock($object->getDocComment(), $context->getTypeContext());
$parents = [];
foreach ($object->extends as $extend) {
@@ -58,7 +58,7 @@ protected function doCreate(
$parents,
$docBlock,
new Location($object->getLine()),
- new Location($object->getEndLine())
+ new Location($object->getEndLine()),
);
$file = $context->peek();
Assert::isInstanceOf($file, FileElement::class);
diff --git a/src/phpDocumentor/Reflection/Php/Factory/Method.php b/src/phpDocumentor/Reflection/Php/Factory/Method.php
index a1f88b66..fc28e313 100644
--- a/src/phpDocumentor/Reflection/Php/Factory/Method.php
+++ b/src/phpDocumentor/Reflection/Php/Factory/Method.php
@@ -45,8 +45,8 @@ public function matches(ContextStack $context, object $object): bool
protected function doCreate(
ContextStack $context,
object $object,
- StrategyContainer $strategies
- ): ?object {
+ StrategyContainer $strategies,
+ ): object|null {
$methodContainer = $context->peek();
Assert::isInstanceOfAny(
$methodContainer,
@@ -55,7 +55,7 @@ protected function doCreate(
Interface_::class,
Trait_::class,
Enum_::class,
- ]
+ ],
);
$method = new MethodDescriptor(
@@ -68,7 +68,7 @@ protected function doCreate(
new Location($object->getLine(), $object->getStartFilePos()),
new Location($object->getEndLine(), $object->getEndFilePos()),
(new Type())->fromPhpParser($object->getReturnType()),
- $object->byRef ?: false
+ $object->byRef ?: false,
);
$methodContainer->addMethod($method);
diff --git a/src/phpDocumentor/Reflection/Php/Factory/Namespace_.php b/src/phpDocumentor/Reflection/Php/Factory/Namespace_.php
index 593a1ca4..7a15d4c5 100644
--- a/src/phpDocumentor/Reflection/Php/Factory/Namespace_.php
+++ b/src/phpDocumentor/Reflection/Php/Factory/Namespace_.php
@@ -13,9 +13,7 @@
use PhpParser\Node\Stmt\Namespace_ as NamespaceNode;
use Webmozart\Assert\Assert;
-use function get_class;
-use function gettype;
-use function is_object;
+use function get_debug_type;
use function sprintf;
class Namespace_ implements ProjectFactoryStrategy
@@ -25,9 +23,7 @@ public function matches(ContextStack $context, object $object): bool
return $object instanceof NamespaceNode;
}
- /**
- * @param NamespaceNode $object
- */
+ /** @param NamespaceNode $object */
public function create(ContextStack $context, object $object, StrategyContainer $strategies): void
{
if (!$this->matches($context, $object)) {
@@ -35,8 +31,8 @@ public function create(ContextStack $context, object $object, StrategyContainer
sprintf(
'%s cannot handle objects with the type %s',
self::class,
- is_object($object) ? get_class($object) : gettype($object)
- )
+ get_debug_type($object),
+ ),
);
}
diff --git a/src/phpDocumentor/Reflection/Php/Factory/Property.php b/src/phpDocumentor/Reflection/Php/Factory/Property.php
index 5c6322bb..1682f5f9 100644
--- a/src/phpDocumentor/Reflection/Php/Factory/Property.php
+++ b/src/phpDocumentor/Reflection/Php/Factory/Property.php
@@ -16,7 +16,6 @@
use phpDocumentor\Reflection\DocBlockFactoryInterface;
use phpDocumentor\Reflection\Location;
use phpDocumentor\Reflection\Php\Class_;
-use phpDocumentor\Reflection\Php\ProjectFactoryStrategy;
use phpDocumentor\Reflection\Php\Property as PropertyDescriptor;
use phpDocumentor\Reflection\Php\StrategyContainer;
use phpDocumentor\Reflection\Php\Trait_;
@@ -31,16 +30,13 @@
* @see PropertyDescriptor
* @see PropertyIterator
*/
-final class Property extends AbstractFactory implements ProjectFactoryStrategy
+final class Property extends AbstractFactory
{
- private PrettyPrinter $valueConverter;
-
/**
* Initializes the object.
*/
- public function __construct(DocBlockFactoryInterface $docBlockFactory, PrettyPrinter $prettyPrinter)
+ public function __construct(DocBlockFactoryInterface $docBlockFactory, private readonly PrettyPrinter $valueConverter)
{
- $this->valueConverter = $prettyPrinter;
parent::__construct($docBlockFactory);
}
@@ -61,15 +57,15 @@ public function matches(ContextStack $context, object $object): bool
protected function doCreate(
ContextStack $context,
object $object,
- StrategyContainer $strategies
- ): ?object {
+ StrategyContainer $strategies,
+ ): object|null {
$propertyContainer = $context->peek();
Assert::isInstanceOfAny(
$propertyContainer,
[
Class_::class,
Trait_::class,
- ]
+ ],
);
$iterator = new PropertyIterator($object);
@@ -89,8 +85,8 @@ protected function doCreate(
new Location($stmt->getLine()),
new Location($stmt->getEndLine()),
(new Type())->fromPhpParser($stmt->getType()),
- $stmt->isReadonly()
- )
+ $stmt->isReadonly(),
+ ),
);
}
diff --git a/src/phpDocumentor/Reflection/Php/Factory/PropertyIterator.php b/src/phpDocumentor/Reflection/Php/Factory/PropertyIterator.php
index 6447c29d..00b58da6 100644
--- a/src/phpDocumentor/Reflection/Php/Factory/PropertyIterator.php
+++ b/src/phpDocumentor/Reflection/Php/Factory/PropertyIterator.php
@@ -30,17 +30,14 @@
*/
final class PropertyIterator implements Iterator
{
- private PropertyNode $property;
-
/** @var int index of the current propertyProperty to use */
private int $index = 0;
/**
* Instantiates this iterator with the propertyNode to iterate.
*/
- public function __construct(PropertyNode $property)
+ public function __construct(private readonly PropertyNode $property)
{
- $this->property = $property;
}
/**
@@ -101,10 +98,8 @@ public function getEndLine(): int
/**
* Gets the type of the property.
- *
- * @return Identifier|Name|ComplexType|null
*/
- public function getType()
+ public function getType(): Identifier|Name|ComplexType|null
{
return $this->property->type;
}
@@ -114,7 +109,7 @@ public function getType()
*
* The doc comment has to be the last comment associated with the node.
*/
- public function getDocComment(): ?Doc
+ public function getDocComment(): Doc|null
{
$docComment = $this->property->props[$this->index]->getDocComment();
if ($docComment === null) {
@@ -134,10 +129,8 @@ public function getName(): string
/**
* returns the default value of the current property.
- *
- * @return string|Expr|null
*/
- public function getDefault()
+ public function getDefault(): string|Expr|null
{
return $this->property->props[$this->index]->default;
}
@@ -150,41 +143,31 @@ public function getFqsen(): Fqsen
return $this->property->props[$this->index]->getAttribute('fqsen');
}
- /**
- * @link http://php.net/manual/en/iterator.current.php
- */
+ /** @link http://php.net/manual/en/iterator.current.php */
public function current(): self
{
return $this;
}
- /**
- * @link http://php.net/manual/en/iterator.next.php
- */
+ /** @link http://php.net/manual/en/iterator.next.php */
public function next(): void
{
++$this->index;
}
- /**
- * @link http://php.net/manual/en/iterator.key.php
- */
- public function key(): ?int
+ /** @link http://php.net/manual/en/iterator.key.php */
+ public function key(): int|null
{
return $this->index;
}
- /**
- * @link http://php.net/manual/en/iterator.valid.php
- */
+ /** @link http://php.net/manual/en/iterator.valid.php */
public function valid(): bool
{
return isset($this->property->props[$this->index]);
}
- /**
- * @link http://php.net/manual/en/iterator.rewind.php
- */
+ /** @link http://php.net/manual/en/iterator.rewind.php */
public function rewind(): void
{
$this->index = 0;
diff --git a/src/phpDocumentor/Reflection/Php/Factory/Reducer/Attribute.php b/src/phpDocumentor/Reflection/Php/Factory/Reducer/Attribute.php
index 78c8c99b..41984f0a 100644
--- a/src/phpDocumentor/Reflection/Php/Factory/Reducer/Attribute.php
+++ b/src/phpDocumentor/Reflection/Php/Factory/Reducer/Attribute.php
@@ -10,19 +10,18 @@
use phpDocumentor\Reflection\Php\CallArgument;
use phpDocumentor\Reflection\Php\Factory\ContextStack;
use phpDocumentor\Reflection\Php\StrategyContainer;
-use PhpParser\Node;
use PhpParser\Node\Arg;
+use PhpParser\Node\AttributeGroup;
use PhpParser\PrettyPrinter\Standard;
use function array_map;
use function assert;
-use function get_class;
use function property_exists;
use function sprintf;
final class Attribute implements Reducer
{
- private Standard $printer;
+ private readonly Standard $printer;
public function __construct()
{
@@ -33,8 +32,8 @@ public function reduce(
ContextStack $context,
object $object,
StrategyContainer $strategies,
- ?object $carry
- ): ?object {
+ object|null $carry,
+ ): object|null {
if ($carry === null) {
return null;
}
@@ -44,17 +43,17 @@ public function reduce(
}
if ($carry instanceof AttributeContainer === false) {
- throw new InvalidArgumentException(sprintf('Attribute can not be added on %s', get_class($carry)));
+ throw new InvalidArgumentException(sprintf('Attribute can not be added on %s', $carry::class));
}
foreach ($object->attrGroups as $attrGroup) {
- assert($attrGroup instanceof Node\AttributeGroup);
+ assert($attrGroup instanceof AttributeGroup);
foreach ($attrGroup->attrs as $attr) {
$carry->addAttribute(
new \phpDocumentor\Reflection\Php\Attribute(
new Fqsen('\\' . $attr->name->toString()),
- array_map([$this, 'buildCallArgument'], $attr->args),
- )
+ array_map($this->buildCallArgument(...), $attr->args),
+ ),
);
}
}
@@ -66,7 +65,7 @@ private function buildCallArgument(Arg $arg): CallArgument
{
return new CallArgument(
$this->printer->prettyPrintExpr($arg->value),
- $arg->name !== null ? $arg->name->toString() : null,
+ $arg->name?->toString(),
);
}
}
diff --git a/src/phpDocumentor/Reflection/Php/Factory/Reducer/Reducer.php b/src/phpDocumentor/Reflection/Php/Factory/Reducer/Reducer.php
index 4d4545b5..aa8321e0 100644
--- a/src/phpDocumentor/Reflection/Php/Factory/Reducer/Reducer.php
+++ b/src/phpDocumentor/Reflection/Php/Factory/Reducer/Reducer.php
@@ -13,6 +13,6 @@ public function reduce(
ContextStack $context,
object $object,
StrategyContainer $strategies,
- ?object $carry
- ): ?object;
+ object|null $carry,
+ ): object|null;
}
diff --git a/src/phpDocumentor/Reflection/Php/Factory/Trait_.php b/src/phpDocumentor/Reflection/Php/Factory/Trait_.php
index 77fcb23b..74624327 100644
--- a/src/phpDocumentor/Reflection/Php/Factory/Trait_.php
+++ b/src/phpDocumentor/Reflection/Php/Factory/Trait_.php
@@ -36,13 +36,13 @@ public function matches(ContextStack $context, object $object): bool
* @param ContextStack $context used to convert nested objects.
* @param TraitNode $object
*/
- protected function doCreate(ContextStack $context, object $object, StrategyContainer $strategies): ?object
+ protected function doCreate(ContextStack $context, object $object, StrategyContainer $strategies): object|null
{
$trait = new TraitElement(
$object->getAttribute('fqsen'),
$this->createDocBlock($object->getDocComment(), $context->getTypeContext()),
new Location($object->getLine()),
- new Location($object->getEndLine())
+ new Location($object->getEndLine()),
);
$file = $context->peek();
diff --git a/src/phpDocumentor/Reflection/Php/Factory/Type.php b/src/phpDocumentor/Reflection/Php/Factory/Type.php
index 3cedf2e1..160f02c6 100644
--- a/src/phpDocumentor/Reflection/Php/Factory/Type.php
+++ b/src/phpDocumentor/Reflection/Php/Factory/Type.php
@@ -26,17 +26,13 @@
use PhpParser\NodeAbstract;
use function array_map;
-use function get_class;
use function implode;
use function is_string;
use function sprintf;
final class Type
{
- /**
- * @param Identifier|Name|ComplexType|null $type
- */
- public function fromPhpParser($type, ?Context $context = null): ?TypeElement
+ public function fromPhpParser(Identifier|Name|ComplexType|null $type, Context|null $context = null): TypeElement|null
{
if ($type === null) {
return null;
@@ -46,10 +42,7 @@ public function fromPhpParser($type, ?Context $context = null): ?TypeElement
->resolve($this->convertPhpParserTypeToString($type), $context);
}
- /**
- * @param NodeAbstract|string $type
- */
- private function convertPhpParserTypeToString($type): string
+ private function convertPhpParserTypeToString(NodeAbstract|string $type): string
{
if (is_string($type)) {
return $type;
@@ -70,7 +63,7 @@ private function convertPhpParserTypeToString($type): string
if ($type instanceof UnionType) {
$typesAsStrings = array_map(
fn ($typeObject): string => $this->convertPhpParserTypeToString($typeObject),
- $type->types
+ $type->types,
);
return implode('|', $typesAsStrings);
@@ -79,12 +72,12 @@ private function convertPhpParserTypeToString($type): string
if ($type instanceof IntersectionType) {
$typesAsStrings = array_map(
fn ($typeObject): string => $this->convertPhpParserTypeToString($typeObject),
- $type->types
+ $type->types,
);
return implode('&', $typesAsStrings);
}
- throw new InvalidArgumentException(sprintf('Unsupported complex type %s', get_class($type)));
+ throw new InvalidArgumentException(sprintf('Unsupported complex type %s', $type::class));
}
}
diff --git a/src/phpDocumentor/Reflection/Php/File.php b/src/phpDocumentor/Reflection/Php/File.php
index 0cac87db..9ef2702c 100644
--- a/src/phpDocumentor/Reflection/Php/File.php
+++ b/src/phpDocumentor/Reflection/Php/File.php
@@ -26,15 +26,7 @@ final class File implements MetaDataContainerInterface
{
use MetadataContainer;
- private ?DocBlock $docBlock = null;
-
- private string $hash;
-
- private string $name;
-
- private string $path;
-
- private string $source;
+ private readonly string $name;
/** @var Fqsen[] */
private array $namespaces = [];
@@ -65,13 +57,9 @@ final class File implements MetaDataContainerInterface
*
* @param string $hash An MD5 hash of the contents if this file.
*/
- public function __construct(string $hash, string $path, string $source = '', ?DocBlock $docBlock = null)
+ public function __construct(private readonly string $hash, private readonly string $path, private readonly string $source = '', private readonly DocBlock|null $docBlock = null)
{
- $this->hash = $hash;
- $this->path = $path;
- $this->name = basename($path);
- $this->source = $source;
- $this->docBlock = $docBlock;
+ $this->name = basename($path);
}
/**
@@ -239,7 +227,7 @@ public function getPath(): string
/**
* Returns the DocBlock of the element if available
*/
- public function getDocBlock(): ?DocBlock
+ public function getDocBlock(): DocBlock|null
{
return $this->docBlock;
}
diff --git a/src/phpDocumentor/Reflection/Php/Function_.php b/src/phpDocumentor/Reflection/Php/Function_.php
index 49312107..21bca78d 100644
--- a/src/phpDocumentor/Reflection/Php/Function_.php
+++ b/src/phpDocumentor/Reflection/Php/Function_.php
@@ -31,32 +31,26 @@ final class Function_ implements Element, MetaDataContainerInterface, AttributeC
use MetadataContainer;
use HasAttributes;
- /** @var Fqsen Full Qualified Structural Element Name */
- private Fqsen $fqsen;
-
/** @var Argument[] */
private array $arguments = [];
- private ?DocBlock $docBlock;
-
- private Location $location;
-
- private Location $endLocation;
+ private readonly Location $location;
- private Type $returnType;
+ private readonly Location $endLocation;
- private bool $hasReturnByReference;
+ private readonly Type $returnType;
/**
* Initializes the object.
*/
public function __construct(
- Fqsen $fqsen,
- ?DocBlock $docBlock = null,
- ?Location $location = null,
- ?Location $endLocation = null,
- ?Type $returnType = null,
- bool $hasReturnByReference = false
+ /** @var Fqsen Full Qualified Structural Element Name */
+ private readonly Fqsen $fqsen,
+ private readonly DocBlock|null $docBlock = null,
+ Location|null $location = null,
+ Location|null $endLocation = null,
+ Type|null $returnType = null,
+ private readonly bool $hasReturnByReference = false,
) {
if ($location === null) {
$location = new Location(-1);
@@ -70,12 +64,9 @@ public function __construct(
$returnType = new Mixed_();
}
- $this->fqsen = $fqsen;
- $this->docBlock = $docBlock;
$this->location = $location;
$this->endLocation = $endLocation;
$this->returnType = $returnType;
- $this->hasReturnByReference = $hasReturnByReference;
}
/**
@@ -115,7 +106,7 @@ public function getName(): string
/**
* Returns the DocBlock of the element if available
*/
- public function getDocBlock(): ?DocBlock
+ public function getDocBlock(): DocBlock|null
{
return $this->docBlock;
}
diff --git a/src/phpDocumentor/Reflection/Php/HasAttributes.php b/src/phpDocumentor/Reflection/Php/HasAttributes.php
index dbbaf0f4..413f64b6 100644
--- a/src/phpDocumentor/Reflection/Php/HasAttributes.php
+++ b/src/phpDocumentor/Reflection/Php/HasAttributes.php
@@ -14,9 +14,7 @@ public function addAttribute(Attribute $attribute): void
$this->attributes[] = $attribute;
}
- /**
- * @return Attribute[]
- */
+ /** @return Attribute[] */
public function getAttributes(): array
{
return $this->attributes;
diff --git a/src/phpDocumentor/Reflection/Php/Interface_.php b/src/phpDocumentor/Reflection/Php/Interface_.php
index 75881d3c..f05f8ab8 100644
--- a/src/phpDocumentor/Reflection/Php/Interface_.php
+++ b/src/phpDocumentor/Reflection/Php/Interface_.php
@@ -28,23 +28,15 @@ final class Interface_ implements Element, MetaDataContainerInterface, Attribute
use MetadataContainer;
use HasAttributes;
- /** @var Fqsen Full Qualified Structural Element Name */
- private Fqsen $fqsen;
-
- private ?DocBlock $docBlock;
-
/** @var Constant[] */
private array $constants = [];
/** @var Method[] */
private array $methods = [];
- /** @var Fqsen[] */
- private array $parents = [];
+ private readonly Location $location;
- private Location $location;
-
- private Location $endLocation;
+ private readonly Location $endLocation;
/**
* Initializes the object.
@@ -52,17 +44,14 @@ final class Interface_ implements Element, MetaDataContainerInterface, Attribute
* @param Fqsen[] $parents
*/
public function __construct(
- Fqsen $fqsen,
- array $parents = [],
- ?DocBlock $docBlock = null,
- ?Location $location = null,
- ?Location $endLocation = null
+ /** @var Fqsen Full Qualified Structural Element Name */
+ private readonly Fqsen $fqsen,
+ private array $parents = [],
+ private readonly DocBlock|null $docBlock = null,
+ Location|null $location = null,
+ Location|null $endLocation = null,
) {
Assert::allIsInstanceOf($parents, Fqsen::class);
-
- $this->fqsen = $fqsen;
- $this->docBlock = $docBlock;
- $this->parents = $parents;
$this->location = $location ?: new Location(-1);
$this->endLocation = $endLocation ?: new Location(-1);
}
@@ -122,7 +111,7 @@ public function getName(): string
/**
* Returns the DocBlock of this interface if available.
*/
- public function getDocBlock(): ?DocBlock
+ public function getDocBlock(): DocBlock|null
{
return $this->docBlock;
}
diff --git a/src/phpDocumentor/Reflection/Php/MetadataContainer.php b/src/phpDocumentor/Reflection/Php/MetadataContainer.php
index aed79777..e0f624e2 100644
--- a/src/phpDocumentor/Reflection/Php/MetadataContainer.php
+++ b/src/phpDocumentor/Reflection/Php/MetadataContainer.php
@@ -25,9 +25,7 @@ trait MetadataContainer
/** @var Metadata[] */
private array $metadata = [];
- /**
- * @throws Exception When metadata key already exists.
- */
+ /** @throws Exception When metadata key already exists. */
public function addMetadata(Metadata $metadata): void
{
if (array_key_exists($metadata->key(), $this->metadata)) {
diff --git a/src/phpDocumentor/Reflection/Php/Method.php b/src/phpDocumentor/Reflection/Php/Method.php
index b11e6c9e..be206c1e 100644
--- a/src/phpDocumentor/Reflection/Php/Method.php
+++ b/src/phpDocumentor/Reflection/Php/Method.php
@@ -29,31 +29,14 @@ final class Method implements Element, MetaDataContainerInterface, AttributeCont
use MetadataContainer;
use HasAttributes;
- /** @var DocBlock|null documentation of this method. */
- private ?DocBlock $docBlock = null;
-
- /** @var Fqsen Full Qualified Structural Element Name */
- private Fqsen $fqsen;
-
- private bool $abstract = false;
-
- private bool $final = false;
-
- private bool $static = false;
-
- /** @var Visibility|null visibility of this method */
- private ?Visibility $visibility = null;
-
/** @var Argument[] */
private array $arguments = [];
- private Location $location;
+ private readonly Location $location;
- private Location $endLocation;
+ private readonly Location $endLocation;
- private Type $returnType;
-
- private bool $hasReturnByReference;
+ private readonly Type $returnType;
/**
* Initializes the all properties.
@@ -61,21 +44,19 @@ final class Method implements Element, MetaDataContainerInterface, AttributeCont
* @param Visibility|null $visibility when null is provided a default 'public' is set.
*/
public function __construct(
- Fqsen $fqsen,
- ?Visibility $visibility = null,
- ?DocBlock $docBlock = null,
- bool $abstract = false,
- bool $static = false,
- bool $final = false,
- ?Location $location = null,
- ?Location $endLocation = null,
- ?Type $returnType = null,
- bool $hasReturnByReference = false
+ /** @var Fqsen Full Qualified Structural Element Name */
+ private readonly Fqsen $fqsen,
+ private Visibility|null $visibility = null,
+ /** @var DocBlock|null documentation of this method. */
+ private readonly DocBlock|null $docBlock = null,
+ private readonly bool $abstract = false,
+ private readonly bool $static = false,
+ private readonly bool $final = false,
+ Location|null $location = null,
+ Location|null $endLocation = null,
+ Type|null $returnType = null,
+ private readonly bool $hasReturnByReference = false,
) {
- $this->fqsen = $fqsen;
- $this->visibility = $visibility;
- $this->docBlock = $docBlock;
-
if ($this->visibility === null) {
$this->visibility = new Visibility('public');
}
@@ -92,13 +73,9 @@ public function __construct(
$returnType = new Mixed_();
}
- $this->abstract = $abstract;
- $this->static = $static;
- $this->final = $final;
$this->location = $location;
$this->endLocation = $endLocation;
$this->returnType = $returnType;
- $this->hasReturnByReference = $hasReturnByReference;
}
/**
@@ -128,7 +105,7 @@ public function isStatic(): bool
/**
* Returns the Visibility of this method.
*/
- public function getVisibility(): ?Visibility
+ public function getVisibility(): Visibility|null
{
return $this->visibility;
}
@@ -170,7 +147,7 @@ public function getName(): string
/**
* Returns the DocBlock of this method if available.
*/
- public function getDocBlock(): ?DocBlock
+ public function getDocBlock(): DocBlock|null
{
return $this->docBlock;
}
diff --git a/src/phpDocumentor/Reflection/Php/Namespace_.php b/src/phpDocumentor/Reflection/Php/Namespace_.php
index 04cbc400..97f048e9 100644
--- a/src/phpDocumentor/Reflection/Php/Namespace_.php
+++ b/src/phpDocumentor/Reflection/Php/Namespace_.php
@@ -26,11 +26,6 @@ final class Namespace_ implements Element, MetaDataContainerInterface
{
use MetadataContainer;
- /**
- * @var Fqsen Full Qualified Structural Element Name
- */
- private Fqsen $fqsen;
-
/**
* @var Fqsen[] fqsen of all functions in this namespace
*/
@@ -59,9 +54,13 @@ final class Namespace_ implements Element, MetaDataContainerInterface
/**
* Initializes the namespace.
*/
- public function __construct(Fqsen $fqsen)
+ public function __construct(
+ /**
+ * @var Fqsen Full Qualified Structural Element Name
+ */
+ private readonly Fqsen $fqsen
+ )
{
- $this->fqsen = $fqsen;
}
/**
diff --git a/src/phpDocumentor/Reflection/Php/NodesFactory.php b/src/phpDocumentor/Reflection/Php/NodesFactory.php
index 3e270cd2..887fe204 100644
--- a/src/phpDocumentor/Reflection/Php/NodesFactory.php
+++ b/src/phpDocumentor/Reflection/Php/NodesFactory.php
@@ -30,24 +30,12 @@
*/
class NodesFactory
{
- /**
- * Parser used to parse the code to nodes.
- */
- private Parser $parser;
-
- /**
- * Containing a number of visitors to do some post processing steps on nodes.
- */
- private NodeTraverserInterface $traverser;
-
/**
* @param Parser $parser used to parse the code
* @param NodeTraverserInterface $traverser used to do some post processing on the nodes
*/
- final public function __construct(Parser $parser, NodeTraverserInterface $traverser)
+ final public function __construct(private readonly Parser $parser, private readonly NodeTraverserInterface $traverser)
{
- $this->parser = $parser;
- $this->traverser = $traverser;
}
/**
diff --git a/src/phpDocumentor/Reflection/Php/Project.php b/src/phpDocumentor/Reflection/Php/Project.php
index 73b330c9..9a3bc48b 100644
--- a/src/phpDocumentor/Reflection/Php/Project.php
+++ b/src/phpDocumentor/Reflection/Php/Project.php
@@ -21,10 +21,6 @@
*/
final class Project implements ProjectInterface
{
- private string $name = '';
-
- private ?Namespace_ $rootNamespace;
-
/** @var File[] */
private array $files = [];
@@ -35,12 +31,10 @@ final class Project implements ProjectInterface
* Initializes this descriptor.
*
* @param string $name Name of the current project.
- * @param Namespace_|null $namespace Root namespace of the project.
+ * @param Namespace_|null $rootNamespace Root namespace of the project.
*/
- public function __construct(string $name, ?Namespace_ $namespace = null)
+ public function __construct(private readonly string $name, private Namespace_|null $rootNamespace = null)
{
- $this->name = $name;
- $this->rootNamespace = $namespace;
if ($this->rootNamespace !== null) {
return;
}
@@ -95,7 +89,7 @@ public function addNamespace(Namespace_ $namespace): void
/**
* Returns the root (global) namespace.
*/
- public function getRootNamespace(): ?Namespace_
+ public function getRootNamespace(): Namespace_|null
{
return $this->rootNamespace;
}
diff --git a/src/phpDocumentor/Reflection/Php/ProjectFactory.php b/src/phpDocumentor/Reflection/Php/ProjectFactory.php
index fa35a1d8..6731ef9c 100644
--- a/src/phpDocumentor/Reflection/Php/ProjectFactory.php
+++ b/src/phpDocumentor/Reflection/Php/ProjectFactory.php
@@ -48,14 +48,14 @@
*/
final class ProjectFactory implements ProjectFactoryInterface
{
- private ProjectFactoryStrategies $strategies;
+ private readonly ProjectFactoryStrategies $strategies;
/**
* Initializes the factory with a number of strategies.
*
* @param ProjectFactoryStrategy[]|ProjectFactoryStrategies $strategies
*/
- public function __construct($strategies)
+ public function __construct(array|ProjectFactoryStrategies $strategies)
{
$this->strategies = is_array($strategies) ? new ProjectFactoryStrategies($strategies) : $strategies;
}
@@ -88,23 +88,23 @@ public static function createInstance(): self
new IfStatement(),
new TraitUse(),
- ]
+ ],
);
$strategies->addStrategy(
new ConstructorPromotion($methodStrategy, $docblockFactory, new PrettyPrinter()),
- 1100
+ 1100,
);
$strategies->addStrategy(new Noop(), -PHP_INT_MAX);
return new static(
- $strategies
+ $strategies,
);
}
public function addStrategy(
ProjectFactoryStrategy $strategy,
- int $priority = ProjectFactoryStrategies::DEFAULT_PRIORITY
+ int $priority = ProjectFactoryStrategies::DEFAULT_PRIORITY,
): void {
$this->strategies->addStrategy($strategy, $priority);
}
diff --git a/src/phpDocumentor/Reflection/Php/ProjectFactoryStrategies.php b/src/phpDocumentor/Reflection/Php/ProjectFactoryStrategies.php
index a4bcf1af..a434e3a3 100644
--- a/src/phpDocumentor/Reflection/Php/ProjectFactoryStrategies.php
+++ b/src/phpDocumentor/Reflection/Php/ProjectFactoryStrategies.php
@@ -17,9 +17,7 @@
use phpDocumentor\Reflection\Php\Factory\ContextStack;
use SplPriorityQueue;
-use function get_class;
-use function is_object;
-use function print_r;
+use function get_debug_type;
use function sprintf;
final class ProjectFactoryStrategies implements StrategyContainer
@@ -27,7 +25,7 @@ final class ProjectFactoryStrategies implements StrategyContainer
public const DEFAULT_PRIORITY = 1000;
/** @var SplPriorityQueue */
- private SplPriorityQueue $strategies;
+ private readonly SplPriorityQueue $strategies;
/**
* Initializes the factory with a number of strategies.
@@ -45,11 +43,9 @@ public function __construct(array $strategies)
/**
* Find the ProjectFactoryStrategy that matches $object.
*
- * @param mixed $object
- *
* @throws OutOfBoundsException When no matching strategy was found.
*/
- public function findMatching(ContextStack $context, $object): ProjectFactoryStrategy
+ public function findMatching(ContextStack $context, mixed $object): ProjectFactoryStrategy
{
foreach (clone $this->strategies as $strategy) {
if ($strategy->matches($context, $object)) {
@@ -60,8 +56,8 @@ public function findMatching(ContextStack $context, $object): ProjectFactoryStra
throw new OutOfBoundsException(
sprintf(
'No matching factory found for %s',
- is_object($object) ? get_class($object) : print_r($object, true)
- )
+ get_debug_type($object),
+ ),
);
}
diff --git a/src/phpDocumentor/Reflection/Php/Property.php b/src/phpDocumentor/Reflection/Php/Property.php
index b5719457..0013de93 100644
--- a/src/phpDocumentor/Reflection/Php/Property.php
+++ b/src/phpDocumentor/Reflection/Php/Property.php
@@ -28,56 +28,36 @@ final class Property implements Element, MetaDataContainerInterface, AttributeCo
use MetadataContainer;
use HasAttributes;
- private Fqsen $fqsen;
-
- private ?DocBlock $docBlock;
-
/** @var string[] $types */
private array $types = [];
- private ?string $default = null;
-
- private bool $static = false;
-
- private ?Visibility $visibility = null;
+ private Visibility|null $visibility = null;
- private Location $location;
+ private readonly Location $location;
- private Location $endLocation;
+ private readonly Location $endLocation;
- private ?Type $type;
-
- private bool $readOnly;
-
- /**
- * @param Visibility|null $visibility when null is provided a default 'public' is set.
- */
+ /** @param Visibility|null $visibility when null is provided a default 'public' is set. */
public function __construct(
- Fqsen $fqsen,
- ?Visibility $visibility = null,
- ?DocBlock $docBlock = null,
- ?string $default = null,
- bool $static = false,
- ?Location $location = null,
- ?Location $endLocation = null,
- ?Type $type = null,
- bool $readOnly = false
+ private readonly Fqsen $fqsen,
+ Visibility|null $visibility = null,
+ private readonly DocBlock|null $docBlock = null,
+ private readonly string|null $default = null,
+ private readonly bool $static = false,
+ Location|null $location = null,
+ Location|null $endLocation = null,
+ private readonly Type|null $type = null,
+ private readonly bool $readOnly = false,
) {
- $this->fqsen = $fqsen;
$this->visibility = $visibility ?: new Visibility('public');
- $this->docBlock = $docBlock;
- $this->default = $default;
- $this->static = $static;
$this->location = $location ?: new Location(-1);
$this->endLocation = $endLocation ?: new Location(-1);
- $this->type = $type;
- $this->readOnly = $readOnly;
}
/**
* returns the default value of this property.
*/
- public function getDefault(): ?string
+ public function getDefault(): string|null
{
return $this->default;
}
@@ -111,7 +91,7 @@ public function addType(string $type): void
/**
* Return visibility of the property.
*/
- public function getVisibility(): ?Visibility
+ public function getVisibility(): Visibility|null
{
return $this->visibility;
}
@@ -135,7 +115,7 @@ public function getName(): string
/**
* Returns the DocBlock of this property.
*/
- public function getDocBlock(): ?DocBlock
+ public function getDocBlock(): DocBlock|null
{
return $this->docBlock;
}
@@ -150,7 +130,7 @@ public function getEndLocation(): Location
return $this->endLocation;
}
- public function getType(): ?Type
+ public function getType(): Type|null
{
return $this->type;
}
diff --git a/src/phpDocumentor/Reflection/Php/StrategyContainer.php b/src/phpDocumentor/Reflection/Php/StrategyContainer.php
index ff8422c7..5ca89ed3 100644
--- a/src/phpDocumentor/Reflection/Php/StrategyContainer.php
+++ b/src/phpDocumentor/Reflection/Php/StrategyContainer.php
@@ -24,9 +24,7 @@ interface StrategyContainer
/**
* Find the ProjectFactoryStrategy that matches $object.
*
- * @param mixed $object
- *
* @throws Exception When no matching strategy was found.
*/
- public function findMatching(ContextStack $context, $object): ProjectFactoryStrategy;
+ public function findMatching(ContextStack $context, mixed $object): ProjectFactoryStrategy;
}
diff --git a/src/phpDocumentor/Reflection/Php/Trait_.php b/src/phpDocumentor/Reflection/Php/Trait_.php
index c89e802b..91fe3747 100644
--- a/src/phpDocumentor/Reflection/Php/Trait_.php
+++ b/src/phpDocumentor/Reflection/Php/Trait_.php
@@ -27,11 +27,6 @@ final class Trait_ implements Element, MetaDataContainerInterface, AttributeCont
use MetadataContainer;
use HasAttributes;
- /** @var Fqsen Full Qualified Structural Element Name */
- private Fqsen $fqsen;
-
- private ?DocBlock $docBlock;
-
/** @var Property[] $properties */
private array $properties = [];
@@ -41,9 +36,9 @@ final class Trait_ implements Element, MetaDataContainerInterface, AttributeCont
/** @var Fqsen[] $usedTraits References to traits consumed by this trait */
private array $usedTraits = [];
- private Location $location;
+ private readonly Location $location;
- private Location $endLocation;
+ private readonly Location $endLocation;
/** @var Constant[] */
private array $constants = [];
@@ -52,10 +47,11 @@ final class Trait_ implements Element, MetaDataContainerInterface, AttributeCont
* Initializes the all properties
*/
public function __construct(
- Fqsen $fqsen,
- ?DocBlock $docBlock = null,
- ?Location $location = null,
- ?Location $endLocation = null
+ /** @var Fqsen Full Qualified Structural Element Name */
+ private readonly Fqsen $fqsen,
+ private readonly DocBlock|null $docBlock = null,
+ Location|null $location = null,
+ Location|null $endLocation = null,
) {
if ($location === null) {
$location = new Location(-1);
@@ -65,8 +61,6 @@ public function __construct(
$endLocation = new Location(-1);
}
- $this->fqsen = $fqsen;
- $this->docBlock = $docBlock;
$this->location = $location;
$this->endLocation = $endLocation;
}
@@ -123,7 +117,7 @@ public function getName(): string
return $this->fqsen->getName();
}
- public function getDocBlock(): ?DocBlock
+ public function getDocBlock(): DocBlock|null
{
return $this->docBlock;
}
diff --git a/src/phpDocumentor/Reflection/Php/ValueEvaluator/ConstantEvaluator.php b/src/phpDocumentor/Reflection/Php/ValueEvaluator/ConstantEvaluator.php
index d10747e0..02834ea1 100644
--- a/src/phpDocumentor/Reflection/Php/ValueEvaluator/ConstantEvaluator.php
+++ b/src/phpDocumentor/Reflection/Php/ValueEvaluator/ConstantEvaluator.php
@@ -12,9 +12,7 @@
use function sprintf;
-/**
- * @internal
- */
+/** @internal */
final class ConstantEvaluator
{
/** @throws ConstExprEvaluationException */
@@ -33,7 +31,7 @@ private function evaluateFallback(Expr $expr, ContextStack $contextStack): strin
$typeContext = $contextStack->getTypeContext();
if ($typeContext === null) {
throw new ConstExprEvaluationException(
- sprintf('Expression of type %s cannot be evaluated', $expr->getType())
+ sprintf('Expression of type %s cannot be evaluated', $expr->getType()),
);
}
@@ -42,7 +40,7 @@ private function evaluateFallback(Expr $expr, ContextStack $contextStack): strin
}
throw new ConstExprEvaluationException(
- sprintf('Expression of type %s cannot be evaluated', $expr->getType())
+ sprintf('Expression of type %s cannot be evaluated', $expr->getType()),
);
}
}
diff --git a/src/phpDocumentor/Reflection/Php/Visibility.php b/src/phpDocumentor/Reflection/Php/Visibility.php
index db793c15..6b1e3e4b 100644
--- a/src/phpDocumentor/Reflection/Php/Visibility.php
+++ b/src/phpDocumentor/Reflection/Php/Visibility.php
@@ -14,6 +14,7 @@
namespace phpDocumentor\Reflection\Php;
use InvalidArgumentException;
+use Stringable;
use function sprintf;
use function strtolower;
@@ -21,7 +22,7 @@
/**
* Value object for visibility values of classes, properties, ect.
*/
-final class Visibility
+final class Visibility implements Stringable
{
/**
* constant for protected visibility
@@ -39,7 +40,7 @@ final class Visibility
public const PRIVATE_ = 'private';
/** @var string value can be public, protected or private */
- private string $visibility;
+ private readonly string $visibility;
/**
* Initializes the object.
@@ -52,7 +53,7 @@ public function __construct(string $visibility)
if ($visibility !== self::PUBLIC_ && $visibility !== self::PROTECTED_ && $visibility !== self::PRIVATE_) {
throw new InvalidArgumentException(
- sprintf('""%s" is not a valid visibility value.', $visibility)
+ sprintf('""%s" is not a valid visibility value.', $visibility),
);
}
diff --git a/src/phpDocumentor/Reflection/Types/NamespaceNodeToContext.php b/src/phpDocumentor/Reflection/Types/NamespaceNodeToContext.php
index b6d3b316..f4c78f70 100644
--- a/src/phpDocumentor/Reflection/Types/NamespaceNodeToContext.php
+++ b/src/phpDocumentor/Reflection/Types/NamespaceNodeToContext.php
@@ -17,7 +17,7 @@
class NamespaceNodeToContext
{
- public function __invoke(?Namespace_ $namespace): Context
+ public function __invoke(Namespace_|null $namespace): Context
{
if (!$namespace) {
return new Context('');
@@ -25,32 +25,26 @@ public function __invoke(?Namespace_ $namespace): Context
return new Context(
$namespace->name ? $namespace->name->toString() : '',
- $this->aliasesToFullyQualifiedNames($namespace)
+ $this->aliasesToFullyQualifiedNames($namespace),
);
}
- /**
- * @return string[] indexed by alias
- */
+ /** @return string[] indexed by alias */
private function aliasesToFullyQualifiedNames(Namespace_ $namespace): array
{
// flatten(flatten(map(stuff)))
- return array_merge([], ...array_merge([], ...array_map(static function ($use): array {
- return array_map(static function (UseUse $useUse) use ($use): array {
- if ($use instanceof GroupUse) {
- return [
- (string) $useUse->getAlias() => $use->prefix->toString() . '\\' . $useUse->name->toString(),
- ];
- }
-
- return [(string) $useUse->getAlias() => $useUse->name->toString()];
- }, $use->uses);
- }, $this->classAlikeUses($namespace))));
+ return array_merge([], ...array_merge([], ...array_map(static fn ($use): array => array_map(static function (UseUse $useUse) use ($use): array {
+ if ($use instanceof GroupUse) {
+ return [
+ (string) $useUse->getAlias() => $use->prefix->toString() . '\\' . $useUse->name->toString(),
+ ];
+ }
+
+ return [(string) $useUse->getAlias() => $useUse->name->toString()];
+ }, $use->uses), $this->classAlikeUses($namespace))));
}
- /**
- * @return Use_[]|GroupUse[]
- */
+ /** @return Use_[]|GroupUse[] */
private function classAlikeUses(Namespace_ $namespace): array
{
return array_filter(
diff --git a/tests/unit/phpDocumentor/Reflection/File/LocalFileTest.php b/tests/unit/phpDocumentor/Reflection/File/LocalFileTest.php
index 93e5dc85..05cd23a1 100644
--- a/tests/unit/phpDocumentor/Reflection/File/LocalFileTest.php
+++ b/tests/unit/phpDocumentor/Reflection/File/LocalFileTest.php
@@ -24,36 +24,28 @@
*/
class LocalFileTest extends TestCase
{
- /**
- * @covers ::getContents
- */
+ /** @covers ::getContents */
public function testGetContents(): void
{
$file = new LocalFile(__FILE__);
$this->assertStringEqualsFile(__FILE__, $file->getContents());
}
- /**
- * @covers ::md5
- */
+ /** @covers ::md5 */
public function testMd5(): void
{
$file = new LocalFile(__FILE__);
$this->assertEquals(md5_file(__FILE__), $file->md5());
}
- /**
- * @covers ::__construct
- */
+ /** @covers ::__construct */
public function testNotExistingFileThrowsException(): void
{
$this->expectException(InvalidArgumentException::class);
new LocalFile('aa');
}
- /**
- * @covers ::path
- */
+ /** @covers ::path */
public function testPath(): void
{
$file = new LocalFile(__FILE__);
diff --git a/tests/unit/phpDocumentor/Reflection/Middleware/ChainFactoryTest.php b/tests/unit/phpDocumentor/Reflection/Middleware/ChainFactoryTest.php
index ff90cfb2..7a7e68f2 100644
--- a/tests/unit/phpDocumentor/Reflection/Middleware/ChainFactoryTest.php
+++ b/tests/unit/phpDocumentor/Reflection/Middleware/ChainFactoryTest.php
@@ -23,9 +23,7 @@
*/
final class ChainFactoryTest extends TestCase
{
- /**
- * @covers ::createExecutionChain
- */
+ /** @covers ::createExecutionChain */
public function testItCreatesAChainOfCallablesThatWillInvokeAllMiddlewares(): void
{
$exampleCommand = new class implements Command {
@@ -41,21 +39,19 @@ static function (): stdClass {
$result->counter = 'a';
return $result;
- }
+ },
);
$this->assertInstanceOf(stdClass::class, $chain(new $exampleCommand()));
$this->assertSame('abc', $chain(new $exampleCommand())->counter);
}
- /**
- * @covers ::createExecutionChain
- */
+ /** @covers ::createExecutionChain */
public function testItThrowsAnExceptionIfAnythingOtherThanAMiddlewareIsPassed(): void
{
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage(
- 'Middleware must be an instance of phpDocumentor\Reflection\Middleware\Middleware but string was given'
+ 'Middleware must be an instance of phpDocumentor\Reflection\Middleware\Middleware but string was given',
);
$middleware = '1';
@@ -68,11 +64,8 @@ public function testItThrowsAnExceptionIfAnythingOtherThanAMiddlewareIsPassed():
private function givenAMiddleware(string $exampleValue): Middleware
{
return new class ($exampleValue) implements Middleware {
- private string $exampleAddedValue;
-
- public function __construct(string $exampleAddedValue)
+ public function __construct(private readonly string $exampleAddedValue)
{
- $this->exampleAddedValue = $exampleAddedValue;
}
public function execute(Command $command, callable $next): object
diff --git a/tests/unit/phpDocumentor/Reflection/NodeVisitor/ElementNameResolverTest.php b/tests/unit/phpDocumentor/Reflection/NodeVisitor/ElementNameResolverTest.php
index 295ff4bd..f5118305 100644
--- a/tests/unit/phpDocumentor/Reflection/NodeVisitor/ElementNameResolverTest.php
+++ b/tests/unit/phpDocumentor/Reflection/NodeVisitor/ElementNameResolverTest.php
@@ -44,9 +44,7 @@ protected function setUp(): void
$this->fixture->beforeTraverse([]);
}
- /**
- * @covers ::enterNode
- */
+ /** @covers ::enterNode */
public function testFunctionWithoutNamespace(): void
{
$function = new Function_('myFunction');
@@ -55,9 +53,7 @@ public function testFunctionWithoutNamespace(): void
$this->assertEquals('\myFunction()', (string) $function->fqsen);
}
- /**
- * @covers ::enterNode
- */
+ /** @covers ::enterNode */
public function testWithClass(): void
{
$class = new Class_('myClass');
@@ -66,9 +62,7 @@ public function testWithClass(): void
$this->assertEquals('\myClass', (string) $class->fqsen);
}
- /**
- * @covers ::enterNode
- */
+ /** @covers ::enterNode */
public function testWithClassMethod(): void
{
$class = new Class_('myClass');
@@ -80,9 +74,7 @@ public function testWithClassMethod(): void
$this->assertEquals('\myClass::method()', (string) $method->fqsen);
}
- /**
- * @covers ::enterNode
- */
+ /** @covers ::enterNode */
public function testWithClassProperty(): void
{
$class = new Class_('myClass');
@@ -105,7 +97,7 @@ public function testDoesNotEnterAnonymousClass(): void
$class = new Class_(null);
$this->assertEquals(
NodeTraverser::DONT_TRAVERSE_CHILDREN,
- $this->fixture->enterNode($class)
+ $this->fixture->enterNode($class),
);
}
@@ -133,9 +125,7 @@ public function testAnonymousClassDoesNotPopParts(): void
$this->assertTrue(true);
}
- /**
- * @covers ::enterNode
- */
+ /** @covers ::enterNode */
public function testClassConstant(): void
{
$const = new Const_('MY_CLASS', new String_('value'));
@@ -149,9 +139,7 @@ public function testClassConstant(): void
$this->assertEquals('\\myClass::MY_CLASS', (string) $const->fqsen);
}
- /**
- * @covers ::enterNode
- */
+ /** @covers ::enterNode */
public function testNamespacedConstant(): void
{
$const = new Const_('MY_CLASS', new String_('value'));
@@ -163,9 +151,7 @@ public function testNamespacedConstant(): void
$this->assertEquals('\\name\\MY_CLASS', (string) $const->fqsen);
}
- /**
- * @covers ::enterNode
- */
+ /** @covers ::enterNode */
public function testNoNameNamespace(): void
{
$const = new Const_('MY_CLASS', new String_('value'));
@@ -177,9 +163,7 @@ public function testNoNameNamespace(): void
$this->assertEquals('\\MY_CLASS', (string) $const->fqsen);
}
- /**
- * @covers ::enterNode
- */
+ /** @covers ::enterNode */
public function testWithEnumWithCase(): void
{
$enum = new Enum_('myEnum');
diff --git a/tests/unit/phpDocumentor/Reflection/Php/ArgumentTest.php b/tests/unit/phpDocumentor/Reflection/Php/ArgumentTest.php
index 38478a10..14696997 100644
--- a/tests/unit/phpDocumentor/Reflection/Php/ArgumentTest.php
+++ b/tests/unit/phpDocumentor/Reflection/Php/ArgumentTest.php
@@ -27,9 +27,7 @@
*/
final class ArgumentTest extends TestCase
{
- /**
- * @covers ::getType
- */
+ /** @covers ::getType */
public function testGetTypes(): void
{
$argument = new Argument('myArgument', null, 'myDefaultValue', true, true);
@@ -40,23 +38,19 @@ public function testGetTypes(): void
new String_(),
'myDefaultValue',
true,
- true
+ true,
);
$this->assertEquals(new String_(), $argument->getType());
}
- /**
- * @covers ::getName
- */
+ /** @covers ::getName */
public function testGetName(): void
{
$argument = new Argument('myArgument', null, 'myDefault', true, true);
$this->assertEquals('myArgument', $argument->getName());
}
- /**
- * @covers ::getDefault
- */
+ /** @covers ::getDefault */
public function testGetDefault(): void
{
$argument = new Argument('myArgument', null, 'myDefaultValue', true, true);
@@ -66,9 +60,7 @@ public function testGetDefault(): void
$this->assertNull($argument->getDefault());
}
- /**
- * @covers ::isByReference
- */
+ /** @covers ::isByReference */
public function testGetWhetherArgumentIsPassedByReference(): void
{
$argument = new Argument('myArgument', null, 'myDefaultValue', true, true);
@@ -78,9 +70,7 @@ public function testGetWhetherArgumentIsPassedByReference(): void
$this->assertFalse($argument->isByReference());
}
- /**
- * @covers ::isVariadic
- */
+ /** @covers ::isVariadic */
public function testGetWhetherArgumentisVariadic(): void
{
$argument = new Argument('myArgument', null, 'myDefaultValue', true, true);
diff --git a/tests/unit/phpDocumentor/Reflection/Php/Class_Test.php b/tests/unit/phpDocumentor/Reflection/Php/Class_Test.php
index 29513963..a139b2e4 100644
--- a/tests/unit/phpDocumentor/Reflection/Php/Class_Test.php
+++ b/tests/unit/phpDocumentor/Reflection/Php/Class_Test.php
@@ -58,33 +58,25 @@ private function getFixture(): MetaDataContainerInterface
return $this->fixture;
}
- /**
- * @covers ::getName
- */
+ /** @covers ::getName */
public function testGettingName(): void
{
$this->assertSame($this->fqsen->getName(), $this->fixture->getName());
}
- /**
- * @covers ::getFqsen
- */
+ /** @covers ::getFqsen */
public function testGettingFqsen(): void
{
$this->assertSame($this->fqsen, $this->fixture->getFqsen());
}
- /**
- * @covers ::getDocBlock
- */
+ /** @covers ::getDocBlock */
public function testGettingDocBlock(): void
{
$this->assertSame($this->docBlock, $this->fixture->getDocBlock());
}
- /**
- * @covers ::getParent
- */
+ /** @covers ::getParent */
public function testGettingParent(): void
{
$class = new Class_($this->fqsen, $this->docBlock);
@@ -169,9 +161,7 @@ public function testAddAndGettingUsedTrait(): void
$this->assertSame(['\MyTrait' => $trait], $this->fixture->getUsedTraits());
}
- /**
- * @covers ::isAbstract
- */
+ /** @covers ::isAbstract */
public function testGettingWhetherClassIsAbstract(): void
{
$class = new Class_($this->fqsen, $this->docBlock);
@@ -181,9 +171,7 @@ public function testGettingWhetherClassIsAbstract(): void
$this->assertTrue($class->isAbstract());
}
- /**
- * @covers ::isFinal
- */
+ /** @covers ::isFinal */
public function testGettingWhetherClassIsFinal(): void
{
$class = new Class_($this->fqsen, $this->docBlock);
@@ -193,9 +181,7 @@ public function testGettingWhetherClassIsFinal(): void
$this->assertTrue($class->isFinal());
}
- /**
- * @covers ::isFinal
- */
+ /** @covers ::isFinal */
public function testGettingWhetherClassIsReadOnly(): void
{
$class = new Class_($this->fqsen, $this->docBlock);
@@ -209,7 +195,7 @@ public function testGettingWhetherClassIsReadOnly(): void
false,
null,
null,
- true
+ true,
);
$this->assertTrue($class->isReadOnly());
}
@@ -223,7 +209,7 @@ public function testLineAndColumnNumberIsReturnedWhenALocationIsProvided(): void
false,
false,
new Location(100, 20),
- new Location(101, 20)
+ new Location(101, 20),
);
$this->assertLineAndColumnNumberIsReturnedWhenALocationIsProvided($fixture);
}
diff --git a/tests/unit/phpDocumentor/Reflection/Php/ConstantTest.php b/tests/unit/phpDocumentor/Reflection/Php/ConstantTest.php
index 40cf4144..bbd79bb2 100644
--- a/tests/unit/phpDocumentor/Reflection/Php/ConstantTest.php
+++ b/tests/unit/phpDocumentor/Reflection/Php/ConstantTest.php
@@ -82,17 +82,13 @@ public function testGetFqsen(): void
$this->assertSame($this->fqsen->getName(), $this->fixture->getName());
}
- /**
- * @covers ::getDocBlock
- */
+ /** @covers ::getDocBlock */
public function testGetDocblock(): void
{
$this->assertSame($this->docBlock, $this->fixture->getDocBlock());
}
- /**
- * @covers ::getVisibility
- */
+ /** @covers ::getVisibility */
public function testGetVisibility(): void
{
$this->assertEquals(new Visibility(Visibility::PUBLIC_), $this->fixture->getVisibility());
diff --git a/tests/unit/phpDocumentor/Reflection/Php/EnumCaseTest.php b/tests/unit/phpDocumentor/Reflection/Php/EnumCaseTest.php
index d2f4dabe..cbc768ee 100644
--- a/tests/unit/phpDocumentor/Reflection/Php/EnumCaseTest.php
+++ b/tests/unit/phpDocumentor/Reflection/Php/EnumCaseTest.php
@@ -51,41 +51,31 @@ private function getFixture(): MetaDataContainerInterface
return $this->fixture;
}
- /**
- * @covers ::getName
- */
+ /** @covers ::getName */
public function testGettingName(): void
{
$this->assertSame($this->fqsen->getName(), $this->fixture->getName());
}
- /**
- * @covers ::getFqsen
- */
+ /** @covers ::getFqsen */
public function testGettingFqsen(): void
{
$this->assertSame($this->fqsen, $this->fixture->getFqsen());
}
- /**
- * @covers ::getDocBlock
- */
+ /** @covers ::getDocBlock */
public function testGettingDocBlock(): void
{
$this->assertSame($this->docBlock, $this->fixture->getDocBlock());
}
- /**
- * @covers ::getValue
- */
+ /** @covers ::getValue */
public function testGetValue(): void
{
$this->assertNull($this->fixture->getValue());
}
- /**
- * @covers ::getLocation
- */
+ /** @covers ::getLocation */
public function testGetLocationReturnsDefault(): void
{
self::assertEquals(new Location(-1), $this->fixture->getLocation());
diff --git a/tests/unit/phpDocumentor/Reflection/Php/Enum_Test.php b/tests/unit/phpDocumentor/Reflection/Php/Enum_Test.php
index 727cfbd0..82bb94cb 100644
--- a/tests/unit/phpDocumentor/Reflection/Php/Enum_Test.php
+++ b/tests/unit/phpDocumentor/Reflection/Php/Enum_Test.php
@@ -56,33 +56,25 @@ private function getFixture(): MetaDataContainerInterface
return $this->fixture;
}
- /**
- * @covers ::getName
- */
+ /** @covers ::getName */
public function testGettingName(): void
{
$this->assertSame($this->fqsen->getName(), $this->fixture->getName());
}
- /**
- * @covers ::getBackedType
- */
+ /** @covers ::getBackedType */
public function testGetBackedWithOutType(): void
{
$this->assertNull($this->fixture->getBackedType());
}
- /**
- * @covers ::getFqsen
- */
+ /** @covers ::getFqsen */
public function testGettingFqsen(): void
{
$this->assertSame($this->fqsen, $this->fixture->getFqsen());
}
- /**
- * @covers ::getDocBlock
- */
+ /** @covers ::getDocBlock */
public function testGettingDocBlock(): 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 2cae57cf..129b9bd9 100644
--- a/tests/unit/phpDocumentor/Reflection/Php/Factory/ArgumentTest.php
+++ b/tests/unit/phpDocumentor/Reflection/Php/Factory/ArgumentTest.php
@@ -43,18 +43,14 @@ protected function setUp(): void
$this->fixture = new Argument(new PrettyPrinter());
}
- /**
- * @covers ::matches
- */
+ /** @covers ::matches */
public function testMatches(): void
{
$this->assertFalse($this->fixture->matches(self::createContext(null), new stdClass()));
$this->assertTrue($this->fixture->matches(self::createContext(null), m::mock(Param::class)));
}
- /**
- * @covers ::create
- */
+ /** @covers ::create */
public function testCreate(): void
{
$factory = new ProjectFactoryStrategies([]);
@@ -65,7 +61,7 @@ public function testCreate(): void
new String_('MyDefault'),
null,
true,
- true
+ true,
);
$this->fixture->create(self::createContext(null)->push($method), $argMock, $factory);
diff --git a/tests/unit/phpDocumentor/Reflection/Php/Factory/ClassConstantIteratorTest.php b/tests/unit/phpDocumentor/Reflection/Php/Factory/ClassConstantIteratorTest.php
index 1597d257..cc7661d0 100644
--- a/tests/unit/phpDocumentor/Reflection/Php/Factory/ClassConstantIteratorTest.php
+++ b/tests/unit/phpDocumentor/Reflection/Php/Factory/ClassConstantIteratorTest.php
@@ -84,9 +84,7 @@ public function testProxyMethods(): void
$this->assertEquals(10, $fixture->getLine());
}
- /**
- * @covers ::getDocComment
- */
+ /** @covers ::getDocComment */
public function testGetDocCommentPropFirst(): void
{
$const = m::mock(Const_::class);
@@ -101,9 +99,7 @@ public function testGetDocCommentPropFirst(): void
$this->assertEquals('test', $fixture->getDocComment()->getText());
}
- /**
- * @covers ::getDocComment
- */
+ /** @covers ::getDocComment */
public function testGetDocComment(): void
{
$const = m::mock(Const_::class);
diff --git a/tests/unit/phpDocumentor/Reflection/Php/Factory/ClassConstantTest.php b/tests/unit/phpDocumentor/Reflection/Php/Factory/ClassConstantTest.php
index 249ebe9e..30945f5d 100644
--- a/tests/unit/phpDocumentor/Reflection/Php/Factory/ClassConstantTest.php
+++ b/tests/unit/phpDocumentor/Reflection/Php/Factory/ClassConstantTest.php
@@ -56,7 +56,7 @@ protected function setUp(): void
$this->docBlockFactory = $this->prophesize(DocBlockFactoryInterface::class);
$this->fixture = new ClassConstant(
$this->docBlockFactory->reveal(),
- new PrettyPrinter()
+ new PrettyPrinter(),
);
}
diff --git a/tests/unit/phpDocumentor/Reflection/Php/Factory/Class_Test.php b/tests/unit/phpDocumentor/Reflection/Php/Factory/Class_Test.php
index 10dd0592..4642d6d6 100644
--- a/tests/unit/phpDocumentor/Reflection/Php/Factory/Class_Test.php
+++ b/tests/unit/phpDocumentor/Reflection/Php/Factory/Class_Test.php
@@ -60,23 +60,19 @@ protected function setUp(): void
$this->fixture = new Class_($this->docblockFactory->reveal());
}
- /**
- * @covers ::matches
- */
+ /** @covers ::matches */
public function testMatches(): void
{
$this->assertFalse($this->fixture->matches(self::createContext(null), new stdClass()));
$this->assertTrue(
$this->fixture->matches(
self::createContext(null),
- $this->prophesize(ClassNode::class)->reveal()
- )
+ $this->prophesize(ClassNode::class)->reveal(),
+ ),
);
}
- /**
- * @covers ::create
- */
+ /** @covers ::create */
public function testSimpleCreate(): void
{
$containerMock = m::mock(StrategyContainer::class);
@@ -92,9 +88,7 @@ public function testSimpleCreate(): void
$this->assertTrue($class->isAbstract());
}
- /**
- * @covers ::create
- */
+ /** @covers ::create */
public function testClassWithParent(): void
{
$containerMock = m::mock(StrategyContainer::class);
@@ -109,9 +103,7 @@ public function testClassWithParent(): void
$this->assertEquals('\Space\MyParent', (string) $class->getParent());
}
- /**
- * @covers ::create
- */
+ /** @covers ::create */
public function testClassImplementingInterface(): void
{
$containerMock = m::mock(StrategyContainer::class);
@@ -129,13 +121,11 @@ public function testClassImplementingInterface(): void
$this->assertEquals(
['\MyInterface' => new Fqsen('\MyInterface')],
- $class->getInterfaces()
+ $class->getInterfaces(),
);
}
- /**
- * @covers ::create
- */
+ /** @covers ::create */
public function testIteratesStatements(): void
{
$method1 = new ClassMethod('MyClass::method1');
@@ -154,7 +144,7 @@ public function testIteratesStatements(): void
$containerMock->findMatching(
Argument::type(ContextStack::class),
- $method1
+ $method1,
)->willReturn($strategyMock->reveal());
$class = $this->performCreate($classMock, $containerMock->reveal());
@@ -163,13 +153,11 @@ public function testIteratesStatements(): void
$this->assertEquals('\Space\MyClass', (string) $class->getFqsen());
$this->assertEquals(
['\MyClass::method1' => $method1Descriptor],
- $class->getMethods()
+ $class->getMethods(),
);
}
- /**
- * @covers ::create
- */
+ /** @covers ::create */
public function testCreateWithDocBlock(): void
{
$doc = new Doc('Text');
@@ -184,10 +172,7 @@ public function testCreateWithDocBlock(): void
$this->assertSame($docBlock, $class->getDocBlock());
}
- /**
- * @return m\MockInterface|ClassNode
- */
- private function buildClassMock()
+ private function buildClassMock(): m\MockInterface|ClassNode
{
$classMock = m::mock(ClassNode::class);
$classMock->shouldReceive('getAttribute')->andReturn(new Fqsen('\Space\MyClass'));
diff --git a/tests/unit/phpDocumentor/Reflection/Php/Factory/ConstructorPromotionTest.php b/tests/unit/phpDocumentor/Reflection/Php/Factory/ConstructorPromotionTest.php
index cdc16bd6..9777ff3e 100644
--- a/tests/unit/phpDocumentor/Reflection/Php/Factory/ConstructorPromotionTest.php
+++ b/tests/unit/phpDocumentor/Reflection/Php/Factory/ConstructorPromotionTest.php
@@ -29,9 +29,7 @@
use function current;
-/**
- * @coversDefaultClass \phpDocumentor\Reflection\Php\Factory\ConstructorPromotion
- */
+/** @coversDefaultClass \phpDocumentor\Reflection\Php\Factory\ConstructorPromotion */
final class ConstructorPromotionTest extends TestCase
{
use ProphecyTrait;
@@ -49,7 +47,7 @@ protected function setUp(): void
$this->fixture = new ConstructorPromotion(
$this->strategy->reveal(),
$this->docblockFactory->reveal(),
- $printer->reveal()
+ $printer->reveal(),
);
}
@@ -63,9 +61,7 @@ public function testMatches(ContextStack $context, object $object, bool $expecte
self::assertEquals($expected, $this->fixture->matches($context, $object));
}
- /**
- * @return mixed[][]
- */
+ /** @return mixed[][] */
public function objectProvider(): array
{
$context = new ContextStack(new Project('test'));
@@ -116,7 +112,7 @@ public function testCreateWithProperty(int $flags, string $visibility, bool $rea
new Doc('text'),
],
],
- $flags
+ $flags,
),
];
@@ -131,7 +127,7 @@ public function testCreateWithProperty(int $flags, string $visibility, bool $rea
$this->fixture->create(
$context,
$methodNode,
- $this->prophesize(StrategyContainer::class)->reveal()
+ $this->prophesize(StrategyContainer::class)->reveal(),
);
$property = current($class->getProperties());
diff --git a/tests/unit/phpDocumentor/Reflection/Php/Factory/ContextStackTest.php b/tests/unit/phpDocumentor/Reflection/Php/Factory/ContextStackTest.php
index 496da452..cd094f08 100644
--- a/tests/unit/phpDocumentor/Reflection/Php/Factory/ContextStackTest.php
+++ b/tests/unit/phpDocumentor/Reflection/Php/Factory/ContextStackTest.php
@@ -12,9 +12,7 @@
use phpDocumentor\Reflection\Types\Context;
use PHPUnit\Framework\TestCase as PHPUnitTestCase;
-/**
- * @coversDefaultClass \phpDocumentor\Reflection\Php\Factory\ContextStack
- */
+/** @coversDefaultClass \phpDocumentor\Reflection\Php\Factory\ContextStack */
final class ContextStackTest extends PHPUnitTestCase
{
/**
diff --git a/tests/unit/phpDocumentor/Reflection/Php/Factory/DefineTest.php b/tests/unit/phpDocumentor/Reflection/Php/Factory/DefineTest.php
index 271a7b9f..83e62d8a 100644
--- a/tests/unit/phpDocumentor/Reflection/Php/Factory/DefineTest.php
+++ b/tests/unit/phpDocumentor/Reflection/Php/Factory/DefineTest.php
@@ -114,9 +114,9 @@ public function testCreateWithDocBlock(): void
[
new Arg(new String_('MY_CONST1')),
new Arg(new String_('a')),
- ]
+ ],
),
- ['comments' => [$doc]]
+ ['comments' => [$doc]],
);
$typeContext = new Context('Space\\MyClass');
@@ -140,8 +140,8 @@ private function buildDefineStub(string $namespace = ''): Expression
[
new Arg(new String_($namespace ? $namespace . '\\MY_CONST1' : 'MY_CONST1')),
new Arg(new String_('a')),
- ]
- )
+ ],
+ ),
);
}
diff --git a/tests/unit/phpDocumentor/Reflection/Php/Factory/EnumCaseTest.php b/tests/unit/phpDocumentor/Reflection/Php/Factory/EnumCaseTest.php
index 0920c8ce..f33306f6 100644
--- a/tests/unit/phpDocumentor/Reflection/Php/Factory/EnumCaseTest.php
+++ b/tests/unit/phpDocumentor/Reflection/Php/Factory/EnumCaseTest.php
@@ -45,23 +45,19 @@ protected function setUp(): void
$this->fixture = new EnumCase($this->docblockFactory->reveal(), new Standard());
}
- /**
- * @covers ::matches
- */
+ /** @covers ::matches */
public function testMatches(): void
{
self::assertFalse($this->fixture->matches(self::createContext(null), new stdClass()));
self::assertTrue(
$this->fixture->matches(
self::createContext(null),
- $this->prophesize(EnumCaseNode::class)->reveal()
- )
+ $this->prophesize(EnumCaseNode::class)->reveal(),
+ ),
);
}
- /**
- * @covers ::create
- */
+ /** @covers ::create */
public function testSimpleCreate(): void
{
$containerMock = $this->prophesize(StrategyContainer::class)->reveal();
@@ -77,10 +73,10 @@ public function testSimpleCreate(): void
new Fqsen('\Space\MyEnum::VALUE'),
null,
new Location(1),
- new Location(2)
+ new Location(2),
),
],
- $result->getCases()
+ $result->getCases(),
);
}
diff --git a/tests/unit/phpDocumentor/Reflection/Php/Factory/Enum_Test.php b/tests/unit/phpDocumentor/Reflection/Php/Factory/Enum_Test.php
index b2527a1b..11d27a5a 100644
--- a/tests/unit/phpDocumentor/Reflection/Php/Factory/Enum_Test.php
+++ b/tests/unit/phpDocumentor/Reflection/Php/Factory/Enum_Test.php
@@ -59,23 +59,19 @@ protected function setUp(): void
$this->fixture = new Enum_($this->docblockFactory->reveal());
}
- /**
- * @covers ::matches
- */
+ /** @covers ::matches */
public function testMatches(): void
{
self::assertFalse($this->fixture->matches(self::createContext(null), new stdClass()));
self::assertTrue(
$this->fixture->matches(
self::createContext(null),
- $this->prophesize(EnumNode::class)->reveal()
- )
+ $this->prophesize(EnumNode::class)->reveal(),
+ ),
);
}
- /**
- * @covers ::create
- */
+ /** @covers ::create */
public function testSimpleCreate(): void
{
$containerMock = m::mock(StrategyContainer::class);
@@ -88,9 +84,7 @@ public function testSimpleCreate(): void
self::assertEquals('\Space\MyEnum', (string) $result->getFqsen());
}
- /**
- * @covers ::create
- */
+ /** @covers ::create */
public function testBackedEnumTypeIsSet(): void
{
$containerMock = m::mock(StrategyContainer::class);
@@ -105,9 +99,7 @@ public function testBackedEnumTypeIsSet(): void
self::assertEquals(new String_(), $result->getBackedType());
}
- /**
- * @covers ::create
- */
+ /** @covers ::create */
public function testClassImplementingInterface(): void
{
$containerMock = m::mock(StrategyContainer::class);
@@ -125,13 +117,11 @@ public function testClassImplementingInterface(): void
self::assertEquals(
['\MyInterface' => new Fqsen('\MyInterface')],
- $result->getInterfaces()
+ $result->getInterfaces(),
);
}
- /**
- * @covers ::create
- */
+ /** @covers ::create */
public function testIteratesStatements(): void
{
$method1 = new ClassMethod('MyEnum::method1');
@@ -150,7 +140,7 @@ public function testIteratesStatements(): void
$containerMock->findMatching(
Argument::type(ContextStack::class),
- $method1
+ $method1,
)->willReturn($strategyMock->reveal());
$result = $this->performCreate($enumMock, $containerMock->reveal());
@@ -159,13 +149,11 @@ public function testIteratesStatements(): void
self::assertEquals('\Space\MyEnum', (string) $result->getFqsen());
self::assertEquals(
['\MyEnum::method1' => $method1Descriptor],
- $result->getMethods()
+ $result->getMethods(),
);
}
- /**
- * @covers ::create
- */
+ /** @covers ::create */
public function testCreateWithDocBlock(): void
{
$doc = new Doc('Text');
@@ -180,10 +168,7 @@ public function testCreateWithDocBlock(): void
self::assertSame($docBlock, $result->getDocBlock());
}
- /**
- * @return m\MockInterface|ClassNode
- */
- private function buildEnumMock()
+ private function buildEnumMock(): m\MockInterface|ClassNode
{
$enumMock = m::mock(EnumNode::class);
$enumMock->shouldReceive('getAttribute')->andReturn(new Fqsen('\Space\MyEnum'));
diff --git a/tests/unit/phpDocumentor/Reflection/Php/Factory/File/CreateCommandTest.php b/tests/unit/phpDocumentor/Reflection/Php/Factory/File/CreateCommandTest.php
index de40743f..7ed26d97 100644
--- a/tests/unit/phpDocumentor/Reflection/Php/Factory/File/CreateCommandTest.php
+++ b/tests/unit/phpDocumentor/Reflection/Php/Factory/File/CreateCommandTest.php
@@ -41,21 +41,17 @@ protected function setUp(): void
$this->fixture = new CreateCommand(
new ContextStack(new Project('test')),
$this->file,
- $this->strategies
+ $this->strategies,
);
}
- /**
- * @covers ::getFile
- */
+ /** @covers ::getFile */
public function testGetFile(): void
{
$this->assertSame($this->file, $this->fixture->getFile());
}
- /**
- * @covers ::getStrategies
- */
+ /** @covers ::getStrategies */
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 0144af23..b3026112 100644
--- a/tests/unit/phpDocumentor/Reflection/Php/Factory/FileTest.php
+++ b/tests/unit/phpDocumentor/Reflection/Php/Factory/FileTest.php
@@ -74,18 +74,14 @@ protected function setUp(): void
$this->fixture = new File($this->docBlockFactory->reveal(), $this->nodesFactoryMock->reveal());
}
- /**
- * @covers ::matches
- */
+ /** @covers ::matches */
public function testMatches(): void
{
$this->assertFalse($this->fixture->matches(self::createContext(null), new stdClass()));
$this->assertTrue($this->fixture->matches(self::createContext(null), m::mock(SourceFile::class)));
}
- /**
- * @covers ::create
- */
+ /** @covers ::create */
public function testMiddlewareIsExecuted(): void
{
$file = new FileElement('aa', __FILE__);
@@ -95,7 +91,7 @@ public function testMiddlewareIsExecuted(): void
$fixture = new File(
$this->docBlockFactory->reveal(),
$this->nodesFactoryMock->reveal(),
- [$middleware->reveal()]
+ [$middleware->reveal()],
);
$context = self::createContext();
$containerMock = $this->prophesize(StrategyContainer::class);
@@ -123,7 +119,7 @@ public function testFileGetsCommentFromFirstNode(Node $node, DocBlockDescriptor
$strategies = $this->prophesize(StrategyContainer::class);
$strategies->findMatching(Argument::type(ContextStack::class), $node)->willReturn(
- $this->prophesize(ProjectFactoryStrategy::class)->reveal()
+ $this->prophesize(ProjectFactoryStrategy::class)->reveal(),
);
$context = self::createContext();
diff --git a/tests/unit/phpDocumentor/Reflection/Php/Factory/Function_Test.php b/tests/unit/phpDocumentor/Reflection/Php/Factory/Function_Test.php
index 23ef9e69..4cd4942a 100644
--- a/tests/unit/phpDocumentor/Reflection/Php/Factory/Function_Test.php
+++ b/tests/unit/phpDocumentor/Reflection/Php/Factory/Function_Test.php
@@ -56,21 +56,17 @@ protected function setUp(): void
$this->fixture = new Function_($this->docBlockFactory->reveal());
}
- /**
- * @covers ::matches
- */
+ /** @covers ::matches */
public function testMatches(): void
{
$this->assertFalse($this->fixture->matches(self::createContext(null), new stdClass()));
$this->assertTrue($this->fixture->matches(
self::createContext(null)->push(new File('hash', 'path')),
- $this->prophesize(\PhpParser\Node\Stmt\Function_::class)->reveal()
+ $this->prophesize(\PhpParser\Node\Stmt\Function_::class)->reveal(),
));
}
- /**
- * @covers ::create
- */
+ /** @covers ::create */
public function testCreateWithoutParameters(): void
{
$functionMock = $this->prophesize(\PhpParser\Node\Stmt\Function_::class);
@@ -91,9 +87,7 @@ public function testCreateWithoutParameters(): void
$this->assertEquals('\SomeSpace::function()', (string) $function->getFqsen());
}
- /**
- * @covers ::create
- */
+ /** @covers ::create */
public function testCreateWithParameters(): void
{
$param1 = new Param(new Variable('param1'));
@@ -111,7 +105,7 @@ public function testCreateWithParameters(): void
$argumentStrategy->create(
Argument::that(fn ($agument): bool => $agument->peek() instanceof FunctionDescriptor),
$param1,
- $containerMock->reveal()
+ $containerMock->reveal(),
)->shouldBeCalled();
$file = new File('hash', 'path');
@@ -119,7 +113,7 @@ public function testCreateWithParameters(): void
$this->fixture->create(
self::createContext(null)->push($file),
$functionMock->reveal(),
- $containerMock->reveal()
+ $containerMock->reveal(),
);
$function = current($file->getFunctions());
@@ -128,9 +122,7 @@ public function testCreateWithParameters(): void
$this->assertEquals('\SomeSpace::function()', (string) $function->getFqsen());
}
- /**
- * @covers ::create
- */
+ /** @covers ::create */
public function testCreateWithDocBlock(): void
{
$doc = new Doc('Text');
@@ -155,9 +147,7 @@ public function testCreateWithDocBlock(): void
$this->assertSame($docBlock, $function->getDocBlock());
}
- /**
- * @covers ::create
- */
+ /** @covers ::create */
public function testIteratesStatements(): void
{
$doc = new Doc('Text');
@@ -175,14 +165,14 @@ public function testIteratesStatements(): void
$containerMock = $this->prophesize(StrategyContainer::class);
$containerMock->findMatching(
Argument::type(ContextStack::class),
- Argument::type(Expression::class)
+ Argument::type(Expression::class),
)->willReturn($strategyMock->reveal())->shouldBeCalledOnce();
$file = new File('hash', 'path');
$this->fixture->create(
self::createContext(null)->push($file),
$functionMock->reveal(),
- $containerMock->reveal()
+ $containerMock->reveal(),
);
}
}
diff --git a/tests/unit/phpDocumentor/Reflection/Php/Factory/GlobalConstantIteratorTest.php b/tests/unit/phpDocumentor/Reflection/Php/Factory/GlobalConstantIteratorTest.php
index 49a67365..4af9acb6 100644
--- a/tests/unit/phpDocumentor/Reflection/Php/Factory/GlobalConstantIteratorTest.php
+++ b/tests/unit/phpDocumentor/Reflection/Php/Factory/GlobalConstantIteratorTest.php
@@ -82,9 +82,7 @@ public function testProxyMethods(): void
$this->assertEquals(10, $fixture->getLine());
}
- /**
- * @covers ::getDocComment
- */
+ /** @covers ::getDocComment */
public function testGetDocCommentPropFirst(): void
{
$const = m::mock(Const_::class);
@@ -99,9 +97,7 @@ public function testGetDocCommentPropFirst(): void
$this->assertEquals('test', $fixture->getDocComment()->getText());
}
- /**
- * @covers ::getDocComment
- */
+ /** @covers ::getDocComment */
public function testGetDocComment(): void
{
$const = m::mock(Const_::class);
diff --git a/tests/unit/phpDocumentor/Reflection/Php/Factory/Interface_Test.php b/tests/unit/phpDocumentor/Reflection/Php/Factory/Interface_Test.php
index dea74ded..91d29db2 100644
--- a/tests/unit/phpDocumentor/Reflection/Php/Factory/Interface_Test.php
+++ b/tests/unit/phpDocumentor/Reflection/Php/Factory/Interface_Test.php
@@ -57,18 +57,14 @@ protected function setUp(): void
$this->fixture = new Interface_($this->docBlockFactory->reveal());
}
- /**
- * @covers ::matches
- */
+ /** @covers ::matches */
public function testMatches(): void
{
$this->assertFalse($this->fixture->matches(self::createContext(null), new stdClass()));
$this->assertTrue($this->fixture->matches(self::createContext(null), m::mock(InterfaceNode::class)));
}
- /**
- * @covers ::create
- */
+ /** @covers ::create */
public function testSimpleCreate(): void
{
$interfaceMock = $this->buildClassMock();
@@ -81,9 +77,7 @@ public function testSimpleCreate(): void
$this->assertEquals('\Space\MyInterface', (string) $interface->getFqsen());
}
- /**
- * @covers ::create
- */
+ /** @covers ::create */
public function testCreateWithDocBlock(): void
{
$doc = new Doc('Text');
@@ -99,9 +93,7 @@ public function testCreateWithDocBlock(): void
$this->assertSame($docBlock, $interface->getDocBlock());
}
- /**
- * @covers ::create
- */
+ /** @covers ::create */
public function testIteratesStatements(): void
{
$method1 = new ClassMethod('MyClass::method1');
@@ -120,7 +112,7 @@ public function testIteratesStatements(): void
$containerMock->findMatching(
Argument::type(ContextStack::class),
- $method1
+ $method1,
)->willReturn($strategyMock->reveal());
$class = $this->performCreate($classMock, $containerMock->reveal());
@@ -129,14 +121,11 @@ public function testIteratesStatements(): void
$this->assertEquals('\Space\MyInterface', (string) $class->getFqsen());
$this->assertEquals(
['\MyClass::method1' => $method1Descriptor],
- $class->getMethods()
+ $class->getMethods(),
);
}
- /**
- * @return m\MockInterface|InterfaceNode
- */
- private function buildClassMock()
+ private function buildClassMock(): m\MockInterface|InterfaceNode
{
$interfaceMock = m::mock(InterfaceNode::class);
$interfaceMock->extends = [];
@@ -154,7 +143,7 @@ private function performCreate(m\MockInterface $interfaceMock, StrategyContainer
$this->fixture->create(
self::createContext(null)->push($file),
$interfaceMock,
- $containerMock
+ $containerMock,
);
return current($file->getInterfaces());
diff --git a/tests/unit/phpDocumentor/Reflection/Php/Factory/MethodTest.php b/tests/unit/phpDocumentor/Reflection/Php/Factory/MethodTest.php
index f2a278ff..b741a6d3 100644
--- a/tests/unit/phpDocumentor/Reflection/Php/Factory/MethodTest.php
+++ b/tests/unit/phpDocumentor/Reflection/Php/Factory/MethodTest.php
@@ -60,18 +60,14 @@ protected function setUp(): void
$this->fixture = new Method($this->docBlockFactory->reveal());
}
- /**
- * @covers ::matches
- */
+ /** @covers ::matches */
public function testMatches(): void
{
$this->assertFalse($this->fixture->matches(self::createContext(null), new stdClass()));
$this->assertTrue($this->fixture->matches(self::createContext(null), m::mock(ClassMethod::class)));
}
- /**
- * @covers ::create
- */
+ /** @covers ::create */
public function testCreateWithoutParameters(): void
{
$classMethodMock = $this->buildClassMethodMock();
@@ -93,9 +89,7 @@ public function testCreateWithoutParameters(): void
$this->assertEquals('public', (string) $method->getVisibility());
}
- /**
- * @covers ::create
- */
+ /** @covers ::create */
public function testCreateProtectedMethod(): void
{
$classMethodMock = $this->buildClassMethodMock();
@@ -117,9 +111,7 @@ public function testCreateProtectedMethod(): void
$this->assertEquals('protected', (string) $method->getVisibility());
}
- /**
- * @covers ::create
- */
+ /** @covers ::create */
public function testCreateWithParameters(): void
{
$param1 = new Param(new Variable('param1'));
@@ -133,13 +125,13 @@ public function testCreateWithParameters(): void
$containerMock = $this->prophesize(StrategyContainer::class);
$containerMock->findMatching(
Argument::type(ContextStack::class),
- $param1
+ $param1,
)->willReturn($argumentStrategy);
$argumentStrategy->create(
Argument::that(static fn ($agument): bool => $agument->peek() instanceof MethodDescriptor),
$param1,
- $containerMock->reveal()
+ $containerMock->reveal(),
)->shouldBeCalled();
$class = new ClassElement(new Fqsen('\\MyClass'));
@@ -154,9 +146,7 @@ public function testCreateWithParameters(): void
$this->assertEquals('private', (string) $method->getVisibility());
}
- /**
- * @covers ::create
- */
+ /** @covers ::create */
public function testCreateWithDocBlock(): void
{
$doc = new Doc('Text');
@@ -179,9 +169,7 @@ public function testCreateWithDocBlock(): void
$this->assertSame($docBlock, $method->getDocBlock());
}
- /**
- * @return MockInterface|ClassMethod
- */
+ /** @return MockInterface|ClassMethod */
private function buildClassMethodMock(): MockInterface
{
$methodMock = m::mock(ClassMethod::class);
@@ -200,9 +188,7 @@ private function buildClassMethodMock(): MockInterface
return $methodMock;
}
- /**
- * @covers ::create
- */
+ /** @covers ::create */
public function testIteratesStatements(): void
{
$method1 = $this->buildClassMethodMock();
@@ -216,7 +202,7 @@ public function testIteratesStatements(): void
$containerMock = $this->prophesize(StrategyContainer::class);
$containerMock->findMatching(
Argument::type(ContextStack::class),
- Argument::type(Expression::class)
+ Argument::type(Expression::class),
)->willReturn($strategyMock->reveal())->shouldBeCalledOnce();
$class = new ClassElement(new Fqsen('\\MyClass'));
diff --git a/tests/unit/phpDocumentor/Reflection/Php/Factory/Namespace_Test.php b/tests/unit/phpDocumentor/Reflection/Php/Factory/Namespace_Test.php
index a88e19a5..ffef61e5 100644
--- a/tests/unit/phpDocumentor/Reflection/Php/Factory/Namespace_Test.php
+++ b/tests/unit/phpDocumentor/Reflection/Php/Factory/Namespace_Test.php
@@ -19,9 +19,7 @@
use function current;
-/**
- * @coversDefaultClass \phpDocumentor\Reflection\Php\Factory\Namespace_
- */
+/** @coversDefaultClass \phpDocumentor\Reflection\Php\Factory\Namespace_ */
final class Namespace_Test extends TestCase
{
use ProphecyTrait;
@@ -31,34 +29,28 @@ protected function setUp(): void
$this->fixture = new Namespace_();
}
- /**
- * @covers ::matches
- */
+ /** @covers ::matches */
public function testMatches(): void
{
$this->assertFalse($this->fixture->matches(self::createContext(null), new stdClass()));
$this->assertTrue($this->fixture->matches(
self::createContext(null),
- $this->prophesize(NamespaceNode::class)->reveal()
+ $this->prophesize(NamespaceNode::class)->reveal(),
));
}
- /**
- * @covers ::create
- */
+ /** @covers ::create */
public function testCreateThrowsException(): void
{
$this->expectException(InvalidArgumentException::class);
$this->fixture->create(
self::createContext(null),
new stdClass(),
- $this->prophesize(StrategyContainer::class)->reveal()
+ $this->prophesize(StrategyContainer::class)->reveal(),
);
}
- /**
- * @covers ::create
- */
+ /** @covers ::create */
public function testIteratesStatements(): void
{
$class = new ClassNode('\MyClass');
@@ -77,7 +69,7 @@ public function testIteratesStatements(): void
$containerMock->findMatching(
Argument::type(ContextStack::class),
- $class
+ $class,
)->willReturn($strategyMock->reveal());
$file = new File('hash', 'path');
diff --git a/tests/unit/phpDocumentor/Reflection/Php/Factory/PropertyIteratorTest.php b/tests/unit/phpDocumentor/Reflection/Php/Factory/PropertyIteratorTest.php
index ce1d1945..99a6e21e 100644
--- a/tests/unit/phpDocumentor/Reflection/Php/Factory/PropertyIteratorTest.php
+++ b/tests/unit/phpDocumentor/Reflection/Php/Factory/PropertyIteratorTest.php
@@ -106,9 +106,7 @@ public function testGetDefault(): void
$this->assertEquals('myDefault', $fixture->getDefault());
}
- /**
- * @covers ::getDocComment
- */
+ /** @covers ::getDocComment */
public function testGetDocCommentPropFirst(): void
{
$prop = m::mock(PropertyProperty::class);
@@ -123,9 +121,7 @@ public function testGetDocCommentPropFirst(): void
$this->assertEquals('test', $fixture->getDocComment()->getText());
}
- /**
- * @covers ::getDocComment
- */
+ /** @covers ::getDocComment */
public function testGetDocComment(): void
{
$prop = m::mock(PropertyProperty::class);
diff --git a/tests/unit/phpDocumentor/Reflection/Php/Factory/PropertyTest.php b/tests/unit/phpDocumentor/Reflection/Php/Factory/PropertyTest.php
index 047f2574..3c375eff 100644
--- a/tests/unit/phpDocumentor/Reflection/Php/Factory/PropertyTest.php
+++ b/tests/unit/phpDocumentor/Reflection/Php/Factory/PropertyTest.php
@@ -114,7 +114,7 @@ public function testCreateMultipleInOneStatement(): void
$property2->setAttribute('fqsen', new Fqsen('\myClass::$property2'));
$node = new PropertyNode(
ClassNode::MODIFIER_PRIVATE | ClassNode::MODIFIER_STATIC,
- [$property1, $property2]
+ [$property1, $property2],
);
$class = $this->performCreate($node);
@@ -139,7 +139,7 @@ private function assertProperty(
PropertyDescriptor $property,
string $visibility,
string $name = 'property',
- ?string $default = '\'MyDefault\''
+ string|null $default = '\'MyDefault\'',
): void {
$this->assertInstanceOf(PropertyDescriptor::class, $property);
$this->assertEquals('\myClass::$' . $name, (string) $property->getFqsen());
diff --git a/tests/unit/phpDocumentor/Reflection/Php/Factory/TestCase.php b/tests/unit/phpDocumentor/Reflection/Php/Factory/TestCase.php
index 6ab04661..442a8bb2 100644
--- a/tests/unit/phpDocumentor/Reflection/Php/Factory/TestCase.php
+++ b/tests/unit/phpDocumentor/Reflection/Php/Factory/TestCase.php
@@ -29,17 +29,15 @@ abstract class TestCase extends MockeryTestCase
{
protected ProjectFactoryStrategy $fixture;
- public static function createContext(?Context $typeContext = null): ContextStack
+ public static function createContext(Context|null $typeContext = null): ContextStack
{
return new ContextStack(
new Project('test'),
- $typeContext
+ $typeContext,
);
}
- /**
- * @covers \phpDocumentor\Reflection\Php\Factory\AbstractFactory::create
- */
+ /** @covers \phpDocumentor\Reflection\Php\Factory\AbstractFactory::create */
public function testCreateThrowsException(): void
{
$this->expectException(InvalidArgumentException::class);
diff --git a/tests/unit/phpDocumentor/Reflection/Php/Factory/TraitUseTest.php b/tests/unit/phpDocumentor/Reflection/Php/Factory/TraitUseTest.php
index 2359c311..184a58a2 100644
--- a/tests/unit/phpDocumentor/Reflection/Php/Factory/TraitUseTest.php
+++ b/tests/unit/phpDocumentor/Reflection/Php/Factory/TraitUseTest.php
@@ -36,16 +36,14 @@ protected function setUp(): void
$this->fixture = new TraitUse();
}
- /**
- * @covers ::matches
- */
+ /** @covers ::matches */
public function testMatchesOnlyTraitUseNode(): void
{
self::assertTrue(
$this->fixture->matches(
self::createContext(),
- $this->givenTraitUse()
- )
+ $this->givenTraitUse(),
+ ),
);
}
diff --git a/tests/unit/phpDocumentor/Reflection/Php/Factory/Trait_Test.php b/tests/unit/phpDocumentor/Reflection/Php/Factory/Trait_Test.php
index 9f3227cf..7acbe604 100644
--- a/tests/unit/phpDocumentor/Reflection/Php/Factory/Trait_Test.php
+++ b/tests/unit/phpDocumentor/Reflection/Php/Factory/Trait_Test.php
@@ -99,7 +99,7 @@ public function testIteratesStatements(): void
$containerMock->findMatching(
Argument::type(ContextStack::class),
- $method1
+ $method1,
)->willReturn($strategyMock->reveal());
$trait = $this->performCreate($classMock, $containerMock->reveal());
@@ -107,13 +107,11 @@ public function testIteratesStatements(): void
$this->assertEquals('\Space\MyTrait', (string) $trait->getFqsen());
$this->assertEquals(
['\Space\MyTrait::method1' => $method1Descriptor],
- $trait->getMethods()
+ $trait->getMethods(),
);
}
- /**
- * @covers ::create
- */
+ /** @covers ::create */
public function testCreateWithDocBlock(): void
{
$doc = new Doc('Text');
@@ -128,10 +126,7 @@ public function testCreateWithDocBlock(): void
$this->assertSame($docBlock, $trait->getDocBlock());
}
- /**
- * @return m\MockInterface|TraitNode
- */
- private function buildTraitMock()
+ private function buildTraitMock(): m\MockInterface|TraitNode
{
$mock = m::mock(TraitNode::class);
$mock->shouldReceive('getAttribute')->andReturn(new Fqsen('\Space\MyTrait'));
diff --git a/tests/unit/phpDocumentor/Reflection/Php/Factory/TypeTest.php b/tests/unit/phpDocumentor/Reflection/Php/Factory/TypeTest.php
index 5fecfb82..037da55e 100644
--- a/tests/unit/phpDocumentor/Reflection/Php/Factory/TypeTest.php
+++ b/tests/unit/phpDocumentor/Reflection/Php/Factory/TypeTest.php
@@ -32,9 +32,7 @@
*/
final class TypeTest extends PhpUnitTestCase
{
- /**
- * @covers ::fromPhpParser
- */
+ /** @covers ::fromPhpParser */
public function testReturnsNullWhenNoTypeIsPassed(): void
{
$factory = new Type();
@@ -44,9 +42,7 @@ public function testReturnsNullWhenNoTypeIsPassed(): void
$this->assertNull($result);
}
- /**
- * @covers ::fromPhpParser
- */
+ /** @covers ::fromPhpParser */
public function testReturnsReflectedType(): void
{
$factory = new Type();
@@ -58,9 +54,7 @@ public function testReturnsReflectedType(): void
$this->assertEquals($expected, $result);
}
- /**
- * @covers ::fromPhpParser
- */
+ /** @covers ::fromPhpParser */
public function testReturnsNullableTypeWhenPassedAPhpParserNullable(): void
{
$factory = new Type();
@@ -72,9 +66,7 @@ public function testReturnsNullableTypeWhenPassedAPhpParserNullable(): void
$this->assertEquals($expected, $result);
}
- /**
- * @covers ::fromPhpParser
- */
+ /** @covers ::fromPhpParser */
public function testReturnsUnion(): void
{
$factory = new Type();
@@ -86,9 +78,7 @@ public function testReturnsUnion(): void
$this->assertEquals($expected, $result);
}
- /**
- * @covers ::fromPhpParser
- */
+ /** @covers ::fromPhpParser */
public function testReturnsUnionGivenVariousTypes(): void
{
$factory = new Type();
@@ -100,9 +90,7 @@ public function testReturnsUnionGivenVariousTypes(): void
$this->assertEquals($expected, $result);
}
- /**
- * @covers ::fromPhpParser
- */
+ /** @covers ::fromPhpParser */
public function testReturnsInterseptionType(): void
{
$factory = new Type();
diff --git a/tests/unit/phpDocumentor/Reflection/Php/FileTest.php b/tests/unit/phpDocumentor/Reflection/Php/FileTest.php
index 7fb07916..287dc8bc 100644
--- a/tests/unit/phpDocumentor/Reflection/Php/FileTest.php
+++ b/tests/unit/phpDocumentor/Reflection/Php/FileTest.php
@@ -147,41 +147,31 @@ public function testAddAndGetEnums(): void
$this->assertEquals(['\MySpace\MyEnum' => $enum], $this->fixture->getEnums());
}
- /**
- * @covers ::getDocBlock
- */
+ /** @covers ::getDocBlock */
public function testGetDocBlock(): void
{
$this->assertSame($this->docBlock, $this->fixture->getDocBlock());
}
- /**
- * @covers ::getHash
- */
+ /** @covers ::getHash */
public function testGetHash(): void
{
$this->assertSame(self::EXAMPLE_HASH, $this->fixture->getHash());
}
- /**
- * @covers ::getName
- */
+ /** @covers ::getName */
public function testGetName(): void
{
$this->assertSame(self::EXAMPLE_NAME, $this->fixture->getName());
}
- /**
- * @covers ::getPath
- */
+ /** @covers ::getPath */
public function testSetAndGetPath(): void
{
$this->assertSame(self::EXAMPLE_PATH, $this->fixture->getPath());
}
- /**
- * @covers ::getSource
- */
+ /** @covers ::getSource */
public function testSetAndGetSource(): void
{
$this->assertSame(self::EXAMPLE_SOURCE, $this->fixture->getSource());
diff --git a/tests/unit/phpDocumentor/Reflection/Php/Function_Test.php b/tests/unit/phpDocumentor/Reflection/Php/Function_Test.php
index 056b2e4c..6ca038e8 100644
--- a/tests/unit/phpDocumentor/Reflection/Php/Function_Test.php
+++ b/tests/unit/phpDocumentor/Reflection/Php/Function_Test.php
@@ -54,9 +54,7 @@ private function getFixture(): MetaDataContainerInterface
return $this->fixture;
}
- /**
- * @covers ::getName
- */
+ /** @covers ::getName */
public function testGetName(): void
{
$this->assertEquals('MyFunction', $this->fixture->getName());
@@ -74,34 +72,26 @@ public function testAddAndGetArguments(): void
$this->assertEquals([$argument], $this->fixture->getArguments());
}
- /**
- * @covers ::getFqsen
- */
+ /** @covers ::getFqsen */
public function testGetFqsen(): void
{
$this->assertSame($this->fqsen, $this->fixture->getFqsen());
}
- /**
- * @covers ::getDocBlock
- */
+ /** @covers ::getDocBlock */
public function testGetDocblock(): void
{
$this->assertSame($this->docBlock, $this->fixture->getDocBlock());
}
- /**
- * @covers ::getReturnType
- */
+ /** @covers ::getReturnType */
public function testGetDefaultReturnType(): void
{
$function = new Function_($this->fqsen);
$this->assertEquals(new Mixed_(), $function->getReturnType());
}
- /**
- * @covers ::getReturnType
- */
+ /** @covers ::getReturnType */
public function testGetReturnTypeFromConstructor(): void
{
$returnType = new String_();
@@ -110,18 +100,14 @@ public function testGetReturnTypeFromConstructor(): void
$this->assertSame($returnType, $function->getReturnType());
}
- /**
- * @covers ::getHasReturnByReference
- */
+ /** @covers ::getHasReturnByReference */
public function testGetHasReturnByReference(): void
{
$function = new Function_($this->fqsen);
$this->assertSame(false, $function->getHasReturnByReference());
}
- /**
- * @covers ::getHasReturnByReference
- */
+ /** @covers ::getHasReturnByReference */
public function testGetHasReturnByReferenceFromConstructor(): void
{
$function = new Function_($this->fqsen, null, null, null, null, true);
diff --git a/tests/unit/phpDocumentor/Reflection/Php/Interface_Test.php b/tests/unit/phpDocumentor/Reflection/Php/Interface_Test.php
index 029945b7..d5d1ccee 100644
--- a/tests/unit/phpDocumentor/Reflection/Php/Interface_Test.php
+++ b/tests/unit/phpDocumentor/Reflection/Php/Interface_Test.php
@@ -63,25 +63,19 @@ private function getFixture(): MetaDataContainerInterface
return $this->fixture;
}
- /**
- * @covers ::getName
- */
+ /** @covers ::getName */
public function testGetName(): void
{
$this->assertSame($this->fqsen->getName(), $this->fixture->getName());
}
- /**
- * @covers ::getFqsen
- */
+ /** @covers ::getFqsen */
public function testGetFqsen(): void
{
$this->assertSame($this->fqsen, $this->fixture->getFqsen());
}
- /**
- * @covers ::getDocBlock
- */
+ /** @covers ::getDocBlock */
public function testGetDocblock(): void
{
$this->assertSame($this->docBlock, $this->fixture->getDocBlock());
@@ -117,9 +111,7 @@ public function testSettingAndGettingMethods(): void
$this->assertEquals(['\MySpace\MyInterface::myMethod()' => $method], $this->fixture->getMethods());
}
- /**
- * @covers ::getParents
- */
+ /** @covers ::getParents */
public function testReturningTheParentsOfThisInterface(): void
{
$this->assertSame($this->exampleParents, $this->fixture->getParents());
@@ -131,9 +123,7 @@ public function testLineAndColumnNumberIsReturnedWhenALocationIsProvided(): void
$this->assertLineAndColumnNumberIsReturnedWhenALocationIsProvided($fixture);
}
- /**
- * @covers ::__construct
- */
+ /** @covers ::__construct */
public function testArrayWithParentsMustBeFqsenObjects(): void
{
$this->expectException(InvalidArgumentException::class);
diff --git a/tests/unit/phpDocumentor/Reflection/Php/MetadataContainerTest.php b/tests/unit/phpDocumentor/Reflection/Php/MetadataContainerTest.php
index c6e2c374..db3cfdd4 100644
--- a/tests/unit/phpDocumentor/Reflection/Php/MetadataContainerTest.php
+++ b/tests/unit/phpDocumentor/Reflection/Php/MetadataContainerTest.php
@@ -22,9 +22,7 @@ public function testSetMetaDataForNonExistingKey(): void
self::assertSame(['stub' => $stub], $this->getFixture()->getMetadata());
}
- /**
- * @covers ::addMetadata
- */
+ /** @covers ::addMetadata */
public function testSetMetaDataWithExistingKeyThrows(): void
{
self::expectException(Exception::class);
diff --git a/tests/unit/phpDocumentor/Reflection/Php/MetadataStub.php b/tests/unit/phpDocumentor/Reflection/Php/MetadataStub.php
index 31b8619e..86618437 100644
--- a/tests/unit/phpDocumentor/Reflection/Php/MetadataStub.php
+++ b/tests/unit/phpDocumentor/Reflection/Php/MetadataStub.php
@@ -8,11 +8,8 @@
final class MetadataStub implements Metadata
{
- private string $key;
-
- public function __construct(string $key)
+ public function __construct(private readonly string $key)
{
- $this->key = $key;
}
public function key(): string
diff --git a/tests/unit/phpDocumentor/Reflection/Php/MethodTest.php b/tests/unit/phpDocumentor/Reflection/Php/MethodTest.php
index e51a5cff..3798bc5a 100644
--- a/tests/unit/phpDocumentor/Reflection/Php/MethodTest.php
+++ b/tests/unit/phpDocumentor/Reflection/Php/MethodTest.php
@@ -64,9 +64,7 @@ public function testGetFqsenAndGetName(): void
$this->assertEquals($this->fqsen->getName(), $method->getName());
}
- /**
- * @covers ::getDocblock
- */
+ /** @covers ::getDocblock */
public function testGetDocBlock(): void
{
$method = new Method($this->fqsen, $this->visibility, $this->docblock);
@@ -91,9 +89,7 @@ public function testAddingAndGettingArguments(): void
$this->assertEquals([$argument], $method->getArguments());
}
- /**
- * @covers ::isAbstract
- */
+ /** @covers ::isAbstract */
public function testGettingWhetherMethodIsAbstract(): void
{
$method = new Method($this->fqsen, $this->visibility, $this->docblock, false);
@@ -103,9 +99,7 @@ public function testGettingWhetherMethodIsAbstract(): void
$this->assertTrue($method->isAbstract());
}
- /**
- * @covers ::isFinal
- */
+ /** @covers ::isFinal */
public function testGettingWhetherMethodIsFinal(): void
{
$method = new Method($this->fqsen, $this->visibility, $this->docblock, false, false, false);
@@ -115,9 +109,7 @@ public function testGettingWhetherMethodIsFinal(): void
$this->assertTrue($method->isFinal());
}
- /**
- * @covers ::isStatic
- */
+ /** @covers ::isStatic */
public function testGettingWhetherMethodIsStatic(): void
{
$method = new Method($this->fqsen, $this->visibility, $this->docblock, false, false, false);
@@ -127,36 +119,28 @@ public function testGettingWhetherMethodIsStatic(): void
$this->assertTrue($method->isStatic());
}
- /**
- * @covers ::getVisibility
- */
+ /** @covers ::getVisibility */
public function testGettingVisibility(): void
{
$method = new Method($this->fqsen, $this->visibility, $this->docblock, false, false, false);
$this->assertSame($this->visibility, $method->getVisibility());
}
- /**
- * @covers ::getVisibility
- */
+ /** @covers ::getVisibility */
public function testGetDefaultVisibility(): void
{
$method = new Method($this->fqsen);
$this->assertEquals(new Visibility('public'), $method->getVisibility());
}
- /**
- * @covers ::getReturnType
- */
+ /** @covers ::getReturnType */
public function testGetDefaultReturnType(): void
{
$method = new Method($this->fqsen);
$this->assertEquals(new Mixed_(), $method->getReturnType());
}
- /**
- * @covers ::getReturnType
- */
+ /** @covers ::getReturnType */
public function testGetReturnTypeFromConstructor(): void
{
$returnType = new String_();
@@ -169,24 +153,20 @@ public function testGetReturnTypeFromConstructor(): void
false,
null,
null,
- $returnType
+ $returnType,
);
$this->assertSame($returnType, $method->getReturnType());
}
- /**
- * @covers ::getHasReturnByReference
- */
+ /** @covers ::getHasReturnByReference */
public function testGetHasReturnByReference(): void
{
$method = new Method($this->fqsen);
$this->assertSame(false, $method->getHasReturnByReference());
}
- /**
- * @covers ::getHasReturnByReference
- */
+ /** @covers ::getHasReturnByReference */
public function testGetHasReturnByReferenceFromConstructor(): void
{
$method = new Method($this->fqsen, null, null, false, false, false, null, null, null, true);
@@ -203,7 +183,7 @@ public function testLineAndColumnNumberIsReturnedWhenALocationIsProvided(): void
false,
false,
new Location(100, 20),
- new Location(101, 20)
+ new Location(101, 20),
);
$this->assertLineAndColumnNumberIsReturnedWhenALocationIsProvided($fixture);
}
diff --git a/tests/unit/phpDocumentor/Reflection/Php/NodesFactoryTest.php b/tests/unit/phpDocumentor/Reflection/Php/NodesFactoryTest.php
index 0c266647..b7d69a80 100644
--- a/tests/unit/phpDocumentor/Reflection/Php/NodesFactoryTest.php
+++ b/tests/unit/phpDocumentor/Reflection/Php/NodesFactoryTest.php
@@ -48,9 +48,7 @@ public function testThatAFactoryWithRecommendedComponentsCanBeInstantiated(): vo
$this->assertEquals($this->givenTheExpectedDefaultNodesFactory(), $factory);
}
- /**
- * @covers ::create
- */
+ /** @covers ::create */
public function testThatCodeGetsConvertedIntoNodes(): void
{
$parser = $this->prophesize(Parser::class);
diff --git a/tests/unit/phpDocumentor/Reflection/Php/ProjectFactoryStrategiesTest.php b/tests/unit/phpDocumentor/Reflection/Php/ProjectFactoryStrategiesTest.php
index 52dc93d4..ce1b20ef 100644
--- a/tests/unit/phpDocumentor/Reflection/Php/ProjectFactoryStrategiesTest.php
+++ b/tests/unit/phpDocumentor/Reflection/Php/ProjectFactoryStrategiesTest.php
@@ -29,9 +29,7 @@
*/
class ProjectFactoryStrategiesTest extends TestCase
{
- /**
- * @covers ::addStrategy
- */
+ /** @covers ::addStrategy */
public function testStrategiesAreChecked(): void
{
new ProjectFactoryStrategies([new DummyFactoryStrategy()]);
@@ -48,22 +46,20 @@ public function testFindMatching(): void
$container = new ProjectFactoryStrategies([$strategy]);
$actual = $container->findMatching(
new ContextStack(new Project('name'), new Context('global')),
- new stdClass()
+ new stdClass(),
);
$this->assertSame($strategy, $actual);
}
- /**
- * @covers ::findMatching
- */
+ /** @covers ::findMatching */
public function testCreateThrowsExceptionWhenStrategyNotFound(): void
{
$this->expectException(OutOfBoundsException::class);
$container = new ProjectFactoryStrategies([]);
$container->findMatching(
new ContextStack(new Project('name'), new Context('global')),
- new stdClass()
+ new stdClass(),
);
}
}
diff --git a/tests/unit/phpDocumentor/Reflection/Php/ProjectFactoryTest.php b/tests/unit/phpDocumentor/Reflection/Php/ProjectFactoryTest.php
index b0044885..ed1e5736 100644
--- a/tests/unit/phpDocumentor/Reflection/Php/ProjectFactoryTest.php
+++ b/tests/unit/phpDocumentor/Reflection/Php/ProjectFactoryTest.php
@@ -78,9 +78,7 @@ public function testCreatingAnInstanceInstantiatesItWithTheRecommendedStrategies
$this->assertInstanceOf(ProjectFactory::class, ProjectFactory::createInstance());
}
- /**
- * @covers ::create
- */
+ /** @covers ::create */
public function testCreate(): void
{
$expected = ['some/file.php', 'some/other.php'];
@@ -88,25 +86,25 @@ public function testCreate(): void
$someOtherStrategy = $this->prophesize(ProjectFactoryStrategy::class);
$someOtherStrategy->matches(
ProphesizeArgument::type(ContextStack::class),
- ProphesizeArgument::any()
+ ProphesizeArgument::any(),
)->willReturn(false);
$someOtherStrategy->create(
ProphesizeArgument::any(),
ProphesizeArgument::any(),
- ProphesizeArgument::any()
+ ProphesizeArgument::any(),
)->shouldNotBeCalled();
$fileStrategyMock = $this->prophesize(ProjectFactoryStrategy::class);
$fileStrategyMock->matches(
ProphesizeArgument::type(ContextStack::class),
- ProphesizeArgument::any()
+ ProphesizeArgument::any(),
)->willReturn(true);
$fileStrategyMock->create(
ProphesizeArgument::type(ContextStack::class),
ProphesizeArgument::type(LocalFile::class),
- ProphesizeArgument::any()
+ ProphesizeArgument::any(),
)->will(function ($args) use (&$calls, $expected): void {
$context = $args[0];
assert($context instanceof ContextStack);
@@ -127,9 +125,7 @@ public function testCreate(): void
$this->assertEquals(['some/file.php', 'some/other.php'], $projectFilePaths);
}
- /**
- * @covers ::create
- */
+ /** @covers ::create */
public function testCreateThrowsExceptionWhenStrategyNotFound(): void
{
$this->expectException(OutOfBoundsException::class);
@@ -137,9 +133,7 @@ public function testCreateThrowsExceptionWhenStrategyNotFound(): void
$projectFactory->create('MyProject', ['aa']);
}
- /**
- * @covers ::create
- */
+ /** @covers ::create */
public function testCreateProjectFromFileWithNamespacedClass(): void
{
$file = new File(md5('some/file.php'), 'some/file.php');
@@ -156,9 +150,7 @@ public function testCreateProjectFromFileWithNamespacedClass(): void
$this->assertEquals('\mySpace\MyClass', key($mySpace->getClasses()));
}
- /**
- * @covers ::create
- */
+ /** @covers ::create */
public function testWithNamespacedInterface(): void
{
$file = new File(md5('some/file.php'), 'some/file.php');
@@ -173,9 +165,7 @@ public function testWithNamespacedInterface(): void
$this->assertEquals('\mySpace\MyInterface', key($mySpace->getInterfaces()));
}
- /**
- * @covers ::create
- */
+ /** @covers ::create */
public function testWithNamespacedFunction(): void
{
$file = new File(md5('some/file.php'), 'some/file.php');
@@ -190,9 +180,7 @@ public function testWithNamespacedFunction(): void
$this->assertEquals('\mySpace\function()', key($mySpace->getFunctions()));
}
- /**
- * @covers ::create
- */
+ /** @covers ::create */
public function testWithNamespacedConstant(): void
{
$file = new File(md5('some/file.php'), 'some/file.php');
@@ -207,9 +195,7 @@ public function testWithNamespacedConstant(): void
$this->assertEquals('\mySpace::MY_CONST', key($mySpace->getConstants()));
}
- /**
- * @covers ::create
- */
+ /** @covers ::create */
public function testWithNamespacedTrait(): void
{
$file = new File(md5('some/file.php'), 'some/file.php');
@@ -224,9 +210,7 @@ public function testWithNamespacedTrait(): void
$this->assertEquals('\mySpace\MyTrait', key($mySpace->getTraits()));
}
- /**
- * @covers ::create
- */
+ /** @covers ::create */
public function testNamespaceSpreadOverMultipleFiles(): void
{
$someFile = new File(md5('some/file.php'), 'some/file.php');
@@ -243,9 +227,7 @@ public function testNamespaceSpreadOverMultipleFiles(): void
$this->assertCount(2, current($namespaces)->getClasses());
}
- /**
- * @covers ::create
- */
+ /** @covers ::create */
public function testSingleFileMultipleNamespaces(): void
{
$someFile = new File(md5('some/file.php'), 'some/file.php');
@@ -289,13 +271,13 @@ private function fetchNamespacesFromMultipleFiles(array $files): array
$fileStrategyMock = $this->prophesize(ProjectFactoryStrategy::class);
$fileStrategyMock->matches(
ProphesizeArgument::type(ContextStack::class),
- ProphesizeArgument::any()
+ ProphesizeArgument::any(),
)->willReturn(true);
$fileStrategyMock->create(
ProphesizeArgument::type(ContextStack::class),
ProphesizeArgument::type(File::class),
- ProphesizeArgument::any()
+ ProphesizeArgument::any(),
)->will(function ($args): void {
$context = $args[0];
assert($context instanceof ContextStack);
diff --git a/tests/unit/phpDocumentor/Reflection/Php/ProjectTest.php b/tests/unit/phpDocumentor/Reflection/Php/ProjectTest.php
index 34cc37da..8df072bf 100644
--- a/tests/unit/phpDocumentor/Reflection/Php/ProjectTest.php
+++ b/tests/unit/phpDocumentor/Reflection/Php/ProjectTest.php
@@ -25,7 +25,7 @@
*/
class ProjectTest extends TestCase
{
- public const EXAMPLE_NAME = 'Initial name';
+ final public const EXAMPLE_NAME = 'Initial name';
private Project $fixture;
diff --git a/tests/unit/phpDocumentor/Reflection/Php/PropertyTest.php b/tests/unit/phpDocumentor/Reflection/Php/PropertyTest.php
index ba05b9d9..5f8b319d 100644
--- a/tests/unit/phpDocumentor/Reflection/Php/PropertyTest.php
+++ b/tests/unit/phpDocumentor/Reflection/Php/PropertyTest.php
@@ -99,7 +99,7 @@ public function testGettingWhetherPropertyIsReadOnly(): void
null,
null,
null,
- true
+ true,
);
$this->assertTrue($property->isReadOnly());
@@ -181,7 +181,7 @@ public function testGetType(): void
false,
null,
null,
- $type
+ $type,
);
$this->assertSame($type, $fixture->getType());
diff --git a/tests/unit/phpDocumentor/Reflection/Php/TestCase.php b/tests/unit/phpDocumentor/Reflection/Php/TestCase.php
index bc7caad3..9be46c68 100644
--- a/tests/unit/phpDocumentor/Reflection/Php/TestCase.php
+++ b/tests/unit/phpDocumentor/Reflection/Php/TestCase.php
@@ -22,8 +22,7 @@
*/
abstract class TestCase extends BaseTestCase
{
- /** @var Element|MetaDataContainerInterface */
- protected $fixture;
+ protected Element|MetaDataContainerInterface $fixture;
/**
* @covers ::getLocation
@@ -48,10 +47,7 @@ public function testLineAndColumnNumberIsReturnedWhenALocationIsProvided(): void
{
}
- /**
- * @param Element|MetaDataContainerInterface $fixture
- */
- protected function assertLineAndColumnNumberIsReturnedWhenALocationIsProvided($fixture): void
+ protected function assertLineAndColumnNumberIsReturnedWhenALocationIsProvided(Element|MetaDataContainerInterface $fixture): void
{
$this->assertSame(100, $fixture->getLocation()->getLineNumber());
$this->assertSame(20, $fixture->getLocation()->getColumnNumber());
diff --git a/tests/unit/phpDocumentor/Reflection/Php/Trait_Test.php b/tests/unit/phpDocumentor/Reflection/Php/Trait_Test.php
index edad4a34..72f5ddd3 100644
--- a/tests/unit/phpDocumentor/Reflection/Php/Trait_Test.php
+++ b/tests/unit/phpDocumentor/Reflection/Php/Trait_Test.php
@@ -123,9 +123,7 @@ public function testAddAndGettingConstants(): void
$this->assertSame(['\MyClass::MY_CONSTANT' => $constant], $this->fixture->getConstants());
}
- /**
- * @covers ::getDocBlock
- */
+ /** @covers ::getDocBlock */
public function testGetDocblock(): void
{
$this->assertSame($this->docBlock, $this->fixture->getDocBlock());
diff --git a/tests/unit/phpDocumentor/Reflection/Php/ValueEvaluator/ConstantEvaluatorTest.php b/tests/unit/phpDocumentor/Reflection/Php/ValueEvaluator/ConstantEvaluatorTest.php
index 91a7db48..ea96ce1d 100644
--- a/tests/unit/phpDocumentor/Reflection/Php/ValueEvaluator/ConstantEvaluatorTest.php
+++ b/tests/unit/phpDocumentor/Reflection/Php/ValueEvaluator/ConstantEvaluatorTest.php
@@ -12,9 +12,7 @@
use PhpParser\Node\Scalar\MagicConst\Namespace_;
use PHPUnit\Framework\TestCase;
-/**
- * @coversDefaultClass \phpDocumentor\Reflection\Php\ValueEvaluator\ConstantEvaluator
- */
+/** @coversDefaultClass \phpDocumentor\Reflection\Php\ValueEvaluator\ConstantEvaluator */
final class ConstantEvaluatorTest extends TestCase
{
/** @covers ::evaluate */
diff --git a/tests/unit/phpDocumentor/Reflection/Php/VisibilityTest.php b/tests/unit/phpDocumentor/Reflection/Php/VisibilityTest.php
index c15b4071..609d644f 100644
--- a/tests/unit/phpDocumentor/Reflection/Php/VisibilityTest.php
+++ b/tests/unit/phpDocumentor/Reflection/Php/VisibilityTest.php
@@ -35,9 +35,7 @@ public function testVisibility(string $input, string $expected): void
$this->assertEquals($expected, (string) $visibility);
}
- /**
- * @return string[][]
- */
+ /** @return string[][] */
public function visibilityProvider(): array
{
return [
@@ -48,9 +46,7 @@ public function visibilityProvider(): array
];
}
- /**
- * @covers ::__construct
- */
+ /** @covers ::__construct */
public function testVisibilityChecksInput(): void
{
$this->expectException(InvalidArgumentException::class);
diff --git a/tests/unit/phpDocumentor/Reflection/Types/NamespaceNodeToContextTest.php b/tests/unit/phpDocumentor/Reflection/Types/NamespaceNodeToContextTest.php
index 73fc7b99..afe924fc 100644
--- a/tests/unit/phpDocumentor/Reflection/Types/NamespaceNodeToContextTest.php
+++ b/tests/unit/phpDocumentor/Reflection/Types/NamespaceNodeToContextTest.php
@@ -23,14 +23,12 @@ final class NamespaceNodeToContextTest extends TestCase
* @dataProvider expectedContextsProvider
* @covers ::__invoke
*/
- public function testConversion(?Namespace_ $namespace, Context $expectedContext): void
+ public function testConversion(Namespace_|null $namespace, Context $expectedContext): void
{
$this->assertEquals($expectedContext, (new NamespaceNodeToContext())->__invoke($namespace));
}
- /**
- * @return (Namespace|Context|null)[][]
- */
+ /** @return (Namespace|Context|null)[][] */
public function expectedContextsProvider(): array
{
$namespaceWithImports = new Namespace_(
@@ -51,11 +49,11 @@ public function expectedContextsProvider(): array
[
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 [
@@ -91,7 +89,7 @@ public function expectedContextsProvider(): array
'MMM' => 'LLL\\MMM',
'OOO' => 'LLL\\NNN',
'PPP' => 'PPP',
- ]
+ ],
),
],
];