Skip to content

Commit

Permalink
Use more precise phpdoc (#6)
Browse files Browse the repository at this point in the history
Co-authored-by: Markus Staab <m.staab@complex-it.de>
  • Loading branch information
staabm and clxmstaab committed Jan 21, 2022
1 parent ad25595 commit 67a32d7
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 25 deletions.
4 changes: 2 additions & 2 deletions src/MatchAllResult.php
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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

0 comments on commit 67a32d7

Please sign in to comment.