Improve array_search inference #20942
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://help.github.com/en/categories/automating-your-workflow-with-github-actions | |
name: "E2E Tests" | |
on: | |
pull_request: | |
paths-ignore: | |
- 'compiler/**' | |
- 'apigen/**' | |
- 'changelog-generator/**' | |
- 'issue-bot/**' | |
push: | |
branches: | |
- "1.12.x" | |
paths-ignore: | |
- 'compiler/**' | |
- 'apigen/**' | |
- 'changelog-generator/**' | |
- 'issue-bot/**' | |
concurrency: | |
group: e2e-${{ github.head_ref || github.run_id }} # will be canceled on subsequent pushes in pull requests but not branches | |
cancel-in-progress: true | |
jobs: | |
result-cache-php-parser-e2e: | |
name: "Result cache PHP-Parser E2E test" | |
runs-on: ${{ matrix.operating-system }} | |
timeout-minutes: 60 | |
strategy: | |
fail-fast: false | |
matrix: | |
operating-system: [ubuntu-latest, windows-latest] | |
steps: | |
- name: "Checkout" | |
uses: actions/checkout@v4 | |
- name: "Install PHP" | |
uses: "shivammathur/setup-php@v2" | |
with: | |
coverage: "none" | |
php-version: "8.1" | |
extensions: mbstring | |
ini-values: memory_limit=256M | |
- name: "Install dependencies" | |
run: "composer install --no-interaction --no-progress" | |
- name: "Tests" | |
run: | | |
git clone https://github.com/nikic/PHP-Parser.git tests/e2e/PHP-Parser && git -C tests/e2e/PHP-Parser checkout v3.1.5 && composer install --working-dir tests/e2e/PHP-Parser && vendor/bin/phpunit tests/e2e/ResultCacheEndToEndTest.php | |
result-cache-e2e-tests: | |
name: "Result cache E2E tests" | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- script: | | |
cd e2e/result-cache-1 | |
echo -n > phpstan-baseline.neon | |
../../bin/phpstan -vvv | |
patch -b src/Bar.php < patch-1.patch | |
cat baseline-1.neon > phpstan-baseline.neon | |
../../bin/phpstan -vvv | |
mv src/Bar.php.orig src/Bar.php | |
echo -n > phpstan-baseline.neon | |
../../bin/phpstan -vvv | |
- script: | | |
cd e2e/result-cache-2 | |
echo -n > phpstan-baseline.neon | |
../../bin/phpstan -vvv | |
patch -b src/Bar.php < patch-1.patch | |
cat baseline-1.neon > phpstan-baseline.neon | |
../../bin/phpstan -vvv | |
mv src/Bar.php.orig src/Bar.php | |
echo -n > phpstan-baseline.neon | |
../../bin/phpstan -vvv | |
- script: | | |
cd e2e/result-cache-3 | |
echo -n > phpstan-baseline.neon | |
../../bin/phpstan -vvv | |
patch -b src/Baz.php < patch-1.patch | |
cat baseline-1.neon > phpstan-baseline.neon | |
../../bin/phpstan -vvv | |
mv src/Baz.php.orig src/Baz.php | |
echo -n > phpstan-baseline.neon | |
../../bin/phpstan -vvv | |
- script: | | |
cd e2e/result-cache-4 | |
echo -n > phpstan-baseline.neon | |
../../bin/phpstan -vvv | |
patch -b src/Bar.php < patch-1.patch | |
cat baseline-1.neon > phpstan-baseline.neon | |
../../bin/phpstan -vvv | |
mv src/Bar.php.orig src/Bar.php | |
echo -n > phpstan-baseline.neon | |
../../bin/phpstan -vvv | |
- script: | | |
cd e2e/result-cache-5 | |
echo -n > phpstan-baseline.neon | |
../../bin/phpstan -vvv | |
patch -b src/Baz.php < patch-1.patch | |
cat baseline-1.neon > phpstan-baseline.neon | |
../../bin/phpstan -vvv | |
mv src/Baz.php.orig src/Baz.php | |
echo -n > phpstan-baseline.neon | |
../../bin/phpstan -vvv | |
- script: | | |
cd e2e/result-cache-6 | |
echo -n > phpstan-baseline.neon | |
../../bin/phpstan -vvv | |
patch -b src/Baz.php < patch-1.patch | |
cat baseline-1.neon > phpstan-baseline.neon | |
../../bin/phpstan -vvv | |
mv src/Baz.php.orig src/Baz.php | |
echo -n > phpstan-baseline.neon | |
../../bin/phpstan -vvv | |
- script: | | |
cd e2e/result-cache-7 | |
echo -n > phpstan-baseline.neon | |
../../bin/phpstan -vvv | |
patch -b src/Bar.php < patch-1.patch | |
cat baseline-1.neon > phpstan-baseline.neon | |
../../bin/phpstan -vvv | |
mv src/Bar.php.orig src/Bar.php | |
echo -n > phpstan-baseline.neon | |
../../bin/phpstan -vvv | |
- script: | | |
cd e2e/bug10449 | |
../../bin/phpstan analyze | |
git apply patch.diff | |
rm phpstan-baseline.neon | |
mv after-phpstan-baseline.neon phpstan-baseline.neon | |
../../bin/phpstan analyze -vvv | |
- script: | | |
cd e2e/bug10449b | |
../../bin/phpstan analyze | |
git apply patch.diff | |
rm phpstan-baseline.neon | |
mv after-phpstan-baseline.neon phpstan-baseline.neon | |
../../bin/phpstan analyze -vvv | |
- script: | | |
cd e2e/bug-9622 | |
echo -n > phpstan-baseline.neon | |
../../bin/phpstan -vvv | |
patch -b src/Foo.php < patch-1.patch | |
cat baseline-1.neon > phpstan-baseline.neon | |
../../bin/phpstan -vvv | |
mv src/Foo.php.orig src/Foo.php | |
echo -n > phpstan-baseline.neon | |
../../bin/phpstan -vvv | |
- script: | | |
cd e2e/bug-9622-trait | |
echo -n > phpstan-baseline.neon | |
../../bin/phpstan -vvv | |
patch -b src/Foo.php < patch-1.patch | |
cat baseline-1.neon > phpstan-baseline.neon | |
../../bin/phpstan -vvv | |
mv src/Foo.php.orig src/Foo.php | |
echo -n > phpstan-baseline.neon | |
../../bin/phpstan -vvv | |
- script: | | |
cd e2e/env-parameter | |
export PHPSTAN_SCOPE_CLASS=MyTestScope | |
ACTUAL=$(../../bin/phpstan dump-parameters -c phpstan.neon --json -l 9 | jq --raw-output '.scopeClass') | |
[[ "$ACTUAL" == "MyTestScope" ]]; | |
- script: | | |
cd e2e/result-cache-8 | |
composer install | |
../../bin/phpstan | |
echo -en '\n' >> build/CustomRule.php | |
OUTPUT=$(../../bin/phpstan 2>&1) | |
grep 'Result cache might not behave correctly' <<< "$OUTPUT" | |
grep 'ResultCache8E2E\\CustomRule' <<< "$OUTPUT" | |
- script: | | |
cd e2e/env-int-key | |
env 1=1 ../../bin/phpstan analyse test.php | |
- script: | | |
cd e2e/result-cache-scanned | |
../../bin/phpstan | |
patch -b src/Generated/Foo.php < patch.patch | |
OUTPUT=$(../bashunit -a exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") | |
echo "$OUTPUT" | |
../bashunit -a contains 'Result cache not used because the metadata do not match: projectConfig, scannedFiles' "$OUTPUT" | |
../bashunit -a contains 'Instantiated class ResultCacheE2EGenerated\Foo not found.' "$OUTPUT" | |
- script: | | |
cd e2e/result-cache-traits | |
../../bin/phpstan analyse | |
patch -b src/FooTrait.php < renameFooTraitMethod.patch | |
OUTPUT=$(../bashunit -a exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") | |
echo "$OUTPUT" | |
../bashunit -a contains 'ClassMentioningClassUsingBarTrait.php:10:Call to an undefined method ResultCacheE2ETraits\ClassUsingBarTrait::doFooTrait(). [identifier=method.notFound]' "$OUTPUT" | |
- script: | | |
cd e2e/editor-mode | |
OUTPUT=$(../bashunit -a exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") | |
echo "$OUTPUT" | |
../bashunit -a contains 'Bar.php:10:Parameter #1 $s of method EditorModeE2E\Bar::requireString() expects string, int given. [identifier=argument.type]' "$OUTPUT" | |
../bashunit -a contains 'Foo.php:10:Method EditorModeE2E\Foo::doFoo() should return int but returns string. [identifier=return.type]' "$OUTPUT" | |
../bashunit -a contains 'Result cache is saved.' "$OUTPUT" | |
OUTPUT=$(../bashunit -a exit_code "1" "../../bin/phpstan analyse -vv --error-format raw --tmp-file differentFoo.php --instead-of src/Foo.php") | |
echo "$OUTPUT" | |
../bashunit -a contains 'Foo.php:10:Method EditorModeE2E\Foo::doFoo() should return float but returns string. [identifier=return.type]' "$OUTPUT" | |
../bashunit -a not_contains 'Foo.php:10:Method EditorModeE2E\Foo::doFoo() should return int but returns string. [identifier=return.type]' "$OUTPUT" | |
../bashunit -a not_contains 'differentFoo.php' "$OUTPUT" | |
../bashunit -a contains 'Bar.php:10:Parameter #1 $s of method EditorModeE2E\Bar::requireString() expects string, float given. [identifier=argument.type]' "$OUTPUT" | |
../bashunit -a contains 'Result cache restored. 2 files will be reanalysed.' "$OUTPUT" | |
../bashunit -a contains 'Result cache was not saved because of --tmp-file and --instead-of CLI options passed (editor mode).' "$OUTPUT" | |
- script: | | |
cd e2e/trait-caching | |
../../bin/phpstan analyze --no-progress --level 8 --error-format raw data/ | |
../../bin/phpstan analyze --no-progress --level 8 --error-format raw data/ | |
- script: | | |
cd e2e/trait-caching | |
../../bin/phpstan analyze --no-progress --level 8 --error-format raw data/ | |
patch -b data/TraitOne.php < TraitOne.patch | |
OUTPUT=$(../../bin/phpstan analyze --no-progress --level 8 --error-format raw data/ || true) | |
echo "$OUTPUT" | |
../bashunit -a line_count 1 "$OUTPUT" | |
../bashunit -a contains 'Method TraitsCachingIssue\TestClassUsingTrait::doBar() should return stdClass but returns Exception.' "$OUTPUT" | |
- script: | | |
cd e2e/trait-caching | |
../../bin/phpstan analyze --no-progress --level 8 --error-format raw data/ | |
patch -b data/TraitTwo.php < TraitTwo.patch | |
OUTPUT=$(../../bin/phpstan analyze --no-progress --level 8 --error-format raw data/ || true) | |
echo "$OUTPUT" | |
../bashunit -a line_count 1 "$OUTPUT" | |
../bashunit -a contains 'Method class@anonymous/TestClassUsingTrait.php:20::doBar() should return stdClass but returns Exception.' "$OUTPUT" | |
- script: | | |
cd e2e/trait-caching | |
../../bin/phpstan analyze --no-progress --level 8 --error-format raw data/ | |
patch -b data/TraitOne.php < TraitOne.patch | |
patch -b data/TraitTwo.php < TraitTwo.patch | |
OUTPUT=$(../../bin/phpstan analyze --no-progress --level 8 --error-format raw data/ || true) | |
echo "$OUTPUT" | |
../bashunit -a line_count 2 "$OUTPUT" | |
../bashunit -a contains 'Method TraitsCachingIssue\TestClassUsingTrait::doBar() should return stdClass but returns Exception.' "$OUTPUT" | |
../bashunit -a contains 'Method class@anonymous/TestClassUsingTrait.php:20::doBar() should return stdClass but returns Exception.' "$OUTPUT" | |
- script: | | |
cd e2e/bad-exclude-paths | |
OUTPUT=$(../../bin/phpstan analyse -c ignore.neon 2>&1 || true) | |
echo "$OUTPUT" | |
../bashunit -a contains 'Invalid entry in ignoreErrors' "$OUTPUT" | |
../bashunit -a contains 'tests is neither a directory, nor a file path, nor a fnmatch pattern.' "$OUTPUT" | |
- script: | | |
cd e2e/bad-exclude-paths | |
OUTPUT=$(../../bin/phpstan analyse -c phpneon.php 2>&1 || true) | |
echo "$OUTPUT" | |
../bashunit -a contains 'Invalid entry in ignoreErrors' "$OUTPUT" | |
../bashunit -a contains 'src/test.php is neither a directory, nor a file path, nor a fnmatch pattern.' "$OUTPUT" | |
- script: | | |
cd e2e/bad-exclude-paths | |
OUTPUT=$(../../bin/phpstan analyse -c excludePaths.neon 2>&1 || true) | |
echo "$OUTPUT" | |
../bashunit -a contains 'Invalid entry in excludePaths' "$OUTPUT" | |
../bashunit -a contains 'tests is neither a directory, nor a file path, nor a fnmatch pattern.' "$OUTPUT" | |
- script: | | |
cd e2e/bad-exclude-paths | |
OUTPUT=$(../../bin/phpstan analyse -c phpneon2.php 2>&1 || true) | |
echo "$OUTPUT" | |
../bashunit -a contains 'Invalid entry in excludePaths' "$OUTPUT" | |
../bashunit -a contains 'src/test.php is neither a directory, nor a file path, nor a fnmatch pattern.' "$OUTPUT" | |
- script: | | |
cd e2e/bad-exclude-paths | |
OUTPUT=$(../../bin/phpstan analyse -c ignoreNonexistentExcludePath.neon) | |
echo "$OUTPUT" | |
- script: | | |
cd e2e/bad-exclude-paths | |
cp -r tmp-node-modules node_modules | |
OUTPUT=$(../../bin/phpstan analyse -c ignoreNonexistentExcludePath.neon) | |
echo "$OUTPUT" | |
- script: | | |
cd e2e/bad-exclude-paths | |
OUTPUT=$(../../bin/phpstan analyse -c ignoreReportUnmatchedFalse.neon) | |
echo "$OUTPUT" | |
- script: | | |
cd e2e/bug-11826 | |
composer install | |
OUTPUT=$(../bashunit -a exit_code "1" "../../bin/phpstan") | |
echo "$OUTPUT" | |
../bashunit -a contains 'Child process error (exit code 255): PHP Fatal error' "$OUTPUT" | |
../bashunit -a contains 'Result is incomplete because of severe errors.' "$OUTPUT" | |
- script: | | |
cd e2e/bug-11857 | |
composer install | |
../../bin/phpstan | |
steps: | |
- name: "Checkout" | |
uses: actions/checkout@v4 | |
- name: "Install PHP" | |
uses: "shivammathur/setup-php@v2" | |
with: | |
coverage: "none" | |
php-version: "8.1" | |
extensions: mbstring | |
ini-values: memory_limit=256M | |
- name: "Install dependencies" | |
run: "composer install --no-interaction --no-progress" | |
- name: "Patch PHPStan" | |
run: "patch src/Analyser/Error.php < e2e/PHPStanErrorPatch.patch" | |
- name: "Install bashunit" | |
run: "curl -s https://bashunit.typeddevs.com/install.sh | bash -s e2e/ 0.17.0" | |
- name: "Test" | |
run: "${{ matrix.script }}" | |
e2e-tests: | |
name: "E2E tests" | |
runs-on: "ubuntu-latest" | |
timeout-minutes: 60 | |
strategy: | |
matrix: | |
include: | |
- script: "bin/phpstan analyse -l 8 -a tests/e2e/data/timecop.php -c tests/e2e/data/empty.neon tests/e2e/data/timecop.php" | |
tools: "pecl" | |
extensions: "timecop-beta" | |
- script: "bin/phpstan analyse -l 8 -a tests/e2e/data/soap.php -c tests/e2e/data/empty.neon tests/e2e/data/soap.php" | |
extensions: "soap" | |
- script: "bin/phpstan analyse -l 8 -a tests/e2e/data/soap.php -c tests/e2e/data/empty.neon tests/e2e/data/soap.php" | |
extensions: "" | |
- script: "bin/phpstan analyse -l 8 tests/e2e/anon-class/Granularity.php" | |
extensions: "" | |
- script: "bin/phpstan analyse -l 8 e2e/phpstan-phpunit-190/test.php -c e2e/phpstan-phpunit-190/test.neon" | |
extensions: "" | |
- script: "bin/phpstan analyse e2e/only-files-not-analysed-trait/src -c e2e/only-files-not-analysed-trait/ignore.neon" | |
extensions: "" | |
- script: "bin/phpstan analyse e2e/only-files-not-analysed-trait/src/Foo.php e2e/only-files-not-analysed-trait/src/BarTrait.php -c e2e/only-files-not-analysed-trait/no-ignore.neon" | |
extensions: "" | |
- script: | | |
cd e2e/baseline-uninit-prop-trait | |
../../bin/phpstan analyse --debug --configuration test-no-baseline.neon --generate-baseline test-baseline.neon | |
../../bin/phpstan analyse --debug --configuration test.neon | |
- script: | | |
cd e2e/baseline-uninit-prop-trait | |
../../bin/phpstan analyse --configuration test-no-baseline.neon --generate-baseline test-baseline.neon | |
../../bin/phpstan analyse --configuration test.neon | |
- script: | | |
cd e2e/discussion-11362 | |
composer install | |
../../bin/phpstan | |
- script: | | |
cd e2e/bug-11819 | |
../../bin/phpstan | |
steps: | |
- name: "Checkout" | |
uses: actions/checkout@v4 | |
- name: "Install PHP" | |
uses: "shivammathur/setup-php@v2" | |
with: | |
coverage: "none" | |
php-version: "8.1" | |
tools: ${{ matrix.tools }} | |
extensions: ${{ matrix.extensions }} | |
- name: "Install dependencies" | |
run: "composer install --no-interaction --no-progress" | |
- name: "Test" | |
run: ${{ matrix.script }} |