From 67d330993f07c7cd9c9a5afe13a30aede812e4ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20B=C3=BCrk?= Date: Wed, 26 Nov 2025 17:42:05 +0100 Subject: [PATCH] [BUGFIX] Mitigate "Using null as an array offset is deprecated" Using `DocBlockFactory->create()` with a phpdocblock hanging a `@throws` tag followed by a exception class name emits following PHP 8.5.0 deprecation: ``` Using null as an array offset is deprecated, use an empty string instead ``` in `StandardTagFactory->getArgumentsForParametersFromWiring()`. This change uses the null-coalsce operator to fallback to an empty string for the value which should be used as an array key instead of using `null` to mitigate the deprecation notice with PHP8.5.0 and matches the behaviour in earlier PHP versions without the deprecation message. --- src/DocBlock/StandardTagFactory.php | 4 ++-- tests/unit/DocBlock/StandardTagFactoryTest.php | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/DocBlock/StandardTagFactory.php b/src/DocBlock/StandardTagFactory.php index d029cd1b..e580ef6a 100644 --- a/src/DocBlock/StandardTagFactory.php +++ b/src/DocBlock/StandardTagFactory.php @@ -282,8 +282,8 @@ private function getArgumentsForParametersFromWiring(array $parameters, array $l } $parameterName = $parameter->getName(); - if (isset($locator[$typeHint])) { - $arguments[$parameterName] = $locator[$typeHint]; + if (isset($locator[$typeHint ?? ''])) { + $arguments[$parameterName] = $locator[$typeHint ?? '']; continue; } diff --git a/tests/unit/DocBlock/StandardTagFactoryTest.php b/tests/unit/DocBlock/StandardTagFactoryTest.php index 8dfced71..a75f5e64 100644 --- a/tests/unit/DocBlock/StandardTagFactoryTest.php +++ b/tests/unit/DocBlock/StandardTagFactoryTest.php @@ -525,6 +525,11 @@ public function validTagProvider(): array 'tag', '@tag (is valid)', ], + 'full-qualified-class-name following a tag name is valid' => [ + '@tag \InvalidArgumentException', + 'tag', + '@tag \InvalidArgumentException', + ], ]; }