Skip to content

Commit edc9939

Browse files
Document assumption that $length ist an integer
1 parent e13f929 commit edc9939

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/Framework/Constraint/Constraint.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
*/
1010
namespace PHPUnit\Framework\Constraint;
1111

12+
use function assert;
1213
use function gettype;
14+
use function is_int;
1315
use function is_object;
1416
use function sprintf;
1517
use function str_replace;
@@ -246,7 +248,12 @@ protected function valueToTypeStringFragment(mixed $value): string
246248

247249
if ($reflector->isAnonymous()) {
248250
$name = str_replace('class@anonymous', '', $reflector->getName());
249-
$name = substr($name, 0, strpos($name, '$'));
251+
252+
$length = strpos($name, '$');
253+
254+
assert(is_int($length));
255+
256+
$name = substr($name, 0, $length);
250257

251258
return 'an instance of anonymous class created at ' . $name . ' ';
252259
}

0 commit comments

Comments
 (0)