diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index ebffbb0..a6dbcbf 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -13,10 +13,10 @@ jobs: fail-fast: false matrix: php: - - '8.0' - '8.1' - '8.2' - '8.3' + - '8.4' steps: - uses: actions/checkout@v5 diff --git a/composer.json b/composer.json index 9c7aa07..ecdf7d8 100644 --- a/composer.json +++ b/composer.json @@ -38,18 +38,18 @@ "docs": "https://github.com/DataValues/Geo/#usage" }, "require": { - "php": ">=8.0", + "php": ">=8.1", "data-values/data-values": "^3.0|^2.0|^1.0|~0.1", "data-values/interfaces": "^1.1.0" }, "require-dev": { "phpunit/phpunit": "^9.4.1", - "mediawiki/mediawiki-codesniffer": "^45", + "mediawiki/mediawiki-codesniffer": "^48", "ockcyp/covers-validator": "^1.3.3", "phpstan/phpstan": "^0.12.68 || ^1.0.0", "phpmd/phpmd": "^2.9.1", - "vimeo/psalm": "^4.4.1", - "maglnet/composer-require-checker": "^3.0|^2.0" + "vimeo/psalm": "^5.26.1||^6.13.1", + "maglnet/composer-require-checker": "^4.7.1" }, "autoload": { "psr-4": { diff --git a/phpcs.xml b/phpcs.xml index 38c068b..3bca368 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -12,5 +12,7 @@ - + + + diff --git a/psalm.xml b/psalm.xml index bafeac2..4e73128 100644 --- a/psalm.xml +++ b/psalm.xml @@ -17,11 +17,16 @@ + + + + + diff --git a/src/Formatters/GlobeCoordinateFormatter.php b/src/Formatters/GlobeCoordinateFormatter.php index fcdb525..90461f7 100644 --- a/src/Formatters/GlobeCoordinateFormatter.php +++ b/src/Formatters/GlobeCoordinateFormatter.php @@ -19,6 +19,7 @@ * TODO: add formatting of globe and precision * * @since 0.1 + * @api * * @license GPL-2.0-or-later * @author Jeroen De Dauw < jeroendedauw@gmail.com > diff --git a/src/Formatters/LatLongFormatter.php b/src/Formatters/LatLongFormatter.php index 6243ff7..08f14b1 100644 --- a/src/Formatters/LatLongFormatter.php +++ b/src/Formatters/LatLongFormatter.php @@ -23,6 +23,7 @@ * MapsCoordinateParser class of the Maps extension for MediaWiki. * * @since 0.1, renamed in 2.0 + * @api * * @license GPL-2.0-or-later * @author Jeroen De Dauw < jeroendedauw@gmail.com > diff --git a/src/GlobeMath.php b/src/GlobeMath.php index 03a2ba8..ed7f163 100644 --- a/src/GlobeMath.php +++ b/src/GlobeMath.php @@ -12,6 +12,7 @@ * GlobeCoordinateValue objects. * * @since 0.2 + * @api * * @license GPL-2.0-or-later * @author Thiemo Kreuz diff --git a/src/PackagePrivate/DmPrecisionDetector.php b/src/PackagePrivate/DmPrecisionDetector.php index bcdaacc..f598495 100644 --- a/src/PackagePrivate/DmPrecisionDetector.php +++ b/src/PackagePrivate/DmPrecisionDetector.php @@ -4,6 +4,9 @@ namespace DataValues\Geo\PackagePrivate; +/** + * @api + */ class DmPrecisionDetector extends PrecisionDetector { private DmsPrecisionDetector $dmsPrecisionDetector; diff --git a/src/PackagePrivate/DmsPrecisionDetector.php b/src/PackagePrivate/DmsPrecisionDetector.php index ecd29b3..2799fc2 100644 --- a/src/PackagePrivate/DmsPrecisionDetector.php +++ b/src/PackagePrivate/DmsPrecisionDetector.php @@ -4,6 +4,9 @@ namespace DataValues\Geo\PackagePrivate; +/** + * @api + */ class DmsPrecisionDetector extends PrecisionDetector { protected function detectDegreePrecision( float $degree ): float { diff --git a/src/PackagePrivate/FloatPrecisionDetector.php b/src/PackagePrivate/FloatPrecisionDetector.php index b445f9d..ae29265 100644 --- a/src/PackagePrivate/FloatPrecisionDetector.php +++ b/src/PackagePrivate/FloatPrecisionDetector.php @@ -4,6 +4,9 @@ namespace DataValues\Geo\PackagePrivate; +/** + * @api + */ class FloatPrecisionDetector extends PrecisionDetector { protected function detectDegreePrecision( float $degree ): float { diff --git a/src/PackagePrivate/LatLongPrecisionParser.php b/src/PackagePrivate/LatLongPrecisionParser.php index 61cdb65..ff27df4 100644 --- a/src/PackagePrivate/LatLongPrecisionParser.php +++ b/src/PackagePrivate/LatLongPrecisionParser.php @@ -9,6 +9,9 @@ use ValueParsers\ParseException; use ValueParsers\ParserOptions; +/** + * @api + */ class LatLongPrecisionParser { private ?ParserOptions $options; diff --git a/src/PackagePrivate/PreciseLatLong.php b/src/PackagePrivate/PreciseLatLong.php index 9351940..a8c01cc 100644 --- a/src/PackagePrivate/PreciseLatLong.php +++ b/src/PackagePrivate/PreciseLatLong.php @@ -6,6 +6,9 @@ use DataValues\Geo\Values\LatLongValue; +/** + * @api + */ class PreciseLatLong { private LatLongValue $latLong; diff --git a/src/PackagePrivate/Precision.php b/src/PackagePrivate/Precision.php index 706db46..ae9815f 100644 --- a/src/PackagePrivate/Precision.php +++ b/src/PackagePrivate/Precision.php @@ -4,6 +4,9 @@ namespace DataValues\Geo\PackagePrivate; +/** + * @api + */ class Precision { private float $precision; diff --git a/src/PackagePrivate/PrecisionParser.php b/src/PackagePrivate/PrecisionParser.php index d08b594..b8dfcab 100644 --- a/src/PackagePrivate/PrecisionParser.php +++ b/src/PackagePrivate/PrecisionParser.php @@ -4,6 +4,9 @@ use ValueParsers\ValueParser; +/** + * @api + */ class PrecisionParser { private ValueParser $latLongParser; diff --git a/src/Parsers/DdCoordinateParser.php b/src/Parsers/DdCoordinateParser.php index bdd9b1f..b255a6c 100644 --- a/src/Parsers/DdCoordinateParser.php +++ b/src/Parsers/DdCoordinateParser.php @@ -12,6 +12,7 @@ * Parser for geographical coordinates in Decimal Degree notation. * * @since 0.1 + * @api * * @license GPL-2.0-or-later * @author Jeroen De Dauw < jeroendedauw@gmail.com > diff --git a/src/Parsers/DmCoordinateParser.php b/src/Parsers/DmCoordinateParser.php index 291b03d..bf21d0c 100644 --- a/src/Parsers/DmCoordinateParser.php +++ b/src/Parsers/DmCoordinateParser.php @@ -11,6 +11,7 @@ * Parser for geographical coordinates in Decimal Minute notation. * * @since 0.1 + * @api * * @license GPL-2.0-or-later * @author Jeroen De Dauw < jeroendedauw@gmail.com > diff --git a/src/Parsers/DmsCoordinateParser.php b/src/Parsers/DmsCoordinateParser.php index 2f65207..421c5ec 100644 --- a/src/Parsers/DmsCoordinateParser.php +++ b/src/Parsers/DmsCoordinateParser.php @@ -11,6 +11,7 @@ * Parser for geographical coordinates in Degree Minute Second notation. * * @since 0.1 + * @api * * @license GPL-2.0-or-later * @author Jeroen De Dauw < jeroendedauw@gmail.com > diff --git a/src/Parsers/FloatCoordinateParser.php b/src/Parsers/FloatCoordinateParser.php index b7fe57f..9637bc2 100644 --- a/src/Parsers/FloatCoordinateParser.php +++ b/src/Parsers/FloatCoordinateParser.php @@ -8,6 +8,7 @@ /** * @since 0.1 + * @api * * @license GPL-2.0-or-later * @author Jeroen De Dauw < jeroendedauw@gmail.com > diff --git a/src/Parsers/GlobeCoordinateParser.php b/src/Parsers/GlobeCoordinateParser.php index a513ded..f3e8f2b 100644 --- a/src/Parsers/GlobeCoordinateParser.php +++ b/src/Parsers/GlobeCoordinateParser.php @@ -14,9 +14,10 @@ /** * Extends the LatLongParser by adding precision detection support. * - * The object that gets constructed is a GlobeCoordinateValue rather then a LatLongValue. + * The object that gets constructed is a GlobeCoordinateValue rather than a LatLongValue. * * @since 0.1 + * @api * * @license GPL-2.0-or-later * @author Jeroen De Dauw < jeroendedauw@gmail.com > diff --git a/src/Parsers/LatLongParser.php b/src/Parsers/LatLongParser.php index 4ab506f..3425ed5 100644 --- a/src/Parsers/LatLongParser.php +++ b/src/Parsers/LatLongParser.php @@ -30,6 +30,7 @@ * MapsCoordinateParser class of the Maps extension for MediaWiki. * * @since 0.1, name changed in 2.0 + * @api * * @license GPL-2.0-or-later * @author Jeroen De Dauw < jeroendedauw@gmail.com > diff --git a/src/Values/GlobeCoordinateValue.php b/src/Values/GlobeCoordinateValue.php index ac9d510..c7e82c2 100644 --- a/src/Values/GlobeCoordinateValue.php +++ b/src/Values/GlobeCoordinateValue.php @@ -12,6 +12,7 @@ * Value Object representing a latitude-longitude pair with a certain precision on a certain globe. * * @since 0.1 + * @api * * @license GPL-2.0-or-later * @author Jeroen De Dauw < jeroendedauw@gmail.com > @@ -122,7 +123,7 @@ public function getHash(): string { * @return string */ public function serialize(): string { - return json_encode( $this->__serialize() ); + return json_encode( $this->__serialize(), JSON_THROW_ON_ERROR ); } public function __serialize(): array { @@ -132,16 +133,16 @@ public function __serialize(): array { /** * @see Serializable::unserialize * - * @param string $value + * @param string $data * * @throws InvalidArgumentException */ - public function unserialize( $value ) { - $this->__unserialize( json_decode( $value ) ); + public function unserialize( $data ): void { + $this->__unserialize( json_decode( $data ) ); } public function __unserialize( array $data ): void { - [ $latitude, $longitude, $altitude, $precision, $globe ] = $data; + [ $latitude, $longitude, , $precision, $globe ] = $data; $this->__construct( new LatLongValue( $latitude, $longitude ), $precision, $globe ); } @@ -186,7 +187,7 @@ public function getArrayValue(): array { public function toArray(): array { return [ 'value' => $this->getArrayValue(), - 'type' => $this->getType(), + 'type' => self::getType(), ]; } diff --git a/src/Values/LatLongValue.php b/src/Values/LatLongValue.php index 1784cee..d188217 100644 --- a/src/Values/LatLongValue.php +++ b/src/Values/LatLongValue.php @@ -15,6 +15,7 @@ * Longitude is specified in degrees within the range [-360, 360]. * * @since 0.1 + * @api * * @license GPL-2.0-or-later * @author Jeroen De Dauw < jeroendedauw@gmail.com > @@ -105,12 +106,12 @@ public function __serialize(): array { /** * @see Serializable::unserialize * - * @param string $value + * @param string $data * * @throws InvalidArgumentException */ - public function unserialize( $value ) { - $this->__unserialize( explode( '|', $value, 2 ) ); + public function unserialize( $data ): void { + $this->__unserialize( explode( '|', $data, 2 ) ); } public function __unserialize( array $data ): void {