diff --git a/.github/workflows/diagnostics.yml b/.github/workflows/diagnostics.yml
index c56232d..d6701db 100644
--- a/.github/workflows/diagnostics.yml
+++ b/.github/workflows/diagnostics.yml
@@ -18,7 +18,7 @@ jobs:
matrix:
include:
- php: '7.4'
- phpcq_install: 'install'
+ phpcq_install: 'update'
phpcq_flags: ''
- php: '8.0'
phpcq_install: 'update'
@@ -28,11 +28,16 @@ jobs:
phpcq_flags: ''
- php: '8.2'
phpcq_install: 'update'
- phpcq_flags: '--exit-0'
-
+ phpcq_flags: ''
+ - php: '8.3'
+ phpcq_install: 'update'
+ phpcq_flags: ''
+ - php: '8.4'
+ phpcq_install: 'update'
+ phpcq_flags: ''
steps:
- name: Pull source
- uses: actions/checkout@v2
+ uses: actions/checkout@v4
- name: Setup PHP with PECL extension
uses: shivammathur/setup-php@v2
@@ -40,7 +45,7 @@ jobs:
php-version: ${{ matrix.php }}
- name: Cache composer cache directory
- uses: actions/cache@v1
+ uses: actions/cache@v4
env:
cache-name: composer-cache-dir-${{ matrix.php }}
with:
@@ -48,7 +53,7 @@ jobs:
key: ${{ runner.os }}-build-${{ env.cache-name }}
- name: Cache phpcq directory
- uses: actions/cache@v1
+ uses: actions/cache@v4
env:
cache-name: phpcq-${{ matrix.php }}
with:
@@ -58,7 +63,7 @@ jobs:
${{ runner.os }}-build-${{ env.cache-name }}-
- name: Cache vendor directory
- uses: actions/cache@v1
+ uses: actions/cache@v4
env:
cache-name: vendor-${{ matrix.php }}
with:
@@ -80,7 +85,7 @@ jobs:
run: ./vendor/bin/phpcq run -o github-action -o default ${{ matrix.phpcq_flags }}
- name: Upload build directory to artifact
- uses: actions/upload-artifact@v2
+ uses: actions/upload-artifact@v4
if: ${{ success() }} || ${{ failure() }}
with:
name: phpcq-builds-php-${{ matrix.php }}
diff --git a/.phpcq.lock b/.phpcq.lock
index 690ee40..8e3e36e 100644
--- a/.phpcq.lock
+++ b/.phpcq.lock
@@ -1 +1 @@
-{"plugins":{"phpunit":{"api-version":"1.0.0","version":"1.0.0.0","type":"php-file","url":"https://phpcq.github.io/repository/phpunit-1.0.0.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0"},"tool":{"phpunit":"^6.0 || ^7.0 || ^8.0 || ^9.0"}},"checksum":{"type":"sha-512","value":"c73f15658e3ba62665f09492ec91c3a6a715760bfaa88473a987538439fff442540148e086e46a6aa18ce55a3ea2fbf76caaa581384cb84a38859fcc609ae7e4"},"tools":{"phpunit":{"version":"9.5.21","url":"https://phar.phpunit.de/phpunit-9.5.21.phar","requirements":{"php":{"php":">=7.3","ext-dom":"*","ext-json":"*","ext-libxml":"*","ext-mbstring":"*","ext-xml":"*","ext-xmlwriter":"*"}},"checksum":{"type":"sha-256","value":"cafb2681fa0ad01201b08b9ba89f7dbb41975147dfe93ffef14b76c06b31fea2"},"signature":"https://phar.phpunit.de/phpunit-9.5.21.phar.asc"}},"composerLock":null},"psalm":{"api-version":"1.0.0","version":"1.1.1.0","type":"php-file","url":"https://phpcq.github.io/repository/psalm-1.1.1.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-dom":"*"},"tool":{"psalm":"^3.0 || ^4.0"}},"checksum":{"type":"sha-512","value":"4a550c9226d7bca582d7c10bd87cce01190c96398936b1613421640c83df62ed1c6e0d44c1b39635414ea8cf4a892a6458d27590793238add24e7cb5547e6ffd"},"tools":{"psalm":{"version":"4.23.0","url":"https://github.com/vimeo/psalm/releases/download/4.23.0/psalm.phar","requirements":{"php":{"php":"^7.1|^8","ext-SimpleXML":"*","ext-ctype":"*","ext-dom":"*","ext-json":"*","ext-libxml":"*","ext-mbstring":"*","ext-tokenizer":"*"}},"checksum":null,"signature":"https://github.com/vimeo/psalm/releases/download/4.23.0/psalm.phar.asc"}},"composerLock":null},"composer-require-checker":{"api-version":"1.0.0","version":"1.1.1.0","type":"php-file","url":"https://phpcq.github.io/repository/composer-require-checker-1.1.1.0.php","signature":null,"requirements":{"php":{"php":"^7.4 || ^8.0"},"tool":{"composer-require-checker":"^3.8 || ^4.0"}},"checksum":{"type":"sha-512","value":"d5415bddfe024c5749d894034583882aee4e5c3e1087815d9fdd81cb5e71630f631a0e35de0ff84b97fbbf738c16ece5f83bd8c00695913eb846aa6f04577dc2"},"tools":{"composer-require-checker":{"version":"3.8.0","url":"https://github.com/maglnet/ComposerRequireChecker/releases/download/3.8.0/composer-require-checker.phar","requirements":{"php":{"php":"^7.4 || ^8.0","ext-json":"*","ext-phar":"*"}},"checksum":null,"signature":"https://github.com/maglnet/ComposerRequireChecker/releases/download/3.8.0/composer-require-checker.phar.asc"}},"composerLock":null},"phpmd":{"api-version":"1.0.0","version":"1.0.1.0","type":"php-file","url":"https://phpcq.github.io/repository/phpmd-1.0.1.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-dom":"*"},"tool":{"phpmd":"^2.6.1"}},"checksum":{"type":"sha-512","value":"88e267b9c36b2edc85e924717606b626e005ac8d97b1f65f5331e2a3b3894dec2cf124f6187541bf759d026477b6d94daacc5d5c81bb09714a68ffabe5698dc5"},"tools":{"phpmd":{"version":"2.12.0","url":"https://github.com/phpmd/phpmd/releases/download/2.12.0/phpmd.phar","requirements":{"php":{"php":">=5.3.9","ext-xml":"*"}},"checksum":null,"signature":null}},"composerLock":null},"phpcpd":{"api-version":"1.0.0","version":"1.1.1.0","type":"php-file","url":"https://phpcq.github.io/repository/phpcpd-1.1.1.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-dom":"*"},"tool":{"phpcpd":"^6.0"}},"checksum":{"type":"sha-512","value":"1189ce0bf3fade4cb4241f1d96f915ef8fc7651f4450dc79fdf464ee3d6be3009316f0d423ce2d4af9d76ad50807b7fdf4d77bfa6d9ee2c91d6eda32ea214433"},"tools":{"phpcpd":{"version":"6.0.3","url":"https://phar.phpunit.de/phpcpd-6.0.3.phar","requirements":{"php":{"php":">=7.3","ext-dom":"*"}},"checksum":{"type":"sha-256","value":"2cbaea7cfda1bb4299d863eb075e977c3f49055dd16d88529fae5150d48a84cb"},"signature":"https://phar.phpunit.de/phpcpd-6.0.3.phar.asc"}},"composerLock":null},"phploc":{"api-version":"1.0.0","version":"1.0.0.0","type":"php-file","url":"https://phpcq.github.io/repository/phploc-1.0.0.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-dom":"*","ext-json":"*"},"tool":{"phploc":"^3.0 || ^4.0 || ^5.0 || ^6.0 || ^7.0"}},"checksum":{"type":"sha-512","value":"f67b02d494796adf553cb3dd13ec06c1cb8e53c799954061749424251379541637538199afb3afa3c7a01cabd1cb6f1c53eb621f015dff9644c6c7cbf10c56d1"},"tools":{"phploc":{"version":"7.0.2","url":"https://phar.phpunit.de/phploc-7.0.2.phar","requirements":{"php":{"php":">=7.3","ext-dom":"*","ext-json":"*"}},"checksum":{"type":"sha-256","value":"3d59778ec86faf25fd00e3a329b2f9ad4a3c751ca91601ea7dab70f887b0bf46"},"signature":"https://phar.phpunit.de/phploc-7.0.2.phar.asc"}},"composerLock":null},"phpcs":{"api-version":"1.0.0","version":"1.1.0.0","type":"php-file","url":"https://phpcq.github.io/repository/phpcs-1.1.0.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-dom":"*"},"tool":{"phpcs":"^3.0 || ^2.0","phpcbf":"^3.0 || ^2.0"}},"checksum":{"type":"sha-512","value":"2737022369da1318cc4e0ea194e8a81019f7b079080d869aab878b7486052fdbe68fee3f28131f35573226def1aabd4bd005e038ee7b767c137b1107c1492a83"},"tools":{"phpcs":{"version":"3.7.1","url":"https://github.com/squizlabs/PHP_CodeSniffer/releases/download/3.7.1/phpcs.phar","requirements":{"php":{"php":">=5.4.0","ext-tokenizer":"*","ext-xmlwriter":"*","ext-simplexml":"*"}},"checksum":null,"signature":"https://github.com/squizlabs/PHP_CodeSniffer/releases/download/3.7.1/phpcs.phar.asc"},"phpcbf":{"version":"3.7.1","url":"https://github.com/squizlabs/PHP_CodeSniffer/releases/download/3.7.1/phpcbf.phar","requirements":{"php":{"php":">=5.4.0","ext-tokenizer":"*","ext-xmlwriter":"*","ext-simplexml":"*"}},"checksum":null,"signature":"https://github.com/squizlabs/PHP_CodeSniffer/releases/download/3.7.1/phpcbf.phar.asc"}},"composerLock":null},"composer-normalize":{"api-version":"1.0.0","version":"1.1.0.0","type":"php-file","url":"https://phpcq.github.io/repository/composer-normalize-1.1.0.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-json":"*"},"tool":{"composer-normalize":"^2.1"}},"checksum":{"type":"sha-512","value":"d59d3557cb20630734878a9115df5dd32d5aff815e5b15be36f6fb5d6e9d83dd36efd84215ab6529edcc924f600946f739a0d9e67723deff95c88346ab502498"},"tools":{"composer-normalize":{"version":"2.28.0","url":"https://github.com/ergebnis/composer-normalize/releases/download/2.28.0/composer-normalize.phar","requirements":{"php":{"php":"^7.4 || ^8.0"}},"checksum":null,"signature":"https://github.com/ergebnis/composer-normalize/releases/download/2.28.0/composer-normalize.phar.asc"}},"composerLock":null}},"tools":[]}
\ No newline at end of file
+{"plugins":{"phpunit":{"api-version":"1.0.0","version":"1.0.0.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/phpunit/phpunit-1.0.0.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0"},"tool":{"phpunit":"^6.0 || ^7.0 || ^8.0 || ^9.0"}},"checksum":{"type":"sha-512","value":"c73f15658e3ba62665f09492ec91c3a6a715760bfaa88473a987538439fff442540148e086e46a6aa18ce55a3ea2fbf76caaa581384cb84a38859fcc609ae7e4"},"tools":{"phpunit":{"version":"9.6.23","url":"https://phar.phpunit.de/phpunit-9.6.23.phar","requirements":{"php":{"php":">=7.3","ext-dom":"*","ext-json":"*","ext-libxml":"*","ext-mbstring":"*","ext-xml":"*","ext-xmlwriter":"*"}},"checksum":{"type":"sha-256","value":"f195cd37de1bd14b4b60aa90af5bea95e8506d828c0dbbcf8dca03d78a38e79f"},"signature":"https://phar.phpunit.de/phpunit-9.6.23.phar.asc"}},"composerLock":null},"psalm":{"api-version":"1.0.0","version":"1.3.0.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/psalm/psalm-1.3.0.0.php","signature":null,"requirements":{"php":{"php":"^7.4 || ^8.0","ext-dom":"*"},"tool":{"psalm":"^3.0 || ^4.0 || ^5.0 || ^6.0"}},"checksum":{"type":"sha-512","value":"4a550c9226d7bca582d7c10bd87cce01190c96398936b1613421640c83df62ed1c6e0d44c1b39635414ea8cf4a892a6458d27590793238add24e7cb5547e6ffd"},"tools":{"psalm":{"version":"6.12.0","url":"https://github.com/vimeo/psalm/releases/download/6.12.0/psalm.phar","requirements":{"php":{"php":"~8.1.31 || ~8.2.27 || ~8.3.16 || ~8.4.3","ext-SimpleXML":"*","ext-ctype":"*","ext-dom":"*","ext-json":"*","ext-libxml":"*","ext-mbstring":"*","ext-tokenizer":"*"}},"checksum":null,"signature":"https://github.com/vimeo/psalm/releases/download/6.12.0/psalm.phar.asc"}},"composerLock":null},"composer-require-checker":{"api-version":"1.0.0","version":"1.1.1.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/composer-require-checker/composer-require-checker-1.1.1.0.php","signature":null,"requirements":{"php":{"php":"^7.4 || ^8.0"},"tool":{"composer-require-checker":"^3.8 || ^4.0"}},"checksum":{"type":"sha-512","value":"d5415bddfe024c5749d894034583882aee4e5c3e1087815d9fdd81cb5e71630f631a0e35de0ff84b97fbbf738c16ece5f83bd8c00695913eb846aa6f04577dc2"},"tools":{"composer-require-checker":{"version":"4.16.1","url":"https://github.com/maglnet/ComposerRequireChecker/releases/download/4.16.1/composer-require-checker.phar","requirements":{"php":{"php":"~8.2.0 || ~8.3.0 || ~8.4.0","ext-phar":"*"}},"checksum":null,"signature":"https://github.com/maglnet/ComposerRequireChecker/releases/download/4.16.1/composer-require-checker.phar.asc"}},"composerLock":null},"phpmd":{"api-version":"1.0.0","version":"1.0.2.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/phpmd/phpmd-1.0.2.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-dom":"*"},"tool":{"phpmd":"^2.6.1"}},"checksum":{"type":"sha-512","value":"f22280a6dec8dbdd2ec1d83b294f23237fe32c34f4a298e52038e0a7a0074d541635b2b488b1a6098a42d8418a6cd8eb804406ea82b91e362be2b5d11a0915b0"},"tools":{"phpmd":{"version":"2.15.0","url":"https://github.com/phpmd/phpmd/releases/download/2.15.0/phpmd.phar","requirements":{"php":{"php":">=5.3.9","ext-xml":"*"}},"checksum":null,"signature":"https://github.com/phpmd/phpmd/releases/download/2.15.0/phpmd.phar.asc"}},"composerLock":null},"phpcpd":{"api-version":"1.0.0","version":"1.1.1.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/phpcpd/phpcpd-1.1.1.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-dom":"*"},"tool":{"phpcpd":"^6.0"}},"checksum":{"type":"sha-512","value":"1189ce0bf3fade4cb4241f1d96f915ef8fc7651f4450dc79fdf464ee3d6be3009316f0d423ce2d4af9d76ad50807b7fdf4d77bfa6d9ee2c91d6eda32ea214433"},"tools":{"phpcpd":{"version":"6.0.3","url":"https://phar.phpunit.de/phpcpd-6.0.3.phar","requirements":{"php":{"php":">=7.3","ext-dom":"*"}},"checksum":{"type":"sha-256","value":"2cbaea7cfda1bb4299d863eb075e977c3f49055dd16d88529fae5150d48a84cb"},"signature":"https://phar.phpunit.de/phpcpd-6.0.3.phar.asc"}},"composerLock":null},"phploc":{"api-version":"1.0.0","version":"1.0.0.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/phploc/phploc-1.0.0.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-dom":"*","ext-json":"*"},"tool":{"phploc":"^3.0 || ^4.0 || ^5.0 || ^6.0 || ^7.0"}},"checksum":{"type":"sha-512","value":"f67b02d494796adf553cb3dd13ec06c1cb8e53c799954061749424251379541637538199afb3afa3c7a01cabd1cb6f1c53eb621f015dff9644c6c7cbf10c56d1"},"tools":{"phploc":{"version":"7.0.2","url":"https://phar.phpunit.de/phploc-7.0.2.phar","requirements":{"php":{"php":">=7.3","ext-dom":"*","ext-json":"*"}},"checksum":{"type":"sha-256","value":"3d59778ec86faf25fd00e3a329b2f9ad4a3c751ca91601ea7dab70f887b0bf46"},"signature":"https://phar.phpunit.de/phploc-7.0.2.phar.asc"}},"composerLock":null},"phpcs":{"api-version":"1.0.0","version":"1.2.0.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/phpcs/phpcs-1.2.0.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-dom":"*"},"tool":{"phpcs":"^3.0 || ^2.0","phpcbf":"^3.0 || ^2.0"}},"checksum":{"type":"sha-512","value":"b6ed00306e76068a6af5e3b1dec837724f9e1900ef1049ce88e7ce195b0583524ca33a73613fba13244307a7ca853b6ddaa14ded69f651c3f184ac130bd1aaad"},"tools":{"phpcs":{"version":"3.13.2","url":"https://github.com/PHPCSStandards/PHP_CodeSniffer/releases/download/3.13.2/phpcs.phar","requirements":{"php":{"php":">=5.4.0","ext-simplexml":"*","ext-tokenizer":"*","ext-xmlwriter":"*"}},"checksum":null,"signature":"https://github.com/PHPCSStandards/PHP_CodeSniffer/releases/download/3.13.2/phpcs.phar.asc"},"phpcbf":{"version":"3.13.2","url":"https://github.com/PHPCSStandards/PHP_CodeSniffer/releases/download/3.13.2/phpcbf.phar","requirements":{"php":{"php":">=5.4.0","ext-simplexml":"*","ext-tokenizer":"*","ext-xmlwriter":"*"}},"checksum":null,"signature":"https://github.com/PHPCSStandards/PHP_CodeSniffer/releases/download/3.13.2/phpcbf.phar.asc"}},"composerLock":null},"composer-normalize":{"api-version":"1.0.0","version":"1.1.1.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/composer-normalize/composer-normalize-1.1.1.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-json":"*"},"tool":{"composer-normalize":"^2.1"}},"checksum":{"type":"sha-512","value":"d9abda440b85d501c58abf9c81bf76f417594b397129215ffa8b777e9bb5e5eda37d7661d661db3c8d11c24f20345bc6fbe56f013b3b9435d459d2b94f086e0f"},"tools":{"composer-normalize":{"version":"2.47.0","url":"https://github.com/ergebnis/composer-normalize/releases/download/2.47.0/composer-normalize.phar","requirements":{"php":{"php":"~7.4.0 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0","ext-json":"*"}},"checksum":null,"signature":"https://github.com/ergebnis/composer-normalize/releases/download/2.47.0/composer-normalize.phar.asc"}},"composerLock":null}},"tools":[]}
\ No newline at end of file
diff --git a/.phpcq.yaml.dist b/.phpcq.yaml.dist
index e676270..5ff46b7 100644
--- a/.phpcq.yaml.dist
+++ b/.phpcq.yaml.dist
@@ -46,8 +46,11 @@ phpcq:
- D2CCAC42F6295E7D
# PHP_CodeSniffer
- 31C7E470E2138192
+ - 97B02DD8E5071466
# Composer normalize
- C00543248C87FB13
+ # PHPMD
+ - 9093F8B32E4815AA
tasks:
fix:
@@ -99,3 +102,7 @@ tasks:
plugin: composer-normalize
config:
dry_run: false
+
+ psalm:
+ config:
+ auto_php_version: false
diff --git a/composer.json b/composer.json
index dee606b..57cd93c 100644
--- a/composer.json
+++ b/composer.json
@@ -17,7 +17,7 @@
}
],
"require": {
- "php": "^7.3 || ^8.0",
+ "php": "^7.4 || ^8.0",
"ext-filter": "*",
"ext-hash": "*",
"ext-json": "*"
diff --git a/composer.lock b/composer.lock
index d4435bc..c9ea712 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": "b818a946b191fcb1b7707fd5d766395c",
+ "content-hash": "8b19bfd6134cf3d24e2207f5369e015d",
"packages": [],
"packages-dev": [
{
@@ -78,11 +78,11 @@
"prefer-stable": false,
"prefer-lowest": false,
"platform": {
- "php": "^7.3 || ^8.0",
+ "php": "^7.4 || ^8.0",
"ext-filter": "*",
"ext-hash": "*",
"ext-json": "*"
},
- "platform-dev": [],
- "plugin-api-version": "2.3.0"
+ "platform-dev": {},
+ "plugin-api-version": "2.6.0"
}
diff --git a/psalm.xml b/psalm.xml
index db645bc..4e9d453 100644
--- a/psalm.xml
+++ b/psalm.xml
@@ -2,11 +2,20 @@
+
+
+
+
+
+
+
+
diff --git a/src/AbstractHash.php b/src/AbstractHash.php
index 42b4bcd..55d16a2 100644
--- a/src/AbstractHash.php
+++ b/src/AbstractHash.php
@@ -60,13 +60,13 @@ public static function createForFile(string $absolutePath, string $type = self::
self::SHA_512 => 'sha512',
];
- return static::create($type, hash_file($hashMap[$type], $absolutePath));
+ return static::create($type, (string) hash_file($hashMap[$type], $absolutePath));
}
/** @return static */
public static function createForString(string $contents, string $type = self::SHA_512): self
{
- return static::create($type, hash(self::HASHMAP[$type], $contents));
+ return static::create($type, (string) hash(self::HASHMAP[$type], $contents));
}
/**
diff --git a/src/Exception/PluginNotFoundException.php b/src/Exception/PluginNotFoundException.php
index 2c5128c..08cf165 100644
--- a/src/Exception/PluginNotFoundException.php
+++ b/src/Exception/PluginNotFoundException.php
@@ -13,7 +13,7 @@ final class PluginNotFoundException extends RuntimeException
*/
private $plugin;
- public function __construct(string $plugin, int $code = 0, Throwable $previous = null)
+ public function __construct(string $plugin, int $code = 0, ?Throwable $previous = null)
{
parent::__construct(sprintf('Plugin "%s" not found', $plugin), $code, $previous);
diff --git a/src/Exception/ToolNotFoundException.php b/src/Exception/ToolNotFoundException.php
index 4716efa..dfa2d8b 100644
--- a/src/Exception/ToolNotFoundException.php
+++ b/src/Exception/ToolNotFoundException.php
@@ -13,7 +13,7 @@ final class ToolNotFoundException extends RuntimeException
*/
private $tool;
- public function __construct(string $tool, int $code = 0, Throwable $previous = null)
+ public function __construct(string $tool, int $code = 0, ?Throwable $previous = null)
{
parent::__construct(sprintf('Tool "%s" not found', $tool), $code, $previous);
diff --git a/src/FileGetContentsJsonFileLoader.php b/src/FileGetContentsJsonFileLoader.php
index f2f5a1e..dfe8bc0 100644
--- a/src/FileGetContentsJsonFileLoader.php
+++ b/src/FileGetContentsJsonFileLoader.php
@@ -4,6 +4,7 @@
namespace Phpcq\RepositoryDefinition;
+use Override;
use Phpcq\RepositoryDefinition\Exception\InvalidHashException;
use Phpcq\RepositoryDefinition\Exception\JsonFileNotFoundException;
@@ -17,6 +18,7 @@
*/
final class FileGetContentsJsonFileLoader implements JsonFileLoaderInterface
{
+ #[Override]
public function load(string $file, ?array $checksum = null): array
{
if (!file_exists($file)) {
diff --git a/src/Plugin/AbstractPluginVersion.php b/src/Plugin/AbstractPluginVersion.php
index 8d3e240..5f3ef2f 100644
--- a/src/Plugin/AbstractPluginVersion.php
+++ b/src/Plugin/AbstractPluginVersion.php
@@ -4,32 +4,26 @@
namespace Phpcq\RepositoryDefinition\Plugin;
+use Override;
use Phpcq\RepositoryDefinition\VersionRequirement;
use Phpcq\RepositoryDefinition\VersionRequirementList;
use RuntimeException;
abstract class AbstractPluginVersion implements PluginVersionInterface
{
- /** @var string */
- private $name;
+ private string $name;
- /** @var string */
- private $version;
+ private string $version;
- /** @var string */
- private $apiVersion;
+ private string $apiVersion;
- /** @var PluginHash */
- private $hash;
+ private PluginHash $hash;
- /** @var PluginRequirements */
- private $requirements;
+ private PluginRequirements $requirements;
- /** @var string */
- private $filePath;
+ private string $filePath;
- /** @var string|null */
- private $signaturePath;
+ private ?string $signaturePath;
public function __construct(
string $name,
@@ -52,41 +46,49 @@ public function __construct(
$this->requirements = $requirements ?? new PluginRequirements();
}
+ #[Override]
public function getApiVersion(): string
{
- return '1.0.0';
+ return $this->apiVersion;
}
+ #[Override]
public function getName(): string
{
return $this->name;
}
+ #[Override]
public function getVersion(): string
{
return $this->version;
}
+ #[Override]
public function getHash(): PluginHash
{
return $this->hash;
}
+ #[Override]
public function getRequirements(): PluginRequirements
{
return $this->requirements;
}
+ #[Override]
public function getFilePath(): string
{
return $this->filePath;
}
+ #[Override]
public function getSignaturePath(): ?string
{
return $this->signaturePath;
}
+ #[Override]
public function merge(PluginVersionInterface $other): void
{
$otherRequirements = $other->getRequirements();
@@ -98,7 +100,7 @@ public function merge(PluginVersionInterface $other): void
[$this->requirements->getComposerRequirements(), $otherRequirements->getComposerRequirements()],
] as $lists
) {
- /** @var VersionRequirementList[] $lists */
+ /** @var array{0: VersionRequirementList, 1: VersionRequirementList} $lists */
$target = $lists[0];
$source = $lists[1];
foreach ($source as $requirement) {
diff --git a/src/Plugin/Plugin.php b/src/Plugin/Plugin.php
index a59b5c4..c68d9d9 100644
--- a/src/Plugin/Plugin.php
+++ b/src/Plugin/Plugin.php
@@ -7,6 +7,7 @@
use InvalidArgumentException;
use IteratorAggregate;
use LogicException;
+use Override;
use Traversable;
/**
@@ -18,17 +19,15 @@ class Plugin implements IteratorAggregate, PluginInterface
{
/**
* The name of the plugin.
- *
- * @var string
*/
- private $name;
+ private string $name;
/**
* All versions of the plugin.
*
* @var PluginVersionInterface[]
*/
- private $versions = [];
+ private array $versions = [];
/**
* Create a new instance.
@@ -43,11 +42,13 @@ public function __construct(string $name)
/**
* Retrieve name.
*/
+ #[Override]
public function getName(): string
{
return $this->name;
}
+ #[Override]
public function addVersion(PluginVersionInterface $version): void
{
if ($version->getName() !== $this->name) {
@@ -60,6 +61,7 @@ public function addVersion(PluginVersionInterface $version): void
$this->versions[$version->getVersion()] = $version;
}
+ #[Override]
public function getVersion(string $version): PluginVersionInterface
{
if (!$this->has($version)) {
@@ -68,11 +70,13 @@ public function getVersion(string $version): PluginVersionInterface
return $this->versions[$version];
}
+ #[Override]
public function has(string $version): bool
{
return isset($this->versions[$version]);
}
+ #[Override]
public function isEmpty(): bool
{
return empty($this->versions);
@@ -83,6 +87,7 @@ public function isEmpty(): bool
*
* @return Traversable
*/
+ #[Override]
public function getIterator(): Traversable
{
foreach ($this->versions as $version) {
diff --git a/src/Plugin/PluginRequirements.php b/src/Plugin/PluginRequirements.php
index adb04e3..4bc6756 100644
--- a/src/Plugin/PluginRequirements.php
+++ b/src/Plugin/PluginRequirements.php
@@ -10,31 +10,23 @@ class PluginRequirements
{
/**
* Platform requirements.
- *
- * @var VersionRequirementList
*/
- private $phpRequirements;
+ private VersionRequirementList $phpRequirements;
/**
* Required tools.
- *
- * @var VersionRequirementList
*/
- private $toolRequirements;
+ private VersionRequirementList $toolRequirements;
/**
* Required peer plugins.
- *
- * @var VersionRequirementList
*/
- private $pluginRequirements;
+ private VersionRequirementList $pluginRequirements;
/**
* Required composer libraries.
- *
- * @var VersionRequirementList
*/
- private $composerRequirements;
+ private VersionRequirementList $composerRequirements;
/**
* Create a new instance.
diff --git a/src/Repository.php b/src/Repository.php
index e618b36..c52f069 100644
--- a/src/Repository.php
+++ b/src/Repository.php
@@ -5,6 +5,7 @@
namespace Phpcq\RepositoryDefinition;
use Generator;
+use Override;
use Phpcq\RepositoryDefinition\Exception\PluginNotFoundException;
use Phpcq\RepositoryDefinition\Exception\ToolNotFoundException;
use Phpcq\RepositoryDefinition\Plugin\PluginInterface;
@@ -12,17 +13,19 @@
class Repository implements RepositoryInterface
{
- /** @var ToolInterface[] */
- private $tools = [];
+ /** @var array */
+ private array $tools = [];
- /** @var PluginInterface[] */
- private $plugins = [];
+ /** @var array */
+ private array $plugins = [];
+ #[Override]
public function hasTool(string $name): bool
{
return isset($this->tools[$name]);
}
+ #[Override]
public function addTool(ToolInterface $tool): void
{
if ($this->hasTool($tool->getName())) {
@@ -32,6 +35,7 @@ public function addTool(ToolInterface $tool): void
$this->tools[$tool->getName()] = $tool;
}
+ #[Override]
public function getTool(string $name): ToolInterface
{
if (!isset($this->tools[$name])) {
@@ -41,11 +45,13 @@ public function getTool(string $name): ToolInterface
return $this->tools[$name];
}
+ #[Override]
public function hasPlugin(string $name): bool
{
return isset($this->plugins[$name]);
}
+ #[Override]
public function addPlugin(PluginInterface $plugin): void
{
if ($this->hasPlugin($plugin->getName())) {
@@ -55,6 +61,7 @@ public function addPlugin(PluginInterface $plugin): void
$this->plugins[$plugin->getName()] = $plugin;
}
+ #[Override]
public function getPlugin(string $name): PluginInterface
{
if (!isset($this->plugins[$name])) {
@@ -71,6 +78,7 @@ public function getPlugin(string $name): PluginInterface
*
* @psalm-return Generator
*/
+ #[Override]
public function iterateTools(): Generator
{
foreach ($this->tools as $tool) {
@@ -85,6 +93,7 @@ public function iterateTools(): Generator
*
* @psalm-return Generator
*/
+ #[Override]
public function iteratePlugins(): Generator
{
foreach ($this->plugins as $plugin) {
diff --git a/src/RepositoryLoader.php b/src/RepositoryLoader.php
index 65783ef..4018a39 100644
--- a/src/RepositoryLoader.php
+++ b/src/RepositoryLoader.php
@@ -77,13 +77,12 @@
final class RepositoryLoader
{
/** @psalm-var array */
- private $tools = [];
+ private array $tools = [];
/** @psalm-var array */
- private $plugins = [];
+ private array $plugins = [];
- /** @var JsonFileLoaderInterface */
- private $fileLoader;
+ private JsonFileLoaderInterface $fileLoader;
/**
* @psalm-param TRepositoryCheckSum|null $checksum
@@ -283,7 +282,7 @@ private function loadPluginHash(array $hash): PluginHash
private function loadToolRequirements(?array $requirements): ToolRequirements
{
$result = new ToolRequirements();
- if (empty($requirements)) {
+ if ($requirements === null || $requirements === []) {
return $result;
}
@@ -305,7 +304,7 @@ private function loadToolRequirements(?array $requirements): ToolRequirements
private function loadPluginRequirements(?array $requirements): PluginRequirements
{
$result = new PluginRequirements();
- if (empty($requirements)) {
+ if ($requirements === null || $requirements === []) {
return $result;
}
@@ -336,7 +335,7 @@ private function validateUrlOrFile(string $url, string $baseDir): string
return $baseDir . '/' . $url;
}
// Perform URL check.
- $path = parse_url($url, PHP_URL_PATH);
+ $path = (string) parse_url($url, PHP_URL_PATH);
$encodedPath = array_map('urlencode', explode('/', $path));
$newUrl = str_replace($path, implode('/', $encodedPath), $url);
if (filter_var($newUrl, FILTER_VALIDATE_URL)) {
diff --git a/src/Tool/Tool.php b/src/Tool/Tool.php
index d195c2f..198b108 100644
--- a/src/Tool/Tool.php
+++ b/src/Tool/Tool.php
@@ -7,6 +7,7 @@
use InvalidArgumentException;
use IteratorAggregate;
use LogicException;
+use Override;
use Traversable;
/**
@@ -18,17 +19,15 @@ class Tool implements IteratorAggregate, ToolInterface
{
/**
* The name of the tool.
- *
- * @var string
*/
- private $name;
+ private string $name;
/**
* All versions of the tool.
*
- * @var ToolVersionInterface[]
+ * @var array
*/
- private $versions = [];
+ private array $versions = [];
/**
* Create a new instance.
@@ -43,11 +42,13 @@ public function __construct(string $name)
/**
* Retrieve name.
*/
+ #[Override]
public function getName(): string
{
return $this->name;
}
+ #[Override]
public function addVersion(ToolVersionInterface $version): void
{
if ($version->getName() !== $this->name) {
@@ -60,6 +61,7 @@ public function addVersion(ToolVersionInterface $version): void
$this->versions[$version->getVersion()] = $version;
}
+ #[Override]
public function getVersion(string $version): ToolVersionInterface
{
if (!$this->has($version)) {
@@ -68,11 +70,13 @@ public function getVersion(string $version): ToolVersionInterface
return $this->versions[$version];
}
+ #[Override]
public function has(string $version): bool
{
return isset($this->versions[$version]);
}
+ #[Override]
public function isEmpty(): bool
{
return empty($this->versions);
@@ -83,6 +87,7 @@ public function isEmpty(): bool
*
* @return Traversable
*/
+ #[Override]
public function getIterator(): Traversable
{
foreach ($this->versions as $version) {
diff --git a/src/Tool/ToolRequirements.php b/src/Tool/ToolRequirements.php
index 68f46ca..86ca8f9 100644
--- a/src/Tool/ToolRequirements.php
+++ b/src/Tool/ToolRequirements.php
@@ -10,17 +10,13 @@ class ToolRequirements
{
/**
* Platform requirements.
- *
- * @var VersionRequirementList
*/
- private $phpRequirements;
+ private VersionRequirementList $phpRequirements;
/**
* Required composer libraries.
- *
- * @var VersionRequirementList
*/
- private $composerRequirements;
+ private VersionRequirementList $composerRequirements;
/**
* Create a new instance.
diff --git a/src/Tool/ToolVersion.php b/src/Tool/ToolVersion.php
index 91ce52f..29e9d7a 100644
--- a/src/Tool/ToolVersion.php
+++ b/src/Tool/ToolVersion.php
@@ -4,28 +4,23 @@
namespace Phpcq\RepositoryDefinition\Tool;
+use Override;
use Phpcq\RepositoryDefinition\VersionRequirement;
use Phpcq\RepositoryDefinition\VersionRequirementList;
class ToolVersion implements ToolVersionInterface
{
- /** @var string */
- private $name;
+ private string $name;
- /** @var string */
- private $version;
+ private string $version;
- /** @var ?string */
- private $pharUrl;
+ private ?string $pharUrl;
- /** @var ?string */
- private $signatureUrl;
+ private ?string $signatureUrl;
- /** @var ToolHash|null */
- private $hash;
+ private ?ToolHash $hash;
- /** @var ToolRequirements */
- private $requirements;
+ private ToolRequirements $requirements;
public function __construct(
string $name,
@@ -43,31 +38,37 @@ public function __construct(
$this->requirements = $requirements ?? new ToolRequirements();
}
+ #[Override]
public function getName(): string
{
return $this->name;
}
+ #[Override]
public function getVersion(): string
{
return $this->version;
}
+ #[Override]
public function getPharUrl(): ?string
{
return $this->pharUrl;
}
+ #[Override]
public function getHash(): ?ToolHash
{
return $this->hash;
}
+ #[Override]
public function getSignatureUrl(): ?string
{
return $this->signatureUrl;
}
+ #[Override]
public function getRequirements(): ToolRequirements
{
return $this->requirements;
@@ -77,6 +78,7 @@ public function getRequirements(): ToolRequirements
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @SuppressWarnings(PHPMD.NPathComplexity)
*/
+ #[Override]
public function merge(ToolVersionInterface $other): void
{
if (null !== ($data = $other->getPharUrl()) && $data !== $this->pharUrl) {
@@ -102,7 +104,7 @@ public function merge(ToolVersionInterface $other): void
[$this->requirements->getComposerRequirements(), $otherRequirements->getComposerRequirements()],
] as $lists
) {
- /** @var VersionRequirementList[] $lists */
+ /** @var array{0: VersionRequirementList, 1: VersionRequirementList} $lists */
$target = $lists[0];
$source = $lists[1];
foreach ($source as $requirement) {
diff --git a/src/VersionRequirement.php b/src/VersionRequirement.php
index 9f3766f..b847f0f 100644
--- a/src/VersionRequirement.php
+++ b/src/VersionRequirement.php
@@ -6,11 +6,9 @@
class VersionRequirement
{
- /** @var string */
- private $name;
+ private string $name;
- /** @var string */
- private $constraint;
+ private string $constraint;
/**
* Create a new instance.
diff --git a/src/VersionRequirementList.php b/src/VersionRequirementList.php
index b0bb40c..9acd77f 100644
--- a/src/VersionRequirementList.php
+++ b/src/VersionRequirementList.php
@@ -7,6 +7,7 @@
use Countable;
use IteratorAggregate;
use LogicException;
+use Override;
use Traversable;
/**
@@ -15,14 +16,14 @@
class VersionRequirementList implements IteratorAggregate, Countable
{
/**
- * @var VersionRequirement[]
+ * @var array
*/
- private $requirements = [];
+ private array $requirements = [];
/**
* Create a new instance.
*
- * @param VersionRequirement[] $requirements
+ * @param array $requirements
*/
public function __construct(array $requirements = [])
{
@@ -55,6 +56,7 @@ public function has(string $name): bool
return isset($this->requirements[$name]);
}
+ #[Override]
public function count(): int
{
return count($this->requirements);
@@ -63,6 +65,7 @@ public function count(): int
/**
* @return Traversable
*/
+ #[Override]
public function getIterator(): Traversable
{
foreach ($this->requirements as $requirement) {