Skip to content

Commit

Permalink
Merge pull request #63 from codders/feat/upgrade-mediawiki-codesniffe…
Browse files Browse the repository at this point in the history
…r-20241206

Upgrade mediawiki-codesniffer to latest version (45.0.0)
  • Loading branch information
JeroenDeDauw authored Dec 6, 2024
2 parents 7c54a89 + ae70d19 commit 7f1aa70
Show file tree
Hide file tree
Showing 16 changed files with 35 additions and 32 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ jobs:
fail-fast: false
matrix:
php:
- '7.2'
- '7.3'
- '7.4'
- '8.0'

Expand Down
9 changes: 7 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -51,5 +51,10 @@
"@test",
"@cs"
]
},
"config": {
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true
}
}
}
1 change: 1 addition & 0 deletions phpcs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@
<rule ref="Generic.Metrics.CyclomaticComplexity" />
<rule ref="Generic.Metrics.NestingLevel" />
<rule ref="Squiz.Operators.ValidLogicalOperators" />
<rule ref="./vendor/mediawiki/mediawiki-codesniffer/MediaWiki"/>
</ruleset>
2 changes: 1 addition & 1 deletion src/ValueFormatters/FormatterOptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/ValueFormatters/FormattingException.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions src/ValueFormatters/ValueFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions src/ValueParsers/ParseException.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/ValueParsers/ParserOptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/ValueParsers/ValueParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
17 changes: 8 additions & 9 deletions src/ValueValidators/Error.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,21 @@
namespace ValueValidators;

/**
* @license GPL-2.0+
* @license GPL-2.0-or-later
* @author Jeroen De Dauw < jeroendedauw@gmail.com >
*/
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 );
}

Expand All @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions src/ValueValidators/Result.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/ValueValidators/ValueValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion tests/ValueFormatters/FormatterOptionsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion tests/ValueParsers/ParserOptionsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions tests/ValueValidators/ErrorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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() );
Expand Down
4 changes: 2 additions & 2 deletions tests/ValueValidators/ResultTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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() {
Expand Down

0 comments on commit 7f1aa70

Please sign in to comment.