Skip to content

Commit 978f458

Browse files
committed
restore nette utils
1 parent e532001 commit 978f458

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"require": {
99
"php": "^8.2",
1010
"illuminate/container": "^11.41|^12.37",
11+
"nette/utils": "^4.0",
1112
"nikic/php-parser": "^5.6",
1213
"symfony/console": "^6.4|^7.0|^8.0",
1314
"symfony/finder": "^6.4|^7.0|^8.0",

src/Analyzer/UnusedDefinitionsAnalyzer.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace Rector\Behastan\Analyzer;
66

7+
use Nette\Utils\Strings;
78
use Rector\Behastan\DefinitionMasksResolver;
89
use Rector\Behastan\Reporting\MaskCollectionStatsPrinter;
910
use Rector\Behastan\UsedInstructionResolver;
@@ -67,8 +68,7 @@ public function analyse(array $contextFiles, array $featureFiles): array
6768
private function isRegexDefinitionUsed(string $regexBehatDefinition, array $featureInstructions): bool
6869
{
6970
foreach ($featureInstructions as $featureInstruction) {
70-
# @ on purpose = the feature instruction might not be a regex pattern
71-
if (@preg_match($featureInstruction, $regexBehatDefinition)) {
71+
if (Strings::match($featureInstruction, $regexBehatDefinition)) {
7272
// it is used!
7373
return true;
7474
}
@@ -98,7 +98,7 @@ private function isMaskUsed(AbstractMask $mask, array $featureInstructions): boo
9898

9999
if ($mask instanceof NamedMask) {
100100
// normalize :mask definition to regex
101-
$regexMask = '#' . preg_replace(self::MASK_VALUE_REGEX, '(.*?)', $mask->mask) . '#';
101+
$regexMask = '#' . Strings::replace($mask->mask, self::MASK_VALUE_REGEX, '(.*?)') . '#';
102102

103103
if ($this->isRegexDefinitionUsed($regexMask, $featureInstructions)) {
104104
return true;

src/UsedInstructionResolver.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace Rector\Behastan;
66

7+
use Nette\Utils\Strings;
78
use RuntimeException;
89
use Symfony\Component\Finder\SplFileInfo;
910

@@ -18,11 +19,9 @@ public function resolveInstructionsFromFeatureFiles(array $featureFileInfos): ar
1819
$instructions = [];
1920

2021
foreach ($featureFileInfos as $featureFileInfo) {
21-
preg_match_all(
22-
'#\s+(Given|When|And|Then)\s+(?<instruction>.*?)\n#m',
22+
$matches = Strings::matchAll(
2323
$featureFileInfo->getContents(),
24-
$matches,
25-
PREG_SET_ORDER
24+
'#\s+(Given|When|And|Then)\s+(?<instruction>.*?)\n#m',
2625
);
2726

2827
if ($matches === []) {

0 commit comments

Comments
 (0)