Skip to content

Commit a1d0ed5

Browse files
minor #47016 Improve some PHPdocs based on existing Symfony stubs in PHPstan and Psalm (mdeboer, wouterj)
This PR was merged into the 6.2 branch. Discussion ---------- Improve some PHPdocs based on existing Symfony stubs in PHPstan and Psalm | Q | A | ------------- | --- | Branch? | 6.2 | Bug fix? | no | New feature? | no | Deprecations? | no (strictly spoken yes, as I guess DebugClassLoader will trigger deprecations for some now?) | Tickets | Replaces #40783 | License | MIT | Doc PR | symfony/symfony-docs#17064 Todo --- * [x] Review the Psalm check of this PR * [x] Test the changes with DebugClassLoader in a real app Description --- This PR adds some more information to the PHPdoc of Symfony classes. By moving the information from the current stubs of static analyzers into Symfony itself: (1) we can improve the experience for all users, (2) reduce false-positives from our own Psalm check and (3) make sure they are in sync with changes done on these classes. <s>To avoid a PR that is too big to review and maintain, the scope of this PR is deliberately kept narrow: * Only PHPdoc from either [Psalm's Symfony stubs](https://github.com/psalm/psalm-plugin-symfony/tree/master/src/Stubs) or [PHPStan's Symfony stubs](https://github.com/phpstan/phpstan-symfony/tree/1.2.x/stubs) is added * The PHPdoc MUST NOT break PHPstorm * The PHPdoc MUST be supported by both PHPstan and Psalm (those are the only two static analyzers that currently ship an official Symfony plugin afaik) * The PHPdoc SHOULD NOT duplicate anything that can already be deduced from either PHP's type declarations or already existing PHPdoc. * The PHPdoc MUST document the contract and NOT be added to fit a 95% use-case or improve auto-completion.</s> EDIT: Replaced the guidelines by symfony/symfony-docs#17064 On top of this, to get this PR approved quicker, I've left out all stubs from the Form (based on the discussions in #40783) and most of [PHPStan's `Envelope` stub](https://github.com/psalm/psalm-plugin-symfony/blob/master/src/Stubs/common/Component/Messenger/Envelope.stubphp) (due to complexity of the PHPdoc). Commits ------- f5a802ab85 [DependencyInjection] Add nice exception when using non-scalar parameter as array key fa7703ba4a [ErrorHandler] Do not patch return types that are not a valid PHP type 38ab6de900 Improve some PHPdocs based on existing Symfony stubs in PHPstan and Psalm
2 parents 0ed8bc9 + 2451597 commit a1d0ed5

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

Envelope.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
final class Envelope
2222
{
2323
/**
24-
* @var array<string, list<StampInterface>>
24+
* @var array<class-string<StampInterface>, list<StampInterface>>
2525
*/
2626
private array $stamps = [];
2727
private object $message;
@@ -106,7 +106,13 @@ public function last(string $stampFqcn): ?StampInterface
106106
}
107107

108108
/**
109+
* @template TStamp of StampInterface
110+
*
111+
* @param class-string<TStamp>|null $stampFqcn
112+
*
109113
* @return StampInterface[]|StampInterface[][] The stamps for the specified FQCN, or all stamps by their class name
114+
*
115+
* @psalm-return ($stampFqcn is string : array<class-string<StampInterface>, list<StampInterface>> ? list<TStamp>)
110116
*/
111117
public function all(string $stampFqcn = null): array
112118
{

0 commit comments

Comments
 (0)