Skip to content

Commit

Permalink
Warn about possibly stale result cache with custom extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejmirtes committed Mar 19, 2024
1 parent 4e2778b commit 9338fdf
Show file tree
Hide file tree
Showing 10 changed files with 344 additions and 2 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/e2e-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,13 @@ jobs:
export PHPSTAN_SCOPE_CLASS=MyTestScope
ACTUAL=$(../../bin/phpstan dump-parameters -c phpstan.neon --json -l 9 | jq --raw-output '.scopeClass')
[[ "$ACTUAL" == "MyTestScope" ]];
- script: |
cd e2e/result-cache-8
composer install
../../bin/phpstan
OUTPUT=$(../../bin/phpstan 2>&1)
grep 'Warning: Result cache might not behave correctly' <<< "$OUTPUT"
grep 'ResultCache8E2E\\CustomRule' <<< "$OUTPUT"
steps:
- name: "Checkout"
Expand Down
1 change: 1 addition & 0 deletions e2e/result-cache-8/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/vendor
24 changes: 24 additions & 0 deletions e2e/result-cache-8/build/CustomRule.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

namespace ResultCache8E2E;

use PhpParser\Node;
use PHPStan\Analyser\Scope;
use PHPStan\Rules\Rule;

/**
* @implements Rule<Node>
*/
class CustomRule implements Rule
{
public function getNodeType(): string
{
return Node::class;
}

public function processNode(Node $node, Scope $scope): array
{
return [];
}

}
24 changes: 24 additions & 0 deletions e2e/result-cache-8/build/CustomRule2.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

namespace ResultCache8E2E;

use PhpParser\Node;
use PHPStan\Analyser\Scope;
use PHPStan\Rules\Rule;

/**
* @implements Rule<Node>
*/
class CustomRule2 implements Rule
{
public function getNodeType(): string
{
return Node::class;
}

public function processNode(Node $node, Scope $scope): array
{
return [];
}

}
14 changes: 14 additions & 0 deletions e2e/result-cache-8/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"require-dev": {
"phpstan/phpstan": "^1.10",
"phpstan/phpstan-webmozart-assert": "^1.2"
},
"autoload": {
"classmap": ["src"]
},
"autoload-dev": {
"classmap": [
"build"
]
}
}
132 changes: 132 additions & 0 deletions e2e/result-cache-8/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions e2e/result-cache-8/phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
includes:
- vendor/phpstan/phpstan-webmozart-assert/extension.neon

parameters:
paths:
- src
level: 8

rules:
- ResultCache8E2E\CustomRule
- ResultCache8E2E\CustomRule3

services:
-
class: ResultCache8E2E\CustomRule2
tags:
- phpstan.rules.rule
24 changes: 24 additions & 0 deletions e2e/result-cache-8/src/CustomRule3.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

namespace ResultCache8E2E;

use PhpParser\Node;
use PHPStan\Analyser\Scope;
use PHPStan\Rules\Rule;

/**
* @implements Rule<Node>
*/
class CustomRule3 implements Rule
{
public function getNodeType(): string
{
return Node::class;
}

public function processNode(Node $node, Scope $scope): array
{
return [];
}

}
8 changes: 8 additions & 0 deletions e2e/result-cache-8/src/Foo.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

namespace ResultCache8E2E;

class Foo
{

}
Loading

0 comments on commit 9338fdf

Please sign in to comment.