@@ -454,6 +454,8 @@ jobs:
454454 ../bashunit -a contains 'UsesHolder.php:9:Function ResultCacheE2EValueDependency\usesHolder() should return int but returns string.' "$OUTPUT"
455455 ../bashunit -a contains 'UsesMayThrow.php:9:Dead catch - RuntimeException is never thrown in the try block.' "$OUTPUT"
456456 ../bashunit -a contains 'UsesRegion.php:7:Region eu is used.' "$OUTPUT"
457+ ../bashunit -a contains 'UsesView.php:7:View dashboard does not exist.' "$OUTPUT"
458+ ../bashunit -a contains 'UsesMake.php:7:Call to an undefined method object::run().' "$OUTPUT"
457459 ../bashunit -a not_contains 'UsesMailer.php' "$OUTPUT"
458460 # The extensions read container.json, which the result cache knows nothing about. A rule and a
459461 # dynamic return type extension both declare the service they ask about - it is recorded once.
@@ -526,6 +528,73 @@ jobs:
526528 echo "$OUTPUT"
527529 ../bashunit -a contains 'UsesRegion.php:7:Region us is used.' "$OUTPUT"
528530 ../bashunit -a not_contains 'Region eu is used.' "$OUTPUT"
531+ # So does a parameter closure this extension: $this in the closure follows the parameter.
532+ 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));'
533+ INFO=$(../../bin/phpstan result-cache-info --json)
534+ echo "$INFO"
535+ ../bashunit -a equals '1' "$(echo "$INFO" | jq --raw-output '.filesToAnalyseCount')"
536+ OUTPUT=$(../bashunit -a exit_code "1" "../../bin/phpstan analyse -vv --error-format raw")
537+ echo "$OUTPUT"
538+ ../bashunit -a contains 'UsesWithThis.php:8:Call to an undefined method ResultCacheE2EValueDependency\Logger::send().' "$OUTPUT"
539+ # So does a type-specifying extension: the narrowed type follows the parameter.
540+ 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));'
541+ INFO=$(../../bin/phpstan result-cache-info --json)
542+ echo "$INFO"
543+ ../bashunit -a equals '1' "$(echo "$INFO" | jq --raw-output '.filesToAnalyseCount')"
544+ OUTPUT=$(../bashunit -a exit_code "1" "../../bin/phpstan analyse -vv --error-format raw")
545+ echo "$OUTPUT"
546+ ../bashunit -a contains 'UsesIsAllowed.php:8:Call to an undefined method ResultCacheE2EValueDependency\Logger::send().' "$OUTPUT"
547+ # A rule tracking a directory: a file the pattern doesn't match changes nothing...
548+ echo 'notes' > views/notes.txt
549+ INFO=$(../../bin/phpstan result-cache-info --json)
550+ echo "$INFO"
551+ ../bashunit -a equals '0' "$(echo "$INFO" | jq --raw-output '.filesToAnalyseCount')"
552+ # ...a matching file appearing re-analyses the file that looked for it.
553+ echo '<p>dashboard</p>' > views/dashboard.html
554+ INFO=$(../../bin/phpstan result-cache-info --json)
555+ echo "$INFO"
556+ ../bashunit -a equals '1' "$(echo "$INFO" | jq --raw-output '.filesToAnalyseCount')"
557+ OUTPUT=$(../bashunit -a exit_code "1" "../../bin/phpstan analyse -vv --error-format raw")
558+ echo "$OUTPUT"
559+ ../bashunit -a not_contains 'View dashboard does not exist.' "$OUTPUT"
560+ # ...and so does a matching file whose contents change.
561+ echo '<p>dashboard, changed</p>' > views/dashboard.html
562+ INFO=$(../../bin/phpstan result-cache-info --json)
563+ echo "$INFO"
564+ ../bashunit -a equals '1' "$(echo "$INFO" | jq --raw-output '.filesToAnalyseCount')"
565+ ../bashunit -a exit_code "1" "../../bin/phpstan analyse -vv --error-format raw"
566+ # A dynamic return type extension tracking a class named in a string: the class appearing - outside
567+ # the analysed paths, so no fallback for new files kicks in - re-analyses the file naming it...
568+ printf '<?php declare(strict_types = 1);\n\nnamespace ResultCacheE2EValueDependency\\Lib;\n\nclass Gadget extends Base\n{\n}\n' > lib/Gadget.php
569+ INFO=$(../../bin/phpstan result-cache-info --json)
570+ echo "$INFO"
571+ ../bashunit -a equals '1' "$(echo "$INFO" | jq --raw-output '.filesToAnalyseCount')"
572+ OUTPUT=$(../bashunit -a exit_code "1" "../../bin/phpstan analyse -vv --error-format raw")
573+ echo "$OUTPUT"
574+ ../bashunit -a not_contains 'UsesMake.php' "$OUTPUT"
575+ # ...a method body edited in its parent class does not...
576+ sed -i.bak 's/return 1;/return 2;/' lib/Base.php && rm lib/Base.php.bak
577+ INFO=$(../../bin/phpstan result-cache-info --json)
578+ echo "$INFO"
579+ ../bashunit -a equals '0' "$(echo "$INFO" | jq --raw-output '.filesToAnalyseCount')"
580+ # ...and a signature changed there does.
581+ printf '<?php declare(strict_types = 1);\n\nnamespace ResultCacheE2EValueDependency\\Lib;\n\nclass Base\n{\n\n\tpublic function run(): string\n\t{\n\t\treturn \x27x\x27;\n\t}\n\n}\n' > lib/Base.php
582+ INFO=$(../../bin/phpstan result-cache-info --json)
583+ echo "$INFO"
584+ ../bashunit -a equals '1' "$(echo "$INFO" | jq --raw-output '.filesToAnalyseCount')"
585+ OUTPUT=$(../bashunit -a exit_code "1" "../../bin/phpstan analyse -vv --error-format raw")
586+ echo "$OUTPUT"
587+ ../bashunit -a contains 'UsesMake.php:7:Function ResultCacheE2EValueDependency\usesMake() should return int but returns string.' "$OUTPUT"
588+ # A class reflection extension tracking on the class: every file using the class is analysed again,
589+ # also one that got the magic method from the reflection cache without asking the extension.
590+ 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));'
591+ INFO=$(../../bin/phpstan result-cache-info --json)
592+ echo "$INFO"
593+ ../bashunit -a equals '3' "$(echo "$INFO" | jq --raw-output '.filesToAnalyseCount')"
594+ OUTPUT=$(../bashunit -a exit_code "1" "../../bin/phpstan analyse -vv --error-format raw")
595+ echo "$OUTPUT"
596+ ../bashunit -a contains 'UsesMagic.php:7:Function ResultCacheE2EValueDependency\usesMagic() should return string but returns int.' "$OUTPUT"
597+ ../bashunit -a contains 'UsesMagicToo.php:7:Function ResultCacheE2EValueDependency\usesMagicToo() should return string but returns int.' "$OUTPUT"
529598 - script : |
530599 cd e2e/result-cache-file-dependency
531600 composer install
0 commit comments