Skip to content

Commit

Permalink
Merge pull request #348 from tighten/drift/php-83-support
Browse files Browse the repository at this point in the history
Add support for PHP 8.3
  • Loading branch information
driftingly authored Dec 1, 2023
2 parents 4d126aa + 847b69f commit 3e998a4
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 4 additions & 3 deletions src/Formatters/NoDatesPropertyOnModels.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
};
}

Expand Down
10 changes: 5 additions & 5 deletions src/Linters/NoDatesPropertyOnModels.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
};
}
}

0 comments on commit 3e998a4

Please sign in to comment.