Skip to content
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

use more precise phpdoc #6

Merged
merged 8 commits into from
Jan 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/MatchAllResult.php
Expand Up @@ -23,7 +23,7 @@ final class MatchAllResult

/**
* @readonly
* @var int
* @var 0|positive-int
*/
public $count;

Expand All @@ -34,7 +34,7 @@ final class MatchAllResult
public $matched;

/**
* @param int $count
* @param 0|positive-int $count
* @param array<array<string|null>> $matches
*/
public function __construct($count, array $matches)
Expand Down
4 changes: 2 additions & 2 deletions src/MatchAllWithOffsetsResult.php
Expand Up @@ -24,7 +24,7 @@ final class MatchAllWithOffsetsResult

/**
* @readonly
* @var int
* @var 0|positive-int
*/
public $count;

Expand All @@ -35,7 +35,7 @@ final class MatchAllWithOffsetsResult
public $matched;

/**
* @param int $count
* @param 0|positive-int $count
* @param array<int|string, list<array{string|null, int}>> $matches
* @phpstan-param array<int|string, list<array{string|null, int<-1, max>}>> $matches
*/
Expand Down
2 changes: 1 addition & 1 deletion src/MatchResult.php
Expand Up @@ -28,7 +28,7 @@ final class MatchResult
public $matched;

/**
* @param int $count
* @param 0|positive-int $count
* @param array<string|null> $matches
*/
public function __construct($count, array $matches)
Expand Down
2 changes: 1 addition & 1 deletion src/MatchWithOffsetsResult.php
Expand Up @@ -29,7 +29,7 @@ final class MatchWithOffsetsResult
public $matched;

/**
* @param int $count
* @param 0|positive-int $count
* @param array<array{string|null, int}> $matches
* @phpstan-param array<int|string, array{string|null, int<-1, max>}> $matches
*/
Expand Down
24 changes: 12 additions & 12 deletions src/Preg.php
Expand Up @@ -16,12 +16,12 @@ class Preg
const ARRAY_MSG = '$subject as an array is not supported. You can use \'foreach\' instead.';

/**
* @param string $pattern
* @param non-empty-string $pattern
* @param string $subject
* @param array<string|null> $matches Set by method
* @param int $flags PREG_UNMATCHED_AS_NULL, only available on PHP 7.2+
* @param int $offset
* @return int
* @return 0|1
*/
public static function match($pattern, $subject, &$matches = null, $flags = 0, $offset = 0)
{
Expand All @@ -40,12 +40,12 @@ public static function match($pattern, $subject, &$matches = null, $flags = 0, $
/**
* Runs preg_match with PREG_OFFSET_CAPTURE
*
* @param string $pattern
* @param non-empty-string $pattern
* @param string $subject
* @param array<int|string, array{string|null, int}> $matches Set by method
* @param int $flags PREG_UNMATCHED_AS_NULL, only available on PHP 7.2+
* @param int $offset
* @return int
* @return 0|1
*
* @phpstan-param array<int|string, array{string|null, int<-1, max>}> $matches
*/
Expand All @@ -60,12 +60,12 @@ public static function matchWithOffsets($pattern, $subject, &$matches, $flags =
}

/**
* @param string $pattern
* @param non-empty-string $pattern
* @param string $subject
* @param array<int|string, list<string|null>> $matches Set by method
* @param int $flags PREG_UNMATCHED_AS_NULL, only available on PHP 7.2+
* @param int $offset
* @return int
* @return 0|positive-int
*/
public static function matchAll($pattern, $subject, &$matches = null, $flags = 0, $offset = 0)
{
Expand All @@ -88,12 +88,12 @@ public static function matchAll($pattern, $subject, &$matches = null, $flags = 0
/**
* Runs preg_match_all with PREG_OFFSET_CAPTURE
*
* @param string $pattern
* @param non-empty-string $pattern
* @param string $subject
* @param array<int|string, list<array{string|null, int}>> $matches Set by method
* @param int $flags PREG_UNMATCHED_AS_NULL, only available on PHP 7.2+
* @param int $offset
* @return int
* @return 0|positive-int
*
* @phpstan-param array<int|string, list<array{string|null, int<-1, max>}>> $matches
*/
Expand Down Expand Up @@ -242,7 +242,7 @@ public static function grep($pattern, array $array, $flags = 0)
}

/**
* @param string $pattern
* @param non-empty-string $pattern
* @param string $subject
* @param array<string|null> $matches Set by method
* @param int $flags PREG_UNMATCHED_AS_NULL, only available on PHP 7.2+
Expand All @@ -255,7 +255,7 @@ public static function isMatch($pattern, $subject, &$matches = null, $flags = 0,
}

/**
* @param string $pattern
* @param non-empty-string $pattern
* @param string $subject
* @param array<int|string, list<string|null>> $matches Set by method
* @param int $flags PREG_UNMATCHED_AS_NULL, only available on PHP 7.2+
Expand All @@ -270,7 +270,7 @@ public static function isMatchAll($pattern, $subject, &$matches = null, $flags =
/**
* Runs preg_match with PREG_OFFSET_CAPTURE
*
* @param string $pattern
* @param non-empty-string $pattern
* @param string $subject
* @param array<int|string, array{string|null, int}> $matches Set by method
* @param int $flags PREG_UNMATCHED_AS_NULL, only available on PHP 7.2+
Expand All @@ -287,7 +287,7 @@ public static function isMatchWithOffsets($pattern, $subject, &$matches, $flags
/**
* Runs preg_match_all with PREG_OFFSET_CAPTURE
*
* @param string $pattern
* @param non-empty-string $pattern
* @param string $subject
* @param array<int|string, list<array{string|null, int}>> $matches Set by method
* @param int $flags PREG_UNMATCHED_AS_NULL, only available on PHP 7.2+
Expand Down
10 changes: 5 additions & 5 deletions src/Regex.php
Expand Up @@ -14,7 +14,7 @@
class Regex
{
/**
* @param string $pattern
* @param non-empty-string $pattern
* @param string $subject
* @param int $offset
* @return bool
Expand All @@ -25,7 +25,7 @@ public static function isMatch($pattern, $subject, $offset = 0)
}

/**
* @param string $pattern
* @param non-empty-string $pattern
* @param string $subject
* @param int $flags PREG_UNMATCHED_AS_NULL, only available on PHP 7.2+
* @param int $offset
Expand All @@ -45,7 +45,7 @@ public static function match($pattern, $subject, $flags = 0, $offset = 0)
/**
* Runs preg_match with PREG_OFFSET_CAPTURE
*
* @param string $pattern
* @param non-empty-string $pattern
* @param string $subject
* @param int $flags PREG_UNMATCHED_AS_NULL, only available on PHP 7.2+
* @param int $offset
Expand All @@ -59,7 +59,7 @@ public static function matchWithOffsets($pattern, $subject, $flags = 0, $offset
}

/**
* @param string $pattern
* @param non-empty-string $pattern
* @param string $subject
* @param int $flags PREG_UNMATCHED_AS_NULL, only available on PHP 7.2+
* @param int $offset
Expand All @@ -83,7 +83,7 @@ public static function matchAll($pattern, $subject, $flags = 0, $offset = 0)
/**
* Runs preg_match_all with PREG_OFFSET_CAPTURE
*
* @param string $pattern
* @param non-empty-string $pattern
* @param string $subject
* @param int $flags PREG_UNMATCHED_AS_NULL, only available on PHP 7.2+
* @param int $offset
Expand Down
4 changes: 2 additions & 2 deletions src/ReplaceResult.php
Expand Up @@ -21,7 +21,7 @@ final class ReplaceResult

/**
* @readonly
* @var int
* @var 0|positive-int
*/
public $count;

Expand All @@ -32,7 +32,7 @@ final class ReplaceResult
public $matched;

/**
* @param int $count
* @param 0|positive-int $count
* @param string $result
*/
public function __construct($count, $result)
Expand Down