Skip to content

Commit

Permalink
[cleanup] Make use of getArgs(), remove ignored from phpstan (#3771)
Browse files Browse the repository at this point in the history
  • Loading branch information
TomasVotruba committed May 8, 2023
1 parent 5a32ed9 commit 1e052f5
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
4 changes: 0 additions & 4 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -215,9 +215,6 @@ parameters:
message: '#Instead of abstract class, use specific service with composition#'
path: rules/Strict/Rector/AbstractFalsyScalarRuleFixerRector.php


- '#Access to an undefined property PhpParser\\Node\\Arg\|PhpParser\\Node\\VariadicPlaceholder\:\:\$value#'

# many internal cases
- '#Calling (.*?) is not covered by backward compatibility promise\. The method might change in a minor PHPStan version#'

Expand Down Expand Up @@ -298,7 +295,6 @@ parameters:
- rules/EarlyReturn/Rector/If_/ChangeNestedIfsToEarlyReturnRector.php
- rules/Php70/EregToPcreTransformer.php
- rules/CodeQuality/Rector/PropertyFetch/ExplicitMethodCallOverMagicGetSetRector.php
- rules/Php72/Rector/Assign/ReplaceEachAssignmentWithKeyCurrentRector.php
- rules/PSR4/Rector/FileWithoutNamespace/NormalizeNamespaceByPSR4ComposerAutoloadRector.php
- rules/Renaming/NodeManipulator/ClassRenamer.php

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,12 @@ public function refactor(Node $node): ?Node
return null;
}

$firstArg = $node->getArgs()[0];
$args = $node->getArgs();
$firstArg = $args[0];

$node->name = new Name('mysqli_connect');
$node->args[0]->value = $this->joinStringWithNode('p:', $firstArg->value);

$args[0]->value = $this->joinStringWithNode('p:', $firstArg->value);

return $node;
}
Expand Down
6 changes: 3 additions & 3 deletions rules/Php80/Rector/Ternary/GetDebugTypeRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,9 @@ public function refactor(Node $node): ?Node

/** @var FuncCall|ClassConstFetch $getClassFuncCallOrClassConstFetchClass */
$getClassFuncCallOrClassConstFetchClass = $node->if;

$firstExpr = $getClassFuncCallOrClassConstFetchClass instanceof FuncCall
? $getClassFuncCallOrClassConstFetchClass->args[0]->value
? $getClassFuncCallOrClassConstFetchClass->getArgs()[0]->value
: $getClassFuncCallOrClassConstFetchClass->class;

return $this->nodeFactory->createFuncCall('get_debug_type', [$firstExpr]);
Expand Down Expand Up @@ -143,8 +144,7 @@ private function areValuesIdentical(Ternary $ternary): bool
/** @var FuncCall $isObjectFuncCall */
$isObjectFuncCall = $ternary->cond;

$firstExpr = $isObjectFuncCall->getArgs()[0]
->value;
$firstExpr = $isObjectFuncCall->getArgs()[0]->value;

/** @var FuncCall|ClassConstFetch $getClassFuncCallOrClassConstFetchClass */
$getClassFuncCallOrClassConstFetchClass = $ternary->if;
Expand Down

0 comments on commit 1e052f5

Please sign in to comment.