Skip to content

Baseline the shopware throws.void error from illegal array offsets - #15470

Open
gnutix wants to merge 1 commit into
phpstan:2.3.xfrom
gnutix:shopware-throws-void-typeerror
Open

gnutix wants to merge 1 commit into
phpstan:2.3.xfrom
gnutix:shopware-throws-void-typeerror

Conversation

@gnutix

@gnutix gnutix commented Oct 12, 2026

Copy link
Copy Markdown

Companion to phpstan/phpstan-src#5977, which models the TypeError PHP 8 throws when an array or object is used as an array key.

The shopware integration test then reports one new error, a true positive:

tests/integration/Core/Content/Seo/SeoUrlGeneratorTest.php:375
Method Psr\Log\AbstractLogger@anonymous/tests/integration/Core/Content/Seo/SeoUrlGeneratorTest.php:361::log() throws exception TypeError but the PHPDoc contains @throws void.
🪪 throws.void

The anonymous logger declares @throws void but does $this->logs[$level][$message][] = $context; with string|\Stringable $message, and a Stringable key throws TypeError ("Cannot access offset of type Stringable@anonymous on array").

This only makes sense together with phpstan-src#5977: merge both or neither.

🤖 Generated with Claude Code

https://claude.ai/code/session_01QW8VaDtn3cMdQowPSh1xGG

phpstan/phpstan-src#5977 models the TypeError PHP 8 throws for an
illegal array key. Shopware's SeoUrlGeneratorTest logger declares
@throws void but writes $this->logs[$level][$message][] with a
string|Stringable key, and a Stringable key throws. A true positive.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QW8VaDtn3cMdQowPSh1xGG
@VincentLanglet

Copy link
Copy Markdown
Contributor

level is typed as int|string so there should be no type error given the fact phpdoc is trusted
https://github.com/shopware/shopware/blob/061e131a2dffff2207bcc4585b1b3e090205304e/tests/integration/Core/Content/Seo/SeoUrlGeneratorTest.php#L368

@gnutix

gnutix commented Oct 13, 2026

Copy link
Copy Markdown
Author

level is typed as int|string so there should be no type error given the fact phpdoc is trusted shopware/shopware@061e131/tests/integration/Core/Content/Seo/SeoUrlGeneratorTest.php#L368

I agree that $level is fine ; the TypeError comes from the second dimension: $message is natively string|\Stringable, and a Stringable object as an array key throws (Cannot access offset of type Stringable@anonymous on array, PHP 8.0+). So @throws void is wrong for that method whenever a Stringable message is logged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants