Skip to content

Commit

Permalink
[CodeQuality] Skip fopen() or die() on LogicalToBooleanRector
Browse files Browse the repository at this point in the history
  • Loading branch information
samsonasik committed Dec 30, 2024
1 parent dfe6f2d commit 8f5de06
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace Rector\Tests\CodeQuality\Rector\LogicalAnd\LogicalToBooleanRector\Fixture;

final class SkipFopenOrDieInAssign
{
public function run(string $fileLocation)
{
$file = fopen($fileLocation, 'w') or die('Unable to open file!');
fwrite($file, "John Doe\nJane Doe\n");
fclose($file);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,14 @@ public function getNodeTypes(): array
/**
* @param LogicalOr|LogicalAnd $node
*/
public function refactor(Node $node): BooleanAnd|BooleanOr
public function refactor(Node $node): BooleanAnd|BooleanOr|null
{
$type = $this->nodeTypeResolver->getType($node->left);

if (! $type->isBoolean()->yes()) {
return null;
}

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

Expand Down

0 comments on commit 8f5de06

Please sign in to comment.