Skip to content

Commit 67a32d7

Browse files
staabmclxmstaab
andauthored
Use more precise phpdoc (#6)
Co-authored-by: Markus Staab <[email protected]>
1 parent ad25595 commit 67a32d7

File tree

7 files changed

+25
-25
lines changed

7 files changed

+25
-25
lines changed

src/MatchAllResult.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ final class MatchAllResult
2323

2424
/**
2525
* @readonly
26-
* @var int
26+
* @var 0|positive-int
2727
*/
2828
public $count;
2929

@@ -34,7 +34,7 @@ final class MatchAllResult
3434
public $matched;
3535

3636
/**
37-
* @param int $count
37+
* @param 0|positive-int $count
3838
* @param array<array<string|null>> $matches
3939
*/
4040
public function __construct($count, array $matches)

src/MatchAllWithOffsetsResult.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ final class MatchAllWithOffsetsResult
2424

2525
/**
2626
* @readonly
27-
* @var int
27+
* @var 0|positive-int
2828
*/
2929
public $count;
3030

@@ -35,7 +35,7 @@ final class MatchAllWithOffsetsResult
3535
public $matched;
3636

3737
/**
38-
* @param int $count
38+
* @param 0|positive-int $count
3939
* @param array<int|string, list<array{string|null, int}>> $matches
4040
* @phpstan-param array<int|string, list<array{string|null, int<-1, max>}>> $matches
4141
*/

src/MatchResult.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ final class MatchResult
2828
public $matched;
2929

3030
/**
31-
* @param int $count
31+
* @param 0|positive-int $count
3232
* @param array<string|null> $matches
3333
*/
3434
public function __construct($count, array $matches)

src/MatchWithOffsetsResult.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ final class MatchWithOffsetsResult
2929
public $matched;
3030

3131
/**
32-
* @param int $count
32+
* @param 0|positive-int $count
3333
* @param array<array{string|null, int}> $matches
3434
* @phpstan-param array<int|string, array{string|null, int<-1, max>}> $matches
3535
*/

src/Preg.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ class Preg
1616
const ARRAY_MSG = '$subject as an array is not supported. You can use \'foreach\' instead.';
1717

1818
/**
19-
* @param string $pattern
19+
* @param non-empty-string $pattern
2020
* @param string $subject
2121
* @param array<string|null> $matches Set by method
2222
* @param int $flags PREG_UNMATCHED_AS_NULL, only available on PHP 7.2+
2323
* @param int $offset
24-
* @return int
24+
* @return 0|1
2525
*/
2626
public static function match($pattern, $subject, &$matches = null, $flags = 0, $offset = 0)
2727
{
@@ -40,12 +40,12 @@ public static function match($pattern, $subject, &$matches = null, $flags = 0, $
4040
/**
4141
* Runs preg_match with PREG_OFFSET_CAPTURE
4242
*
43-
* @param string $pattern
43+
* @param non-empty-string $pattern
4444
* @param string $subject
4545
* @param array<int|string, array{string|null, int}> $matches Set by method
4646
* @param int $flags PREG_UNMATCHED_AS_NULL, only available on PHP 7.2+
4747
* @param int $offset
48-
* @return int
48+
* @return 0|1
4949
*
5050
* @phpstan-param array<int|string, array{string|null, int<-1, max>}> $matches
5151
*/
@@ -60,12 +60,12 @@ public static function matchWithOffsets($pattern, $subject, &$matches, $flags =
6060
}
6161

6262
/**
63-
* @param string $pattern
63+
* @param non-empty-string $pattern
6464
* @param string $subject
6565
* @param array<int|string, list<string|null>> $matches Set by method
6666
* @param int $flags PREG_UNMATCHED_AS_NULL, only available on PHP 7.2+
6767
* @param int $offset
68-
* @return int
68+
* @return 0|positive-int
6969
*/
7070
public static function matchAll($pattern, $subject, &$matches = null, $flags = 0, $offset = 0)
7171
{
@@ -88,12 +88,12 @@ public static function matchAll($pattern, $subject, &$matches = null, $flags = 0
8888
/**
8989
* Runs preg_match_all with PREG_OFFSET_CAPTURE
9090
*
91-
* @param string $pattern
91+
* @param non-empty-string $pattern
9292
* @param string $subject
9393
* @param array<int|string, list<array{string|null, int}>> $matches Set by method
9494
* @param int $flags PREG_UNMATCHED_AS_NULL, only available on PHP 7.2+
9595
* @param int $offset
96-
* @return int
96+
* @return 0|positive-int
9797
*
9898
* @phpstan-param array<int|string, list<array{string|null, int<-1, max>}>> $matches
9999
*/
@@ -242,7 +242,7 @@ public static function grep($pattern, array $array, $flags = 0)
242242
}
243243

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

257257
/**
258-
* @param string $pattern
258+
* @param non-empty-string $pattern
259259
* @param string $subject
260260
* @param array<int|string, list<string|null>> $matches Set by method
261261
* @param int $flags PREG_UNMATCHED_AS_NULL, only available on PHP 7.2+
@@ -270,7 +270,7 @@ public static function isMatchAll($pattern, $subject, &$matches = null, $flags =
270270
/**
271271
* Runs preg_match with PREG_OFFSET_CAPTURE
272272
*
273-
* @param string $pattern
273+
* @param non-empty-string $pattern
274274
* @param string $subject
275275
* @param array<int|string, array{string|null, int}> $matches Set by method
276276
* @param int $flags PREG_UNMATCHED_AS_NULL, only available on PHP 7.2+
@@ -287,7 +287,7 @@ public static function isMatchWithOffsets($pattern, $subject, &$matches, $flags
287287
/**
288288
* Runs preg_match_all with PREG_OFFSET_CAPTURE
289289
*
290-
* @param string $pattern
290+
* @param non-empty-string $pattern
291291
* @param string $subject
292292
* @param array<int|string, list<array{string|null, int}>> $matches Set by method
293293
* @param int $flags PREG_UNMATCHED_AS_NULL, only available on PHP 7.2+

src/Regex.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
class Regex
1515
{
1616
/**
17-
* @param string $pattern
17+
* @param non-empty-string $pattern
1818
* @param string $subject
1919
* @param int $offset
2020
* @return bool
@@ -25,7 +25,7 @@ public static function isMatch($pattern, $subject, $offset = 0)
2525
}
2626

2727
/**
28-
* @param string $pattern
28+
* @param non-empty-string $pattern
2929
* @param string $subject
3030
* @param int $flags PREG_UNMATCHED_AS_NULL, only available on PHP 7.2+
3131
* @param int $offset
@@ -45,7 +45,7 @@ public static function match($pattern, $subject, $flags = 0, $offset = 0)
4545
/**
4646
* Runs preg_match with PREG_OFFSET_CAPTURE
4747
*
48-
* @param string $pattern
48+
* @param non-empty-string $pattern
4949
* @param string $subject
5050
* @param int $flags PREG_UNMATCHED_AS_NULL, only available on PHP 7.2+
5151
* @param int $offset
@@ -59,7 +59,7 @@ public static function matchWithOffsets($pattern, $subject, $flags = 0, $offset
5959
}
6060

6161
/**
62-
* @param string $pattern
62+
* @param non-empty-string $pattern
6363
* @param string $subject
6464
* @param int $flags PREG_UNMATCHED_AS_NULL, only available on PHP 7.2+
6565
* @param int $offset
@@ -83,7 +83,7 @@ public static function matchAll($pattern, $subject, $flags = 0, $offset = 0)
8383
/**
8484
* Runs preg_match_all with PREG_OFFSET_CAPTURE
8585
*
86-
* @param string $pattern
86+
* @param non-empty-string $pattern
8787
* @param string $subject
8888
* @param int $flags PREG_UNMATCHED_AS_NULL, only available on PHP 7.2+
8989
* @param int $offset

src/ReplaceResult.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ final class ReplaceResult
2121

2222
/**
2323
* @readonly
24-
* @var int
24+
* @var 0|positive-int
2525
*/
2626
public $count;
2727

@@ -32,7 +32,7 @@ final class ReplaceResult
3232
public $matched;
3333

3434
/**
35-
* @param int $count
35+
* @param 0|positive-int $count
3636
* @param string $result
3737
*/
3838
public function __construct($count, $result)

0 commit comments

Comments
 (0)