mirror of
https://github.com/rectorphp/rector.git
synced 2024-06-04 02:10:51 +00:00
[Laravel 5.7] Add parent boot rule (#4580)
* move file to templates, to remove confusion in the root * use stable symplify * [Laravel] Add AddParentBootToModelClassMethodRector * [ci-review] Generate Rector & Nodes documentation * [ci-review] propagate monorepo dependencies * [ci-review] Rector Rectify Co-authored-by: rector-bot <tomas@getrector.org>
This commit is contained in:
parent
75714bb3d6
commit
4c6da2c4bf
|
@ -47,13 +47,13 @@
|
||||||
"symfony/finder": "^4.4.8|^5.1",
|
"symfony/finder": "^4.4.8|^5.1",
|
||||||
"symfony/http-kernel": "^4.4.8|^5.1",
|
"symfony/http-kernel": "^4.4.8|^5.1",
|
||||||
"symfony/process": "^4.4.8|^5.1",
|
"symfony/process": "^4.4.8|^5.1",
|
||||||
"symplify/autowire-array-parameter": "^8.3.48",
|
"symplify/autowire-array-parameter": "8.3.48",
|
||||||
"symplify/composer-json-manipulator": "^8.3.48",
|
"symplify/composer-json-manipulator": "8.3.48",
|
||||||
"symplify/console-color-diff": "^8.3.48",
|
"symplify/console-color-diff": "8.3.48",
|
||||||
"symplify/easy-testing": "^8.3.48",
|
"symplify/easy-testing": "8.3.48",
|
||||||
"symplify/package-builder": "^8.3.48",
|
"symplify/package-builder": "8.3.48",
|
||||||
"symplify/set-config-resolver": "^8.3.48",
|
"symplify/set-config-resolver": "8.3.48",
|
||||||
"symplify/smart-file-system": "^8.3.48",
|
"symplify/smart-file-system": "8.3.48",
|
||||||
"webmozart/assert": "^1.9"
|
"webmozart/assert": "^1.9"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
|
@ -67,11 +67,11 @@
|
||||||
"php-parallel-lint/php-parallel-lint": "^1.2",
|
"php-parallel-lint/php-parallel-lint": "^1.2",
|
||||||
"phpunit/phpunit": "^8.5|^9.2",
|
"phpunit/phpunit": "^8.5|^9.2",
|
||||||
"psr/event-dispatcher": "^1.0",
|
"psr/event-dispatcher": "^1.0",
|
||||||
"symplify/changelog-linker": "^8.3.48",
|
"symplify/changelog-linker": "8.3.48",
|
||||||
"symplify/easy-coding-standard": "^8.3.48",
|
"symplify/easy-coding-standard": "8.3.48",
|
||||||
"symplify/easy-testing": "^8.3.48",
|
"symplify/easy-testing": "8.3.48",
|
||||||
"symplify/monorepo-builder": "^8.3.48",
|
"symplify/monorepo-builder": "8.3.48",
|
||||||
"symplify/phpstan-extensions": "^8.3.48",
|
"symplify/phpstan-extensions": "8.3.48",
|
||||||
"tracy/tracy": "^2.7"
|
"tracy/tracy": "^2.7"
|
||||||
},
|
},
|
||||||
"replace": {
|
"replace": {
|
||||||
|
@ -345,7 +345,6 @@
|
||||||
"sort-packages": true,
|
"sort-packages": true,
|
||||||
"process-timeout": 0
|
"process-timeout": 0
|
||||||
},
|
},
|
||||||
"prefer-stable": true,
|
|
||||||
"extra": {
|
"extra": {
|
||||||
"patches": {
|
"patches": {
|
||||||
"nette/application": [
|
"nette/application": [
|
||||||
|
|
|
@ -8,54 +8,48 @@ use Rector\Generic\Rector\ClassMethod\ChangeMethodVisibilityRector;
|
||||||
use Rector\Generic\ValueObject\ArgumentAdder;
|
use Rector\Generic\ValueObject\ArgumentAdder;
|
||||||
use Rector\Generic\ValueObject\ArgumentRemover;
|
use Rector\Generic\ValueObject\ArgumentRemover;
|
||||||
use Rector\Generic\ValueObject\ChangeMethodVisibility;
|
use Rector\Generic\ValueObject\ChangeMethodVisibility;
|
||||||
|
use Rector\Laravel\Rector\ClassMethod\AddParentBootToModelClassMethodRector;
|
||||||
use Rector\Laravel\Rector\StaticCall\Redirect301ToPermanentRedirectRector;
|
use Rector\Laravel\Rector\StaticCall\Redirect301ToPermanentRedirectRector;
|
||||||
use function Rector\SymfonyPhpConfig\inline_value_objects;
|
use function Rector\SymfonyPhpConfig\inline_value_objects;
|
||||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||||
|
|
||||||
# see: https://laravel.com/docs/5.7/upgrade
|
# see: https://laravel.com/docs/5.7/upgrade
|
||||||
|
|
||||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||||
$services = $containerConfigurator->services();
|
$services = $containerConfigurator->services();
|
||||||
|
$services->set(ChangeMethodVisibilityRector::class)->call('configure', [[
|
||||||
$services->set(ChangeMethodVisibilityRector::class)
|
ChangeMethodVisibilityRector::METHOD_VISIBILITIES => inline_value_objects([
|
||||||
->call('configure', [[
|
new ChangeMethodVisibility('Illuminate\Routing\Router', 'addRoute', 'public'),
|
||||||
ChangeMethodVisibilityRector::METHOD_VISIBILITIES => inline_value_objects([
|
new ChangeMethodVisibility('Illuminate\Contracts\Auth\Access\Gate', 'raw', 'public'),
|
||||||
new ChangeMethodVisibility('Illuminate\Routing\Router', 'addRoute', 'public'),
|
]),
|
||||||
new ChangeMethodVisibility('Illuminate\Contracts\Auth\Access\Gate', 'raw', 'public'),
|
]]);
|
||||||
]),
|
$services->set(ArgumentAdderRector::class)->call('configure', [[
|
||||||
]]);
|
ArgumentAdderRector::ADDED_ARGUMENTS => inline_value_objects([
|
||||||
|
new ArgumentAdder('Illuminate\Auth\Middleware\Authenticate', 'authenticate', 0, 'request'),
|
||||||
$services->set(ArgumentAdderRector::class)
|
new ArgumentAdder(
|
||||||
->call('configure', [[
|
'Illuminate\Foundation\Auth\ResetsPasswords',
|
||||||
ArgumentAdderRector::ADDED_ARGUMENTS => inline_value_objects([
|
'sendResetResponse',
|
||||||
new ArgumentAdder('Illuminate\Auth\Middleware\Authenticate', 'authenticate', 0, 'request'),
|
0,
|
||||||
new ArgumentAdder(
|
'request',
|
||||||
'Illuminate\Foundation\Auth\ResetsPasswords',
|
null,
|
||||||
'sendResetResponse',
|
'Illuminate\Http\Illuminate\Http'
|
||||||
0,
|
),
|
||||||
'request',
|
new ArgumentAdder(
|
||||||
null,
|
'Illuminate\Foundation\Auth\SendsPasswordResetEmails',
|
||||||
'Illuminate\Http\Illuminate\Http'
|
'sendResetLinkResponse',
|
||||||
),
|
0,
|
||||||
new ArgumentAdder(
|
'request',
|
||||||
'Illuminate\Foundation\Auth\SendsPasswordResetEmails',
|
null,
|
||||||
'sendResetLinkResponse',
|
'Illuminate\Http\Illuminate\Http'
|
||||||
0,
|
),
|
||||||
'request',
|
]),
|
||||||
null,
|
]]);
|
||||||
'Illuminate\Http\Illuminate\Http'
|
|
||||||
),
|
|
||||||
]),
|
|
||||||
]]);
|
|
||||||
|
|
||||||
$services->set(Redirect301ToPermanentRedirectRector::class);
|
$services->set(Redirect301ToPermanentRedirectRector::class);
|
||||||
|
$services->set(ArgumentRemoverRector::class)->call('configure', [[
|
||||||
$services->set(ArgumentRemoverRector::class)
|
ArgumentRemoverRector::REMOVED_ARGUMENTS => inline_value_objects([
|
||||||
->call('configure', [[
|
new ArgumentRemover('Illuminate\Foundation\Application', 'register', 1, [
|
||||||
ArgumentRemoverRector::REMOVED_ARGUMENTS => inline_value_objects([
|
'name' => 'options',
|
||||||
new ArgumentRemover('Illuminate\Foundation\Application', 'register', 1, [
|
|
||||||
'name' => 'options',
|
|
||||||
]),
|
|
||||||
]),
|
]),
|
||||||
]]);
|
]),
|
||||||
|
]]);
|
||||||
|
$services->set(AddParentBootToModelClassMethodRector::class);
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
# All 604 Rectors Overview
|
# All 605 Rectors Overview
|
||||||
|
|
||||||
- [Projects](#projects)
|
- [Projects](#projects)
|
||||||
---
|
---
|
||||||
|
@ -23,7 +23,7 @@
|
||||||
- [FileSystemRector](#filesystemrector) (1)
|
- [FileSystemRector](#filesystemrector) (1)
|
||||||
- [Generic](#generic) (34)
|
- [Generic](#generic) (34)
|
||||||
- [JMS](#jms) (2)
|
- [JMS](#jms) (2)
|
||||||
- [Laravel](#laravel) (3)
|
- [Laravel](#laravel) (4)
|
||||||
- [Legacy](#legacy) (4)
|
- [Legacy](#legacy) (4)
|
||||||
- [MagicDisclosure](#magicdisclosure) (3)
|
- [MagicDisclosure](#magicdisclosure) (3)
|
||||||
- [MockeryToProphecy](#mockerytoprophecy) (2)
|
- [MockeryToProphecy](#mockerytoprophecy) (2)
|
||||||
|
@ -7061,6 +7061,27 @@ Removes JMS\DiExtraBundle\Annotation\Services annotation
|
||||||
|
|
||||||
## Laravel
|
## Laravel
|
||||||
|
|
||||||
|
### `AddParentBootToModelClassMethodRector`
|
||||||
|
|
||||||
|
- class: [`Rector\Laravel\Rector\ClassMethod\AddParentBootToModelClassMethodRector`](/rules/laravel/src/Rector/ClassMethod/AddParentBootToModelClassMethodRector.php)
|
||||||
|
- [test fixtures](/rules/laravel/tests/Rector/ClassMethod/AddParentBootToModelClassMethodRector/Fixture)
|
||||||
|
|
||||||
|
Add parent::boot(); call to `boot()` class method in child of `Illuminate\Database\Eloquent\Model`
|
||||||
|
|
||||||
|
```diff
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class Product extends Model
|
||||||
|
{
|
||||||
|
public function boot()
|
||||||
|
{
|
||||||
|
+ parent::boot();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
<br><br>
|
||||||
|
|
||||||
### `MinutesToSecondsInCacheRector`
|
### `MinutesToSecondsInCacheRector`
|
||||||
|
|
||||||
- class: [`Rector\Laravel\Rector\StaticCall\MinutesToSecondsInCacheRector`](/rules/laravel/src/Rector/StaticCall/MinutesToSecondsInCacheRector.php)
|
- class: [`Rector\Laravel\Rector\StaticCall\MinutesToSecondsInCacheRector`](/rules/laravel/src/Rector/StaticCall/MinutesToSecondsInCacheRector.php)
|
||||||
|
|
|
@ -7,11 +7,11 @@
|
||||||
"symfony/dependency-injection": "^4.4.8|^5.1",
|
"symfony/dependency-injection": "^4.4.8|^5.1",
|
||||||
"symfony/config": "^4.4.8|^5.1",
|
"symfony/config": "^4.4.8|^5.1",
|
||||||
"symfony/http-kernel": "^4.4.8|^5.1",
|
"symfony/http-kernel": "^4.4.8|^5.1",
|
||||||
"symplify/package-builder": "^8.3.48"
|
"symplify/package-builder": "8.3.48"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"phpunit/phpunit": "^8.5|^9.2",
|
"phpunit/phpunit": "^8.5|^9.2",
|
||||||
"symplify/easy-testing": "^8.3.48"
|
"symplify/easy-testing": "8.3.48"
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-4": {
|
"psr-4": {
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
"php": "^7.2.4|^8.0",
|
"php": "^7.2.4|^8.0",
|
||||||
"symfony/dependency-injection": "^4.4.8|^5.1",
|
"symfony/dependency-injection": "^4.4.8|^5.1",
|
||||||
"symfony/http-kernel": "^4.4.8|^5.1",
|
"symfony/http-kernel": "^4.4.8|^5.1",
|
||||||
"symplify/package-builder": "^8.3.48"
|
"symplify/package-builder": "8.3.48"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"phpunit/phpunit": "^8.5|^9.2"
|
"phpunit/phpunit": "^8.5|^9.2"
|
||||||
|
|
|
@ -0,0 +1,120 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Rector\Laravel\Rector\ClassMethod;
|
||||||
|
|
||||||
|
use PhpParser\Node;
|
||||||
|
use PhpParser\Node\Stmt\ClassMethod;
|
||||||
|
use PhpParser\Node\Stmt\Expression;
|
||||||
|
use Rector\Core\Rector\AbstractRector;
|
||||||
|
use Rector\Core\RectorDefinition\CodeSample;
|
||||||
|
use Rector\Core\RectorDefinition\RectorDefinition;
|
||||||
|
use Rector\Nette\NodeAnalyzer\StaticCallAnalyzer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see https://laracasts.com/discuss/channels/laravel/laravel-57-upgrade-observer-problem
|
||||||
|
*
|
||||||
|
* @see \Rector\Laravel\Tests\Rector\ClassMethod\AddParentBootToModelClassMethodRector\AddParentBootToModelClassMethodRectorTest
|
||||||
|
*/
|
||||||
|
final class AddParentBootToModelClassMethodRector extends AbstractRector
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private const BOOT = 'boot';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var StaticCallAnalyzer
|
||||||
|
*/
|
||||||
|
private $staticCallAnalyzer;
|
||||||
|
|
||||||
|
public function __construct(StaticCallAnalyzer $staticCallAnalyzer)
|
||||||
|
{
|
||||||
|
$this->staticCallAnalyzer = $staticCallAnalyzer;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getDefinition(): RectorDefinition
|
||||||
|
{
|
||||||
|
return new RectorDefinition(
|
||||||
|
'Add parent::boot(); call to boot() class method in child of Illuminate\Database\Eloquent\Model',
|
||||||
|
[
|
||||||
|
new CodeSample(
|
||||||
|
<<<'CODE_SAMPLE'
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class Product extends Model
|
||||||
|
{
|
||||||
|
public function boot()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
CODE_SAMPLE
|
||||||
|
|
||||||
|
,
|
||||||
|
<<<'CODE_SAMPLE'
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class Product extends Model
|
||||||
|
{
|
||||||
|
public function boot()
|
||||||
|
{
|
||||||
|
parent::boot();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
CODE_SAMPLE
|
||||||
|
|
||||||
|
),
|
||||||
|
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string[]
|
||||||
|
*/
|
||||||
|
public function getNodeTypes(): array
|
||||||
|
{
|
||||||
|
return [ClassMethod::class];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param ClassMethod $node
|
||||||
|
*/
|
||||||
|
public function refactor(Node $node): ?Node
|
||||||
|
{
|
||||||
|
if (! $this->isInObjectType($node, 'Illuminate\Database\Eloquent\Model')) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! $this->isName($node->name, self::BOOT)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ((array) $node->stmts as $key => $classMethodStmt) {
|
||||||
|
if ($classMethodStmt instanceof Expression) {
|
||||||
|
$classMethodStmt = $classMethodStmt->expr;
|
||||||
|
}
|
||||||
|
|
||||||
|
// is in the 1st position? → only correct place
|
||||||
|
// @see https://laracasts.com/discuss/channels/laravel/laravel-57-upgrade-observer-problem?page=0#reply=454409
|
||||||
|
if (! $this->staticCallAnalyzer->isParentCallNamed($classMethodStmt, self::BOOT)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($key === 0) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// wrong location → remove it
|
||||||
|
unset($node->stmts[$key]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// missing, we need to add one
|
||||||
|
$staticCall = $this->nodeFactory->createStaticCall('parent', self::BOOT);
|
||||||
|
$parentStaticCallExpression = new Expression($staticCall);
|
||||||
|
|
||||||
|
$node->stmts = array_merge([$parentStaticCallExpression], (array) $node->stmts);
|
||||||
|
|
||||||
|
return $node;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,31 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Rector\Laravel\Tests\Rector\ClassMethod\AddParentBootToModelClassMethodRector;
|
||||||
|
|
||||||
|
use Iterator;
|
||||||
|
use Rector\Laravel\Rector\ClassMethod\AddParentBootToModelClassMethodRector;
|
||||||
|
use Rector\Testing\PHPUnit\AbstractRectorTestCase;
|
||||||
|
use Symplify\SmartFileSystem\SmartFileInfo;
|
||||||
|
|
||||||
|
final class AddParentBootToModelClassMethodRectorTest extends AbstractRectorTestCase
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @dataProvider provideData()
|
||||||
|
*/
|
||||||
|
public function test(SmartFileInfo $fileInfo): void
|
||||||
|
{
|
||||||
|
$this->doTestFileInfo($fileInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function provideData(): Iterator
|
||||||
|
{
|
||||||
|
return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture');
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getRectorClass(): string
|
||||||
|
{
|
||||||
|
return AddParentBootToModelClassMethodRector::class;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,30 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Rector\Laravel\Tests\Rector\ClassMethod\AddParentBootToModelClassMethodRector\Fixture;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class Product extends Model
|
||||||
|
{
|
||||||
|
public function boot()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
|
-----
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Rector\Laravel\Tests\Rector\ClassMethod\AddParentBootToModelClassMethodRector\Fixture;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class Product extends Model
|
||||||
|
{
|
||||||
|
public function boot()
|
||||||
|
{
|
||||||
|
parent::boot();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
|
@ -0,0 +1,33 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Rector\Laravel\Tests\Rector\ClassMethod\AddParentBootToModelClassMethodRector\Fixture;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class OnTheLastLine extends Model
|
||||||
|
{
|
||||||
|
public function boot()
|
||||||
|
{
|
||||||
|
$value = 1000;
|
||||||
|
parent::boot();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
|
-----
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Rector\Laravel\Tests\Rector\ClassMethod\AddParentBootToModelClassMethodRector\Fixture;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class OnTheLastLine extends Model
|
||||||
|
{
|
||||||
|
public function boot()
|
||||||
|
{
|
||||||
|
parent::boot();
|
||||||
|
$value = 1000;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
|
@ -3,6 +3,7 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace Rector\Nette\NodeAnalyzer;
|
namespace Rector\Nette\NodeAnalyzer;
|
||||||
|
|
||||||
|
use PhpParser\Node;
|
||||||
use PhpParser\Node\Expr;
|
use PhpParser\Node\Expr;
|
||||||
use PhpParser\Node\Expr\StaticCall;
|
use PhpParser\Node\Expr\StaticCall;
|
||||||
use Rector\NodeNameResolver\NodeNameResolver;
|
use Rector\NodeNameResolver\NodeNameResolver;
|
||||||
|
@ -19,20 +20,24 @@ final class StaticCallAnalyzer
|
||||||
$this->nodeNameResolver = $nodeNameResolver;
|
$this->nodeNameResolver = $nodeNameResolver;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isParentCallNamed(StaticCall $staticCall, string $desiredMethodName): bool
|
public function isParentCallNamed(Node $node, string $desiredMethodName): bool
|
||||||
{
|
{
|
||||||
if ($staticCall->class instanceof Expr) {
|
if (! $node instanceof StaticCall) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! $this->nodeNameResolver->isName($staticCall->class, 'parent')) {
|
if ($node->class instanceof Expr) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($staticCall->name instanceof Expr) {
|
if (! $this->nodeNameResolver->isName($node->class, 'parent')) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->nodeNameResolver->isName($staticCall->name, $desiredMethodName);
|
if ($node->name instanceof Expr) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->nodeNameResolver->isName($node->name, $desiredMethodName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,10 +45,10 @@ final class InitCommand extends AbstractCommand
|
||||||
$rectorConfigFiles = $this->smartFileSystem->exists(getcwd() . '/rector.php');
|
$rectorConfigFiles = $this->smartFileSystem->exists(getcwd() . '/rector.php');
|
||||||
|
|
||||||
if (! $rectorConfigFiles) {
|
if (! $rectorConfigFiles) {
|
||||||
$this->smartFileSystem->copy(__DIR__ . '/../../../rector.php.dist', getcwd() . '/rector.php');
|
$this->smartFileSystem->copy(__DIR__ . '/../../../templates/rector.php.dist', getcwd() . '/rector.php');
|
||||||
$this->symfonyStyle->success('rector.php config file has been generated successfully');
|
$this->symfonyStyle->success('"rector.php" config file has been generated successfully!');
|
||||||
} else {
|
} else {
|
||||||
$this->symfonyStyle->error('Config file not generated. A rector.php configuration file already exists');
|
$this->symfonyStyle->error('Config file not generated. A "rector.php" configuration file already exists');
|
||||||
}
|
}
|
||||||
|
|
||||||
return ShellCode::SUCCESS;
|
return ShellCode::SUCCESS;
|
||||||
|
|
|
@ -425,6 +425,11 @@ final class NodeFactory
|
||||||
return $uses;
|
return $uses;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function createStaticCall(string $class, string $method): StaticCall
|
||||||
|
{
|
||||||
|
return new StaticCall(new Name($class), $method);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param mixed $item
|
* @param mixed $item
|
||||||
* @param string|int|null $key
|
* @param string|int|null $key
|
||||||
|
|
11
stubs/Illuminate/Database/Eloquent/Model.php
Normal file
11
stubs/Illuminate/Database/Eloquent/Model.php
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Illuminate\Database\Eloquent;
|
||||||
|
|
||||||
|
if (class_exists('Illuminate\Database\Eloquent\Model')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract class Model
|
||||||
|
{
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user