You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Because of this, Strings::split() also returns delimiters in the result set in cases where regexp contains subpatterns. Therefore, the Rector’s recommendation is incorrect, because in these cases method Strings::split() returns a different data set in the array.
The text was updated successfully, but these errors were encountered:
$content = 'Hi my name is Tom';
$pattern = '#(\s)#'; // '#\s#' works fine, without "()"$nativePieces = preg_split($pattern, $content);
var_dump($nativePieces);
$utilsPieces = \Nette\Utils\Strings::split($content, $pattern);
var_dump($utilsPieces);
// should be truevar_dump($nativePieces === $utilsPieces);
dev-master@225f873
PHP 7.3.11
vendor/bin/rector process src tests --config rector-ci.yaml --dry-run
Current Behaviour
Source: https://travis-ci.org/cpliakas/git-wrapper/jobs/615485754#L322-L353
What is the problem
Nette Utils uses flag
PREG_SPLIT_DELIM_CAPTURE
by default when splitting lines:https://github.com/nette/utils/blob/f1dc08536b040d5b569ee63354343145cbe6c591/src/Utils/Strings.php#L435
Because of this, Strings::split() also returns delimiters in the result set in cases where regexp contains subpatterns. Therefore, the Rector’s recommendation is incorrect, because in these cases method
Strings::split()
returns a different data set in the array.The text was updated successfully, but these errors were encountered: