diff --git a/.github/workflows/backward-compatibility.yml b/.github/workflows/backward-compatibility.yml index c0bdcb9480..b1bdee7855 100644 --- a/.github/workflows/backward-compatibility.yml +++ b/.github/workflows/backward-compatibility.yml @@ -6,10 +6,10 @@ on: pull_request: push: branches: - - "master" + - "**" env: - COMPOSER_ROOT_VERSION: "1.4.x-dev" + COMPOSER_ROOT_VERSION: "1.5.x-dev" jobs: backward-compatibility: diff --git a/.github/workflows/compiler-tests.yml b/.github/workflows/compiler-tests.yml index 65e1c2e58d..3333d665fe 100644 --- a/.github/workflows/compiler-tests.yml +++ b/.github/workflows/compiler-tests.yml @@ -6,10 +6,10 @@ on: pull_request: push: branches: - - "master" + - "**" env: - COMPOSER_ROOT_VERSION: "1.4.x-dev" + COMPOSER_ROOT_VERSION: "1.5.x-dev" jobs: compiler-tests: @@ -48,20 +48,20 @@ jobs: integration-tests: if: github.event_name == 'pull_request' needs: compiler-tests - uses: phpstan/phpstan/.github/workflows/integration-tests.yml@master + uses: phpstan/phpstan/.github/workflows/integration-tests.yml@1.5.x with: - ref: master + ref: 1.5.x extension-tests: if: github.event_name == 'pull_request' needs: compiler-tests - uses: phpstan/phpstan/.github/workflows/extension-tests.yml@master + uses: phpstan/phpstan/.github/workflows/extension-tests.yml@1.5.x with: - ref: master + ref: 1.5.x other-tests: if: github.event_name == 'pull_request' needs: compiler-tests - uses: phpstan/phpstan/.github/workflows/other-tests.yml@master + uses: phpstan/phpstan/.github/workflows/other-tests.yml@1.5.x with: - ref: master + ref: 1.5.x diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index 136ef4969e..2c7ff7add9 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -8,12 +8,12 @@ on: - 'compiler/**' push: branches: - - "master" + - "**" paths-ignore: - 'compiler/**' env: - COMPOSER_ROOT_VERSION: "1.4.x-dev" + COMPOSER_ROOT_VERSION: "1.5.x-dev" jobs: result-cache-e2e-tests: diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 6c7afe5f5a..0d64be5317 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -6,10 +6,10 @@ on: pull_request: push: branches: - - "master" + - "**" env: - COMPOSER_ROOT_VERSION: "1.4.x-dev" + COMPOSER_ROOT_VERSION: "1.5.x-dev" jobs: lint: diff --git a/.github/workflows/phar.yml b/.github/workflows/phar.yml index 678701860a..3952d78e56 100644 --- a/.github/workflows/phar.yml +++ b/.github/workflows/phar.yml @@ -5,9 +5,9 @@ name: "Compile PHAR" on: push: branches: - - "master" + - "1.5.x" tags: - - '1.*' + - '1.5.*' concurrency: phar @@ -53,6 +53,7 @@ jobs: repository: phpstan/phpstan path: phpstan-dist token: ${{ secrets.PAT }} + ref: 1.5.x - name: "cp PHAR" run: cp tmp/phpstan.phar phpstan-dist/phpstan.phar @@ -79,13 +80,13 @@ jobs: git config user.email "ondrej@mirtes.cz" && \ git config user.name "Ondrej Mirtes" - - name: "Commit PHAR - master" + - name: "Commit PHAR - development" working-directory: phpstan-dist if: "!startsWith(github.ref, 'refs/tags/')" run: | git add phpstan.phar phpstan.phar.asc && \ git commit -S -m "Updated PHPStan to commit ${{ github.event.after }}" -m "${{ steps.git-log.outputs.log }}" && \ - git push --quiet origin master + git push --quiet origin 1.5.x - name: "Commit PHAR - tag" working-directory: phpstan-dist @@ -93,6 +94,6 @@ jobs: run: | git add phpstan.phar phpstan.phar.asc && \ git commit -S -m "PHPStan ${GITHUB_REF#refs/tags/}" -m "${{ steps.git-log.outputs.log }}" && \ - git push --quiet origin master && \ + git push --quiet origin 1.5.x && \ git tag -s ${GITHUB_REF#refs/tags/} -m "${GITHUB_REF#refs/tags/}" && \ git push --quiet origin ${GITHUB_REF#refs/tags/} diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml index 543254e867..7a2e880070 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/static-analysis.yml @@ -8,12 +8,12 @@ on: - 'compiler/**' push: branches: - - "master" + - "**" paths-ignore: - 'compiler/**' env: - COMPOSER_ROOT_VERSION: "1.4.x-dev" + COMPOSER_ROOT_VERSION: "1.5.x-dev" jobs: static-analysis: diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index f9f0e8b07f..cfdbc37dfe 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -8,12 +8,12 @@ on: - 'compiler/**' push: branches: - - "master" + - "**" paths-ignore: - 'compiler/**' env: - COMPOSER_ROOT_VERSION: "1.4.x-dev" + COMPOSER_ROOT_VERSION: "1.5.x-dev" jobs: tests: diff --git a/build-cs/composer.lock b/build-cs/composer.lock index b787a5858a..475b81fba0 100644 --- a/build-cs/composer.lock +++ b/build-cs/composer.lock @@ -200,32 +200,32 @@ }, { "name": "slevomat/coding-standard", - "version": "7.0.18", + "version": "7.0.19", "source": { "type": "git", "url": "https://github.com/slevomat/coding-standard.git", - "reference": "b81ac84f41a4797dc25c8ede1b0718e2a74be0fc" + "reference": "bef66a43815bbf9b5f49775e9ded3f7c6ba0cc37" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/slevomat/coding-standard/zipball/b81ac84f41a4797dc25c8ede1b0718e2a74be0fc", - "reference": "b81ac84f41a4797dc25c8ede1b0718e2a74be0fc", + "url": "https://api.github.com/repos/slevomat/coding-standard/zipball/bef66a43815bbf9b5f49775e9ded3f7c6ba0cc37", + "reference": "bef66a43815bbf9b5f49775e9ded3f7c6ba0cc37", "shasum": "" }, "require": { "dealerdirect/phpcodesniffer-composer-installer": "^0.6.2 || ^0.7", "php": "^7.1 || ^8.0", "phpstan/phpdoc-parser": "^1.0.0", - "squizlabs/php_codesniffer": "^3.6.1" + "squizlabs/php_codesniffer": "^3.6.2" }, "require-dev": { - "phing/phing": "2.17.0", - "php-parallel-lint/php-parallel-lint": "1.3.1", - "phpstan/phpstan": "1.2.0", + "phing/phing": "2.17.2", + "php-parallel-lint/php-parallel-lint": "1.3.2", + "phpstan/phpstan": "1.4.6", "phpstan/phpstan-deprecation-rules": "1.0.0", "phpstan/phpstan-phpunit": "1.0.0", "phpstan/phpstan-strict-rules": "1.1.0", - "phpunit/phpunit": "7.5.20|8.5.21|9.5.10" + "phpunit/phpunit": "7.5.20|8.5.21|9.5.16" }, "type": "phpcodesniffer-standard", "extra": { @@ -245,7 +245,7 @@ "description": "Slevomat Coding Standard for PHP_CodeSniffer complements Consistence Coding Standard by providing sniffs with additional checks.", "support": { "issues": "https://github.com/slevomat/coding-standard/issues", - "source": "https://github.com/slevomat/coding-standard/tree/7.0.18" + "source": "https://github.com/slevomat/coding-standard/tree/7.0.19" }, "funding": [ { @@ -257,7 +257,7 @@ "type": "tidelift" } ], - "time": "2021-12-07T17:19:06+00:00" + "time": "2022-03-01T18:01:41+00:00" }, { "name": "squizlabs/php_codesniffer", diff --git a/compiler/composer.lock b/compiler/composer.lock index 399d42395f..30074d1e1e 100644 --- a/compiler/composer.lock +++ b/compiler/composer.lock @@ -8,16 +8,16 @@ "packages": [ { "name": "nette/neon", - "version": "v3.3.2", + "version": "v3.3.3", "source": { "type": "git", "url": "https://github.com/nette/neon.git", - "reference": "54b287d8c2cdbe577b02e28ca1713e275b05ece2" + "reference": "22e384da162fab42961d48eb06c06d3ad0c11b95" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nette/neon/zipball/54b287d8c2cdbe577b02e28ca1713e275b05ece2", - "reference": "54b287d8c2cdbe577b02e28ca1713e275b05ece2", + "url": "https://api.github.com/repos/nette/neon/zipball/22e384da162fab42961d48eb06c06d3ad0c11b95", + "reference": "22e384da162fab42961d48eb06c06d3ad0c11b95", "shasum": "" }, "require": { @@ -70,9 +70,9 @@ ], "support": { "issues": "https://github.com/nette/neon/issues", - "source": "https://github.com/nette/neon/tree/v3.3.2" + "source": "https://github.com/nette/neon/tree/v3.3.3" }, - "time": "2021-11-25T15:57:41+00:00" + "time": "2022-03-10T02:04:26+00:00" }, { "name": "psr/container", @@ -129,16 +129,16 @@ }, { "name": "symfony/console", - "version": "v6.0.3", + "version": "v6.0.5", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "22e8efd019c3270c4f79376234a3f8752cd25490" + "reference": "3bebf4108b9e07492a2a4057d207aa5a77d146b1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/22e8efd019c3270c4f79376234a3f8752cd25490", - "reference": "22e8efd019c3270c4f79376234a3f8752cd25490", + "url": "https://api.github.com/repos/symfony/console/zipball/3bebf4108b9e07492a2a4057d207aa5a77d146b1", + "reference": "3bebf4108b9e07492a2a4057d207aa5a77d146b1", "shasum": "" }, "require": { @@ -204,7 +204,7 @@ "terminal" ], "support": { - "source": "https://github.com/symfony/console/tree/v6.0.3" + "source": "https://github.com/symfony/console/tree/v6.0.5" }, "funding": [ { @@ -220,20 +220,20 @@ "type": "tidelift" } ], - "time": "2022-01-26T17:23:29+00:00" + "time": "2022-02-25T10:48:52+00:00" }, { "name": "symfony/filesystem", - "version": "v6.0.3", + "version": "v6.0.6", "source": { "type": "git", "url": "https://github.com/symfony/filesystem.git", - "reference": "6ae49c4fda17322171a2b8dc5f70bc6edbc498e1" + "reference": "52b888523545b0b4049ab9ce48766802484d7046" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/filesystem/zipball/6ae49c4fda17322171a2b8dc5f70bc6edbc498e1", - "reference": "6ae49c4fda17322171a2b8dc5f70bc6edbc498e1", + "url": "https://api.github.com/repos/symfony/filesystem/zipball/52b888523545b0b4049ab9ce48766802484d7046", + "reference": "52b888523545b0b4049ab9ce48766802484d7046", "shasum": "" }, "require": { @@ -267,7 +267,7 @@ "description": "Provides basic utilities for the filesystem", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/filesystem/tree/v6.0.3" + "source": "https://github.com/symfony/filesystem/tree/v6.0.6" }, "funding": [ { @@ -283,7 +283,7 @@ "type": "tidelift" } ], - "time": "2022-01-02T09:55:41+00:00" + "time": "2022-03-02T12:58:14+00:00" }, { "name": "symfony/finder", @@ -348,7 +348,7 @@ }, { "name": "symfony/polyfill-ctype", - "version": "v1.24.0", + "version": "v1.25.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-ctype.git", @@ -380,12 +380,12 @@ } }, "autoload": { - "psr-4": { - "Symfony\\Polyfill\\Ctype\\": "" - }, "files": [ "bootstrap.php" - ] + ], + "psr-4": { + "Symfony\\Polyfill\\Ctype\\": "" + } }, "notification-url": "https://packagist.org/downloads/", "license": [ @@ -410,7 +410,7 @@ "portable" ], "support": { - "source": "https://github.com/symfony/polyfill-ctype/tree/v1.24.0" + "source": "https://github.com/symfony/polyfill-ctype/tree/v1.25.0" }, "funding": [ { @@ -430,7 +430,7 @@ }, { "name": "symfony/polyfill-intl-grapheme", - "version": "v1.24.0", + "version": "v1.25.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-intl-grapheme.git", @@ -459,12 +459,12 @@ } }, "autoload": { - "psr-4": { - "Symfony\\Polyfill\\Intl\\Grapheme\\": "" - }, "files": [ "bootstrap.php" - ] + ], + "psr-4": { + "Symfony\\Polyfill\\Intl\\Grapheme\\": "" + } }, "notification-url": "https://packagist.org/downloads/", "license": [ @@ -491,7 +491,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-intl-grapheme/tree/v1.24.0" + "source": "https://github.com/symfony/polyfill-intl-grapheme/tree/v1.25.0" }, "funding": [ { @@ -511,7 +511,7 @@ }, { "name": "symfony/polyfill-intl-normalizer", - "version": "v1.24.0", + "version": "v1.25.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-intl-normalizer.git", @@ -540,12 +540,12 @@ } }, "autoload": { - "psr-4": { - "Symfony\\Polyfill\\Intl\\Normalizer\\": "" - }, "files": [ "bootstrap.php" ], + "psr-4": { + "Symfony\\Polyfill\\Intl\\Normalizer\\": "" + }, "classmap": [ "Resources/stubs" ] @@ -575,7 +575,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.24.0" + "source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.25.0" }, "funding": [ { @@ -595,7 +595,7 @@ }, { "name": "symfony/polyfill-mbstring", - "version": "v1.24.0", + "version": "v1.25.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-mbstring.git", @@ -627,12 +627,12 @@ } }, "autoload": { - "psr-4": { - "Symfony\\Polyfill\\Mbstring\\": "" - }, "files": [ "bootstrap.php" - ] + ], + "psr-4": { + "Symfony\\Polyfill\\Mbstring\\": "" + } }, "notification-url": "https://packagist.org/downloads/", "license": [ @@ -658,7 +658,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.24.0" + "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.25.0" }, "funding": [ { @@ -678,16 +678,16 @@ }, { "name": "symfony/process", - "version": "v6.0.3", + "version": "v6.0.5", "source": { "type": "git", "url": "https://github.com/symfony/process.git", - "reference": "298ed357274c1868c20a0061df256a1250a6c4af" + "reference": "1ccceccc6497e96f4f646218f04b97ae7d9fa7a1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/process/zipball/298ed357274c1868c20a0061df256a1250a6c4af", - "reference": "298ed357274c1868c20a0061df256a1250a6c4af", + "url": "https://api.github.com/repos/symfony/process/zipball/1ccceccc6497e96f4f646218f04b97ae7d9fa7a1", + "reference": "1ccceccc6497e96f4f646218f04b97ae7d9fa7a1", "shasum": "" }, "require": { @@ -719,7 +719,7 @@ "description": "Executes commands in sub-processes", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/process/tree/v6.0.3" + "source": "https://github.com/symfony/process/tree/v6.0.5" }, "funding": [ { @@ -735,7 +735,7 @@ "type": "tidelift" } ], - "time": "2022-01-26T17:23:29+00:00" + "time": "2022-01-30T18:19:12+00:00" }, { "name": "symfony/service-contracts", @@ -851,12 +851,12 @@ }, "type": "library", "autoload": { - "psr-4": { - "Symfony\\Component\\String\\": "" - }, "files": [ "Resources/functions.php" ], + "psr-4": { + "Symfony\\Component\\String\\": "" + }, "exclude-from-classmap": [ "/Tests/" ] @@ -908,29 +908,30 @@ "packages-dev": [ { "name": "doctrine/instantiator", - "version": "1.4.0", + "version": "1.4.1", "source": { "type": "git", "url": "https://github.com/doctrine/instantiator.git", - "reference": "d56bf6102915de5702778fe20f2de3b2fe570b5b" + "reference": "10dcfce151b967d20fde1b34ae6640712c3891bc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/instantiator/zipball/d56bf6102915de5702778fe20f2de3b2fe570b5b", - "reference": "d56bf6102915de5702778fe20f2de3b2fe570b5b", + "url": "https://api.github.com/repos/doctrine/instantiator/zipball/10dcfce151b967d20fde1b34ae6640712c3891bc", + "reference": "10dcfce151b967d20fde1b34ae6640712c3891bc", "shasum": "" }, "require": { "php": "^7.1 || ^8.0" }, "require-dev": { - "doctrine/coding-standard": "^8.0", + "doctrine/coding-standard": "^9", "ext-pdo": "*", "ext-phar": "*", - "phpbench/phpbench": "^0.13 || 1.0.0-alpha2", - "phpstan/phpstan": "^0.12", - "phpstan/phpstan-phpunit": "^0.12", - "phpunit/phpunit": "^7.0 || ^8.0 || ^9.0" + "phpbench/phpbench": "^0.16 || ^1", + "phpstan/phpstan": "^1.4", + "phpstan/phpstan-phpunit": "^1", + "phpunit/phpunit": "^7.5 || ^8.5 || ^9.5", + "vimeo/psalm": "^4.22" }, "type": "library", "autoload": { @@ -957,7 +958,7 @@ ], "support": { "issues": "https://github.com/doctrine/instantiator/issues", - "source": "https://github.com/doctrine/instantiator/tree/1.4.0" + "source": "https://github.com/doctrine/instantiator/tree/1.4.1" }, "funding": [ { @@ -973,38 +974,42 @@ "type": "tidelift" } ], - "time": "2020-11-10T18:47:58+00:00" + "time": "2022-03-03T08:28:38+00:00" }, { "name": "myclabs/deep-copy", - "version": "1.10.2", + "version": "1.11.0", "source": { "type": "git", "url": "https://github.com/myclabs/DeepCopy.git", - "reference": "776f831124e9c62e1a2c601ecc52e776d8bb7220" + "reference": "14daed4296fae74d9e3201d2c4925d1acb7aa614" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/776f831124e9c62e1a2c601ecc52e776d8bb7220", - "reference": "776f831124e9c62e1a2c601ecc52e776d8bb7220", + "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/14daed4296fae74d9e3201d2c4925d1acb7aa614", + "reference": "14daed4296fae74d9e3201d2c4925d1acb7aa614", "shasum": "" }, "require": { "php": "^7.1 || ^8.0" }, + "conflict": { + "doctrine/collections": "<1.6.8", + "doctrine/common": "<2.13.3 || >=3,<3.2.2" + }, "require-dev": { - "doctrine/collections": "^1.0", - "doctrine/common": "^2.6", - "phpunit/phpunit": "^7.1" + "doctrine/collections": "^1.6.8", + "doctrine/common": "^2.13.3 || ^3.2.2", + "phpunit/phpunit": "^7.5.20 || ^8.5.23 || ^9.5.13" }, "type": "library", "autoload": { - "psr-4": { - "DeepCopy\\": "src/DeepCopy/" - }, "files": [ "src/DeepCopy/deep_copy.php" - ] + ], + "psr-4": { + "DeepCopy\\": "src/DeepCopy/" + } }, "notification-url": "https://packagist.org/downloads/", "license": [ @@ -1020,7 +1025,7 @@ ], "support": { "issues": "https://github.com/myclabs/DeepCopy/issues", - "source": "https://github.com/myclabs/DeepCopy/tree/1.10.2" + "source": "https://github.com/myclabs/DeepCopy/tree/1.11.0" }, "funding": [ { @@ -1028,7 +1033,7 @@ "type": "tidelift" } ], - "time": "2020-11-13T09:40:50+00:00" + "time": "2022-03-03T13:19:32+00:00" }, { "name": "nikic/php-parser", @@ -1148,16 +1153,16 @@ }, { "name": "phar-io/version", - "version": "3.1.0", + "version": "3.2.1", "source": { "type": "git", "url": "https://github.com/phar-io/version.git", - "reference": "bae7c545bef187884426f042434e561ab1ddb182" + "reference": "4f7fd7836c6f332bb2933569e566a0d6c4cbed74" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phar-io/version/zipball/bae7c545bef187884426f042434e561ab1ddb182", - "reference": "bae7c545bef187884426f042434e561ab1ddb182", + "url": "https://api.github.com/repos/phar-io/version/zipball/4f7fd7836c6f332bb2933569e566a0d6c4cbed74", + "reference": "4f7fd7836c6f332bb2933569e566a0d6c4cbed74", "shasum": "" }, "require": { @@ -1193,9 +1198,9 @@ "description": "Library for handling version information and constraints", "support": { "issues": "https://github.com/phar-io/version/issues", - "source": "https://github.com/phar-io/version/tree/3.1.0" + "source": "https://github.com/phar-io/version/tree/3.2.1" }, - "time": "2021-02-23T14:00:09+00:00" + "time": "2022-02-21T01:04:05+00:00" }, { "name": "phpdocumentor/reflection-common", @@ -1545,16 +1550,16 @@ }, { "name": "phpunit/php-code-coverage", - "version": "9.2.10", + "version": "9.2.15", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "d5850aaf931743067f4bfc1ae4cbd06468400687" + "reference": "2e9da11878c4202f97915c1cb4bb1ca318a63f5f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/d5850aaf931743067f4bfc1ae4cbd06468400687", - "reference": "d5850aaf931743067f4bfc1ae4cbd06468400687", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/2e9da11878c4202f97915c1cb4bb1ca318a63f5f", + "reference": "2e9da11878c4202f97915c1cb4bb1ca318a63f5f", "shasum": "" }, "require": { @@ -1610,7 +1615,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", - "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.10" + "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.15" }, "funding": [ { @@ -1618,7 +1623,7 @@ "type": "github" } ], - "time": "2021-12-05T09:12:13+00:00" + "time": "2022-03-07T09:28:20+00:00" }, { "name": "phpunit/php-file-iterator", @@ -1863,16 +1868,16 @@ }, { "name": "phpunit/phpunit", - "version": "9.5.13", + "version": "9.5.18", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "597cb647654ede35e43b137926dfdfef0fb11743" + "reference": "1b5856028273bfd855e60a887278857d872ec67a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/597cb647654ede35e43b137926dfdfef0fb11743", - "reference": "597cb647654ede35e43b137926dfdfef0fb11743", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/1b5856028273bfd855e60a887278857d872ec67a", + "reference": "1b5856028273bfd855e60a887278857d872ec67a", "shasum": "" }, "require": { @@ -1888,7 +1893,7 @@ "phar-io/version": "^3.0.2", "php": ">=7.3", "phpspec/prophecy": "^1.12.1", - "phpunit/php-code-coverage": "^9.2.7", + "phpunit/php-code-coverage": "^9.2.13", "phpunit/php-file-iterator": "^3.0.5", "phpunit/php-invoker": "^3.1.1", "phpunit/php-text-template": "^2.0.3", @@ -1923,11 +1928,11 @@ } }, "autoload": { - "classmap": [ - "src/" - ], "files": [ "src/Framework/Assert/Functions.php" + ], + "classmap": [ + "src/" ] }, "notification-url": "https://packagist.org/downloads/", @@ -1950,7 +1955,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", - "source": "https://github.com/sebastianbergmann/phpunit/tree/9.5.13" + "source": "https://github.com/sebastianbergmann/phpunit/tree/9.5.18" }, "funding": [ { @@ -1962,7 +1967,7 @@ "type": "github" } ], - "time": "2022-01-24T07:33:35+00:00" + "time": "2022-03-08T06:52:28+00:00" }, { "name": "sebastian/cli-parser", @@ -2470,16 +2475,16 @@ }, { "name": "sebastian/global-state", - "version": "5.0.3", + "version": "5.0.5", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/global-state.git", - "reference": "23bd5951f7ff26f12d4e3242864df3e08dec4e49" + "reference": "0ca8db5a5fc9c8646244e629625ac486fa286bf2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/23bd5951f7ff26f12d4e3242864df3e08dec4e49", - "reference": "23bd5951f7ff26f12d4e3242864df3e08dec4e49", + "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/0ca8db5a5fc9c8646244e629625ac486fa286bf2", + "reference": "0ca8db5a5fc9c8646244e629625ac486fa286bf2", "shasum": "" }, "require": { @@ -2522,7 +2527,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/global-state/issues", - "source": "https://github.com/sebastianbergmann/global-state/tree/5.0.3" + "source": "https://github.com/sebastianbergmann/global-state/tree/5.0.5" }, "funding": [ { @@ -2530,7 +2535,7 @@ "type": "github" } ], - "time": "2021-06-11T13:31:12+00:00" + "time": "2022-02-14T08:28:10+00:00" }, { "name": "sebastian/lines-of-code", diff --git a/composer.json b/composer.json index f9943dc0ee..45c70f5f28 100644 --- a/composer.json +++ b/composer.json @@ -14,7 +14,7 @@ "hoa/exception": "^1.0", "hoa/regex": "1.17.01.13", "jean85/pretty-package-versions": "^1.0.3", - "jetbrains/phpstorm-stubs": "dev-master#248e61f4d4a8bee1348facc98fecbd4bc41984f1", + "jetbrains/phpstorm-stubs": "dev-master#25c2ba4791d7c08e62aae0793336694ea4fd424a", "nette/bootstrap": "^3.0", "nette/di": "^3.0.11", "nette/finder": "^2.5", @@ -24,7 +24,7 @@ "nikic/php-parser": "^4.13.2", "ondram/ci-detector": "^3.4.0", "ondrejmirtes/better-reflection": "5.0.7.2", - "phpstan/php-8-stubs": "0.1.48", + "phpstan/php-8-stubs": "0.1.49", "phpstan/phpdoc-parser": "^1.2.0", "react/child-process": "^0.6.4", "react/event-loop": "^1.2", @@ -73,9 +73,6 @@ } }, "extra": { - "branch-alias": { - "dev-master": "1.4-dev" - }, "patcher": { "search": "patches" } diff --git a/composer.lock b/composer.lock index 3497da7b42..1f89e62581 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "ede0704e050d946882afd2613bdbb349", + "content-hash": "317daa3b733dc326442f1c6bd70a8333", "packages": [ { "name": "clue/block-react", @@ -1432,12 +1432,12 @@ "source": { "type": "git", "url": "https://github.com/JetBrains/phpstorm-stubs.git", - "reference": "248e61f4d4a8bee1348facc98fecbd4bc41984f1" + "reference": "25c2ba4791d7c08e62aae0793336694ea4fd424a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/JetBrains/phpstorm-stubs/zipball/248e61f4d4a8bee1348facc98fecbd4bc41984f1", - "reference": "248e61f4d4a8bee1348facc98fecbd4bc41984f1", + "url": "https://api.github.com/repos/JetBrains/phpstorm-stubs/zipball/25c2ba4791d7c08e62aae0793336694ea4fd424a", + "reference": "25c2ba4791d7c08e62aae0793336694ea4fd424a", "shasum": "" }, "require-dev": { @@ -1473,7 +1473,7 @@ "support": { "source": "https://github.com/JetBrains/phpstorm-stubs/tree/master" }, - "time": "2022-03-07T17:51:23+00:00" + "time": "2022-03-15T14:13:43+00:00" }, { "name": "nette/bootstrap", @@ -2248,16 +2248,16 @@ }, { "name": "phpstan/php-8-stubs", - "version": "0.1.48", + "version": "0.1.49", "source": { "type": "git", "url": "https://github.com/phpstan/php-8-stubs.git", - "reference": "6fc5082cf5a2d629c54543c4067d3fe6e68c6f8e" + "reference": "095a11fc8ba747bd200fc91701ef1c824818bf49" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/php-8-stubs/zipball/6fc5082cf5a2d629c54543c4067d3fe6e68c6f8e", - "reference": "6fc5082cf5a2d629c54543c4067d3fe6e68c6f8e", + "url": "https://api.github.com/repos/phpstan/php-8-stubs/zipball/095a11fc8ba747bd200fc91701ef1c824818bf49", + "reference": "095a11fc8ba747bd200fc91701ef1c824818bf49", "shasum": "" }, "type": "library", @@ -2274,9 +2274,9 @@ "description": "PHP stubs extracted from php-src", "support": { "issues": "https://github.com/phpstan/php-8-stubs/issues", - "source": "https://github.com/phpstan/php-8-stubs/tree/0.1.48" + "source": "https://github.com/phpstan/php-8-stubs/tree/0.1.49" }, - "time": "2022-03-10T00:11:46+00:00" + "time": "2022-03-11T00:14:16+00:00" }, { "name": "phpstan/phpdoc-parser", @@ -2907,12 +2907,12 @@ }, "type": "library", "autoload": { - "psr-4": { - "React\\Promise\\": "src/" - }, "files": [ "src/functions_include.php" - ] + ], + "psr-4": { + "React\\Promise\\": "src/" + } }, "notification-url": "https://packagist.org/downloads/", "license": [ @@ -2962,12 +2962,12 @@ }, "type": "library", "autoload": { - "psr-4": { - "React\\Promise\\Stream\\": "src/" - }, "files": [ "src/functions_include.php" - ] + ], + "psr-4": { + "React\\Promise\\Stream\\": "src/" + } }, "notification-url": "https://packagist.org/downloads/", "license": [ @@ -3045,12 +3045,12 @@ }, "type": "library", "autoload": { - "psr-4": { - "React\\Promise\\Timer\\": "src/" - }, "files": [ "src/functions_include.php" - ] + ], + "psr-4": { + "React\\Promise\\Timer\\": "src/" + } }, "notification-url": "https://packagist.org/downloads/", "license": [ @@ -3301,12 +3301,12 @@ } }, "autoload": { - "psr-4": { - "RingCentral\\Psr7\\": "src/" - }, "files": [ "src/functions_include.php" - ] + ], + "psr-4": { + "RingCentral\\Psr7\\": "src/" + } }, "notification-url": "https://packagist.org/downloads/", "license": [ @@ -3594,12 +3594,12 @@ } }, "autoload": { - "psr-4": { - "Symfony\\Polyfill\\Ctype\\": "" - }, "files": [ "bootstrap.php" - ] + ], + "psr-4": { + "Symfony\\Polyfill\\Ctype\\": "" + } }, "notification-url": "https://packagist.org/downloads/", "license": [ @@ -3673,12 +3673,12 @@ } }, "autoload": { - "psr-4": { - "Symfony\\Polyfill\\Intl\\Grapheme\\": "" - }, "files": [ "bootstrap.php" - ] + ], + "psr-4": { + "Symfony\\Polyfill\\Intl\\Grapheme\\": "" + } }, "notification-url": "https://packagist.org/downloads/", "license": [ @@ -3754,12 +3754,12 @@ } }, "autoload": { - "psr-4": { - "Symfony\\Polyfill\\Intl\\Normalizer\\": "" - }, "files": [ "bootstrap.php" ], + "psr-4": { + "Symfony\\Polyfill\\Intl\\Normalizer\\": "" + }, "classmap": [ "Resources/stubs" ] @@ -3841,12 +3841,12 @@ } }, "autoload": { - "psr-4": { - "Symfony\\Polyfill\\Mbstring\\": "" - }, "files": [ "bootstrap.php" - ] + ], + "psr-4": { + "Symfony\\Polyfill\\Mbstring\\": "" + } }, "notification-url": "https://packagist.org/downloads/", "license": [ @@ -3918,12 +3918,12 @@ } }, "autoload": { - "psr-4": { - "Symfony\\Polyfill\\Php72\\": "" - }, "files": [ "bootstrap.php" - ] + ], + "psr-4": { + "Symfony\\Polyfill\\Php72\\": "" + } }, "notification-url": "https://packagist.org/downloads/", "license": [ @@ -3994,12 +3994,12 @@ } }, "autoload": { - "psr-4": { - "Symfony\\Polyfill\\Php73\\": "" - }, "files": [ "bootstrap.php" ], + "psr-4": { + "Symfony\\Polyfill\\Php73\\": "" + }, "classmap": [ "Resources/stubs" ] @@ -4073,12 +4073,12 @@ } }, "autoload": { - "psr-4": { - "Symfony\\Polyfill\\Php74\\": "" - }, "files": [ "bootstrap.php" - ] + ], + "psr-4": { + "Symfony\\Polyfill\\Php74\\": "" + } }, "notification-url": "https://packagist.org/downloads/", "license": [ @@ -4153,12 +4153,12 @@ } }, "autoload": { - "psr-4": { - "Symfony\\Polyfill\\Php80\\": "" - }, "files": [ "bootstrap.php" ], + "psr-4": { + "Symfony\\Polyfill\\Php80\\": "" + }, "classmap": [ "Resources/stubs" ] @@ -4386,12 +4386,12 @@ }, "type": "library", "autoload": { - "psr-4": { - "Symfony\\Component\\String\\": "" - }, "files": [ "Resources/functions.php" ], + "psr-4": { + "Symfony\\Component\\String\\": "" + }, "exclude-from-classmap": [ "/Tests/" ] @@ -4670,12 +4670,12 @@ }, "type": "library", "autoload": { - "psr-4": { - "DeepCopy\\": "src/DeepCopy/" - }, "files": [ "src/DeepCopy/deep_copy.php" - ] + ], + "psr-4": { + "DeepCopy\\": "src/DeepCopy/" + } }, "notification-url": "https://packagist.org/downloads/", "license": [ @@ -5799,11 +5799,11 @@ } }, "autoload": { - "classmap": [ - "src/" - ], "files": [ "src/Framework/Assert/Functions.php" + ], + "classmap": [ + "src/" ] }, "notification-url": "https://packagist.org/downloads/", diff --git a/conf/config.level5.neon b/conf/config.level5.neon index c890be88ec..c6d7885f59 100644 --- a/conf/config.level5.neon +++ b/conf/config.level5.neon @@ -8,6 +8,7 @@ parameters: rules: - PHPStan\Rules\DateTimeInstantiationRule - PHPStan\Rules\Functions\ImplodeFunctionRule + - PHPStan\Rules\Functions\ArrayFilterEmptyRule services: - diff --git a/src/Analyser/MutatingScope.php b/src/Analyser/MutatingScope.php index 7bdd515031..ffe61015bc 100644 --- a/src/Analyser/MutatingScope.php +++ b/src/Analyser/MutatingScope.php @@ -2660,7 +2660,14 @@ private function resolveType(Expr $node): Type continue; } - return $dynamicFunctionReturnTypeExtension->getTypeFromFunctionCall($functionReflection, $node, $this); + $resolvedType = $dynamicFunctionReturnTypeExtension->getTypeFromFunctionCall( + $functionReflection, + $node, + $this, + ); + if ($resolvedType !== null) { + return $resolvedType; + } } return ParametersAcceptorSelector::selectFromArgs( @@ -5659,7 +5666,16 @@ private function exactInstantiation(New_ $node, string $className): ?Type continue; } - $resolvedTypes[] = $dynamicStaticMethodReturnTypeExtension->getTypeFromStaticMethodCall($constructorMethod, $methodCall, $this); + $resolvedType = $dynamicStaticMethodReturnTypeExtension->getTypeFromStaticMethodCall( + $constructorMethod, + $methodCall, + $this, + ); + if ($resolvedType === null) { + continue; + } + + $resolvedTypes[] = $resolvedType; } if (count($resolvedTypes) > 0) { @@ -5835,7 +5851,12 @@ private function methodCallReturnType(Type $typeWithMethod, string $methodName, continue; } - $resolvedTypes[] = $dynamicMethodReturnTypeExtension->getTypeFromMethodCall($methodReflection, $methodCall, $this); + $resolvedType = $dynamicMethodReturnTypeExtension->getTypeFromMethodCall($methodReflection, $methodCall, $this); + if ($resolvedType === null) { + continue; + } + + $resolvedTypes[] = $resolvedType; } } else { foreach ($this->dynamicReturnTypeExtensionRegistry->getDynamicStaticMethodReturnTypeExtensionsForClass($className) as $dynamicStaticMethodReturnTypeExtension) { @@ -5843,7 +5864,16 @@ private function methodCallReturnType(Type $typeWithMethod, string $methodName, continue; } - $resolvedTypes[] = $dynamicStaticMethodReturnTypeExtension->getTypeFromStaticMethodCall($methodReflection, $methodCall, $this); + $resolvedType = $dynamicStaticMethodReturnTypeExtension->getTypeFromStaticMethodCall( + $methodReflection, + $methodCall, + $this, + ); + if ($resolvedType === null) { + continue; + } + + $resolvedTypes[] = $resolvedType; } } } diff --git a/src/Command/AnalyseApplication.php b/src/Command/AnalyseApplication.php index 8e175c7725..73aab3de3e 100644 --- a/src/Command/AnalyseApplication.php +++ b/src/Command/AnalyseApplication.php @@ -7,11 +7,13 @@ use PHPStan\Analyser\ResultCache\ResultCacheManagerFactory; use PHPStan\Internal\BytesHelper; use PHPStan\PhpDoc\StubValidator; +use PHPStan\ShouldNotHappenException; use Symfony\Component\Console\Input\InputInterface; use function array_merge; use function count; use function is_string; use function memory_get_peak_usage; +use function microtime; use function sprintf; class AnalyseApplication @@ -148,15 +150,21 @@ private function runAnalyser( $errorOutput->getStyle()->progressAdvance($step); }; } else { - $preFileCallback = static function (string $file) use ($stdOutput): void { + $startTime = null; + $preFileCallback = static function (string $file) use ($stdOutput, &$startTime): void { $stdOutput->writeLineFormatted($file); + $startTime = microtime(true); }; $postFileCallback = null; if ($stdOutput->isDebug()) { $previousMemory = memory_get_peak_usage(true); - $postFileCallback = static function () use ($stdOutput, &$previousMemory): void { + $postFileCallback = static function () use ($stdOutput, &$previousMemory, &$startTime): void { + if ($startTime === null) { + throw new ShouldNotHappenException(); + } $currentTotalMemory = memory_get_peak_usage(true); - $stdOutput->writeLineFormatted(sprintf('--- consumed %s, total %s', BytesHelper::bytes($currentTotalMemory - $previousMemory), BytesHelper::bytes($currentTotalMemory))); + $elapsedTime = microtime(true) - $startTime; + $stdOutput->writeLineFormatted(sprintf('--- consumed %s, total %s, took %.2f s', BytesHelper::bytes($currentTotalMemory - $previousMemory), BytesHelper::bytes($currentTotalMemory), $elapsedTime)); $previousMemory = $currentTotalMemory; }; } diff --git a/src/Rules/Functions/ArrayFilterEmptyRule.php b/src/Rules/Functions/ArrayFilterEmptyRule.php new file mode 100644 index 0000000000..798324e5b3 --- /dev/null +++ b/src/Rules/Functions/ArrayFilterEmptyRule.php @@ -0,0 +1,63 @@ + + */ +class ArrayFilterEmptyRule implements Rule +{ + + public function __construct(private ReflectionProvider $reflectionProvider) + { + } + + public function getNodeType(): string + { + return FuncCall::class; + } + + public function processNode(Node $node, Scope $scope): array + { + if (!($node->name instanceof Node\Name)) { + return []; + } + + if (strtolower($this->reflectionProvider->resolveFunctionName($node->name, $scope)) !== 'array_filter') { + return []; + } + + $args = $node->getArgs(); + if (count($args) !== 1) { + return []; + } + + $arrayType = $scope->getType($args[0]->value); + $falsyType = StaticTypeFactory::falsey(); + + if ($falsyType->isSuperTypeOf($arrayType->getIterableValueType())->no()) { + $message = 'Parameter #1 $array (%s) to function array_filter cannot contain empty values, call has no effect.'; + return [ + RuleErrorBuilder::message(sprintf( + $message, + $arrayType->describe(VerbosityLevel::value()), + ))->build(), + ]; + } + + return []; + } + +} diff --git a/src/Type/DynamicFunctionReturnTypeExtension.php b/src/Type/DynamicFunctionReturnTypeExtension.php index ac4750ce53..92941735a3 100644 --- a/src/Type/DynamicFunctionReturnTypeExtension.php +++ b/src/Type/DynamicFunctionReturnTypeExtension.php @@ -12,6 +12,6 @@ interface DynamicFunctionReturnTypeExtension public function isFunctionSupported(FunctionReflection $functionReflection): bool; - public function getTypeFromFunctionCall(FunctionReflection $functionReflection, FuncCall $functionCall, Scope $scope): Type; + public function getTypeFromFunctionCall(FunctionReflection $functionReflection, FuncCall $functionCall, Scope $scope): ?Type; } diff --git a/src/Type/DynamicMethodReturnTypeExtension.php b/src/Type/DynamicMethodReturnTypeExtension.php index 58635acca7..35f5b505ca 100644 --- a/src/Type/DynamicMethodReturnTypeExtension.php +++ b/src/Type/DynamicMethodReturnTypeExtension.php @@ -14,6 +14,6 @@ public function getClass(): string; public function isMethodSupported(MethodReflection $methodReflection): bool; - public function getTypeFromMethodCall(MethodReflection $methodReflection, MethodCall $methodCall, Scope $scope): Type; + public function getTypeFromMethodCall(MethodReflection $methodReflection, MethodCall $methodCall, Scope $scope): ?Type; } diff --git a/src/Type/DynamicStaticMethodReturnTypeExtension.php b/src/Type/DynamicStaticMethodReturnTypeExtension.php index e2de530f9f..94560039a6 100644 --- a/src/Type/DynamicStaticMethodReturnTypeExtension.php +++ b/src/Type/DynamicStaticMethodReturnTypeExtension.php @@ -14,6 +14,6 @@ public function getClass(): string; public function isStaticMethodSupported(MethodReflection $methodReflection): bool; - public function getTypeFromStaticMethodCall(MethodReflection $methodReflection, StaticCall $methodCall, Scope $scope): Type; + public function getTypeFromStaticMethodCall(MethodReflection $methodReflection, StaticCall $methodCall, Scope $scope): ?Type; } diff --git a/tests/PHPStan/Rules/Exceptions/CatchWithUnthrownExceptionRuleTest.php b/tests/PHPStan/Rules/Exceptions/CatchWithUnthrownExceptionRuleTest.php index 80fe132f33..ea8625fb5f 100644 --- a/tests/PHPStan/Rules/Exceptions/CatchWithUnthrownExceptionRuleTest.php +++ b/tests/PHPStan/Rules/Exceptions/CatchWithUnthrownExceptionRuleTest.php @@ -276,15 +276,15 @@ public function testBug6791(): void $this->analyse([__DIR__ . '/data/bug-6791.php'], [ [ 'Dead catch - TypeError is never thrown in the try block.', - 17, + 22, ], [ 'Dead catch - TypeError is never thrown in the try block.', - 29, + 34, ], [ 'Dead catch - TypeError is never thrown in the try block.', - 33, + 38, ], ]); } diff --git a/tests/PHPStan/Rules/Exceptions/data/bug-6791.php b/tests/PHPStan/Rules/Exceptions/data/bug-6791.php index 84a2eacfcd..e02f88031a 100644 --- a/tests/PHPStan/Rules/Exceptions/data/bug-6791.php +++ b/tests/PHPStan/Rules/Exceptions/data/bug-6791.php @@ -11,24 +11,33 @@ class Foo { public $array; } -$foo = new Foo(); -try { - $foo->intArray = ["a"]; -} catch (\TypeError $e) {} - -try { - $foo->set = ["a"]; -} catch (\TypeError $e) {} - -try { - $foo->set = new \Ds\Set; -} catch (\TypeError $e) {} - -try { - $foo->array = ["a"]; -} catch (\TypeError $e) {} - -try { - $foo->array = "non-array"; -} catch (\TypeError $e) {} +class Bar +{ + + public function doFoo() + { + $foo = new Foo(); + try { + $foo->intArray = ["a"]; + } catch (\TypeError $e) {} + + try { + $foo->set = ["a"]; + } catch (\TypeError $e) {} + + try { + $foo->set = new \Ds\Set; + } catch (\TypeError $e) {} + + try { + $foo->array = ["a"]; + } catch (\TypeError $e) {} + + try { + $foo->array = "non-array"; + } catch (\TypeError $e) {} + } + +} + diff --git a/tests/PHPStan/Rules/Functions/ArrayFilterEmptyRuleTest.php b/tests/PHPStan/Rules/Functions/ArrayFilterEmptyRuleTest.php new file mode 100644 index 0000000000..2c0d8c4e70 --- /dev/null +++ b/tests/PHPStan/Rules/Functions/ArrayFilterEmptyRuleTest.php @@ -0,0 +1,47 @@ + + */ +class ArrayFilterEmptyRuleTest extends RuleTestCase +{ + + protected function getRule(): Rule + { + return new ArrayFilterEmptyRule($this->createReflectionProvider()); + } + + public function testFile(): void + { + $expectedErrors = [ + [ + 'Parameter #1 $array (array{1, 3}) to function array_filter cannot contain empty values, call has no effect.', + 10, + ], + [ + 'Parameter #1 $array (array{\'test\'}) to function array_filter cannot contain empty values, call has no effect.', + 11, + ], + [ + 'Parameter #1 $array (array{true, true}) to function array_filter cannot contain empty values, call has no effect.', + 17, + ], + [ + 'Parameter #1 $array (array{stdClass}) to function array_filter cannot contain empty values, call has no effect.', + 18, + ], + [ + 'Parameter #1 $array (array) to function array_filter cannot contain empty values, call has no effect.', + 20, + ], + ]; + + $this->analyse([__DIR__ . '/data/array_filter_empty.php'], $expectedErrors); + } + +} diff --git a/tests/PHPStan/Rules/Functions/data/array_filter_empty.php b/tests/PHPStan/Rules/Functions/data/array_filter_empty.php new file mode 100644 index 0000000000..58d187f097 --- /dev/null +++ b/tests/PHPStan/Rules/Functions/data/array_filter_empty.php @@ -0,0 +1,21 @@ + $objectsOrNull */ +$objectsOrNull = []; + +array_filter([0]); +array_filter([0,1,3]); +array_filter([1,3]); +array_filter(['test']); +array_filter(['', 'test']); +array_filter([null]); +array_filter([null, 'test']); +array_filter([false, 'test']); +array_filter([true, false]); +array_filter([true, true]); +array_filter([new \stdClass()]); +array_filter([new \stdClass(), null]); +array_filter($objects); +array_filter($objectsOrNull);