Skip to content

Commit d459ec1

Browse files
calebdwGeniJaho
andauthored
fix: skip scope method that is not a scope (#380)
Co-authored-by: Geni Jaho <[email protected]>
1 parent 2368e10 commit d459ec1

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

src/Rector/ClassMethod/MakeModelAttributesAndScopesProtectedRector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ private function isScopeMethod(ClassMethod $classMethod): bool
144144
{
145145
$name = $this->getName($classMethod);
146146

147-
if (str_starts_with((string) $name, 'scope')) {
147+
if ((bool) preg_match('/^scope.+$/', $name)) {
148148
return true;
149149
}
150150

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
namespace RectorLaravel\Tests\Rector\ClassMethod\MakeModelAttributesAndScopesProtectedRector\Fixture;
4+
5+
use Illuminate\Database\Eloquent\Model;
6+
7+
class SkipScopeMethodNotScope extends Model
8+
{
9+
public function scope(): string
10+
{
11+
return 'foo';
12+
}
13+
}
14+
15+
?>

0 commit comments

Comments
 (0)