-
-
Notifications
You must be signed in to change notification settings - Fork 338
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[DowngradePhp72] Handle in assign on DowngradePregUnmatchedAsNullCons…
…tantRector (#1872) * [DowngradePhp72] Handle in assign on DowngradePregUnmatchedAsNullConstantRector * update fixture * create assign ternary * Fixed 🎉 * phpstan * phpstan
- Loading branch information
1 parent
9d077f0
commit f686cba
Showing
2 changed files
with
66 additions
and
5 deletions.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
...hp72/Rector/FuncCall/DowngradePregUnmatchedAsNullConstantRector/Fixture/in_assign.php.inc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\DowngradePhp72\Rector\FuncCall\DowngradePregUnmatchedAsNullConstantRector\Fixture; | ||
|
||
function inAssign($pattern, $subject, $matches, $flags, $offset) | ||
{ | ||
$result = preg_match($pattern, $subject, $matches, $flags | PREG_UNMATCHED_AS_NULL, $offset); | ||
if ($result === false) { | ||
throw \Composer\Pcre\PcreException::fromFunction('preg_match', $pattern); | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Tests\DowngradePhp72\Rector\FuncCall\DowngradePregUnmatchedAsNullConstantRector\Fixture; | ||
|
||
function inAssign($pattern, $subject, $matches, $flags, $offset) | ||
{ | ||
preg_match($pattern, $subject, $matches, $flags, $offset); | ||
array_walk_recursive($matches, function (&$value) { | ||
if ($value === '') { | ||
$value = null; | ||
} | ||
}); | ||
$result = $matches === [] ? false : 1; | ||
if ($result === false) { | ||
throw \Composer\Pcre\PcreException::fromFunction('preg_match', $pattern); | ||
} | ||
} | ||
|
||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters