Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -129,17 +129,17 @@ private function matchResponseExpr(Expr $expr): ?Expr
return null;
}

$varType = $this->nodeTypeResolver->getType($expr->var);
if (! $varType instanceof ObjectType) {
// must be status method call
if (! $this->isName($expr->name, 'getStatusCode')) {
return null;
}

if (! $varType->isInstanceof(ResponseClass::BASIC)->yes()) {
$varType = $this->nodeTypeResolver->getType($expr->var);
if (! $varType instanceof ObjectType) {
return null;
}

// must be status method call
if (! $this->isName($expr->name, 'getStatusCode')) {
if (! $varType->isInstanceof(ResponseClass::BASIC)->yes()) {
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ public function getNodeTypes(): array
*/
public function refactor(Node $node): ?MethodCall
{
if (! $this->isName($node->name, 'addViolationAt')) {
return null;
}

$objectType = $this->nodeTypeResolver->getType($node->var);
if (! $objectType instanceof ObjectType) {
return null;
Expand All @@ -76,10 +80,6 @@ public function refactor(Node $node): ?MethodCall
return null;
}

if (! $this->isName($node->name, 'addViolationAt')) {
return null;
}

$args = $node->getArgs();
$path = $args[0];
$message = $args[1];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,22 +60,21 @@ public function getNodeTypes(): array
*/
public function refactor(Node $node): ?Node
{
if ($node instanceof ClassConstFetch && (
if ($node instanceof String_) {
if ($node->value !== 'console.exception') {
return null;
}

return $this->nodeFactory->createClassConstFetch($this->consoleEventsObjectType->getClassName(), 'ERROR');
}

if (
$this->isObjectType($node->class, $this->consoleEventsObjectType) &&
$this->isName($node->name, 'EXCEPTION')
)
) {
return $this->nodeFactory->createClassConstFetch($this->consoleEventsObjectType->getClassName(), 'ERROR');
}

if (! $node instanceof String_) {
return null;
}

if ($node->value !== 'console.exception') {
return null;
}

return $this->nodeFactory->createClassConstFetch($this->consoleEventsObjectType->getClassName(), 'ERROR');
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,17 +64,17 @@ public function refactor(Node $node): ?Node
return null;
}

if (count($node->args) === 1) {
return null;
}

if (! $this->isObjectType(
$node->var,
new ObjectType('Symfony\Component\DependencyInjection\ContainerBuilder')
)) {
return null;
}

if (count($node->args) === 1) {
return null;
}

$node->args = $this->nodeFactory->createArgs([$this->nodeFactory->createTrue()]);

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

if (count($node->args) <= 2) {
return null;
}

if (! $this->isObjectType(
$node->var,
new ObjectType('Symfony\Component\VarDumper\Test\VarDumperTestTrait')
)) {
return null;
}

if (count($node->args) <= 2) {
return null;
}

$secondArg = $node->args[2];
if (! $secondArg instanceof Arg) {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@ public function refactor(Node $node): MethodCall|BooleanOr|null
return null;
}

if (! $this->isName($node->name, 'isGranted')) {
return null;
}

$objectType = $this->nodeTypeResolver->getType($node->var);
if (! $objectType instanceof ObjectType) {
return null;
Expand All @@ -123,10 +127,6 @@ public function refactor(Node $node): MethodCall|BooleanOr|null
return null;
}

if (! $this->isName($node->name, 'isGranted')) {
return null;
}

return $this->handleIsGranted($node);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,11 @@ public function getNodeTypes(): array
*/
public function refactor(Node $node): ?Node
{
if (! $this->isObjectType($node->var, new ObjectType('Symfony\Component\Filesystem\Filesystem'))) {
if (! $this->isName($node->name, 'mirror')) {
return null;
}

if (! $this->isName($node->name, 'mirror')) {
if (! $this->isObjectType($node->var, new ObjectType('Symfony\Component\Filesystem\Filesystem'))) {
return null;
}

Expand Down
Loading