diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index b7a4afc..c3ac085 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -18,7 +18,7 @@ jobs: strategy: fail-fast: false matrix: - php-version: ['8.2', '8.3', '8.4', '8.5'] + php-version: ['8.3', '8.4', '8.5'] uses: simplesamlphp/simplesamlphp-test-framework/.github/workflows/reusable_phplinter.yml@v1.10.6 with: @@ -44,7 +44,7 @@ jobs: fail-fast: false matrix: operating-system: [ubuntu-latest] - php-versions: ['8.2', '8.3', '8.4', '8.5'] + php-versions: ['8.3', '8.4', '8.5'] steps: - name: Setup PHP, with composer and extensions @@ -107,7 +107,7 @@ jobs: fail-fast: true matrix: operating-system: [windows-latest] - php-versions: ['8.2', '8.3', '8.4', '8.5'] + php-versions: ['8.3', '8.4', '8.5'] steps: - name: Setup PHP, with composer and extensions @@ -225,7 +225,7 @@ jobs: uses: shivammathur/setup-php@v2 with: # Should be the lowest supported version - php-version: '8.2' + php-version: '8.3' extensions: ctype, date, dom, filter, hash, intl, mbstring, openssl, pcre, spl, xml tools: composer coverage: none diff --git a/.github/workflows/reusable_phplinter.yml b/.github/workflows/reusable_phplinter.yml index c96d1d1..c7ce48c 100644 --- a/.github/workflows/reusable_phplinter.yml +++ b/.github/workflows/reusable_phplinter.yml @@ -19,7 +19,7 @@ on: # yamllint disable-line rule:truthy default: ${{ github.ref }} env: - supported: '["7.4", "8.0", "8.1", "8.2", "8.3", "8.4", "8.5"]' + supported: '["8.3", "8.4", "8.5"]' jobs: linter: @@ -45,29 +45,10 @@ jobs: coverage: "none" extensions: :redis - - name: Install overtrue/phplint (v3.4) - if: inputs.php-version == '7.4' + - name: Install overtrue/phplint (v9.7) run: | sleep $((random % 10)) - phive install overtrue/phplint@~3.4.0 --force-accept-unsigned --target ./bin - - - name: Install overtrue/phplint (v4.5) - if: inputs.php-version == '8.0' - run: | - sleep $((random % 10)) - phive install overtrue/phplint@~4.5.0 --force-accept-unsigned --target ./bin - - - name: Install overtrue/phplint (v9.4) - if: inputs.php-version == '8.1' - run: | - sleep $((random % 10)) - phive install overtrue/phplint@~9.4.0 --force-accept-unsigned --target ./bin - - - name: Install overtrue/phplint (v9.6) - if: inputs.php-version != '7.4' && inputs.php-version != '8.0' && inputs.php-version != '8.1' - run: | - sleep $((random % 10)) - phive install overtrue/phplint@~9.6.0 --force-accept-unsigned --target ./bin + phive install overtrue/phplint@~9.7.1 --force-accept-unsigned --target ./bin - name: Lint PHP files run: | diff --git a/composer.json b/composer.json index bd4b845..a2073af 100644 --- a/composer.json +++ b/composer.json @@ -21,20 +21,20 @@ } }, "require": { - "php": "^8.2", + "php": "^8.3", "ext-curl": "*", "icanhazstring/composer-unused": "^0.9", - "maglnet/composer-require-checker": "^4", + "maglnet/composer-require-checker": "^4.19", "phpstan/extension-installer": "^1.4", "phpstan/phpstan": "^2.1", "phpstan/phpstan-mockery": "^2.0", "phpstan/phpstan-phpunit": "^2.0", - "phpunit/phpunit": "^11.5 || ^12.3", + "phpunit/phpunit": "^12.3", "psr/log": "^3.0", - "slevomat/coding-standard": "^8.20", + "slevomat/coding-standard": "^8.25", "squizlabs/php_codesniffer": "^4.0", - "symfony/phpunit-bridge": "^7.3 || ^8.0" + "symfony/phpunit-bridge": "^8.0" }, "require-dev": { "simplesamlphp/simplesamlphp": "^2.5@dev" diff --git a/lib/ArrayLogger.php b/lib/ArrayLogger.php index 04d07db..40e2f6c 100644 --- a/lib/ArrayLogger.php +++ b/lib/ArrayLogger.php @@ -8,7 +8,6 @@ use SimpleSAML\Logger\LoggingHandlerInterface; /** - * @deprecated - superseeded by PSR-3 compliant SimpleTestLogger */ class ArrayLogger implements LoggingHandlerInterface { @@ -18,6 +17,7 @@ class ArrayLogger implements LoggingHandlerInterface public array $logs = []; + #[\Deprecated('Superseeded by PSR-3 compliant SimpleTestLogger', '20-05-2023')] public function __construct(Configuration $config) { // don't do anything with the configuration diff --git a/lib/BuiltInServer.php b/lib/BuiltInServer.php index 34bf8d8..ed3a2ce 100644 --- a/lib/BuiltInServer.php +++ b/lib/BuiltInServer.php @@ -41,31 +41,23 @@ class BuiltInServer { /** * The PID of the running server. - * - * @var int */ - protected $pid = 0; + protected int $pid = 0; /** * The address (host:port) where the server is listening for connections after being started. - * - * @var string */ - protected $address = 'example.org'; + protected string $address = 'example.org'; /** * The name of a "router" file to run for every request performed to this server. - * - * @var string */ - protected $router = ''; + protected string $router = ''; /** * The document root of the server. - * - * @var string */ - protected $docroot; + protected string $docroot; /** @@ -158,7 +150,6 @@ public function start(): string /** * Stop the built-in server. - * @return void */ public function stop(): void { @@ -200,7 +191,6 @@ public function getRouter(): string * Set the "router" file. * * @param string $router The name of a "router" file to use when starting the server. - * @return void */ public function setRouter(string $router): void { diff --git a/lib/ClearStateTestCase.php b/lib/ClearStateTestCase.php index f66ca44..46380b3 100644 --- a/lib/ClearStateTestCase.php +++ b/lib/ClearStateTestCase.php @@ -13,13 +13,11 @@ class ClearStateTestCase extends TestCase { /** * Used for managing and clearing state - * @var \SimpleSAML\TestUtils\StateClearer|null */ - protected static $stateClearer = null; + protected static ?StateClearer $stateClearer = null; /** - * @return void */ public static function setUpBeforeClass(): void { @@ -31,7 +29,6 @@ public static function setUpBeforeClass(): void /** - * @return void */ protected function setUp(): void { @@ -40,7 +37,6 @@ protected function setUp(): void /** - * @return void */ public static function tearDownAfterClass(): void { @@ -50,7 +46,6 @@ public static function tearDownAfterClass(): void /** * Clear any SSP global state to reduce spill over between tests. - * @return void */ public static function clearState(): void { diff --git a/lib/ReduceSpillOverTest.php b/lib/ReduceSpillOverTest.php index 542b22c..de0ad44 100644 --- a/lib/ReduceSpillOverTest.php +++ b/lib/ReduceSpillOverTest.php @@ -9,13 +9,13 @@ /** * Test that ensures state doesn't spill over between tests + * * @package SimpleSAML\Test\Utils */ class ReduceSpillOverTest extends ClearStateTestCase { /** * Set some global state - * @return void */ public function testSetState(): void { @@ -28,7 +28,7 @@ public function testSetState(): void /** * Confirm global state removed prior to next test - * @return void + * * @throws \SimpleSAML\Error\ConfigurationError */ public function testStateRemoved(): void diff --git a/lib/SigningTestCase.php b/lib/SigningTestCase.php index 3df76fc..620ef4d 100644 --- a/lib/SigningTestCase.php +++ b/lib/SigningTestCase.php @@ -16,42 +16,31 @@ */ class SigningTestCase extends TestCase { - /** @var \SimpleSAML\Configuration */ - protected $config; + protected Configuration $config; - /** @var string $root_directory */ - protected $root_directory; + protected string $root_directory; - /** @var string $cert_directory */ - protected $cert_directory = 'certificates/rsa-pem'; + protected string $cert_directory = 'certificates/rsa-pem'; - /** @var string $ca_private_key_file */ - protected $ca_private_key_file = 'simplesamlphp.org-ca_nopasswd.key'; + protected string $ca_private_key_file = 'simplesamlphp.org-ca_nopasswd.key'; - /** @var string $ca_certificate_file */ - protected $ca_certificate_file = 'simplesamlphp.org-ca.crt'; + protected string $ca_certificate_file = 'simplesamlphp.org-ca.crt'; - /** @var string $good_private_key_file */ - protected $good_private_key_file = 'signed.simplesamlphp.org_nopasswd.key'; + protected string $good_private_key_file = 'signed.simplesamlphp.org_nopasswd.key'; - /** @var string $good_certificate_file */ - protected $good_certificate_file = 'signed.simplesamlphp.org.crt'; + protected string $good_certificate_file = 'signed.simplesamlphp.org.crt'; // openssl genrsa -out example.org-ca.key 1024 - /** @var string $ca_private_key */ - protected $ca_private_key; + protected string $ca_private_key; // openssl req -key example.org-ca.key -new -x509 -days 36500 -out example.org-ca.crt - /** @var string $ca_certificate */ - protected $ca_certificate; + protected string $ca_certificate; // openssl genrsa -out signed.example.org.key 1024 - /** @var string $good_private_key */ - protected $good_private_key; + protected string $good_private_key; // openssl req -key signed.example.org.key -new -out signed.example.org.crt - /** @var string $good_certificate */ - protected $good_certificate; + protected string $good_certificate; /** @@ -69,7 +58,6 @@ public function __construct() /** - * @return array */ public function getCertDirContent(): array { @@ -83,7 +71,6 @@ public function getCertDirContent(): array /** - * @return void */ public function setUp(): void { @@ -94,7 +81,6 @@ public function setUp(): void /** - * @return void */ public function tearDown(): void { @@ -106,7 +92,6 @@ public function tearDown(): void * @param \SimpleSAML\Configuration $service * @param class-string $className * @param mixed|null $value - * @return void */ protected function clearInstance(Configuration $service, string $className, $value = null): void { diff --git a/lib/SimpleTestLogger.php b/lib/SimpleTestLogger.php index 18b123a..6e5a429 100644 --- a/lib/SimpleTestLogger.php +++ b/lib/SimpleTestLogger.php @@ -18,7 +18,6 @@ final class SimpleTestLogger extends AbstractLogger { /** - * @var array */ private array $messages = []; @@ -27,8 +26,6 @@ final class SimpleTestLogger extends AbstractLogger * @param mixed $level * @param string|\Stringable $message * @param mixed[] $context - * - * @return void */ public function log($level, string|Stringable $message, array $context = []): void { @@ -44,8 +41,6 @@ public function log($level, string|Stringable $message, array $context = []): vo * Get all the messages logged at the specified level * * @param mixed $level - * - * @return array */ public function getMessagesForLevel($level): array { @@ -59,8 +54,6 @@ public function getMessagesForLevel($level): array * Check if the given message exists within the log * * @param string|\Stringable $messageToFind - * - * @return bool */ public function hasMessage(string|Stringable $messageToFind): bool { diff --git a/lib/StateClearer.php b/lib/StateClearer.php index b610608..7d5263f 100644 --- a/lib/StateClearer.php +++ b/lib/StateClearer.php @@ -16,15 +16,13 @@ class StateClearer { /** * Global state to restore between test runs - * @var array */ - private $backups = []; + private array $backups = []; /** * Class that implement \SimpleSAML\Utils\ClearableState and should have clearInternalState called between tests - * @var array */ - private $clearableState = [ + private array $clearableState = [ Configuration::class, MetaDataStorageHandler::class, Session::class, @@ -33,15 +31,13 @@ class StateClearer /** * Environmental variables to unset - * @var array */ - private $vars_to_unset = ['SIMPLESAMLPHP_CONFIG_DIR']; + private array $vars_to_unset = ['SIMPLESAMLPHP_CONFIG_DIR']; /** - * @return void */ - public function backupGlobals() + public function backupGlobals(): void { // Backup any state that is needed as part of processing, so we can restore it later. // TODO: phpunit's backupGlobals = false, yet we are trying to do a similar thing here. Is that an issue? @@ -51,7 +47,6 @@ public function backupGlobals() $this->backups['$_GET'] = $_GET; $this->backups['$_POST'] = $_POST; $this->backups['$_SERVER'] = $_SERVER; - /** @psalm-suppress RedundantCondition */ $this->backups['$_SESSION'] = isset($_SESSION) ? $_SESSION : []; $this->backups['$_REQUEST'] = $_REQUEST; } @@ -59,9 +54,8 @@ public function backupGlobals() /** * Clear any global state. - * @return void */ - public function clearGlobals() + public function clearGlobals(): void { if (!empty($this->backups)) { $_COOKIE = $this->backups['$_COOKIE']; @@ -80,9 +74,8 @@ public function clearGlobals() /** * Clear any SSP specific state, such as SSP enviormental variables or cached internals. - * @return void */ - public function clearSSPState() + public function clearSSPState(): void { foreach ($this->clearableState as $var) { $var::clearInternalState(); diff --git a/phpcs-simplesamlphp.xml b/phpcs-simplesamlphp.xml index d8b92b5..97c4617 100644 --- a/phpcs-simplesamlphp.xml +++ b/phpcs-simplesamlphp.xml @@ -29,6 +29,9 @@ + + + diff --git a/src/TemplateTest.php b/src/TemplateTest.php index 3abc98a..37481e4 100644 --- a/src/TemplateTest.php +++ b/src/TemplateTest.php @@ -16,13 +16,10 @@ * * @author Tim van Dijen * @package SimpleSAMLphp - * - * @psalm-suppress InternalMethod */ class TemplateTest extends TestCase { /** - * @return void */ public function testSyntax(): void {