diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index ddc09c5..e92803f 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -12,7 +12,7 @@ jobs: strategy: matrix: os: [ubuntu, macos, windows] - php: ["8.1", "8.2"] + php: ["8.1", "8.2", "8.3"] dependencies: [lowest, stable] steps: - uses: actions/checkout@v2 diff --git a/src/Formatters/NoDatesPropertyOnModels.php b/src/Formatters/NoDatesPropertyOnModels.php index 87612c2..72b6b9a 100644 --- a/src/Formatters/NoDatesPropertyOnModels.php +++ b/src/Formatters/NoDatesPropertyOnModels.php @@ -25,6 +25,8 @@ class NoDatesPropertyOnModels extends BaseFormatter public const DESCRIPTION = 'Use `$casts` instead of `$dates` on Eloquent models.'; + protected bool $model = false; + public function format(Parser $parser, Lexer $lexer): string { $traverser = new NodeTraverser; @@ -65,13 +67,12 @@ public function format(Parser $parser, Lexer $lexer): string private function nodeFinderForModelProperty(string $attribute): Closure { return function (Node $node) use ($attribute) { - static $model = false; if ($this->extendsAny($node, ['Model', 'Pivot', 'Authenticatable'])) { - $model = true; + $this->model = true; } - return $model && $node instanceof Property && (string) $node->props[0]->name === $attribute; + return $this->model && $node instanceof Property && (string) $node->props[0]->name === $attribute; }; } diff --git a/src/Linters/NoDatesPropertyOnModels.php b/src/Linters/NoDatesPropertyOnModels.php index 0e10a2b..f6e9f30 100644 --- a/src/Linters/NoDatesPropertyOnModels.php +++ b/src/Linters/NoDatesPropertyOnModels.php @@ -14,16 +14,16 @@ class NoDatesPropertyOnModels extends BaseLinter public const DESCRIPTION = 'The `$dates` property was deprecated in Laravel 8. Use `$casts` instead.'; + protected bool $model = false; + protected function visitor(): Closure { - return function (Node $node) use (&$model) { - static $model = false; - + return function (Node $node) { if ($this->extendsAny($node, ['Model', 'Pivot', 'Authenticatable'])) { - $model = true; + $this->model = true; } - return $model && $node instanceof Property && (string) $node->props[0]->name === 'dates'; + return $this->model && $node instanceof Property && (string) $node->props[0]->name === 'dates'; }; } }