diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index 5bfed46f51d..f137e4b9550 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -131,8 +131,8 @@ jobs: OUTPUT=$(../../bin/phpstan -vvv 2>&1) echo "$OUTPUT" UNCHANGED=$([ "$INODE" = "$(ls -i tmp/resultCache.php | awk '{print $1}')" ] && echo unchanged || echo replaced) - ../bashunit -a equals 'unchanged' "$UNCHANGED" - ../bashunit -a contains 'Result cache was not rewritten because it is unchanged.' "$OUTPUT" + ../bashunit assert equals 'unchanged' "$UNCHANGED" + ../bashunit assert contains 'Result cache was not rewritten because it is unchanged.' "$OUTPUT" echo >> src/Foo.php ../../bin/phpstan # The cache is written next to its final path and renamed into place, so saving it @@ -140,13 +140,13 @@ jobs: # next run reads. That is what keeps a run killed mid-save from leaving a partial # cache behind. REPLACED=$([ "$INODE" != "$(ls -i tmp/resultCache.php | awk '{print $1}')" ] && echo replaced || echo 'written in place') - ../bashunit -a equals 'replaced' "$REPLACED" + ../bashunit assert equals 'replaced' "$REPLACED" # A completed save leaves nothing next to the cache file. LEFTOVERS=$(ls tmp/ | grep -c '\.tmp$' || true) - ../bashunit -a equals '0' "$LEFTOVERS" + ../bashunit assert equals '0' "$LEFTOVERS" OUTPUT=$(../../bin/phpstan -vvv 2>&1) echo "$OUTPUT" - ../bashunit -a contains 'Result cache restored. 0 files will be reanalysed.' "$OUTPUT" + ../bashunit assert contains 'Result cache restored. 0 files will be reanalysed.' "$OUTPUT" - script: | cd e2e/result-cache-11 echo -n > phpstan-baseline.neon @@ -166,8 +166,8 @@ jobs: cp tmp-a/resultCache.php tmp-b/resultCache.php OUTPUT=$(../../bin/phpstan analyse -c moved.neon -vv 2>&1) echo "$OUTPUT" - ../bashunit -a contains 'Result cache restored. 0 files will be reanalysed.' "$OUTPUT" - ../bashunit -a not_contains 'metadata do not match' "$OUTPUT" + ../bashunit assert contains 'Result cache restored. 0 files will be reanalysed.' "$OUTPUT" + ../bashunit assert not_contains 'metadata do not match' "$OUTPUT" - script: | cd e2e/result-cache-truncated ../../bin/phpstan -vvv @@ -176,45 +176,45 @@ jobs: php truncate.php OUTPUT=$(../../bin/phpstan -vvv 2>&1) echo "$OUTPUT" - ../bashunit -a contains 'an error occurred while loading the cache file' "$OUTPUT" - ../bashunit -a contains 'Result cache is saved.' "$OUTPUT" + ../bashunit assert contains 'an error occurred while loading the cache file' "$OUTPUT" + ../bashunit assert contains 'Result cache is saved.' "$OUTPUT" # And once more inside a section that is read lazily, which is a different code path. php truncate-lazy.php OUTPUT=$(../../bin/phpstan -vvv 2>&1) echo "$OUTPUT" - ../bashunit -a contains 'is truncated at entry' "$OUTPUT" + ../bashunit assert contains 'is truncated at entry' "$OUTPUT" OUTPUT=$(../../bin/phpstan -vvv 2>&1) echo "$OUTPUT" - ../bashunit -a contains 'Result cache restored.' "$OUTPUT" + ../bashunit assert contains 'Result cache restored.' "$OUTPUT" - script: | cd e2e/result-cache-worker-count OUTPUT=$(../../bin/phpstan -vvv 2>&1) echo "$OUTPUT" - ../bashunit -a contains 'largest of 2' "$OUTPUT" + ../bashunit assert contains 'largest of 2' "$OUTPUT" # Only some files are analysed again, so the result is rebuilt from the cache # and must still report the peak memory of the workers. echo '// changed' >> src/Foo.php echo '// changed' >> src/Bar.php OUTPUT=$(../../bin/phpstan -vvv 2>&1) echo "$OUTPUT" - ../bashunit -a contains 'Result cache restored. 2 files will be reanalysed.' "$OUTPUT" - ../bashunit -a contains 'largest of 2' "$OUTPUT" + ../bashunit assert contains 'Result cache restored. 2 files will be reanalysed.' "$OUTPUT" + ../bashunit assert contains 'largest of 2' "$OUTPUT" - script: | cd e2e/result-cache-stale-objects - OUTPUT=$(../bashunit -a exit_code "1" "../../bin/phpstan -vvv") + OUTPUT=$(../bashunit assert exit_code "1" "../../bin/phpstan -vvv") echo "$OUTPUT" # Renaming a property inside the cache file is what a cache written by a PHPStan whose # classes have changed since looks like: the payload does not carry the property the class # now declares, so reconstructing the object leaves it uninitialized and reading it throws. php rename-property.php - OUTPUT=$(../bashunit -a exit_code "1" "../../bin/phpstan -vvv") + OUTPUT=$(../bashunit assert exit_code "1" "../../bin/phpstan -vvv") echo "$OUTPUT" - ../bashunit -a contains 'could not be read back' "$OUTPUT" - ../bashunit -a contains 'Result cache is saved.' "$OUTPUT" + ../bashunit assert contains 'could not be read back' "$OUTPUT" + ../bashunit assert contains 'Result cache is saved.' "$OUTPUT" # The cache written in its place is usable again. - OUTPUT=$(../bashunit -a exit_code "1" "../../bin/phpstan -vvv") + OUTPUT=$(../bashunit assert exit_code "1" "../../bin/phpstan -vvv") echo "$OUTPUT" - ../bashunit -a contains 'Result cache restored.' "$OUTPUT" + ../bashunit assert contains 'Result cache restored.' "$OUTPUT" - script: | cd e2e/bug-14514 composer install @@ -308,8 +308,8 @@ jobs: - script: | cd e2e/statement-parameter PARAMETERS=$(../../bin/phpstan dump-parameters -c phpstan.neon --json -l 9) - ../bashunit -a equals 'PHPSTAN' "$(echo "$PARAMETERS" | jq --raw-output '.statementParameter')" - ../bashunit -a equals 'PHPSTAN/suffix' "$(echo "$PARAMETERS" | jq --raw-output '.concatenatedStatementParameter')" + ../bashunit assert equals 'PHPSTAN' "$(echo "$PARAMETERS" | jq --raw-output '.statementParameter')" + ../bashunit assert equals 'PHPSTAN/suffix' "$(echo "$PARAMETERS" | jq --raw-output '.concatenatedStatementParameter')" - script: | cd e2e/env-int-key env 1=1 ../../bin/phpstan analyse test.php @@ -320,11 +320,11 @@ jobs: # analysed directory) is tracked as a file dependency: editing it re-analyses just the # files depending on it instead of invalidating the whole result cache. patch -b src/Generated/Foo.php < patch.patch - OUTPUT=$(../bashunit -a exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") + OUTPUT=$(../bashunit assert exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") echo "$OUTPUT" - ../bashunit -a contains 'Scanned files with changed symbols (1); re-analysing the files affected by them.' "$OUTPUT" - ../bashunit -a contains 'Result cache restored. 1 file will be reanalysed.' "$OUTPUT" - ../bashunit -a contains 'Instantiated class ResultCacheE2EGenerated\Foo not found.' "$OUTPUT" + ../bashunit assert contains 'Scanned files with changed symbols (1); re-analysing the files affected by them.' "$OUTPUT" + ../bashunit assert contains 'Result cache restored. 1 file will be reanalysed.' "$OUTPUT" + ../bashunit assert contains 'Instantiated class ResultCacheE2EGenerated\Foo not found.' "$OUTPUT" - script: | cd e2e/bug-15125 composer install @@ -337,137 +337,137 @@ jobs: ../../bin/phpstan analyse OUTPUT=$(../../bin/phpstan analyse -vvv 2>&1) echo "$OUTPUT" - ../bashunit -a not_contains 'Result cache not used because the metadata do not match' "$OUTPUT" - ../bashunit -a not_contains 'Composer metadata changed but no package versions changed' "$OUTPUT" - ../bashunit -a contains 'Result cache restored. 0 files will be reanalysed.' "$OUTPUT" + ../bashunit assert not_contains 'Result cache not used because the metadata do not match' "$OUTPUT" + ../bashunit assert not_contains 'Composer metadata changed but no package versions changed' "$OUTPUT" + ../bashunit assert contains 'Result cache restored. 0 files will be reanalysed.' "$OUTPUT" # --autoload-file is recorded in executedFilesHashes under the path it was given with; # a './' segment must not keep the cache from being reused either. ../../bin/phpstan analyse -a ./vendor/autoload.php OUTPUT=$(../../bin/phpstan analyse -a ./vendor/autoload.php -vvv 2>&1) echo "$OUTPUT" - ../bashunit -a not_contains 'Result cache not used because the metadata do not match' "$OUTPUT" - ../bashunit -a contains 'Result cache restored. 0 files will be reanalysed.' "$OUTPUT" + ../bashunit assert not_contains 'Result cache not used because the metadata do not match' "$OUTPUT" + ../bashunit assert contains 'Result cache restored. 0 files will be reanalysed.' "$OUTPUT" - script: | cd e2e/result-cache-scanned-2 ../../bin/phpstan analyse # Editing a file from scanDirectories re-analyses only the files depending on it - # src/Unrelated.php and src/UsesExtra.php are left alone. patch -b scanned/Dep.php < patch.patch - OUTPUT=$(../bashunit -a exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") + OUTPUT=$(../bashunit assert exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") echo "$OUTPUT" - ../bashunit -a contains 'Result cache restored. 1 file will be reanalysed.' "$OUTPUT" - ../bashunit -a contains 'Foo.php:10:Method ResultCacheE2EScanned2\Foo::doFoo() should return int but returns string.' "$OUTPUT" + ../bashunit assert contains 'Result cache restored. 1 file will be reanalysed.' "$OUTPUT" + ../bashunit assert contains 'Foo.php:10:Method ResultCacheE2EScanned2\Foo::doFoo() should return int but returns string.' "$OUTPUT" # Undoing the edit makes the error go away again. mv scanned/Dep.php.orig scanned/Dep.php - OUTPUT=$(../bashunit -a exit_code "0" "../../bin/phpstan analyse -vv --error-format raw") + OUTPUT=$(../bashunit assert exit_code "0" "../../bin/phpstan analyse -vv --error-format raw") echo "$OUTPUT" - ../bashunit -a contains 'Result cache restored. 1 file will be reanalysed.' "$OUTPUT" + ../bashunit assert contains 'Result cache restored. 1 file will be reanalysed.' "$OUTPUT" # The same for a file listed in scanFiles. patch -b scan-file/Extra.php < patch-2.patch - OUTPUT=$(../bashunit -a exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") + OUTPUT=$(../bashunit assert exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") echo "$OUTPUT" - ../bashunit -a contains 'Result cache restored. 1 file will be reanalysed.' "$OUTPUT" - ../bashunit -a contains 'UsesExtra.php:10:Method ResultCacheE2EScanned2\UsesExtra::doUsesExtra() should return int but returns string.' "$OUTPUT" + ../bashunit assert contains 'Result cache restored. 1 file will be reanalysed.' "$OUTPUT" + ../bashunit assert contains 'UsesExtra.php:10:Method ResultCacheE2EScanned2\UsesExtra::doUsesExtra() should return int but returns string.' "$OUTPUT" # Deleting a scanned file re-analyses the files depending on it. rm scanned/Dep.php - OUTPUT=$(../bashunit -a exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") + OUTPUT=$(../bashunit assert exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") echo "$OUTPUT" - ../bashunit -a contains 'Result cache restored. 1 file will be reanalysed.' "$OUTPUT" - ../bashunit -a contains 'Foo.php:10:Call to method doDep() on an unknown class ResultCacheE2EScanned2\Dep.' "$OUTPUT" + ../bashunit assert contains 'Result cache restored. 1 file will be reanalysed.' "$OUTPUT" + ../bashunit assert contains 'Foo.php:10:Call to method doDep() on an unknown class ResultCacheE2EScanned2\Dep.' "$OUTPUT" - script: | cd e2e/result-cache-scanned-new-file - OUTPUT=$(../bashunit -a exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") + OUTPUT=$(../bashunit assert exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") echo "$OUTPUT" - ../bashunit -a contains 'UsesNew.php:10:Instantiated class ResultCacheE2EScannedNewFile\NewlyScanned not found.' "$OUTPUT" + ../bashunit assert contains 'UsesNew.php:10:Instantiated class ResultCacheE2EScannedNewFile\NewlyScanned not found.' "$OUTPUT" # A file that newly appears in a scanDirectories directory may define a symbol that was # reported as unknown somewhere, so the files with errors are re-analysed too - the same # way a new analysed file makes them re-analysed. src/Foo.php is still left alone. mv new-file/NewlyScanned.php scanned/NewlyScanned.php - OUTPUT=$(../bashunit -a exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") + OUTPUT=$(../bashunit assert exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") echo "$OUTPUT" - ../bashunit -a contains 'Scanned files with changed symbols (1); re-analysing the files affected by them.' "$OUTPUT" - ../bashunit -a contains 'Result cache restored. 1 file will be reanalysed.' "$OUTPUT" - ../bashunit -a not_contains 'Instantiated class ResultCacheE2EScannedNewFile\NewlyScanned not found.' "$OUTPUT" - ../bashunit -a contains 'UsesNew.php:10:Method ResultCacheE2EScannedNewFile\UsesNew::doUsesNew() should return int but returns string.' "$OUTPUT" + ../bashunit assert contains 'Scanned files with changed symbols (1); re-analysing the files affected by them.' "$OUTPUT" + ../bashunit assert contains 'Result cache restored. 1 file will be reanalysed.' "$OUTPUT" + ../bashunit assert not_contains 'Instantiated class ResultCacheE2EScannedNewFile\NewlyScanned not found.' "$OUTPUT" + ../bashunit assert contains 'UsesNew.php:10:Method ResultCacheE2EScannedNewFile\UsesNew::doUsesNew() should return int but returns string.' "$OUTPUT" - script: | cd e2e/result-cache-scanned-exported-nodes # src/Bar.php refers to a class that does not exist yet, so it has an error from the start. - OUTPUT=$(../bashunit -a exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") + OUTPUT=$(../bashunit assert exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") echo "$OUTPUT" - ../bashunit -a contains 'Bar.php:10:Instantiated class ResultCacheE2EScannedExportedNodes\NewDep not found.' "$OUTPUT" + ../bashunit assert contains 'Bar.php:10:Instantiated class ResultCacheE2EScannedExportedNodes\NewDep not found.' "$OUTPUT" # An edit inside a method body of a scanned file changes nothing the files depending on it # can see, so nothing is re-analysed - not the file depending on it, and not the file # with the error either. The same as for an analysed file, where only a change in the # exported nodes (a signature, a PHPDoc, a visibility) reaches the dependents. patch -b scanned/Dep.php < body.patch - OUTPUT=$(../bashunit -a exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") + OUTPUT=$(../bashunit assert exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") echo "$OUTPUT" - ../bashunit -a contains 'Result cache restored. 0 files will be reanalysed.' "$OUTPUT" - ../bashunit -a not_contains 'Scanned files with changed symbols' "$OUTPUT" - ../bashunit -a contains 'Result cache is saved.' "$OUTPUT" + ../bashunit assert contains 'Result cache restored. 0 files will be reanalysed.' "$OUTPUT" + ../bashunit assert not_contains 'Scanned files with changed symbols' "$OUTPUT" + ../bashunit assert contains 'Result cache is saved.' "$OUTPUT" # The new contents are recorded: the next run has nothing to notice. - OUTPUT=$(../bashunit -a exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") + OUTPUT=$(../bashunit assert exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") echo "$OUTPUT" - ../bashunit -a not_contains 'Scanned files with changed symbols' "$OUTPUT" - ../bashunit -a contains 'Result cache restored. 0 files will be reanalysed.' "$OUTPUT" - ../bashunit -a contains 'Result cache was not rewritten because it is unchanged.' "$OUTPUT" + ../bashunit assert not_contains 'Scanned files with changed symbols' "$OUTPUT" + ../bashunit assert contains 'Result cache restored. 0 files will be reanalysed.' "$OUTPUT" + ../bashunit assert contains 'Result cache was not rewritten because it is unchanged.' "$OUTPUT" # A changed return type is an exported node change: the file depending on it is # re-analysed. A changed signature cannot make a new symbol available, so the file with # the error is left alone. mv scanned/Dep.php.orig scanned/Dep.php patch -b scanned/Dep.php < signature.patch - OUTPUT=$(../bashunit -a exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") + OUTPUT=$(../bashunit assert exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") echo "$OUTPUT" - ../bashunit -a contains 'Result cache restored. 1 file will be reanalysed.' "$OUTPUT" - ../bashunit -a contains 'Foo.php:10:Method ResultCacheE2EScannedExportedNodes\Foo::doFoo() should return int but returns string.' "$OUTPUT" - ../bashunit -a contains 'Bar.php:10:Instantiated class ResultCacheE2EScannedExportedNodes\NewDep not found.' "$OUTPUT" + ../bashunit assert contains 'Result cache restored. 1 file will be reanalysed.' "$OUTPUT" + ../bashunit assert contains 'Foo.php:10:Method ResultCacheE2EScannedExportedNodes\Foo::doFoo() should return int but returns string.' "$OUTPUT" + ../bashunit assert contains 'Bar.php:10:Instantiated class ResultCacheE2EScannedExportedNodes\NewDep not found.' "$OUTPUT" # A file without any exported nodes appearing in the scanned directory cannot define the # missing symbol: nothing is re-analysed. mv new-file/NoSymbols.php scanned/NoSymbols.php - OUTPUT=$(../bashunit -a exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") + OUTPUT=$(../bashunit assert exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") echo "$OUTPUT" - ../bashunit -a contains 'Result cache restored. 0 files will be reanalysed.' "$OUTPUT" - ../bashunit -a contains 'Bar.php:10:Instantiated class ResultCacheE2EScannedExportedNodes\NewDep not found.' "$OUTPUT" + ../bashunit assert contains 'Result cache restored. 0 files will be reanalysed.' "$OUTPUT" + ../bashunit assert contains 'Bar.php:10:Instantiated class ResultCacheE2EScannedExportedNodes\NewDep not found.' "$OUTPUT" # A file declaring a class may define a symbol reported as unknown, so the files with # errors are re-analysed - both of them - and the error about the class is gone. mv new-file/NewDep.php scanned/NewDep.php - OUTPUT=$(../bashunit -a exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") + OUTPUT=$(../bashunit assert exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") echo "$OUTPUT" - ../bashunit -a contains 'Result cache restored. 2 files will be reanalysed.' "$OUTPUT" - ../bashunit -a not_contains 'Bar.php:10:Instantiated class ResultCacheE2EScannedExportedNodes\NewDep not found.' "$OUTPUT" - ../bashunit -a contains 'Foo.php:10:Method ResultCacheE2EScannedExportedNodes\Foo::doFoo() should return int but returns string.' "$OUTPUT" + ../bashunit assert contains 'Result cache restored. 2 files will be reanalysed.' "$OUTPUT" + ../bashunit assert not_contains 'Bar.php:10:Instantiated class ResultCacheE2EScannedExportedNodes\NewDep not found.' "$OUTPUT" + ../bashunit assert contains 'Foo.php:10:Method ResultCacheE2EScannedExportedNodes\Foo::doFoo() should return int but returns string.' "$OUTPUT" - script: | cd e2e/result-cache-inner-function - OUTPUT=$(../bashunit -a exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") + OUTPUT=$(../bashunit assert exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") echo "$OUTPUT" - ../bashunit -a contains 'Outer.php:8:Inner named functions are not supported by PHPStan.' "$OUTPUT" - ../bashunit -a contains 'Other.php:10:Method ResultCacheE2EInnerFunction\Other::doOther() should return int but returns string.' "$OUTPUT" + ../bashunit assert contains 'Outer.php:8:Inner named functions are not supported by PHPStan.' "$OUTPUT" + ../bashunit assert contains 'Other.php:10:Method ResultCacheE2EInnerFunction\Other::doOther() should return int but returns string.' "$OUTPUT" # A function declared inside another function is not an exported node, so an edit of the # file declaring it looks like no symbol appeared or disappeared: only the file itself is # re-analysed, not every file with errors. patch -b src/Outer.php < body.patch INFO=$(../../bin/phpstan result-cache-info --json) echo "$INFO" - ../bashunit -a equals 'true' "$(echo "$INFO" | jq --raw-output '.resultCacheUsed')" - ../bashunit -a equals '1' "$(echo "$INFO" | jq --raw-output '.filesToAnalyseCount')" + ../bashunit assert equals 'true' "$(echo "$INFO" | jq --raw-output '.resultCacheUsed')" + ../bashunit assert equals '1' "$(echo "$INFO" | jq --raw-output '.filesToAnalyseCount')" - script: | cd e2e/result-cache-define-in-function - OUTPUT=$(../bashunit -a exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") + OUTPUT=$(../bashunit assert exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") echo "$OUTPUT" - ../bashunit -a contains 'Other.php:10:Method ResultCacheE2EDefineInFunction\Other::doOther() should return int but returns string.' "$OUTPUT" + ../bashunit assert contains 'Other.php:10:Method ResultCacheE2EDefineInFunction\Other::doOther() should return int but returns string.' "$OUTPUT" # A define() inside a function or method body is not an exported node, so an edit of the # file calling it looks like no symbol appeared or disappeared: only the file itself is # re-analysed, not every file with errors. patch -b src/functions.php < body.patch INFO=$(../../bin/phpstan result-cache-info --json) echo "$INFO" - ../bashunit -a equals 'true' "$(echo "$INFO" | jq --raw-output '.resultCacheUsed')" - ../bashunit -a equals '1' "$(echo "$INFO" | jq --raw-output '.filesToAnalyseCount')" + ../bashunit assert equals 'true' "$(echo "$INFO" | jq --raw-output '.resultCacheUsed')" + ../bashunit assert equals '1' "$(echo "$INFO" | jq --raw-output '.filesToAnalyseCount')" - script: | cd e2e/result-cache-function-shares-method-name - OUTPUT=$(../bashunit -a exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") + OUTPUT=$(../bashunit assert exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") echo "$OUTPUT" - ../bashunit -a contains 'Caller.php:10:Parameter #1 $string of function strlen expects string, int given.' "$OUTPUT" + ../bashunit assert contains 'Caller.php:10:Parameter #1 $string of function strlen expects string, int given.' "$OUTPUT" # with-method.php has a method named like the function and is scanned after functions.php, # so the cached reflection of the function must still be tied to functions.php patch -b src/functions.php < changeReturnType.patch @@ -475,50 +475,50 @@ jobs: - script: | cd e2e/result-cache-value-dependency composer install - OUTPUT=$(../bashunit -a exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") - echo "$OUTPUT" - ../bashunit -a contains 'UsesCache.php:7:Service cache does not exist.' "$OUTPUT" - ../bashunit -a contains "UsesLocale.php:10:Function ResultCacheE2EValueDependency\usesLocale() should return 'none' but returns 'cs'." "$OUTPUT" - ../bashunit -a contains "UsesLocaleToo.php:10:Function ResultCacheE2EValueDependency\usesLocaleToo() should return 'none' but returns 'cs'." "$OUTPUT" - ../bashunit -a contains 'Holder.php:17:Method ResultCacheE2EValueDependency\Holder::isDebug() should return int but returns string.' "$OUTPUT" - ../bashunit -a contains 'UsesHolder.php:9:Function ResultCacheE2EValueDependency\usesHolder() should return int but returns string.' "$OUTPUT" - ../bashunit -a contains 'UsesMayThrow.php:9:Dead catch - RuntimeException is never thrown in the try block.' "$OUTPUT" - ../bashunit -a contains 'UsesRegion.php:7:Region eu is used.' "$OUTPUT" - ../bashunit -a contains 'UsesView.php:7:View dashboard does not exist.' "$OUTPUT" - ../bashunit -a contains 'UsesMake.php:7:Call to an undefined method object::run().' "$OUTPUT" - ../bashunit -a not_contains 'UsesMailer.php' "$OUTPUT" + OUTPUT=$(../bashunit assert exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") + echo "$OUTPUT" + ../bashunit assert contains 'UsesCache.php:7:Service cache does not exist.' "$OUTPUT" + ../bashunit assert contains "UsesLocale.php:10:Function ResultCacheE2EValueDependency\usesLocale() should return 'none' but returns 'cs'." "$OUTPUT" + ../bashunit assert contains "UsesLocaleToo.php:10:Function ResultCacheE2EValueDependency\usesLocaleToo() should return 'none' but returns 'cs'." "$OUTPUT" + ../bashunit assert contains 'Holder.php:17:Method ResultCacheE2EValueDependency\Holder::isDebug() should return int but returns string.' "$OUTPUT" + ../bashunit assert contains 'UsesHolder.php:9:Function ResultCacheE2EValueDependency\usesHolder() should return int but returns string.' "$OUTPUT" + ../bashunit assert contains 'UsesMayThrow.php:9:Dead catch - RuntimeException is never thrown in the try block.' "$OUTPUT" + ../bashunit assert contains 'UsesRegion.php:7:Region eu is used.' "$OUTPUT" + ../bashunit assert contains 'UsesView.php:7:View dashboard does not exist.' "$OUTPUT" + ../bashunit assert contains 'UsesMake.php:7:Call to an undefined method object::run().' "$OUTPUT" + ../bashunit assert not_contains 'UsesMailer.php' "$OUTPUT" # The extensions read container.json, which the result cache knows nothing about. A rule and a # dynamic return type extension both declare the service they ask about - it is recorded once. # A change of its value re-analyses only the file asking about it. php -r '$c = json_decode(file_get_contents("container.json"), true); $c["services"]["mailer"] = "ResultCacheE2EValueDependency\\Logger"; file_put_contents("container.json", json_encode($c, JSON_PRETTY_PRINT));' INFO=$(../../bin/phpstan result-cache-info --json) echo "$INFO" - ../bashunit -a equals '1' "$(echo "$INFO" | jq --raw-output '.filesToAnalyseCount')" - OUTPUT=$(../bashunit -a exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") + ../bashunit assert equals '1' "$(echo "$INFO" | jq --raw-output '.filesToAnalyseCount')" + OUTPUT=$(../bashunit assert exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") echo "$OUTPUT" - ../bashunit -a contains 'UsesMailer.php:7:Call to an undefined method ResultCacheE2EValueDependency\Logger::send().' "$OUTPUT" + ../bashunit assert contains 'UsesMailer.php:7:Call to an undefined method ResultCacheE2EValueDependency\Logger::send().' "$OUTPUT" # Values nobody asked about do not re-analyse anything. php -r '$c = json_decode(file_get_contents("container.json"), true); $c["parameters"]["timezone"] = "UTC"; $c["services"]["router"] = "ResultCacheE2EValueDependency\\Logger"; file_put_contents("container.json", json_encode($c, JSON_PRETTY_PRINT));' INFO=$(../../bin/phpstan result-cache-info --json) echo "$INFO" - ../bashunit -a equals '0' "$(echo "$INFO" | jq --raw-output '.filesToAnalyseCount')" + ../bashunit assert equals '0' "$(echo "$INFO" | jq --raw-output '.filesToAnalyseCount')" # A value that was missing is watched too. php -r '$c = json_decode(file_get_contents("container.json"), true); $c["services"]["cache"] = "ResultCacheE2EValueDependency\\Logger"; file_put_contents("container.json", json_encode($c, JSON_PRETTY_PRINT));' INFO=$(../../bin/phpstan result-cache-info --json) echo "$INFO" - ../bashunit -a equals '1' "$(echo "$INFO" | jq --raw-output '.filesToAnalyseCount')" - OUTPUT=$(../bashunit -a exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") + ../bashunit assert equals '1' "$(echo "$INFO" | jq --raw-output '.filesToAnalyseCount')" + OUTPUT=$(../bashunit assert exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") echo "$OUTPUT" - ../bashunit -a not_contains 'Service cache does not exist.' "$OUTPUT" + ../bashunit assert not_contains 'Service cache does not exist.' "$OUTPUT" # Every file asking about the same value is re-analysed. php -r '$c = json_decode(file_get_contents("container.json"), true); $c["parameters"]["locale"] = "en"; file_put_contents("container.json", json_encode($c, JSON_PRETTY_PRINT));' INFO=$(../../bin/phpstan result-cache-info --json) echo "$INFO" - ../bashunit -a equals '2' "$(echo "$INFO" | jq --raw-output '.filesToAnalyseCount')" - OUTPUT=$(../bashunit -a exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") + ../bashunit assert equals '2' "$(echo "$INFO" | jq --raw-output '.filesToAnalyseCount')" + OUTPUT=$(../bashunit assert exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") echo "$OUTPUT" - ../bashunit -a contains "UsesLocale.php:10:Function ResultCacheE2EValueDependency\usesLocale() should return 'none' but returns 'en'." "$OUTPUT" - ../bashunit -a contains "UsesLocaleToo.php:10:Function ResultCacheE2EValueDependency\usesLocaleToo() should return 'none' but returns 'en'." "$OUTPUT" + ../bashunit assert contains "UsesLocale.php:10:Function ResultCacheE2EValueDependency\usesLocale() should return 'none' but returns 'en'." "$OUTPUT" + ../bashunit assert contains "UsesLocaleToo.php:10:Function ResultCacheE2EValueDependency\usesLocaleToo() should return 'none' but returns 'en'." "$OUTPUT" # Scope::getFile() is not the file to re-analyse when the extension runs outside the walk of the # analysed file: the type of Holder::$debug is inferred from the constructor on a scope of # src/Holder.php, whenever the property is first needed, and it is cached. So it is what @@ -527,125 +527,125 @@ jobs: php -r '$c = json_decode(file_get_contents("container.json"), true); $c["parameters"]["debug"] = "1"; file_put_contents("container.json", json_encode($c, JSON_PRETTY_PRINT));' INFO=$(../../bin/phpstan result-cache-info --json) echo "$INFO" - ../bashunit -a equals '2' "$(echo "$INFO" | jq --raw-output '.filesToAnalyseCount')" - OUTPUT=$(../bashunit -a exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") + ../bashunit assert equals '2' "$(echo "$INFO" | jq --raw-output '.filesToAnalyseCount')" + OUTPUT=$(../bashunit assert exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") echo "$OUTPUT" - ../bashunit -a not_contains 'Holder.php' "$OUTPUT" + ../bashunit assert not_contains 'Holder.php' "$OUTPUT" # Inside a trait, the value is asked about in the analysis of the class using it - that's the # file re-analysed, and the error is reported in the trait. php -r '$c = json_decode(file_get_contents("container.json"), true); $c["services"]["logger"] = "ResultCacheE2EValueDependency\\Mailer"; file_put_contents("container.json", json_encode($c, JSON_PRETTY_PRINT));' INFO=$(../../bin/phpstan result-cache-info --json) echo "$INFO" - ../bashunit -a equals '2' "$(echo "$INFO" | jq --raw-output '.filesToAnalyseCount')" - OUTPUT=$(../bashunit -a exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") + ../bashunit assert equals '2' "$(echo "$INFO" | jq --raw-output '.filesToAnalyseCount')" + OUTPUT=$(../bashunit assert exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") echo "$OUTPUT" - ../bashunit -a contains 'UsesLogger.php:7:Call to an undefined method ResultCacheE2EValueDependency\Mailer::log().' "$OUTPUT" - ../bashunit -a contains 'LoggerTrait.php (in context of class ResultCacheE2EValueDependency\UsesLoggerTrait):10:Call to an undefined method ResultCacheE2EValueDependency\Mailer::log().' "$OUTPUT" + ../bashunit assert contains 'UsesLogger.php:7:Call to an undefined method ResultCacheE2EValueDependency\Mailer::log().' "$OUTPUT" + ../bashunit assert contains 'LoggerTrait.php (in context of class ResultCacheE2EValueDependency\UsesLoggerTrait):10:Call to an undefined method ResultCacheE2EValueDependency\Mailer::log().' "$OUTPUT" # A dynamic throw type extension tracks the values it reads too. php -r '$c = json_decode(file_get_contents("container.json"), true); $c["parameters"]["throwing"] = "yes"; file_put_contents("container.json", json_encode($c, JSON_PRETTY_PRINT));' INFO=$(../../bin/phpstan result-cache-info --json) echo "$INFO" - ../bashunit -a equals '1' "$(echo "$INFO" | jq --raw-output '.filesToAnalyseCount')" - OUTPUT=$(../bashunit -a exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") + ../bashunit assert equals '1' "$(echo "$INFO" | jq --raw-output '.filesToAnalyseCount')" + OUTPUT=$(../bashunit assert exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") echo "$OUTPUT" - ../bashunit -a not_contains 'Dead catch' "$OUTPUT" + ../bashunit assert not_contains 'Dead catch' "$OUTPUT" # So does a collector: the data it collected is collected again in the analysis of the file. php -r '$c = json_decode(file_get_contents("container.json"), true); $c["parameters"]["region"] = "us"; file_put_contents("container.json", json_encode($c, JSON_PRETTY_PRINT));' INFO=$(../../bin/phpstan result-cache-info --json) echo "$INFO" - ../bashunit -a equals '1' "$(echo "$INFO" | jq --raw-output '.filesToAnalyseCount')" - OUTPUT=$(../bashunit -a exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") + ../bashunit assert equals '1' "$(echo "$INFO" | jq --raw-output '.filesToAnalyseCount')" + OUTPUT=$(../bashunit assert exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") echo "$OUTPUT" - ../bashunit -a contains 'UsesRegion.php:7:Region us is used.' "$OUTPUT" - ../bashunit -a not_contains 'Region eu is used.' "$OUTPUT" + ../bashunit assert contains 'UsesRegion.php:7:Region us is used.' "$OUTPUT" + ../bashunit assert not_contains 'Region eu is used.' "$OUTPUT" # So does a parameter closure this extension: $this in the closure follows the parameter. php -r '$c = json_decode(file_get_contents("container.json"), true); $c["parameters"]["closureThis"] = "ResultCacheE2EValueDependency\\Logger"; file_put_contents("container.json", json_encode($c, JSON_PRETTY_PRINT));' INFO=$(../../bin/phpstan result-cache-info --json) echo "$INFO" - ../bashunit -a equals '1' "$(echo "$INFO" | jq --raw-output '.filesToAnalyseCount')" - OUTPUT=$(../bashunit -a exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") + ../bashunit assert equals '1' "$(echo "$INFO" | jq --raw-output '.filesToAnalyseCount')" + OUTPUT=$(../bashunit assert exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") echo "$OUTPUT" - ../bashunit -a contains 'UsesWithThis.php:8:Call to an undefined method ResultCacheE2EValueDependency\Logger::send().' "$OUTPUT" + ../bashunit assert contains 'UsesWithThis.php:8:Call to an undefined method ResultCacheE2EValueDependency\Logger::send().' "$OUTPUT" # So does a type-specifying extension: the narrowed type follows the parameter. php -r '$c = json_decode(file_get_contents("container.json"), true); $c["parameters"]["allowedClass"] = "ResultCacheE2EValueDependency\\Logger"; file_put_contents("container.json", json_encode($c, JSON_PRETTY_PRINT));' INFO=$(../../bin/phpstan result-cache-info --json) echo "$INFO" - ../bashunit -a equals '1' "$(echo "$INFO" | jq --raw-output '.filesToAnalyseCount')" - OUTPUT=$(../bashunit -a exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") + ../bashunit assert equals '1' "$(echo "$INFO" | jq --raw-output '.filesToAnalyseCount')" + OUTPUT=$(../bashunit assert exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") echo "$OUTPUT" - ../bashunit -a contains 'UsesIsAllowed.php:8:Call to an undefined method ResultCacheE2EValueDependency\Logger::send().' "$OUTPUT" + ../bashunit assert contains 'UsesIsAllowed.php:8:Call to an undefined method ResultCacheE2EValueDependency\Logger::send().' "$OUTPUT" # A rule tracking a directory: a file the pattern doesn't match changes nothing... echo 'notes' > views/notes.txt INFO=$(../../bin/phpstan result-cache-info --json) echo "$INFO" - ../bashunit -a equals '0' "$(echo "$INFO" | jq --raw-output '.filesToAnalyseCount')" + ../bashunit assert equals '0' "$(echo "$INFO" | jq --raw-output '.filesToAnalyseCount')" # ...a matching file appearing re-analyses the file that looked for it. echo '
dashboard
' > views/dashboard.html INFO=$(../../bin/phpstan result-cache-info --json) echo "$INFO" - ../bashunit -a equals '1' "$(echo "$INFO" | jq --raw-output '.filesToAnalyseCount')" - OUTPUT=$(../bashunit -a exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") + ../bashunit assert equals '1' "$(echo "$INFO" | jq --raw-output '.filesToAnalyseCount')" + OUTPUT=$(../bashunit assert exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") echo "$OUTPUT" - ../bashunit -a not_contains 'View dashboard does not exist.' "$OUTPUT" + ../bashunit assert not_contains 'View dashboard does not exist.' "$OUTPUT" # ...and so does a matching file whose contents change. echo 'dashboard, changed
' > views/dashboard.html INFO=$(../../bin/phpstan result-cache-info --json) echo "$INFO" - ../bashunit -a equals '1' "$(echo "$INFO" | jq --raw-output '.filesToAnalyseCount')" - ../bashunit -a exit_code "1" "../../bin/phpstan analyse -vv --error-format raw" + ../bashunit assert equals '1' "$(echo "$INFO" | jq --raw-output '.filesToAnalyseCount')" + ../bashunit assert exit_code "1" "../../bin/phpstan analyse -vv --error-format raw" # A dynamic return type extension tracking a class named in a string: the class appearing - outside # the analysed paths, so no fallback for new files kicks in - re-analyses the file naming it... printf ' lib/Gadget.php INFO=$(../../bin/phpstan result-cache-info --json) echo "$INFO" - ../bashunit -a equals '1' "$(echo "$INFO" | jq --raw-output '.filesToAnalyseCount')" - OUTPUT=$(../bashunit -a exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") + ../bashunit assert equals '1' "$(echo "$INFO" | jq --raw-output '.filesToAnalyseCount')" + OUTPUT=$(../bashunit assert exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") echo "$OUTPUT" - ../bashunit -a not_contains 'UsesMake.php' "$OUTPUT" + ../bashunit assert not_contains 'UsesMake.php' "$OUTPUT" # ...a method body edited in its parent class does not... sed -i.bak 's/return 1;/return 2;/' lib/Base.php && rm lib/Base.php.bak INFO=$(../../bin/phpstan result-cache-info --json) echo "$INFO" - ../bashunit -a equals '0' "$(echo "$INFO" | jq --raw-output '.filesToAnalyseCount')" + ../bashunit assert equals '0' "$(echo "$INFO" | jq --raw-output '.filesToAnalyseCount')" # ...and a signature changed there does. printf ' lib/Base.php INFO=$(../../bin/phpstan result-cache-info --json) echo "$INFO" - ../bashunit -a equals '1' "$(echo "$INFO" | jq --raw-output '.filesToAnalyseCount')" - OUTPUT=$(../bashunit -a exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") + ../bashunit assert equals '1' "$(echo "$INFO" | jq --raw-output '.filesToAnalyseCount')" + OUTPUT=$(../bashunit assert exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") echo "$OUTPUT" - ../bashunit -a contains 'UsesMake.php:7:Function ResultCacheE2EValueDependency\usesMake() should return int but returns string.' "$OUTPUT" + ../bashunit assert contains 'UsesMake.php:7:Function ResultCacheE2EValueDependency\usesMake() should return int but returns string.' "$OUTPUT" # A class reflection extension tracking on the class: every file using the class is analysed again, # also one that got the magic method from the reflection cache without asking the extension. php -r '$c = json_decode(file_get_contents("container.json"), true); $c["parameters"]["greeting"] = "1"; file_put_contents("container.json", json_encode($c, JSON_PRETTY_PRINT));' INFO=$(../../bin/phpstan result-cache-info --json) echo "$INFO" - ../bashunit -a equals '3' "$(echo "$INFO" | jq --raw-output '.filesToAnalyseCount')" - OUTPUT=$(../bashunit -a exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") + ../bashunit assert equals '3' "$(echo "$INFO" | jq --raw-output '.filesToAnalyseCount')" + OUTPUT=$(../bashunit assert exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") echo "$OUTPUT" - ../bashunit -a contains 'UsesMagic.php:7:Function ResultCacheE2EValueDependency\usesMagic() should return string but returns int.' "$OUTPUT" - ../bashunit -a contains 'UsesMagicToo.php:7:Function ResultCacheE2EValueDependency\usesMagicToo() should return string but returns int.' "$OUTPUT" + ../bashunit assert contains 'UsesMagic.php:7:Function ResultCacheE2EValueDependency\usesMagic() should return string but returns int.' "$OUTPUT" + ../bashunit assert contains 'UsesMagicToo.php:7:Function ResultCacheE2EValueDependency\usesMagicToo() should return string but returns int.' "$OUTPUT" - script: | cd e2e/result-cache-file-dependency composer install - OUTPUT=$(../bashunit -a exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") - echo "$OUTPUT" - ../bashunit -a contains "UsesFunction.php:10:Function ResultCacheE2EFileDependency\usesFunction() should return 'none' but returns 'function-1'." "$OUTPUT" - ../bashunit -a contains "UsesMethod.php:10:Function ResultCacheE2EFileDependency\usesMethod() should return 'none' but returns 'method-1'." "$OUTPUT" - ../bashunit -a contains "UsesStaticMethod.php:10:Function ResultCacheE2EFileDependency\usesStaticMethod() should return 'none' but returns 'static-method-1'." "$OUTPUT" - ../bashunit -a contains 'Holder.php:17:Method ResultCacheE2EFileDependency\Holder::get() should return int but returns string.' "$OUTPUT" - ../bashunit -a contains 'UsesHolder.php:9:Function ResultCacheE2EFileDependency\usesHolder() should return int but returns string.' "$OUTPUT" - ../bashunit -a contains 'UsesDeprecatedConfig.php:7:Deprecated config asks for an error.' "$OUTPUT" - ../bashunit -a not_contains 'Config asks for an error.' "$OUTPUT" + OUTPUT=$(../bashunit assert exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") + echo "$OUTPUT" + ../bashunit assert contains "UsesFunction.php:10:Function ResultCacheE2EFileDependency\usesFunction() should return 'none' but returns 'function-1'." "$OUTPUT" + ../bashunit assert contains "UsesMethod.php:10:Function ResultCacheE2EFileDependency\usesMethod() should return 'none' but returns 'method-1'." "$OUTPUT" + ../bashunit assert contains "UsesStaticMethod.php:10:Function ResultCacheE2EFileDependency\usesStaticMethod() should return 'none' but returns 'static-method-1'." "$OUTPUT" + ../bashunit assert contains 'Holder.php:17:Method ResultCacheE2EFileDependency\Holder::get() should return int but returns string.' "$OUTPUT" + ../bashunit assert contains 'UsesHolder.php:9:Function ResultCacheE2EFileDependency\usesHolder() should return int but returns string.' "$OUTPUT" + ../bashunit assert contains 'UsesDeprecatedConfig.php:7:Deprecated config asks for an error.' "$OUTPUT" + ../bashunit assert not_contains 'Config asks for an error.' "$OUTPUT" # The paths declared with the deprecated RuleErrorBuilder::fileDependency() are declared on the # scope of the rule's node. printf 'quiet\n' > data/deprecated.txt INFO=$(../../bin/phpstan result-cache-info --json) echo "$INFO" - ../bashunit -a equals '1' "$(echo "$INFO" | jq --raw-output '.filesToAnalyseCount')" - OUTPUT=$(../bashunit -a exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") + ../bashunit assert equals '1' "$(echo "$INFO" | jq --raw-output '.filesToAnalyseCount')" + OUTPUT=$(../bashunit assert exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") echo "$OUTPUT" - ../bashunit -a not_contains 'Deprecated config asks for an error.' "$OUTPUT" + ../bashunit assert not_contains 'Deprecated config asks for an error.' "$OUTPUT" # A rule declares its dependency on src/Config.php whether it reports an error or not. The file # declares no symbols, so no change of it reaches its exported nodes - any change re-analyses the # files of the rule's nodes anyway, next to the changed file itself: src/UsesConfig.php and @@ -654,42 +654,42 @@ jobs: printf " src/Config.php INFO=$(../../bin/phpstan result-cache-info --json) echo "$INFO" - ../bashunit -a equals '3' "$(echo "$INFO" | jq --raw-output '.filesToAnalyseCount')" - OUTPUT=$(../bashunit -a exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") + ../bashunit assert equals '3' "$(echo "$INFO" | jq --raw-output '.filesToAnalyseCount')" + OUTPUT=$(../bashunit assert exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") echo "$OUTPUT" - ../bashunit -a contains 'UsesConfig.php:7:Config asks for an error.' "$OUTPUT" - ../bashunit -a contains 'ConfigHolder.php:10:Config asks for an error.' "$OUTPUT" + ../bashunit assert contains 'UsesConfig.php:7:Config asks for an error.' "$OUTPUT" + ../bashunit assert contains 'ConfigHolder.php:10:Config asks for an error.' "$OUTPUT" printf " src/Config.php INFO=$(../../bin/phpstan result-cache-info --json) echo "$INFO" - ../bashunit -a equals '3' "$(echo "$INFO" | jq --raw-output '.filesToAnalyseCount')" - OUTPUT=$(../bashunit -a exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") + ../bashunit assert equals '3' "$(echo "$INFO" | jq --raw-output '.filesToAnalyseCount')" + OUTPUT=$(../bashunit assert exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") echo "$OUTPUT" - ../bashunit -a contains 'UsesConfig.php:7:Config asks for an error.' "$OUTPUT" + ../bashunit assert contains 'UsesConfig.php:7:Config asks for an error.' "$OUTPUT" # Dynamic return type extensions of a function, a method and a static method declared in # src/functions.php and src/Repository.php read a data file each. A change of one re-analyses the # file with the call - not the one declaring the function or the method. printf 'function-2\n' > data/function.txt INFO=$(../../bin/phpstan result-cache-info --json) echo "$INFO" - ../bashunit -a equals '1' "$(echo "$INFO" | jq --raw-output '.filesToAnalyseCount')" - OUTPUT=$(../bashunit -a exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") + ../bashunit assert equals '1' "$(echo "$INFO" | jq --raw-output '.filesToAnalyseCount')" + OUTPUT=$(../bashunit assert exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") echo "$OUTPUT" - ../bashunit -a contains "UsesFunction.php:10:Function ResultCacheE2EFileDependency\usesFunction() should return 'none' but returns 'function-2'." "$OUTPUT" + ../bashunit assert contains "UsesFunction.php:10:Function ResultCacheE2EFileDependency\usesFunction() should return 'none' but returns 'function-2'." "$OUTPUT" printf 'method-2\n' > data/method.txt INFO=$(../../bin/phpstan result-cache-info --json) echo "$INFO" - ../bashunit -a equals '1' "$(echo "$INFO" | jq --raw-output '.filesToAnalyseCount')" - OUTPUT=$(../bashunit -a exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") + ../bashunit assert equals '1' "$(echo "$INFO" | jq --raw-output '.filesToAnalyseCount')" + OUTPUT=$(../bashunit assert exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") echo "$OUTPUT" - ../bashunit -a contains "UsesMethod.php:10:Function ResultCacheE2EFileDependency\usesMethod() should return 'none' but returns 'method-2'." "$OUTPUT" + ../bashunit assert contains "UsesMethod.php:10:Function ResultCacheE2EFileDependency\usesMethod() should return 'none' but returns 'method-2'." "$OUTPUT" printf 'static-method-2\n' > data/static-method.txt INFO=$(../../bin/phpstan result-cache-info --json) echo "$INFO" - ../bashunit -a equals '1' "$(echo "$INFO" | jq --raw-output '.filesToAnalyseCount')" - OUTPUT=$(../bashunit -a exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") + ../bashunit assert equals '1' "$(echo "$INFO" | jq --raw-output '.filesToAnalyseCount')" + OUTPUT=$(../bashunit assert exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") echo "$OUTPUT" - ../bashunit -a contains "UsesStaticMethod.php:10:Function ResultCacheE2EFileDependency\usesStaticMethod() should return 'none' but returns 'static-method-2'." "$OUTPUT" + ../bashunit assert contains "UsesStaticMethod.php:10:Function ResultCacheE2EFileDependency\usesStaticMethod() should return 'none' but returns 'static-method-2'." "$OUTPUT" # Scope::getFile() is not the file to re-analyse when the extension runs outside the walk of the # analysed file: the type of Holder::$value is inferred from the constructor on a scope of # src/Holder.php, whenever the property is first needed - in the analysis of src/Holder.php, or of @@ -698,71 +698,71 @@ jobs: printf 'int\n' > data/holder.txt INFO=$(../../bin/phpstan result-cache-info --json) echo "$INFO" - ../bashunit -a equals '2' "$(echo "$INFO" | jq --raw-output '.filesToAnalyseCount')" - OUTPUT=$(../bashunit -a exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") + ../bashunit assert equals '2' "$(echo "$INFO" | jq --raw-output '.filesToAnalyseCount')" + OUTPUT=$(../bashunit assert exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") echo "$OUTPUT" - ../bashunit -a not_contains 'Holder.php:17:Method ResultCacheE2EFileDependency\Holder::get() should return int but returns string.' "$OUTPUT" - ../bashunit -a not_contains 'UsesHolder.php:9:Function ResultCacheE2EFileDependency\usesHolder() should return int but returns string.' "$OUTPUT" + ../bashunit assert not_contains 'Holder.php:17:Method ResultCacheE2EFileDependency\Holder::get() should return int but returns string.' "$OUTPUT" + ../bashunit assert not_contains 'UsesHolder.php:9:Function ResultCacheE2EFileDependency\usesHolder() should return int but returns string.' "$OUTPUT" # Deleting a declared file re-analyses the files depending on it too, and it stays watched while # it is missing: creating it again re-analyses them again. rm data/function.txt INFO=$(../../bin/phpstan result-cache-info --json) echo "$INFO" - ../bashunit -a equals '1' "$(echo "$INFO" | jq --raw-output '.filesToAnalyseCount')" - OUTPUT=$(../bashunit -a exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") + ../bashunit assert equals '1' "$(echo "$INFO" | jq --raw-output '.filesToAnalyseCount')" + OUTPUT=$(../bashunit assert exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") echo "$OUTPUT" - ../bashunit -a contains "UsesFunction.php:10:Function ResultCacheE2EFileDependency\usesFunction() should return 'none' but returns 'missing'." "$OUTPUT" + ../bashunit assert contains "UsesFunction.php:10:Function ResultCacheE2EFileDependency\usesFunction() should return 'none' but returns 'missing'." "$OUTPUT" printf 'function-3\n' > data/function.txt INFO=$(../../bin/phpstan result-cache-info --json) echo "$INFO" - ../bashunit -a equals '1' "$(echo "$INFO" | jq --raw-output '.filesToAnalyseCount')" - OUTPUT=$(../bashunit -a exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") + ../bashunit assert equals '1' "$(echo "$INFO" | jq --raw-output '.filesToAnalyseCount')" + OUTPUT=$(../bashunit assert exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") echo "$OUTPUT" - ../bashunit -a contains "UsesFunction.php:10:Function ResultCacheE2EFileDependency\usesFunction() should return 'none' but returns 'function-3'." "$OUTPUT" + ../bashunit assert contains "UsesFunction.php:10:Function ResultCacheE2EFileDependency\usesFunction() should return 'none' but returns 'function-3'." "$OUTPUT" # The same for what src/Holder.php declares. rm data/holder.txt INFO=$(../../bin/phpstan result-cache-info --json) echo "$INFO" - ../bashunit -a equals '2' "$(echo "$INFO" | jq --raw-output '.filesToAnalyseCount')" - OUTPUT=$(../bashunit -a exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") + ../bashunit assert equals '2' "$(echo "$INFO" | jq --raw-output '.filesToAnalyseCount')" + OUTPUT=$(../bashunit assert exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") echo "$OUTPUT" - ../bashunit -a contains 'Holder.php:17:Method ResultCacheE2EFileDependency\Holder::get() should return int but returns string.' "$OUTPUT" - ../bashunit -a contains 'UsesHolder.php:9:Function ResultCacheE2EFileDependency\usesHolder() should return int but returns string.' "$OUTPUT" + ../bashunit assert contains 'Holder.php:17:Method ResultCacheE2EFileDependency\Holder::get() should return int but returns string.' "$OUTPUT" + ../bashunit assert contains 'UsesHolder.php:9:Function ResultCacheE2EFileDependency\usesHolder() should return int but returns string.' "$OUTPUT" printf 'int\n' > data/holder.txt INFO=$(../../bin/phpstan result-cache-info --json) echo "$INFO" - ../bashunit -a equals '2' "$(echo "$INFO" | jq --raw-output '.filesToAnalyseCount')" - OUTPUT=$(../bashunit -a exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") + ../bashunit assert equals '2' "$(echo "$INFO" | jq --raw-output '.filesToAnalyseCount')" + OUTPUT=$(../bashunit assert exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") echo "$OUTPUT" - ../bashunit -a not_contains 'Holder.php:17:Method ResultCacheE2EFileDependency\Holder::get() should return int but returns string.' "$OUTPUT" - ../bashunit -a not_contains 'UsesHolder.php:9:Function ResultCacheE2EFileDependency\usesHolder() should return int but returns string.' "$OUTPUT" + ../bashunit assert not_contains 'Holder.php:17:Method ResultCacheE2EFileDependency\Holder::get() should return int but returns string.' "$OUTPUT" + ../bashunit assert not_contains 'UsesHolder.php:9:Function ResultCacheE2EFileDependency\usesHolder() should return int but returns string.' "$OUTPUT" # And for a declared file that is analysed itself: deleted, it is no longer analysed, and the files # of the rule's nodes are re-analysed; created again, all three are - and as with any new file, so # are the three files with errors. rm src/Config.php INFO=$(../../bin/phpstan result-cache-info --json) echo "$INFO" - ../bashunit -a equals '2' "$(echo "$INFO" | jq --raw-output '.filesToAnalyseCount')" - OUTPUT=$(../bashunit -a exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") + ../bashunit assert equals '2' "$(echo "$INFO" | jq --raw-output '.filesToAnalyseCount')" + OUTPUT=$(../bashunit assert exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") echo "$OUTPUT" - ../bashunit -a not_contains 'Config asks for an error.' "$OUTPUT" + ../bashunit assert not_contains 'Config asks for an error.' "$OUTPUT" printf " src/Config.php INFO=$(../../bin/phpstan result-cache-info --json) echo "$INFO" - ../bashunit -a equals '6' "$(echo "$INFO" | jq --raw-output '.filesToAnalyseCount')" - OUTPUT=$(../bashunit -a exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") + ../bashunit assert equals '6' "$(echo "$INFO" | jq --raw-output '.filesToAnalyseCount')" + OUTPUT=$(../bashunit assert exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") echo "$OUTPUT" - ../bashunit -a contains 'UsesConfig.php:7:Config asks for an error.' "$OUTPUT" + ../bashunit assert contains 'UsesConfig.php:7:Config asks for an error.' "$OUTPUT" - script: | cd e2e/result-cache-scanned-trait ../../bin/phpstan analyse # A trait living in a scanned file is tracked the same way, including through the # used-trait dependencies. patch -b scanned/DepTrait.php < patch.patch - OUTPUT=$(../bashunit -a exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") + OUTPUT=$(../bashunit assert exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") echo "$OUTPUT" - ../bashunit -a contains 'Result cache restored. 1 file will be reanalysed.' "$OUTPUT" - ../bashunit -a contains 'UsesTrait.php:12:Method ResultCacheE2EScannedTrait\UsesTrait::doIt() should return int but returns string.' "$OUTPUT" + ../bashunit assert contains 'Result cache restored. 1 file will be reanalysed.' "$OUTPUT" + ../bashunit assert contains 'UsesTrait.php:12:Method ResultCacheE2EScannedTrait\UsesTrait::doIt() should return int but returns string.' "$OUTPUT" - script: | cd e2e/result-cache-autoloaded composer install @@ -771,60 +771,60 @@ jobs: # through the Composer autoloader - is tracked as a file dependency too, so editing it # re-analyses the files depending on it instead of leaving stale results behind. patch -b other/Dep.php < patch.patch - OUTPUT=$(../bashunit -a exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") + OUTPUT=$(../bashunit assert exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") echo "$OUTPUT" - ../bashunit -a contains 'Result cache restored. 1 file will be reanalysed.' "$OUTPUT" - ../bashunit -a contains 'Foo.php:12:Method ResultCacheE2EAutoloaded\Foo::doFoo() should return int but returns string.' "$OUTPUT" + ../bashunit assert contains 'Result cache restored. 1 file will be reanalysed.' "$OUTPUT" + ../bashunit assert contains 'Foo.php:12:Method ResultCacheE2EAutoloaded\Foo::doFoo() should return int but returns string.' "$OUTPUT" - script: | cd e2e/result-cache-autoloaded-constant composer install # The same sequence on a project file that is neither analysed nor scanned - it is only # reachable through the Composer autoloader, so it is tracked through the dependency graph # alone. - OUTPUT=$(../bashunit -a exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") + OUTPUT=$(../bashunit assert exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") echo "$OUTPUT" - ../bashunit -a contains 'Foo.php:10:Dumped type: 1' "$OUTPUT" + ../bashunit assert contains 'Foo.php:10:Dumped type: 1' "$OUTPUT" # The constant is renamed to one the class already declares. The file is invalid PHP, but # the class still reflects, so the file using the constant is re-analysed through its # dependency edge. patch -b other/Dep.php < duplicate.patch - OUTPUT=$(../bashunit -a exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") + OUTPUT=$(../bashunit assert exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") echo "$OUTPUT" - ../bashunit -a contains 'Result cache restored. 1 file will be reanalysed.' "$OUTPUT" - ../bashunit -a contains 'Foo.php:10:Access to undefined constant ResultCacheE2EAutoloadedConstant\Dep::CON.' "$OUTPUT" + ../bashunit assert contains 'Result cache restored. 1 file will be reanalysed.' "$OUTPUT" + ../bashunit assert contains 'Foo.php:10:Access to undefined constant ResultCacheE2EAutoloadedConstant\Dep::CON.' "$OUTPUT" # Renamed to something else instead. mv other/Dep.php.orig other/Dep.php patch -b other/Dep.php < renamed.patch - OUTPUT=$(../bashunit -a exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") + OUTPUT=$(../bashunit assert exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") echo "$OUTPUT" - ../bashunit -a contains 'Result cache restored. 1 file will be reanalysed.' "$OUTPUT" - ../bashunit -a contains 'Foo.php:10:Access to undefined constant ResultCacheE2EAutoloadedConstant\Dep::CON.' "$OUTPUT" + ../bashunit assert contains 'Result cache restored. 1 file will be reanalysed.' "$OUTPUT" + ../bashunit assert contains 'Foo.php:10:Access to undefined constant ResultCacheE2EAutoloadedConstant\Dep::CON.' "$OUTPUT" # Broken the same way again. mv other/Dep.php.orig other/Dep.php patch -b other/Dep.php < duplicate.patch - OUTPUT=$(../bashunit -a exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") + OUTPUT=$(../bashunit assert exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") echo "$OUTPUT" - ../bashunit -a contains 'Result cache restored. 1 file will be reanalysed.' "$OUTPUT" - ../bashunit -a contains 'Foo.php:10:Access to undefined constant ResultCacheE2EAutoloadedConstant\Dep::CON.' "$OUTPUT" + ../bashunit assert contains 'Result cache restored. 1 file will be reanalysed.' "$OUTPUT" + ../bashunit assert contains 'Foo.php:10:Access to undefined constant ResultCacheE2EAutoloadedConstant\Dep::CON.' "$OUTPUT" # And put back the way it was. mv other/Dep.php.orig other/Dep.php - OUTPUT=$(../bashunit -a exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") + OUTPUT=$(../bashunit assert exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") echo "$OUTPUT" - ../bashunit -a contains 'Result cache restored. 1 file will be reanalysed.' "$OUTPUT" - ../bashunit -a contains 'Foo.php:10:Dumped type: 1' "$OUTPUT" + ../bashunit assert contains 'Result cache restored. 1 file will be reanalysed.' "$OUTPUT" + ../bashunit assert contains 'Foo.php:10:Dumped type: 1' "$OUTPUT" # A syntax error makes the class disappear altogether: the file using it reports an unknown # class and records no dependency edge to the file, so nothing but the file being fixed can # bring the file using it back - it must be re-analysed once the class is there again. patch -b other/Dep.php < broken.patch - OUTPUT=$(../bashunit -a exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") + OUTPUT=$(../bashunit assert exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") echo "$OUTPUT" - ../bashunit -a contains 'Result cache restored. 1 file will be reanalysed.' "$OUTPUT" - ../bashunit -a contains 'Foo.php:10:Access to constant CON on an unknown class ResultCacheE2EAutoloadedConstant\Dep.' "$OUTPUT" + ../bashunit assert contains 'Result cache restored. 1 file will be reanalysed.' "$OUTPUT" + ../bashunit assert contains 'Foo.php:10:Access to constant CON on an unknown class ResultCacheE2EAutoloadedConstant\Dep.' "$OUTPUT" mv other/Dep.php.orig other/Dep.php - OUTPUT=$(../bashunit -a exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") + OUTPUT=$(../bashunit assert exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") echo "$OUTPUT" - ../bashunit -a contains 'Result cache restored. 1 file will be reanalysed.' "$OUTPUT" - ../bashunit -a contains 'Foo.php:10:Dumped type: 1' "$OUTPUT" + ../bashunit assert contains 'Result cache restored. 1 file will be reanalysed.' "$OUTPUT" + ../bashunit assert contains 'Foo.php:10:Dumped type: 1' "$OUTPUT" - script: | cd e2e/result-cache-scanned-vendor composer install @@ -833,10 +833,10 @@ jobs: # dependency - packages are tracked at package granularity - so editing it still has to # invalidate the whole result cache instead of leaving stale results behind. patch -b vendor/test/scanned-lib/src/Dep.php < patch.patch - OUTPUT=$(../bashunit -a exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") + OUTPUT=$(../bashunit assert exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") echo "$OUTPUT" - ../bashunit -a contains 'changed and belongs to a Composer package.' "$OUTPUT" - ../bashunit -a contains 'Foo.php:12:Method ResultCacheE2EScannedVendor\Foo::doFoo() should return int but returns string.' "$OUTPUT" + ../bashunit assert contains 'changed and belongs to a Composer package.' "$OUTPUT" + ../bashunit assert contains 'Foo.php:12:Method ResultCacheE2EScannedVendor\Foo::doFoo() should return int but returns string.' "$OUTPUT" - script: | cd e2e/result-cache-bootstrap ../../bin/phpstan analyse @@ -844,40 +844,40 @@ jobs: # analysis. It stays part of the executedFilesHashes metadata and keeps invalidating the # whole result cache - the scanned file tracking does not apply to it. patch -b bootstrap.php < patch.patch - OUTPUT=$(../bashunit -a exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") + OUTPUT=$(../bashunit assert 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: executedFilesHashes' "$OUTPUT" - ../bashunit -a contains 'Foo.php:10:Method ResultCacheE2EBootstrap\Foo::doFoo() should return int but returns string.' "$OUTPUT" + ../bashunit assert contains 'Result cache not used because the metadata do not match: executedFilesHashes' "$OUTPUT" + ../bashunit assert contains 'Foo.php:10:Method ResultCacheE2EBootstrap\Foo::doFoo() should return int but returns string.' "$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") + OUTPUT=$(../bashunit assert 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" + ../bashunit assert contains 'ClassMentioningClassUsingBarTrait.php:10:Call to an undefined method ResultCacheE2ETraits\ClassUsingBarTrait::doFooTrait(). [identifier=method.notFound]' "$OUTPUT" - script: | cd e2e/result-cache-trait-alongside-class ../../bin/phpstan analyse patch -b src/FooTrait.php < changeFooTraitBody.patch - OUTPUT=$(../bashunit -a exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") + OUTPUT=$(../bashunit assert exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") echo "$OUTPUT" - ../bashunit -a contains 'FooTrait.php (in context of class ResultCacheE2ETraitAlongsideClass\ClassUsingFooTrait):10:Method ResultCacheE2ETraitAlongsideClass\ClassUsingFooTrait::doFooTrait() should return stdClass but returns Exception. [identifier=return.type]' "$OUTPUT" + ../bashunit assert contains 'FooTrait.php (in context of class ResultCacheE2ETraitAlongsideClass\ClassUsingFooTrait):10:Method ResultCacheE2ETraitAlongsideClass\ClassUsingFooTrait::doFooTrait() should return stdClass but returns Exception. [identifier=return.type]' "$OUTPUT" - script: | cd e2e/editor-mode - OUTPUT=$(../bashunit -a exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") + OUTPUT=$(../bashunit assert 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" + ../bashunit assert contains 'Bar.php:10:Parameter #1 $s of method EditorModeE2E\Bar::requireString() expects string, int given. [identifier=argument.type]' "$OUTPUT" + ../bashunit assert contains 'Foo.php:10:Method EditorModeE2E\Foo::doFoo() should return int but returns string. [identifier=return.type]' "$OUTPUT" + ../bashunit assert 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") + OUTPUT=$(../bashunit assert 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" + ../bashunit assert contains 'Foo.php:10:Method EditorModeE2E\Foo::doFoo() should return float but returns string. [identifier=return.type]' "$OUTPUT" + ../bashunit assert not_contains 'Foo.php:10:Method EditorModeE2E\Foo::doFoo() should return int but returns string. [identifier=return.type]' "$OUTPUT" + ../bashunit assert not_contains 'differentFoo.php' "$OUTPUT" + ../bashunit assert contains 'Bar.php:10:Parameter #1 $s of method EditorModeE2E\Bar::requireString() expects string, float given. [identifier=argument.type]' "$OUTPUT" + ../bashunit assert contains 'Result cache restored. 2 files will be reanalysed.' "$OUTPUT" + ../bashunit assert 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/ @@ -886,55 +886,55 @@ jobs: cd e2e/trait-caching ../../bin/phpstan analyze --no-progress --level 8 --error-format raw data/ patch -b data/TraitOne.php < TraitOne.patch - OUTPUT=$(../bashunit -a exit_code "1" "../../bin/phpstan analyze --no-progress --level 8 --error-format raw data/") + OUTPUT=$(../bashunit assert exit_code "1" "../../bin/phpstan analyze --no-progress --level 8 --error-format raw data/") echo "$OUTPUT" - ../bashunit -a line_count 2 "$OUTPUT" - ../bashunit -a matches "Note: Using configuration file .+phpstan.neon." "$OUTPUT" - ../bashunit -a contains 'Method TraitsCachingIssue\TestClassUsingTrait::doBar() should return stdClass but returns Exception.' "$OUTPUT" + ../bashunit assert line_count 2 "$OUTPUT" + ../bashunit assert matches "Note: Using configuration file .+phpstan.neon." "$OUTPUT" + ../bashunit assert 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=$(../bashunit -a exit_code "1" "../../bin/phpstan analyze --no-progress --level 8 --error-format raw data/") + OUTPUT=$(../bashunit assert exit_code "1" "../../bin/phpstan analyze --no-progress --level 8 --error-format raw data/") echo "$OUTPUT" - ../bashunit -a line_count 2 "$OUTPUT" - ../bashunit -a matches "Note: Using configuration file .+phpstan.neon." "$OUTPUT" - ../bashunit -a contains 'Method class@anonymous/TestClassUsingTrait.php:20::doBar() should return stdClass but returns Exception.' "$OUTPUT" + ../bashunit assert line_count 2 "$OUTPUT" + ../bashunit assert matches "Note: Using configuration file .+phpstan.neon." "$OUTPUT" + ../bashunit assert 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=$(../bashunit -a exit_code "1" "../../bin/phpstan analyze --no-progress --level 8 --error-format raw data/") + OUTPUT=$(../bashunit assert exit_code "1" "../../bin/phpstan analyze --no-progress --level 8 --error-format raw data/") echo "$OUTPUT" - ../bashunit -a line_count 3 "$OUTPUT" - ../bashunit -a matches "Note: Using configuration file .+phpstan.neon." "$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" + ../bashunit assert line_count 3 "$OUTPUT" + ../bashunit assert matches "Note: Using configuration file .+phpstan.neon." "$OUTPUT" + ../bashunit assert contains 'Method TraitsCachingIssue\TestClassUsingTrait::doBar() should return stdClass but returns Exception.' "$OUTPUT" + ../bashunit assert contains 'Method class@anonymous/TestClassUsingTrait.php:20::doBar() should return stdClass but returns Exception.' "$OUTPUT" - script: | cd e2e/bad-exclude-paths - OUTPUT=$(../bashunit -a exit_code "1" "../../bin/phpstan analyse -c ignore.neon") + OUTPUT=$(../bashunit assert exit_code "1" "../../bin/phpstan analyse -c ignore.neon") 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" + ../bashunit assert contains 'Invalid entry in ignoreErrors' "$OUTPUT" + ../bashunit assert contains 'tests" is neither a directory, nor a file path, nor a fnmatch pattern.' "$OUTPUT" - script: | cd e2e/bad-exclude-paths - OUTPUT=$(../bashunit -a exit_code "1" "../../bin/phpstan analyse -c phpneon.php") + OUTPUT=$(../bashunit assert exit_code "1" "../../bin/phpstan analyse -c phpneon.php") 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" + ../bashunit assert contains 'Invalid entry in ignoreErrors' "$OUTPUT" + ../bashunit assert contains '"src/test.php" is neither a directory, nor a file path, nor a fnmatch pattern.' "$OUTPUT" - script: | cd e2e/bad-exclude-paths - OUTPUT=$(../bashunit -a exit_code "1" "../../bin/phpstan analyse -c excludePaths.neon") + OUTPUT=$(../bashunit assert exit_code "1" "../../bin/phpstan analyse -c excludePaths.neon") 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" + ../bashunit assert contains 'Invalid entry in excludePaths' "$OUTPUT" + ../bashunit assert contains 'tests" is neither a directory, nor a file path, nor a fnmatch pattern.' "$OUTPUT" - script: | cd e2e/bad-exclude-paths - OUTPUT=$(../bashunit -a exit_code "1" "../../bin/phpstan analyse -c phpneon2.php") + OUTPUT=$(../bashunit assert exit_code "1" "../../bin/phpstan analyse -c phpneon2.php") 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" + ../bashunit assert contains 'Invalid entry in excludePaths' "$OUTPUT" + ../bashunit assert 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) @@ -951,56 +951,56 @@ jobs: - script: | cd e2e/bug-11826 composer install - OUTPUT=$(../bashunit -a exit_code "1" "../../bin/phpstan") + OUTPUT=$(../bashunit assert 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" + ../bashunit assert contains 'Child process error (exit code 255): PHP Fatal error' "$OUTPUT" + ../bashunit assert contains 'Result is incomplete because of severe errors.' "$OUTPUT" - script: | cd e2e/oom-forked-worker composer install - OUTPUT=$(../bashunit -a exit_code "1" "../../bin/phpstan analyse --memory-limit=300M") + OUTPUT=$(../bashunit assert exit_code "1" "../../bin/phpstan analyse --memory-limit=300M") echo "$OUTPUT" - ../bashunit -a contains 'Child process error: PHPStan process crashed' "$OUTPUT" - ../bashunit -a contains 'Result is incomplete because of severe errors.' "$OUTPUT" + ../bashunit assert contains 'Child process error: PHPStan process crashed' "$OUTPUT" + ../bashunit assert contains 'Result is incomplete because of severe errors.' "$OUTPUT" - script: | cd e2e/bug-11857 composer install ../../bin/phpstan - script: | cd e2e/in-trait - OUTPUT=$(../bashunit -a exit_code "1" "../../bin/phpstan --error-format=raw") - ../bashunit -a contains 'FooTrait.php:10:Strict comparison using === between int<0, max> and false will always evaluate to false.' "$OUTPUT" - ../bashunit -a contains 'FooTrait.php (in context of class E2EInTrait\Bar):18:Strict comparison using === between E2EInTrait\Bar and null will always evaluate to false.' "$OUTPUT" - ../bashunit -a contains 'FooTrait.php (in context of class E2EInTrait\Foo):18:Strict comparison using === between E2EInTrait\Foo and null will always evaluate to false.' "$OUTPUT" + OUTPUT=$(../bashunit assert exit_code "1" "../../bin/phpstan --error-format=raw") + ../bashunit assert contains 'FooTrait.php:10:Strict comparison using === between int<0, max> and false will always evaluate to false.' "$OUTPUT" + ../bashunit assert contains 'FooTrait.php (in context of class E2EInTrait\Bar):18:Strict comparison using === between E2EInTrait\Bar and null will always evaluate to false.' "$OUTPUT" + ../bashunit assert contains 'FooTrait.php (in context of class E2EInTrait\Foo):18:Strict comparison using === between E2EInTrait\Foo and null will always evaluate to false.' "$OUTPUT" - script: | cd e2e/bug-14718 # https://github.com/phpstan/phpstan/issues/14718 # An inline @phpstan-ignore on an error deduplicated directly into the trait must # suppress it, consistently with both an empty and a primed result cache. ../../bin/phpstan clear-result-cache - ../bashunit -a exit_code "0" "../../bin/phpstan --error-format=raw" - ../bashunit -a exit_code "0" "../../bin/phpstan --error-format=raw" + ../bashunit assert exit_code "0" "../../bin/phpstan --error-format=raw" + ../bashunit assert exit_code "0" "../../bin/phpstan --error-format=raw" # With the ignore removed, the error is reported directly in the trait file. sed -i 's# // @phpstan-ignore identical.alwaysFalse##' src/FooTrait.php ../../bin/phpstan clear-result-cache - OUTPUT=$(../bashunit -a exit_code "1" "../../bin/phpstan --error-format=raw") - ../bashunit -a contains 'FooTrait.php:10:Strict comparison using === between int<0, max> and false will always evaluate to false.' "$OUTPUT" + OUTPUT=$(../bashunit assert exit_code "1" "../../bin/phpstan --error-format=raw") + ../bashunit assert contains 'FooTrait.php:10:Strict comparison using === between int<0, max> and false will always evaluate to false.' "$OUTPUT" # An ignoreErrors path may target the error by the trait file (hides it for # all using classes) or by a using-class file - a class-pathed entry accounts # only for its own class's context, so the other using class's context is # still reported (see also the e2e/bug-14932 script). ../../bin/phpstan clear-result-cache - ../bashunit -a exit_code "0" "../../bin/phpstan analyse --error-format=raw -c ignore-trait-path.neon" + ../bashunit assert exit_code "0" "../../bin/phpstan analyse --error-format=raw -c ignore-trait-path.neon" ../../bin/phpstan clear-result-cache - OUTPUT=$(../bashunit -a exit_code "1" "../../bin/phpstan analyse --error-format=raw -c ignore-class-path.neon") - ../bashunit -a contains 'FooTrait.php (in context of class Bug14718\Bar):10:Strict comparison using === between int<0, max> and false will always evaluate to false.' "$OUTPUT" - ../bashunit -a not_contains 'was not matched' "$OUTPUT" + OUTPUT=$(../bashunit assert exit_code "1" "../../bin/phpstan analyse --error-format=raw -c ignore-class-path.neon") + ../bashunit assert contains 'FooTrait.php (in context of class Bug14718\Bar):10:Strict comparison using === between int<0, max> and false will always evaluate to false.' "$OUTPUT" + ../bashunit assert not_contains 'was not matched' "$OUTPUT" # A generated baseline suppresses the error on re-run, with both an empty and a # primed result cache (the issue reported baseline generation as impossible). ../../bin/phpstan --generate-baseline=baseline.neon ../../bin/phpstan clear-result-cache - ../bashunit -a exit_code "0" "../../bin/phpstan analyse --error-format=raw -c with-baseline.neon" - ../bashunit -a exit_code "0" "../../bin/phpstan analyse --error-format=raw -c with-baseline.neon" + ../bashunit assert exit_code "0" "../../bin/phpstan analyse --error-format=raw -c with-baseline.neon" + ../bashunit assert exit_code "0" "../../bin/phpstan analyse --error-format=raw -c with-baseline.neon" - script: | cd e2e/bug-14932 # https://github.com/phpstan/phpstan/issues/14932 @@ -1013,97 +1013,97 @@ jobs: # trait file (no "in context of"); errors whose message differs per using # class stay reported in each class context. ../../bin/phpstan clear-result-cache - OUTPUT=$(../bashunit -a exit_code "1" "../../bin/phpstan analyse --error-format=raw") - ../bashunit -a contains 'SomeTrait.php:17:Right side of && is always true.' "$OUTPUT" - ../bashunit -a not_contains 'SomeTrait.php (in context of' "$OUTPUT" - ../bashunit -a contains 'DiffMessageTrait.php (in context of class Bug14932\AMailer):10:Strict comparison' "$OUTPUT" - ../bashunit -a contains 'DiffMessageTrait.php (in context of class Bug14932\BMailer):10:Strict comparison' "$OUTPUT" + OUTPUT=$(../bashunit assert exit_code "1" "../../bin/phpstan analyse --error-format=raw") + ../bashunit assert contains 'SomeTrait.php:17:Right side of && is always true.' "$OUTPUT" + ../bashunit assert not_contains 'SomeTrait.php (in context of' "$OUTPUT" + ../bashunit assert contains 'DiffMessageTrait.php (in context of class Bug14932\AMailer):10:Strict comparison' "$OUTPUT" + ../bashunit assert contains 'DiffMessageTrait.php (in context of class Bug14932\BMailer):10:Strict comparison' "$OUTPUT" # An ignoreErrors path targeting the trait file hides the error from all # using classes - with both an empty and a primed result cache. ../../bin/phpstan clear-result-cache - ../bashunit -a exit_code "0" "../../bin/phpstan analyse --error-format=raw -c ignore-trait-path.neon" - ../bashunit -a exit_code "0" "../../bin/phpstan analyse --error-format=raw -c ignore-trait-path.neon" + ../bashunit assert exit_code "0" "../../bin/phpstan analyse --error-format=raw -c ignore-trait-path.neon" + ../bashunit assert exit_code "0" "../../bin/phpstan analyse --error-format=raw -c ignore-trait-path.neon" # An ignoreErrors path targeting one using class accounts only for that # class's context: the entry matches (no ignore.unmatched), and the error is # still reported in the context of the other class - deterministically, with # both an empty and a primed result cache. ../../bin/phpstan clear-result-cache - OUTPUT=$(../bashunit -a exit_code "1" "../../bin/phpstan analyse --error-format=raw -c ignore-class-a-path.neon") - ../bashunit -a contains 'SomeTrait.php (in context of class Bug14932\BMailer):17:Right side of && is always true.' "$OUTPUT" - ../bashunit -a not_contains 'was not matched' "$OUTPUT" - OUTPUT=$(../bashunit -a exit_code "1" "../../bin/phpstan analyse --error-format=raw -c ignore-class-a-path.neon") - ../bashunit -a contains 'SomeTrait.php (in context of class Bug14932\BMailer):17:Right side of && is always true.' "$OUTPUT" + OUTPUT=$(../bashunit assert exit_code "1" "../../bin/phpstan analyse --error-format=raw -c ignore-class-a-path.neon") + ../bashunit assert contains 'SomeTrait.php (in context of class Bug14932\BMailer):17:Right side of && is always true.' "$OUTPUT" + ../bashunit assert not_contains 'was not matched' "$OUTPUT" + OUTPUT=$(../bashunit assert exit_code "1" "../../bin/phpstan analyse --error-format=raw -c ignore-class-a-path.neon") + ../bashunit assert contains 'SomeTrait.php (in context of class Bug14932\BMailer):17:Right side of && is always true.' "$OUTPUT" ../../bin/phpstan clear-result-cache - OUTPUT=$(../bashunit -a exit_code "1" "../../bin/phpstan analyse --error-format=raw -c ignore-class-b-path.neon") - ../bashunit -a contains 'SomeTrait.php (in context of class Bug14932\AMailer):17:Right side of && is always true.' "$OUTPUT" - ../bashunit -a not_contains 'was not matched' "$OUTPUT" + OUTPUT=$(../bashunit assert exit_code "1" "../../bin/phpstan analyse --error-format=raw -c ignore-class-b-path.neon") + ../bashunit assert contains 'SomeTrait.php (in context of class Bug14932\AMailer):17:Right side of && is always true.' "$OUTPUT" + ../bashunit assert not_contains 'was not matched' "$OUTPUT" # Entries covering every using class hide the error completely - this is what # a baseline generated by PHPStan <= 2.1 recorded (one entry per class # context), so such baselines keep working with no unmatched entries. ../../bin/phpstan clear-result-cache - ../bashunit -a exit_code "0" "../../bin/phpstan analyse --error-format=raw -c ignore-both-class-paths.neon" - ../bashunit -a exit_code "0" "../../bin/phpstan analyse --error-format=raw -c ignore-both-class-paths.neon" + ../bashunit assert exit_code "0" "../../bin/phpstan analyse --error-format=raw -c ignore-both-class-paths.neon" + ../bashunit assert exit_code "0" "../../bin/phpstan analyse --error-format=raw -c ignore-both-class-paths.neon" # A directory path covering the using classes (but not the trait file) accounts # per-context too: without count it hides all contexts... ../../bin/phpstan clear-result-cache - ../bashunit -a exit_code "0" "../../bin/phpstan analyse --error-format=raw -c ignore-dir-path.neon" + ../bashunit assert exit_code "0" "../../bin/phpstan analyse --error-format=raw -c ignore-dir-path.neon" # ...and with count: 1 it covers one of the two contexts: the other is reported # in its context, and the count mismatch reports the true occurrence count. ../../bin/phpstan clear-result-cache - OUTPUT=$(../bashunit -a exit_code "1" "../../bin/phpstan analyse --error-format=raw -c ignore-dir-count.neon") - ../bashunit -a contains 'SomeTrait.php (in context of class Bug14932\BMailer):17:Right side of && is always true.' "$OUTPUT" - ../bashunit -a contains 'is expected to occur 1 time, but occurred 2 times' "$OUTPUT" + OUTPUT=$(../bashunit assert exit_code "1" "../../bin/phpstan analyse --error-format=raw -c ignore-dir-count.neon") + ../bashunit assert contains 'SomeTrait.php (in context of class Bug14932\BMailer):17:Right side of && is always true.' "$OUTPUT" + ../bashunit assert contains 'is expected to occur 1 time, but occurred 2 times' "$OUTPUT" # The add-a-using-class flicker from the issue: prime the result cache with # BMailer as the trait's only user (the class-pathed entry covers the only # context), then add AMailer. The AMailer context is reported - on the # partial run and identically on every unchanged run after it. rm src/Mailers/AMailer.php ../../bin/phpstan clear-result-cache - ../bashunit -a exit_code "0" "../../bin/phpstan analyse --error-format=raw -c ignore-class-b-path.neon" + ../bashunit assert exit_code "0" "../../bin/phpstan analyse --error-format=raw -c ignore-class-b-path.neon" cp AMailer.php.dist src/Mailers/AMailer.php - OUTPUT=$(../bashunit -a exit_code "1" "../../bin/phpstan analyse --error-format=raw -c ignore-class-b-path.neon") - ../bashunit -a contains 'SomeTrait.php (in context of class Bug14932\AMailer):17:Right side of && is always true.' "$OUTPUT" - OUTPUT=$(../bashunit -a exit_code "1" "../../bin/phpstan analyse --error-format=raw -c ignore-class-b-path.neon") - ../bashunit -a contains 'SomeTrait.php (in context of class Bug14932\AMailer):17:Right side of && is always true.' "$OUTPUT" + OUTPUT=$(../bashunit assert exit_code "1" "../../bin/phpstan analyse --error-format=raw -c ignore-class-b-path.neon") + ../bashunit assert contains 'SomeTrait.php (in context of class Bug14932\AMailer):17:Right side of && is always true.' "$OUTPUT" + OUTPUT=$(../bashunit assert exit_code "1" "../../bin/phpstan analyse --error-format=raw -c ignore-class-b-path.neon") + ../bashunit assert contains 'SomeTrait.php (in context of class Bug14932\AMailer):17:Right side of && is always true.' "$OUTPUT" # --generate-baseline attributes the fully deduplicated error to the trait # file, and the baseline holds on re-run with an empty and a primed cache. ../../bin/phpstan clear-result-cache ../../bin/phpstan analyse -c generate-only.neon --generate-baseline=baseline.neon - ../bashunit -a contains 'path: src/SomeTrait.php' "$(cat baseline.neon)" - ../bashunit -a not_contains 'AMailer.php' "$(cat baseline.neon)" - ../bashunit -a not_contains 'BMailer.php' "$(cat baseline.neon)" + ../bashunit assert contains 'path: src/SomeTrait.php' "$(cat baseline.neon)" + ../bashunit assert not_contains 'AMailer.php' "$(cat baseline.neon)" + ../bashunit assert not_contains 'BMailer.php' "$(cat baseline.neon)" ../../bin/phpstan clear-result-cache - ../bashunit -a exit_code "0" "../../bin/phpstan analyse --error-format=raw -c with-baseline.neon" - ../bashunit -a exit_code "0" "../../bin/phpstan analyse --error-format=raw -c with-baseline.neon" + ../bashunit assert exit_code "0" "../../bin/phpstan analyse --error-format=raw -c with-baseline.neon" + ../bashunit assert exit_code "0" "../../bin/phpstan analyse --error-format=raw -c with-baseline.neon" # Generating a baseline on top of a one-class ignore records the surviving # context under its class path, and the combination holds on re-run. ../../bin/phpstan clear-result-cache ../../bin/phpstan analyse -c ignore-class-a-path.neon --generate-baseline=partial-baseline.neon - ../bashunit -a contains 'path: src/Mailers/BMailer.php' "$(cat partial-baseline.neon)" - ../bashunit -a not_contains 'SomeTrait.php' "$(cat partial-baseline.neon)" + ../bashunit assert contains 'path: src/Mailers/BMailer.php' "$(cat partial-baseline.neon)" + ../bashunit assert not_contains 'SomeTrait.php' "$(cat partial-baseline.neon)" ../../bin/phpstan clear-result-cache - ../bashunit -a exit_code "0" "../../bin/phpstan analyse --error-format=raw -c with-partial-baseline.neon" - ../bashunit -a exit_code "0" "../../bin/phpstan analyse --error-format=raw -c with-partial-baseline.neon" + ../bashunit assert exit_code "0" "../../bin/phpstan analyse --error-format=raw -c with-partial-baseline.neon" + ../bashunit assert exit_code "0" "../../bin/phpstan analyse --error-format=raw -c with-partial-baseline.neon" # A full generated baseline (trait path for the deduplicated error, class # paths for the per-context errors) holds on re-run as well. ../../bin/phpstan clear-result-cache ../../bin/phpstan --generate-baseline=full-baseline.neon - ../bashunit -a contains 'path: src/Mailers/AMailer.php' "$(cat full-baseline.neon)" - ../bashunit -a contains 'path: src/Mailers/BMailer.php' "$(cat full-baseline.neon)" - ../bashunit -a contains 'path: src/SomeTrait.php' "$(cat full-baseline.neon)" + ../bashunit assert contains 'path: src/Mailers/AMailer.php' "$(cat full-baseline.neon)" + ../bashunit assert contains 'path: src/Mailers/BMailer.php' "$(cat full-baseline.neon)" + ../bashunit assert contains 'path: src/SomeTrait.php' "$(cat full-baseline.neon)" ../../bin/phpstan clear-result-cache - ../bashunit -a exit_code "0" "../../bin/phpstan analyse --error-format=raw -c with-full-baseline.neon" - ../bashunit -a exit_code "0" "../../bin/phpstan analyse --error-format=raw -c with-full-baseline.neon" + ../bashunit assert exit_code "0" "../../bin/phpstan analyse --error-format=raw -c with-full-baseline.neon" + ../bashunit assert exit_code "0" "../../bin/phpstan analyse --error-format=raw -c with-full-baseline.neon" - script: | cd e2e/result-cache-meta-extension composer install ../../bin/phpstan -vvv ../../bin/phpstan -vvv --fail-without-result-cache echo 'modified-hash' > hash.txt - OUTPUT=$(../bashunit -a exit_code "2" "../../bin/phpstan -vvv --fail-without-result-cache") + OUTPUT=$(../bashunit assert exit_code "2" "../../bin/phpstan -vvv --fail-without-result-cache") echo "$OUTPUT" - ../bashunit -a matches "Note: Using configuration file .+phpstan.neon." "$OUTPUT" - ../bashunit -a contains 'Result cache not used because the metadata do not match: metaExtensions' "$OUTPUT" + ../bashunit assert matches "Note: Using configuration file .+phpstan.neon." "$OUTPUT" + ../bashunit assert contains 'Result cache not used because the metadata do not match: metaExtensions' "$OUTPUT" - script: | cd e2e/result-cache-meta-extension-throw composer install @@ -1111,10 +1111,10 @@ jobs: # An exception thrown from ResultCacheMetaExtension::getHash() during result cache # restore must fail the run with a non-zero exit code - even when a bootstrap file # installs a global exception handler that would otherwise swallow it into exit 0. - OUTPUT=$(../bashunit -a exit_code "1" "../../bin/phpstan --error-format=raw") + OUTPUT=$(../bashunit assert exit_code "1" "../../bin/phpstan --error-format=raw") echo "$OUTPUT" - ../bashunit -a contains 'boom from getHash' "$OUTPUT" - ../bashunit -a not_contains 'Swallowed by global exception handler' "$OUTPUT" + ../bashunit assert contains 'boom from getHash' "$OUTPUT" + ../bashunit assert not_contains 'Swallowed by global exception handler' "$OUTPUT" - script: | cd e2e/result-cache-restore-without-reflection composer install @@ -1124,22 +1124,22 @@ jobs: cd e2e/result-cache-constants ../../bin/phpstan analyse patch -b src/Constants.php < changeConstantValue.patch - OUTPUT=$(../bashunit -a exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") + OUTPUT=$(../bashunit assert exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") echo "$OUTPUT" - ../bashunit -a contains 'ClassUsingConstant.php:13:Method ResultCacheE2EConstants\ClassUsingConstant::getMode() should return int<1, 3> but returns 5. [identifier=return.type]' "$OUTPUT" + ../bashunit assert contains 'ClassUsingConstant.php:13:Method ResultCacheE2EConstants\ClassUsingConstant::getMode() should return int<1, 3> but returns 5. [identifier=return.type]' "$OUTPUT" mv src/Constants.php.orig src/Constants.php ../../bin/phpstan analyse patch -b src/Constants.php < renameConstant.patch - OUTPUT=$(../bashunit -a exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") + OUTPUT=$(../bashunit assert exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") echo "$OUTPUT" - ../bashunit -a contains 'ClassUsingConstant.php:13:Constant SOME_MODE not found. [identifier=constant.notFound]' "$OUTPUT" + ../bashunit assert contains 'ClassUsingConstant.php:13:Constant SOME_MODE not found. [identifier=constant.notFound]' "$OUTPUT" - script: | cd e2e/result-cache-define ../../bin/phpstan analyse patch -b src/define.php < changeDefineValue.patch - OUTPUT=$(../bashunit -a exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") + OUTPUT=$(../bashunit assert exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") echo "$OUTPUT" - ../bashunit -a contains 'ClassUsingDefine.php:13:Method ResultCacheE2EDefine\ClassUsingDefine::getMode() should return int<1, 3> but returns 5. [identifier=return.type]' "$OUTPUT" + ../bashunit assert contains 'ClassUsingDefine.php:13:Method ResultCacheE2EDefine\ClassUsingDefine::getMode() should return int<1, 3> but returns 5. [identifier=return.type]' "$OUTPUT" - script: | cd e2e/result-cache-composer-lock composer install @@ -1149,19 +1149,19 @@ jobs: # when composer.lock is not committed. The result cache must be kept, not discarded. jq '.["content-hash"]="0000000000000000000000000000000000000000"' composer.lock > composer.lock.new mv composer.lock.new composer.lock - OUTPUT=$(../bashunit -a exit_code "0" "../../bin/phpstan analyse -vv") + OUTPUT=$(../bashunit assert exit_code "0" "../../bin/phpstan analyse -vv") echo "$OUTPUT" - ../bashunit -a contains 'Composer metadata changed but no package versions changed; keeping the result cache.' "$OUTPUT" - ../bashunit -a contains 'Result cache restored. 0 files will be reanalysed.' "$OUTPUT" + ../bashunit assert contains 'Composer metadata changed but no package versions changed; keeping the result cache.' "$OUTPUT" + ../bashunit assert contains 'Result cache restored. 0 files will be reanalysed.' "$OUTPUT" # Change the content hash again AND edit a single source file: the cache is still kept # (no package changed), and only the one changed file is reanalysed. printf '\n' >> src/Foo.php jq '.["content-hash"]="1111111111111111111111111111111111111111"' composer.lock > composer.lock.new mv composer.lock.new composer.lock - OUTPUT=$(../bashunit -a exit_code "0" "../../bin/phpstan analyse -vv") + OUTPUT=$(../bashunit assert exit_code "0" "../../bin/phpstan analyse -vv") echo "$OUTPUT" - ../bashunit -a contains 'Composer metadata changed but no package versions changed; keeping the result cache.' "$OUTPUT" - ../bashunit -a contains 'Result cache restored. 1 file will be reanalysed.' "$OUTPUT" + ../bashunit assert contains 'Composer metadata changed but no package versions changed; keeping the result cache.' "$OUTPUT" + ../bashunit assert contains 'Result cache restored. 1 file will be reanalysed.' "$OUTPUT" - script: | cd e2e/result-cache-phar-bootstrap # A bootstrapFile living inside a phar is hashed into executedFilesHashes under its @@ -1177,9 +1177,9 @@ jobs: if grep -oE "'[^']*boot\.phar/boot\.php'" tmp/resultCache.php | grep -v 'phar://'; then echo 'bootstrap path stored without its phar:// scheme'; exit 1 fi - OUTPUT=$(../bashunit -a exit_code "0" "../../bin/phpstan analyse -vv") + OUTPUT=$(../bashunit assert exit_code "0" "../../bin/phpstan analyse -vv") echo "$OUTPUT" - ../bashunit -a contains 'Result cache restored. 0 files will be reanalysed.' "$OUTPUT" + ../bashunit assert contains 'Result cache restored. 0 files will be reanalysed.' "$OUTPUT" - script: | cd e2e/result-cache-relative-path # Cold run: paths are stored relative to the phpstan install (the anchor), so the cache @@ -1194,9 +1194,9 @@ jobs: exit 1 fi # Warm run: the relative cache re-absolutizes against the current anchor and is fully reused. - OUTPUT=$(../bashunit -a exit_code "0" "../../bin/phpstan analyse -vv") + OUTPUT=$(../bashunit assert exit_code "0" "../../bin/phpstan analyse -vv") echo "$OUTPUT" - ../bashunit -a contains 'Result cache restored. 0 files will be reanalysed.' "$OUTPUT" + ../bashunit assert contains 'Result cache restored. 0 files will be reanalysed.' "$OUTPUT" - script: | cd e2e/result-cache-relative-path # An optional excludePath must reach the cache the way a required one does. It used to @@ -1208,9 +1208,9 @@ jobs: grep -o "$(cd ../.. && pwd)/[^'\"]*" tmp-optional-path/resultCache.php | sort -u | head -20 exit 1 fi - OUTPUT=$(../bashunit -a exit_code "0" "../../bin/phpstan analyse -c phpstan-optional-path.neon -vv") + OUTPUT=$(../bashunit assert exit_code "0" "../../bin/phpstan analyse -c phpstan-optional-path.neon -vv") echo "$OUTPUT" - ../bashunit -a contains 'Result cache restored. 0 files will be reanalysed.' "$OUTPUT" + ../bashunit assert contains 'Result cache restored. 0 files will be reanalysed.' "$OUTPUT" - script: | cd e2e/result-cache-relative-path @@ -1238,9 +1238,9 @@ jobs: # running phpstan in a different worktree in between did not disturb it. cd "$MAIN" git -C ../.. worktree remove --force "$WORKTREE" - OUTPUT=$(../bashunit -a exit_code "0" "../../bin/phpstan analyse -vv") + OUTPUT=$(../bashunit assert exit_code "0" "../../bin/phpstan analyse -vv") echo "$OUTPUT" - ../bashunit -a contains 'Result cache restored. 0 files will be reanalysed.' "$OUTPUT" + ../bashunit assert contains 'Result cache restored. 0 files will be reanalysed.' "$OUTPUT" - script: | cd e2e/result-cache-package-update composer install @@ -1251,10 +1251,10 @@ jobs: # test/logger), not for the whole project. patch -p1 < updatePackage.patch composer update test/logger --no-cache - OUTPUT=$(../bashunit -a exit_code "0" "../../bin/phpstan analyse -vv") + OUTPUT=$(../bashunit assert exit_code "0" "../../bin/phpstan analyse -vv") echo "$OUTPUT" - ../bashunit -a contains 'Composer packages changed (test/logger); re-analysing the files depending on them and the files with errors.' "$OUTPUT" - ../bashunit -a contains 'Result cache restored. 1 file will be reanalysed.' "$OUTPUT" + ../bashunit assert contains 'Composer packages changed (test/logger); re-analysing the files depending on them and the files with errors.' "$OUTPUT" + ../bashunit assert contains 'Result cache restored. 1 file will be reanalysed.' "$OUTPUT" - script: | cd e2e/result-cache-path-repository composer install @@ -1262,56 +1262,56 @@ jobs: # Updating an installed package re-analyses only the files depending on it. patch -p0 < updatePsrLog.patch composer update psr/log --no-cache - OUTPUT=$(../bashunit -a exit_code "0" "../../bin/phpstan analyse -vv") + OUTPUT=$(../bashunit assert exit_code "0" "../../bin/phpstan analyse -vv") echo "$OUTPUT" - ../bashunit -a contains 'Composer packages changed (psr/log); re-analysing the files depending on them and the files with errors.' "$OUTPUT" - ../bashunit -a contains 'Result cache restored. 1 file will be reanalysed.' "$OUTPUT" + ../bashunit assert contains 'Composer packages changed (psr/log); re-analysing the files depending on them and the files with errors.' "$OUTPUT" + ../bashunit assert contains 'Result cache restored. 1 file will be reanalysed.' "$OUTPUT" # Editing a file of an installed package is not a valid thing to do - the next Composer # command overwrites it - so PHPStan does not track it and keeps the cached results, even # though this edit takes away a method the analysed code calls. php -r '$f = "vendor/psr/log/src/LoggerInterface.php"; file_put_contents($f, str_replace("public function info(", "public function renamedInfo(", file_get_contents($f)));' - OUTPUT=$(../bashunit -a exit_code "0" "../../bin/phpstan analyse -vv") + OUTPUT=$(../bashunit assert exit_code "0" "../../bin/phpstan analyse -vv") echo "$OUTPUT" - ../bashunit -a contains 'Result cache restored. 0 files will be reanalysed.' "$OUTPUT" - ../bashunit -a not_contains 'Call to an undefined method' "$OUTPUT" + ../bashunit assert contains 'Result cache restored. 0 files will be reanalysed.' "$OUTPUT" + ../bashunit assert not_contains 'Call to an undefined method' "$OUTPUT" # A package from a path repository is the opposite case: it is the project's own code, # edited in place without any Composer command noticing, so its files are tracked like the # project's other non-analysed files. Symlinked, the installed package is the source # directory - an edit inside a method body changes nothing the files using it can see. patch -b -p0 < symlinked-body.patch - OUTPUT=$(../bashunit -a exit_code "0" "../../bin/phpstan analyse -vv") + OUTPUT=$(../bashunit assert exit_code "0" "../../bin/phpstan analyse -vv") echo "$OUTPUT" - ../bashunit -a contains 'Result cache restored. 0 files will be reanalysed.' "$OUTPUT" + ../bashunit assert contains 'Result cache restored. 0 files will be reanalysed.' "$OUTPUT" # A changed return type does reach them. mv symlinked-lib/src/SymlinkedDep.php.orig symlinked-lib/src/SymlinkedDep.php patch -b -p0 < symlinked-signature.patch - OUTPUT=$(../bashunit -a exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") + OUTPUT=$(../bashunit assert exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") echo "$OUTPUT" - ../bashunit -a contains 'Result cache restored. 1 file will be reanalysed.' "$OUTPUT" - ../bashunit -a contains 'UsesSymlinked.php:16:Method ResultCacheE2EPathRepository\UsesSymlinked::doUsesSymlinked() should return int but returns string.' "$OUTPUT" + ../bashunit assert contains 'Result cache restored. 1 file will be reanalysed.' "$OUTPUT" + ../bashunit assert contains 'UsesSymlinked.php:16:Method ResultCacheE2EPathRepository\UsesSymlinked::doUsesSymlinked() should return int but returns string.' "$OUTPUT" # Undoing it clears the error again. mv symlinked-lib/src/SymlinkedDep.php.orig symlinked-lib/src/SymlinkedDep.php - OUTPUT=$(../bashunit -a exit_code "0" "../../bin/phpstan analyse -vv") + OUTPUT=$(../bashunit assert exit_code "0" "../../bin/phpstan analyse -vv") echo "$OUTPUT" - ../bashunit -a contains 'Result cache restored. 1 file will be reanalysed.' "$OUTPUT" + ../bashunit assert contains 'Result cache restored. 1 file will be reanalysed.' "$OUTPUT" # Copied instead of symlinked, the analysis reads the installed copy, so editing the # directory Composer copied from is not something PHPStan can see at all. patch -b -p0 < copied-source-signature.patch - OUTPUT=$(../bashunit -a exit_code "0" "../../bin/phpstan analyse -vv") + OUTPUT=$(../bashunit assert exit_code "0" "../../bin/phpstan analyse -vv") echo "$OUTPUT" - ../bashunit -a contains 'Result cache restored. 0 files will be reanalysed.' "$OUTPUT" + ../bashunit assert contains 'Result cache restored. 0 files will be reanalysed.' "$OUTPUT" mv copied-lib/src/CopiedDep.php.orig copied-lib/src/CopiedDep.php # The installed copy is tracked the same way the symlinked package is. patch -b -p0 < copied-body.patch - OUTPUT=$(../bashunit -a exit_code "0" "../../bin/phpstan analyse -vv") + OUTPUT=$(../bashunit assert exit_code "0" "../../bin/phpstan analyse -vv") echo "$OUTPUT" - ../bashunit -a contains 'Result cache restored. 0 files will be reanalysed.' "$OUTPUT" + ../bashunit assert contains 'Result cache restored. 0 files will be reanalysed.' "$OUTPUT" mv vendor/test/copied-lib/src/CopiedDep.php.orig vendor/test/copied-lib/src/CopiedDep.php patch -b -p0 < copied-signature.patch - OUTPUT=$(../bashunit -a exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") + OUTPUT=$(../bashunit assert exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") echo "$OUTPUT" - ../bashunit -a contains 'Result cache restored. 1 file will be reanalysed.' "$OUTPUT" - ../bashunit -a contains 'UsesCopied.php:16:Method ResultCacheE2EPathRepository\UsesCopied::doUsesCopied() should return int but returns string.' "$OUTPUT" + ../bashunit assert contains 'Result cache restored. 1 file will be reanalysed.' "$OUTPUT" + ../bashunit assert contains 'UsesCopied.php:16:Method ResultCacheE2EPathRepository\UsesCopied::doUsesCopied() should return int but returns string.' "$OUTPUT" - script: | cd e2e/result-cache-composer-json composer install @@ -1321,59 +1321,59 @@ jobs: # metadata - composerLocks and composerInstalled cover composer.lock and installed.php, and # neither of those moves when only composer.json changes. patch -p0 < platform.patch - OUTPUT=$(../bashunit -a exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") + OUTPUT=$(../bashunit assert exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") echo "$OUTPUT" - ../bashunit -a contains 'Foo.php:10:Function str_contains not found.' "$OUTPUT" + ../bashunit assert contains 'Foo.php:10:Function str_contains not found.' "$OUTPUT" - script: | cd e2e/result-cache-empty-file-gains-symbol # src/script.php declares no symbol, so the cache holds no exported nodes entry for it at # all, and src/user.php uses a class that does not exist yet. - OUTPUT=$(../bashunit -a exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") + OUTPUT=$(../bashunit assert exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") echo "$OUTPUT" - ../bashunit -a contains 'user.php:7:Instantiated class ResultCacheE2EEmptyFileGainsSymbol\Thing not found.' "$OUTPUT" + ../bashunit assert contains 'user.php:7:Instantiated class ResultCacheE2EEmptyFileGainsSymbol\Thing not found.' "$OUTPUT" # That file now declares a class. A root symbol appeared, so the files with errors have to # be re-analysed, the same way a brand new file makes them re-analysed - the missing # exported nodes entry must not be read as "nothing changed". mv gains/script.php src/script.php - OUTPUT=$(../bashunit -a exit_code "0" "../../bin/phpstan analyse -vv --error-format raw") + OUTPUT=$(../bashunit assert exit_code "0" "../../bin/phpstan analyse -vv --error-format raw") echo "$OUTPUT" - ../bashunit -a not_contains 'Instantiated class ResultCacheE2EEmptyFileGainsSymbol\Thing not found.' "$OUTPUT" + ../bashunit assert not_contains 'Instantiated class ResultCacheE2EEmptyFileGainsSymbol\Thing not found.' "$OUTPUT" - script: | cd e2e/result-cache-parse-error # src/Thing.php has a parse error, and src/User.php uses the class it would declare. The parse # error carries an exception, so src/Thing.php is left out of the result cache, but the rest # of it is saved. - OUTPUT=$(../bashunit -a exit_code "1" "../../bin/phpstan analyse -vvv --error-format raw") + OUTPUT=$(../bashunit assert exit_code "1" "../../bin/phpstan analyse -vvv --error-format raw") echo "$OUTPUT" - ../bashunit -a contains 'Thing.php:12:Syntax error, unexpected EOF on line 12' "$OUTPUT" - ../bashunit -a contains 'Result cache is saved.' "$OUTPUT" + ../bashunit assert contains 'Thing.php:12:Syntax error, unexpected EOF on line 12' "$OUTPUT" + ../bashunit assert contains 'Result cache is saved.' "$OUTPUT" test -f tmp/resultCache.php # Only src/Thing.php is analysed again, and the result cache is not rewritten. - OUTPUT=$(../bashunit -a exit_code "1" "../../bin/phpstan analyse -vvv --error-format raw") + OUTPUT=$(../bashunit assert exit_code "1" "../../bin/phpstan analyse -vvv --error-format raw") echo "$OUTPUT" - ../bashunit -a contains 'Thing.php:12:Syntax error, unexpected EOF on line 12' "$OUTPUT" - ../bashunit -a contains 'Result cache restored. 1 file will be reanalysed.' "$OUTPUT" - ../bashunit -a contains 'Result cache was not rewritten because it is unchanged.' "$OUTPUT" + ../bashunit assert contains 'Thing.php:12:Syntax error, unexpected EOF on line 12' "$OUTPUT" + ../bashunit assert contains 'Result cache restored. 1 file will be reanalysed.' "$OUTPUT" + ../bashunit assert contains 'Result cache was not rewritten because it is unchanged.' "$OUTPUT" # Fixing the parse error declares Thing, so the error that src/User.php had in the result # cache goes away. cp fixed/Thing.php src/Thing.php - OUTPUT=$(../bashunit -a exit_code "0" "../../bin/phpstan analyse -vvv --error-format raw") + OUTPUT=$(../bashunit assert exit_code "0" "../../bin/phpstan analyse -vvv --error-format raw") echo "$OUTPUT" - ../bashunit -a not_contains 'not found' "$OUTPUT" + ../bashunit assert not_contains 'not found' "$OUTPUT" # A reflection error, here a class that extends itself, still keeps the result cache from # being saved. cp loop/Loop.php src/Loop.php - OUTPUT=$(../bashunit -a exit_code "1" "../../bin/phpstan analyse -vvv --error-format raw") + OUTPUT=$(../bashunit assert exit_code "1" "../../bin/phpstan analyse -vvv --error-format raw") echo "$OUTPUT" - ../bashunit -a contains 'Result cache was not saved because of non-ignorable exception: Reflection error: Circular reference' "$OUTPUT" + ../bashunit assert contains 'Result cache was not saved because of non-ignorable exception: Reflection error: Circular reference' "$OUTPUT" - script: | cd e2e/result-cache-internal-error composer dump-autoload # A rule that throws is an internal error. The result cache is not saved. - OUTPUT=$(../bashunit -a exit_code "1" "../../bin/phpstan analyse -vvv --error-format raw") + OUTPUT=$(../bashunit assert exit_code "1" "../../bin/phpstan analyse -vvv --error-format raw") echo "$OUTPUT" - ../bashunit -a contains 'Internal error: The rule crashed.' "$OUTPUT" - ../bashunit -a contains 'Result cache was not saved' "$OUTPUT" + ../bashunit assert contains 'Internal error: The rule crashed.' "$OUTPUT" + ../bashunit assert contains 'Result cache was not saved' "$OUTPUT" test ! -f tmp/resultCache.php - script: | cd e2e/result-cache-string-class @@ -1382,9 +1382,9 @@ jobs: # system rather than through a name node, and the dependency graph records no edge from # Thing.php to Factory.php. Deleting the class still has to be noticed. rm src/Thing.php - OUTPUT=$(../bashunit -a exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") + OUTPUT=$(../bashunit assert exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") echo "$OUTPUT" - ../bashunit -a contains 'Factory.php:12:Instantiated class ResultCacheE2EStringClass\Thing not found.' "$OUTPUT" + ../bashunit assert contains 'Factory.php:12:Instantiated class ResultCacheE2EStringClass\Thing not found.' "$OUTPUT" - script: | cd e2e/result-cache-import-type-deleted ../../bin/phpstan analyse @@ -1392,12 +1392,12 @@ jobs: # unresolvable, and a file whose PHPDoc cannot be resolved records no dependencies at all - # the edge to User.php is dropped. The next edit of Base.php must still reach User.php. rm src/Aliases.php - OUTPUT=$(../bashunit -a exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") + OUTPUT=$(../bashunit assert exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") echo "$OUTPUT" patch -b -p0 < signature.patch - OUTPUT=$(../bashunit -a exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") + OUTPUT=$(../bashunit assert exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") echo "$OUTPUT" - ../bashunit -a contains 'User.php:10:Method ResultCacheE2EImportType\User::doUser() should return int but returns string.' "$OUTPUT" + ../bashunit assert contains 'User.php:10:Method ResultCacheE2EImportType\User::doUser() should return int but returns string.' "$OUTPUT" - script: | cd e2e/result-cache-require-deleted ../../bin/phpstan analyse @@ -1405,22 +1405,22 @@ jobs: # of it exists anywhere in the cache. Deleting it has to be noticed all the same: the rule # that checks the path reports an error the moment it is gone. rm config/app.php - OUTPUT=$(../bashunit -a exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") + OUTPUT=$(../bashunit assert exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") echo "$OUTPUT" - ../bashunit -a contains 'Foo.php:10:Path in require() "config/app.php" is not a file or it does not exist.' "$OUTPUT" + ../bashunit assert contains 'Foo.php:10:Path in require() "config/app.php" is not a file or it does not exist.' "$OUTPUT" # And putting it back has to clear the error again. printf ' config/app.php - OUTPUT=$(../bashunit -a exit_code "0" "../../bin/phpstan analyse -vv --error-format raw") + OUTPUT=$(../bashunit assert exit_code "0" "../../bin/phpstan analyse -vv --error-format raw") echo "$OUTPUT" - ../bashunit -a not_contains 'is not a file or it does not exist' "$OUTPUT" + ../bashunit assert not_contains 'is not a file or it does not exist' "$OUTPUT" - script: | cd e2e/result-cache-vendor-class-appears composer install # The class does not exist yet, and an error about a class that does not exist records no # dependency on anything - there is no file to point at. - OUTPUT=$(../bashunit -a exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") + OUTPUT=$(../bashunit assert exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") echo "$OUTPUT" - ../bashunit -a contains 'Foo.php:10:Parameter $logger of method ResultCacheE2EVendorClassAppears\Foo::doFoo() has invalid type Psr\Log\PluginProvidedLogger.' "$OUTPUT" + ../bashunit assert contains 'Foo.php:10:Parameter $logger of method ResultCacheE2EVendorClassAppears\Foo::doFoo() has invalid type Psr\Log\PluginProvidedLogger.' "$OUTPUT" # Composer updates the package, and a plugin writes the class into it on the way - which is # what phpstan/phpstan#15164 is about. Nothing the cache knows about points at that file, # so the files with errors have to be re-analysed on a package change; otherwise the error @@ -1428,95 +1428,95 @@ jobs: patch -p0 < updatePsrLog.patch composer update psr/log --no-cache cp plugin-writes/PluginProvidedLogger.php vendor/psr/log/src/PluginProvidedLogger.php - OUTPUT=$(../bashunit -a exit_code "0" "../../bin/phpstan analyse -vv --error-format raw") + OUTPUT=$(../bashunit assert exit_code "0" "../../bin/phpstan analyse -vv --error-format raw") echo "$OUTPUT" - ../bashunit -a contains 'Composer packages changed (psr/log); re-analysing the files depending on them and the files with errors.' "$OUTPUT" - ../bashunit -a not_contains 'has invalid type Psr\Log\PluginProvidedLogger' "$OUTPUT" + ../bashunit assert contains 'Composer packages changed (psr/log); re-analysing the files depending on them and the files with errors.' "$OUTPUT" + ../bashunit assert not_contains 'has invalid type Psr\Log\PluginProvidedLogger' "$OUTPUT" - script: | cd e2e/ext-ds-version cp composer-json/v1-platform.json composer.json composer install --ignore-platform-reqs - OUTPUT=$(../bashunit -a exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") + OUTPUT=$(../bashunit assert exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") echo "$OUTPUT" - ../bashunit -a contains 'Foo.php:12:Instantiated class Ds\Seq not found.' "$OUTPUT" + ../bashunit assert contains 'Foo.php:12:Instantiated class Ds\Seq not found.' "$OUTPUT" # Only composer.json changes - composer.lock and installed.php stay as they are - and it now # selects the ext-ds 2 stubs. src/Bar.php has no error with ext-ds 1, so only its dependency on # ext-ds re-analyses it; src/Baz.php does not use ext-ds and stays cached. cp composer-json/v2-platform.json composer.json - OUTPUT=$(../bashunit -a exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") + OUTPUT=$(../bashunit assert exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") echo "$OUTPUT" - ../bashunit -a contains 'PHP extension versions changed (ext-ds); re-analysing the files depending on them and the files with errors.' "$OUTPUT" - ../bashunit -a contains 'Result cache restored. 2 files will be reanalysed.' "$OUTPUT" - ../bashunit -a contains 'Foo.php:11:Instantiated class Ds\Vector not found.' "$OUTPUT" - ../bashunit -a contains 'Bar.php:15:Call to an undefined method Ds\Pair