Skip to content

Commit 67cd76f

Browse files
authored
Merge pull request #808 from frankbv/0.13-php8
Fix 0.13 calling preg_replace_callback with a NULL argument in PHP 8
2 parents ab14d1e + f66613b commit 67cd76f

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

lib/generator/src/ClassUtils.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ public static function shortenClassName($definition)
2929

3030
public static function shortenClassFromCode($code, callable $callback = null)
3131
{
32+
if (null === $code) {
33+
return '';
34+
}
35+
3236
if (null === $callback) {
3337
$callback = function ($matches) {
3438
return static::shortenClassName($matches[1]);

lib/generator/tests/ClassUtilsTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ public function shortenClassFromCodeDataProvider(): iterable
3333
return [
3434
['$toto, \Toto\Tata $test', '$toto, Tata $test'],
3535
['\Tata $test', 'Tata $test'],
36+
[null, ''],
3637
];
3738
}
3839
}

0 commit comments

Comments
 (0)