diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index 022f822..95723ad 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -13,8 +13,6 @@ jobs: fail-fast: false matrix: php: - - '7.2' - - '7.3' - '7.4' - '8.0' diff --git a/composer.json b/composer.json index 6baeb9e..d37ee5c 100644 --- a/composer.json +++ b/composer.json @@ -20,11 +20,11 @@ } ], "require": { - "php": ">=7.2" + "php": ">=7.4" }, "require-dev": { "phpunit/phpunit": "~8.5", - "mediawiki/mediawiki-codesniffer": "^34", + "mediawiki/mediawiki-codesniffer": "^45", "ockcyp/covers-validator": "~1.0", "phpstan/phpstan": "^0.12.68", "phpmd/phpmd": "^2.9.1" @@ -51,5 +51,10 @@ "@test", "@cs" ] + }, + "config": { + "allow-plugins": { + "dealerdirect/phpcodesniffer-composer-installer": true + } } } diff --git a/phpcs.xml b/phpcs.xml index dbd5e77..fed4e3c 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -12,4 +12,5 @@ + diff --git a/src/ValueFormatters/FormatterOptions.php b/src/ValueFormatters/FormatterOptions.php index 55dab96..6a95e0b 100644 --- a/src/ValueFormatters/FormatterOptions.php +++ b/src/ValueFormatters/FormatterOptions.php @@ -9,7 +9,7 @@ use RuntimeException; /** - * @license GPL-2.0+ + * @license GPL-2.0-or-later * @author Jeroen De Dauw < jeroendedauw@gmail.com > */ final class FormatterOptions { diff --git a/src/ValueFormatters/FormattingException.php b/src/ValueFormatters/FormattingException.php index 5e7e52b..84f483d 100644 --- a/src/ValueFormatters/FormattingException.php +++ b/src/ValueFormatters/FormattingException.php @@ -7,7 +7,7 @@ use RuntimeException; /** - * @license GPL-2.0+ + * @license GPL-2.0-or-later * @author Jeroen De Dauw < jeroendedauw@gmail.com > */ class FormattingException extends RuntimeException { diff --git a/src/ValueFormatters/ValueFormatter.php b/src/ValueFormatters/ValueFormatter.php index a839b70..87040cb 100644 --- a/src/ValueFormatters/ValueFormatter.php +++ b/src/ValueFormatters/ValueFormatter.php @@ -8,7 +8,7 @@ * Interface for value formatters, typically (but not limited to) expecting a DataValue object and * returning a string. * - * @license GPL-2.0+ + * @license GPL-2.0-or-later * @author Jeroen De Dauw < jeroendedauw@gmail.com > */ interface ValueFormatter { @@ -17,7 +17,7 @@ interface ValueFormatter { * Identifier for the option that holds the code of the language in which the formatter should * operate. */ - const OPT_LANG = 'lang'; + public const OPT_LANG = 'lang'; /** * @param mixed $value diff --git a/src/ValueParsers/ParseException.php b/src/ValueParsers/ParseException.php index 4c203e8..0fbe8f9 100644 --- a/src/ValueParsers/ParseException.php +++ b/src/ValueParsers/ParseException.php @@ -7,7 +7,7 @@ use RuntimeException; /** - * @license GPL-2.0+ + * @license GPL-2.0-or-later * @author Jeroen De Dauw < jeroendedauw@gmail.com > */ class ParseException extends RuntimeException { @@ -23,11 +23,11 @@ class ParseException extends RuntimeException { private $rawValue; /** - * @param string $message A plain english message describing the error + * @param string $message A plain english message describing the error * @param string|null $rawValue The raw value that failed to be parsed. * @param string|null $expectedFormat An identifier for the format the raw value did not match */ - public function __construct( string $message, string $rawValue = null, string $expectedFormat = null ) { + public function __construct( string $message, ?string $rawValue = null, ?string $expectedFormat = null ) { parent::__construct( $message ); $this->expectedFormat = $expectedFormat; $this->rawValue = $rawValue; diff --git a/src/ValueParsers/ParserOptions.php b/src/ValueParsers/ParserOptions.php index d486c3b..7ebe801 100644 --- a/src/ValueParsers/ParserOptions.php +++ b/src/ValueParsers/ParserOptions.php @@ -8,7 +8,7 @@ use RuntimeException; /** - * @license GPL-2.0+ + * @license GPL-2.0-or-later * @author Jeroen De Dauw < jeroendedauw@gmail.com > */ final class ParserOptions { diff --git a/src/ValueParsers/ValueParser.php b/src/ValueParsers/ValueParser.php index 2c757b5..c5d17db 100644 --- a/src/ValueParsers/ValueParser.php +++ b/src/ValueParsers/ValueParser.php @@ -8,7 +8,7 @@ * Interface for value parsers, typically (but not limited to) expecting a string and returning a * DataValue object. * - * @license GPL-2.0+ + * @license GPL-2.0-or-later * @author Jeroen De Dauw < jeroendedauw@gmail.com > */ interface ValueParser { diff --git a/src/ValueValidators/Error.php b/src/ValueValidators/Error.php index 6f8113a..df50cef 100644 --- a/src/ValueValidators/Error.php +++ b/src/ValueValidators/Error.php @@ -5,7 +5,7 @@ namespace ValueValidators; /** - * @license GPL-2.0+ + * @license GPL-2.0-or-later * @author Jeroen De Dauw < jeroendedauw@gmail.com > */ class Error { @@ -13,14 +13,13 @@ class Error { public const SEVERITY_ERROR = 9; public const SEVERITY_WARNING = 4; - private $text; - private $severity; - private $property; + private string $text; + private int $severity; + private ?string $property; + private string $code; + private array $params; - private $code; - private $params; - - public static function newError( string $text = '', string $property = null, string $code = 'invalid', array $params = [] ): self { + public static function newError( string $text = '', ?string $property = null, string $code = 'invalid', array $params = [] ): self { return new self( $text, self::SEVERITY_ERROR, $property, $code, $params ); } @@ -37,7 +36,7 @@ public function getText(): string { } /** - * @return integer, element of the ValueValidatorError::SEVERITY_ enum + * @return int element of the ValueValidatorError::SEVERITY_ enum */ public function getSeverity(): int { return $this->severity; diff --git a/src/ValueValidators/Result.php b/src/ValueValidators/Result.php index 62d48dc..62d9cf6 100644 --- a/src/ValueValidators/Result.php +++ b/src/ValueValidators/Result.php @@ -5,13 +5,13 @@ namespace ValueValidators; /** - * @license GPL-2.0+ + * @license GPL-2.0-or-later * @author Jeroen De Dauw < jeroendedauw@gmail.com > */ final class Result { - private $isValid; - private $errors; + private bool $isValid; + private array $errors; /** * @return self diff --git a/src/ValueValidators/ValueValidator.php b/src/ValueValidators/ValueValidator.php index fa2e283..feb6730 100644 --- a/src/ValueValidators/ValueValidator.php +++ b/src/ValueValidators/ValueValidator.php @@ -5,7 +5,7 @@ namespace ValueValidators; /** - * @license GPL-2.0+ + * @license GPL-2.0-or-later * @author Jeroen De Dauw < jeroendedauw@gmail.com > */ interface ValueValidator { diff --git a/tests/ValueFormatters/FormatterOptionsTest.php b/tests/ValueFormatters/FormatterOptionsTest.php index 69494aa..13e1751 100644 --- a/tests/ValueFormatters/FormatterOptionsTest.php +++ b/tests/ValueFormatters/FormatterOptionsTest.php @@ -13,7 +13,7 @@ * @group ValueFormatters * @group DataValueExtensions * - * @license GPL-2.0+ + * @license GPL-2.0-or-later * @author Jeroen De Dauw < jeroendedauw@gmail.com > */ class FormatterOptionsTest extends TestCase { diff --git a/tests/ValueParsers/ParserOptionsTest.php b/tests/ValueParsers/ParserOptionsTest.php index 5e48052..982f47e 100644 --- a/tests/ValueParsers/ParserOptionsTest.php +++ b/tests/ValueParsers/ParserOptionsTest.php @@ -13,7 +13,7 @@ * @group ValueParsers * @group DataValueExtensions * - * @license GPL-2.0+ + * @license GPL-2.0-or-later * @author Jeroen De Dauw < jeroendedauw@gmail.com > */ class ParserOptionsTest extends TestCase { diff --git a/tests/ValueValidators/ErrorTest.php b/tests/ValueValidators/ErrorTest.php index b004851..f76fb73 100644 --- a/tests/ValueValidators/ErrorTest.php +++ b/tests/ValueValidators/ErrorTest.php @@ -13,7 +13,7 @@ * @group ValueValidators * @group DataValueExtensions * - * @license GPL-2.0+ + * @license GPL-2.0-or-later * @author Jeroen De Dauw < jeroendedauw@gmail.com > */ class ErrorTest extends TestCase { @@ -49,7 +49,7 @@ public function testNewError() { */ $this->assertInstanceOf( 'ValueValidators\Error', $error ); - $this->assertTrue( is_string( $error->getProperty() ) || is_null( $error->getProperty() ) ); + $this->assertTrue( is_string( $error->getProperty() ) || $error->getProperty() === null ); if ( count( $args ) > 0 ) { $this->assertSame( $args[0], $error->getText() ); diff --git a/tests/ValueValidators/ResultTest.php b/tests/ValueValidators/ResultTest.php index dc4056e..20c12e1 100644 --- a/tests/ValueValidators/ResultTest.php +++ b/tests/ValueValidators/ResultTest.php @@ -14,7 +14,7 @@ * @group ValueValidators * @group DataValueExtensions * - * @license GPL-2.0+ + * @license GPL-2.0-or-later * @author Daniel Kinzler */ class ResultTest extends TestCase { @@ -23,7 +23,7 @@ public function testNewSuccess() { $result = Result::newSuccess(); $this->assertTrue( $result->isValid() ); - $this->assertEmpty( $result->getErrors() ); + $this->assertCount( 0, $result->getErrors() ); } public function testNewError() {