mirror of
https://github.com/rectorphp/rector.git
synced 2024-05-31 00:10:51 +00:00
[Php73] Skip Encapsed on StringifyStrNeedlesRector + Temporary Pin PHPStan 1.6.9 (#2352)
* [Php73] Skip Encapsed on StringifyStrNeedlesRector
* phpstan
* [ci-review] Rector Rectify
* [ci-review] Rector Rectify
* Fixed 🎉
* eol
* update requirement to PHPStan 1.7.0
* temporary pin to 1.6.9
* [ci-review] Rector Rectify
* [ci-review] Rector Rectify
Co-authored-by: GitHub Action <action@github.com>
This commit is contained in:
parent
1691157a64
commit
f25715b7b3
|
@ -7,7 +7,7 @@
|
|||
],
|
||||
"require": {
|
||||
"php": "^7.2|^8.0",
|
||||
"phpstan/phpstan": "^1.6.8"
|
||||
"phpstan/phpstan": "1.6.9"
|
||||
},
|
||||
"autoload": {
|
||||
"files": [
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
"nikic/php-parser": "^4.13.2",
|
||||
"ondram/ci-detector": "^4.1",
|
||||
"phpstan/phpdoc-parser": "^1.5.1",
|
||||
"phpstan/phpstan": "^1.6.8",
|
||||
"phpstan/phpstan": "1.6.9",
|
||||
"phpstan/phpstan-phpunit": "^1.0",
|
||||
"psr/log": "^2.0",
|
||||
"react/child-process": "^0.6.4",
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
<?php
|
||||
|
||||
namespace Rector\Tests\Php73\Rector\FuncCall\StringifyStrNeedlesRector\Fixture;
|
||||
|
||||
function skipEncapsed()
|
||||
{
|
||||
$str = 'bar';
|
||||
strpos('foo bar', " {$str}");
|
||||
}
|
|
@ -109,6 +109,7 @@ CODE_SAMPLE
|
|||
continue;
|
||||
}
|
||||
|
||||
/** @var ReflectionMethod $parentReflectionMethod */
|
||||
$parentReflectionMethod = $nativeClassReflection->getMethod($methodName);
|
||||
if ($this->isClassMethodCompatibleWithParentReflectionMethod($classMethod, $parentReflectionMethod)) {
|
||||
continue;
|
||||
|
|
|
@ -18,7 +18,7 @@ final class BitwiseFlagCleaner
|
|||
) {
|
||||
}
|
||||
|
||||
public function cleanFuncCall(FuncCall $funcCall, BitwiseOr $bitwiseOr, Expr $expr = null, string $flag): void
|
||||
public function cleanFuncCall(FuncCall $funcCall, BitwiseOr $bitwiseOr, string $flag, Expr $expr = null): void
|
||||
{
|
||||
if ($bitwiseOr->left instanceof BitwiseOr) {
|
||||
/** @var BitwiseOr $leftLeft */
|
||||
|
@ -36,7 +36,7 @@ final class BitwiseFlagCleaner
|
|||
}
|
||||
|
||||
if ($bitwiseOr->left instanceof BitwiseOr) {
|
||||
$this->cleanFuncCall($funcCall, $bitwiseOr->left, $bitwiseOr->right, $flag);
|
||||
$this->cleanFuncCall($funcCall, $bitwiseOr->left, $flag, $bitwiseOr->right);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -79,7 +79,7 @@ final class DowngradePregUnmatchedAsNullConstantRector extends AbstractRector
|
|||
$variable = $args[2]->value;
|
||||
|
||||
if ($flags instanceof BitwiseOr) {
|
||||
$this->bitwiseFlagCleaner->cleanFuncCall($node, $flags, null, self::UNMATCHED_NULL_FLAG);
|
||||
$this->bitwiseFlagCleaner->cleanFuncCall($node, $flags, self::UNMATCHED_NULL_FLAG, null);
|
||||
if (! $this->nodeComparator->areNodesEqual($flags, $args[3]->value)) {
|
||||
return $this->handleEmptyStringToNullMatch($node, $variable);
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ use PhpParser\Node;
|
|||
use PhpParser\Node\Arg;
|
||||
use PhpParser\Node\Expr\Cast\String_;
|
||||
use PhpParser\Node\Expr\FuncCall;
|
||||
use PhpParser\Node\Scalar\Encapsed;
|
||||
use PHPStan\Type\StringType;
|
||||
use Rector\Core\Rector\AbstractRector;
|
||||
use Rector\Core\ValueObject\PhpVersionFeature;
|
||||
|
@ -106,6 +107,10 @@ CODE_SAMPLE
|
|||
return null;
|
||||
}
|
||||
|
||||
if ($needleArgValue instanceof Encapsed) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$node->args[1]->value = new String_($node->args[1]->value);
|
||||
|
||||
return $node;
|
||||
|
|
Loading…
Reference in New Issue
Block a user