mirror of
https://github.com/rectorphp/rector.git
synced 2024-07-31 22:00:23 +00:00
Remove isOnClassMethodCall() (#6116)
This commit is contained in:
parent
620309c0d7
commit
5dcedbd825
@ -7,6 +7,5 @@ use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigura
|
||||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
$services = $containerConfigurator->services();
|
||||
|
||||
$services->set(RemoveSetTempDirOnExcelWriterRector::class);
|
||||
};
|
||||
|
@ -70,7 +70,11 @@ CODE_SAMPLE
|
||||
*/
|
||||
public function refactor(Node $node): ?Node
|
||||
{
|
||||
if (! $this->isOnClassMethodCall($node, new ObjectType('Carbon\Carbon'), 'diffForHumans')) {
|
||||
if (! $this->isObjectType($node->var, new ObjectType('Carbon\Carbon'))) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (! $this->isName($node->name, 'diffForHumans')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -65,7 +65,11 @@ CODE_SAMPLE
|
||||
*/
|
||||
public function refactor(Node $node): ?Node
|
||||
{
|
||||
if (! $this->isOnClassMethodCall($node, new ObjectType('PHPExcel_Style_Conditional'), 'setCondition')) {
|
||||
if (! $this->isObjectType($node->var, new ObjectType('PHPExcel_Style_Conditional'))) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (! $this->isName($node->name, 'setCondition')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -63,7 +63,11 @@ CODE_SAMPLE
|
||||
*/
|
||||
public function refactor(Node $node): ?Node
|
||||
{
|
||||
if (! $this->isOnClassMethodCall($node, new ObjectType('PHPExcel_Worksheet'), 'duplicateStyleArray')) {
|
||||
if (! $this->isObjectType($node->var, new ObjectType('PHPExcel_Worksheet'))) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (! $this->nodeNameResolver->isName($node->name, 'duplicateStyleArray')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -61,7 +61,11 @@ CODE_SAMPLE
|
||||
*/
|
||||
public function refactor(Node $node): ?Node
|
||||
{
|
||||
if (! $this->isOnClassMethodCall($node, new ObjectType('PHPExcel_Writer_Excel5'), 'setTempDir')) {
|
||||
if (! $this->isObjectType($node->var, new ObjectType('PHPExcel_Writer_Excel5'))) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (! $this->isName($node->name, 'setTempDir')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -78,8 +78,7 @@ CODE_SAMPLE
|
||||
*/
|
||||
public function refactor(Node $node): ?Node
|
||||
{
|
||||
$callerType = $this->getObjectType($node->class);
|
||||
if (! $callerType->isSuperTypeOf(new ObjectType('PHPExcel_IOFactory'))->yes()) {
|
||||
if (! $this->isObjectType($node->class, new ObjectType('PHPExcel_IOFactory'))) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -7,7 +7,6 @@ namespace Rector\Core\Rector;
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Arg;
|
||||
use PhpParser\Node\Expr;
|
||||
use PhpParser\Node\Expr\MethodCall;
|
||||
use PhpParser\Node\Name;
|
||||
use PhpParser\Node\Stmt;
|
||||
use PhpParser\Node\Stmt\Class_;
|
||||
@ -412,15 +411,6 @@ abstract class AbstractRector extends NodeVisitorAbstract implements PhpRectorIn
|
||||
}
|
||||
}
|
||||
|
||||
protected function isOnClassMethodCall(MethodCall $methodCall, ObjectType $objectType, string $methodName): bool
|
||||
{
|
||||
if (! $this->isObjectType($methodCall->var, $objectType)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $this->isName($methodCall->name, $methodName);
|
||||
}
|
||||
|
||||
protected function isOpenSourceProjectType(): bool
|
||||
{
|
||||
$projectType = $this->parameterProvider->provideStringParameter(Option::PROJECT_TYPE);
|
||||
|
Loading…
Reference in New Issue
Block a user