Skip to content

feat: return arrays in enforce methods #46

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 28, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Preg.php
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@
throw PcreException::fromFunction('preg_split', $pattern);
}

return $result;

Check failure on line 255 in src/Preg.php

View workflow job for this annotation

GitHub Actions / PHPStan (7.4)

Method Composer\Pcre\Preg::split() should return list<string> but returns list<array{string, int<0, max>}|string>.

Check failure on line 255 in src/Preg.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.3)

Method Composer\Pcre\Preg::split() should return list<string> but returns list<array{string, int<0, max>}|string>.
}

/**
Expand Down Expand Up @@ -395,7 +395,7 @@
* @return array<int|string, string>
* @throws UnexpectedNullMatchException
*/
private static function enforceNonNullMatches(string $pattern, array $matches, string $variantMethod)
private static function enforceNonNullMatches(string $pattern, array $matches, string $variantMethod): array
{
foreach ($matches as $group => $match) {
if (is_string($match) || (is_array($match) && is_string($match[0]))) {
Expand All @@ -414,7 +414,7 @@
* @return array<int|string, list<string>>
* @throws UnexpectedNullMatchException
*/
private static function enforceNonNullMatchAll(string $pattern, array $matches, string $variantMethod)
private static function enforceNonNullMatchAll(string $pattern, array $matches, string $variantMethod): array
{
foreach ($matches as $group => $groupMatches) {
foreach ($groupMatches as $match) {
Expand Down
Loading