From b9b0505e97bf2aab99865b9cf5fe402a62e06da0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Pr=C3=A9vot?= <taffit@debian.org> Date: Sat, 25 Jan 2025 11:14:27 +0100 Subject: [PATCH] New upstream version 1.9.3 --- .github/workflows/tests.yml | 2 +- composer.json | 8 +++----- phpstan-baseline.neon | 2 +- phpstan.neon.dist | 1 - phpunit.xml.dist | 2 +- psalm-baseline.xml | 2 ++ psalm.xml | 3 +++ src/PhpOption/Option.php | 4 ++-- tests/PhpOption/Tests/OptionTest.php | 6 ++++++ vendor-bin/phpstan/composer.json | 2 +- vendor-bin/psalm/composer.json | 2 +- 11 files changed, 21 insertions(+), 13 deletions(-) create mode 100644 psalm-baseline.xml diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index c7bf82b..ac73b00 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -11,7 +11,7 @@ jobs: strategy: matrix: - php: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3'] + php: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4'] steps: - name: Checkout Code diff --git a/composer.json b/composer.json index 77f50a3..91dd6fb 100644 --- a/composer.json +++ b/composer.json @@ -20,7 +20,7 @@ }, "require-dev": { "bamarni/composer-bin-plugin": "^1.8.2", - "phpunit/phpunit": "^8.5.34 || ^9.6.13 || ^10.4.2" + "phpunit/phpunit": "^8.5.39 || ^9.6.20 || ^10.5.28" }, "autoload": { "psr-4": { @@ -41,12 +41,10 @@ "extra": { "bamarni-bin": { "bin-links": true, - "forward-command": true + "forward-command": false }, "branch-alias": { "dev-master": "1.9-dev" } - }, - "minimum-stability": "dev", - "prefer-stable": true + } } diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index dda1b4a..5310bd2 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -21,7 +21,7 @@ parameters: path: src/PhpOption/Option.php - - message: "#^Parameter \\#2 \\$callback of function array_reduce expects callable\\(mixed, mixed\\)\\: mixed, Closure\\(mixed, PhpOption\\\\Option\\)\\: mixed given\\.$#" + message: "#^Parameter \\#2 \\$callback of function array_reduce expects callable\\(bool\\|TReturn, mixed\\)\\: \\(bool\\|TReturn\\), Closure\\(mixed, PhpOption\\\\Option\\)\\: \\(bool\\|TReturn\\) given\\.$#" count: 1 path: src/PhpOption/Option.php diff --git a/phpstan.neon.dist b/phpstan.neon.dist index fd7a646..6f8227f 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -5,4 +5,3 @@ parameters: level: max paths: - src - checkGenericClassInNonGenericObjectType: false diff --git a/phpunit.xml.dist b/phpunit.xml.dist index ae1c473..14025a6 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> -<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" beStrictAboutTestsThatDoNotTestAnything="true" beStrictAboutOutputDuringTests="true" bootstrap="tests/bootstrap.php" colors="true" failOnRisky="true" failOnWarning="true" processIsolation="false" stopOnError="false" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.0/phpunit.xsd"> +<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" beStrictAboutTestsThatDoNotTestAnything="true" beStrictAboutOutputDuringTests="true" bootstrap="tests/bootstrap.php" colors="true" failOnRisky="true" failOnWarning="true" processIsolation="false" stopOnError="false" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.4/phpunit.xsd"> <testsuites> <testsuite name="PhpOption Type Test Suite"> <directory>./tests/PhpOption/</directory> diff --git a/psalm-baseline.xml b/psalm-baseline.xml new file mode 100644 index 0000000..7bf39a8 --- /dev/null +++ b/psalm-baseline.xml @@ -0,0 +1,2 @@ +<?xml version="1.0" encoding="UTF-8"?> +<files psalm-version="5.25.0@01a8eb06b9e9cc6cfb6a320bf9fb14331919d505"/> diff --git a/psalm.xml b/psalm.xml index db645bc..7ee17a8 100644 --- a/psalm.xml +++ b/psalm.xml @@ -5,6 +5,9 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="https://getpsalm.org/schema/config" xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd" + errorBaseline="psalm-baseline.xml" + findUnusedBaselineEntry="true" + findUnusedCode="false" > <projectFiles> <directory name="src" /> diff --git a/src/PhpOption/Option.php b/src/PhpOption/Option.php index 172924c..91fab9c 100644 --- a/src/PhpOption/Option.php +++ b/src/PhpOption/Option.php @@ -62,13 +62,13 @@ abstract class Option implements IteratorAggregate * @template S * * @param array<string|int,S>|ArrayAccess<string|int,S>|null $array A potential array or \ArrayAccess value. - * @param string $key The key to check. + * @param string|int|null $key The key to check. * * @return Option<S> */ public static function fromArraysValue($array, $key) { - if (!(is_array($array) || $array instanceof ArrayAccess) || !isset($array[$key])) { + if ($key === null || !(is_array($array) || $array instanceof ArrayAccess) || !isset($array[$key])) { return None::create(); } diff --git a/tests/PhpOption/Tests/OptionTest.php b/tests/PhpOption/Tests/OptionTest.php index d386ff2..4e31b92 100644 --- a/tests/PhpOption/Tests/OptionTest.php +++ b/tests/PhpOption/Tests/OptionTest.php @@ -31,11 +31,17 @@ class OptionTest extends TestCase self::assertEquals(None::create(), Option::fromArraysValue(null, 'bar')); self::assertEquals(None::create(), Option::fromArraysValue(['foo' => 'bar'], 'baz')); self::assertEquals(None::create(), Option::fromArraysValue(['foo' => null], 'foo')); + self::assertEquals(None::create(), Option::fromArraysValue(['foo' => 'bar'], null)); self::assertEquals(new Some('foo'), Option::fromArraysValue(['foo' => 'foo'], 'foo')); + self::assertEquals(new Some('foo'), Option::fromArraysValue([13 => 'foo'], 13)); $object = new SomeArrayObject(); $object['foo'] = 'foo'; self::assertEquals(new Some('foo'), Option::fromArraysValue($object, 'foo')); + + $object = new SomeArrayObject(); + $object[13] = 'foo'; + self::assertEquals(new Some('foo'), Option::fromArraysValue($object, 13)); } public function testFromReturn(): void diff --git a/vendor-bin/phpstan/composer.json b/vendor-bin/phpstan/composer.json index d572d14..e24f982 100644 --- a/vendor-bin/phpstan/composer.json +++ b/vendor-bin/phpstan/composer.json @@ -1,6 +1,6 @@ { "require": { - "phpstan/phpstan": "1.10.41" + "phpstan/phpstan": "1.11.7" }, "config": { "preferred-install": "dist" diff --git a/vendor-bin/psalm/composer.json b/vendor-bin/psalm/composer.json index c87e133..5aceaa6 100644 --- a/vendor-bin/psalm/composer.json +++ b/vendor-bin/psalm/composer.json @@ -1,6 +1,6 @@ { "require": { - "psalm/phar": "5.15.0" + "psalm/phar": "5.25.0" }, "config": { "preferred-install": "dist" -- GitLab