Repository navigation
fix(docblock): @implements naming another interface reports the same message with or without type arguments - #14650
Conversation
…message with or without type arguments vimeo#6096 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Behaviour change (messages only; the issue type and location stay
|
✅ Performance: unchanged · Types: unchanged
How to read this table
✅ symfony: issues +2 −2Memory 3 596 → 3 596 MB (+0.0 %) · Wall 263.4 → 267.4 s (+1.5 %)
Changed in place (2) @@ 2 places InvalidDocblock @@
src/Symfony/Component/Form/Flow/FormFlow.php:29
src/Symfony/Component/Form/Flow/FormFlowBuilder.php:30
- …must include the name of an implemented class, got IteratorAggregate<string, FormInterface…
+ …must include the name of an implemented interface, got IteratorAggregate<string, FormInterface…✅ tempest: issues +2 −2Memory 895 → 895 MB (+0.0 %) · Wall 36.9 → 36.5 s (−1.2 %)
Changed in place (1) @@ packages/support/src/Arr/ManipulatesArray.php:24 InvalidDocblock @@
- …must include the name of an implemented class, got ArrayAccess<TKey:ManipulatesArray as array-key, TValue…
- …must include the name of an implemented class, got Iterator<TKey:ManipulatesArray as array-key, TValue…
+ …must include the name of an implemented interface, got ArrayAccess<TKey:ManipulatesArray as array-key, TValue…
+ …must include the name of an implemented interface, got Iterator<TKey:ManipulatesArray as array-key, TValue…head c8bf6b7 · base 9028ade (merge-base) · workflow run |
orklah
left a comment
There was a problem hiding this comment.
Thanks! The unified message is right, and the tests show it.
One thing to change: TGenericObject extends TNamedObject, so the new check at the top of the loop also catches generic types, and the existing if (!isset($related_classes[$generic_class_lc])) block further down can no longer be reached. The same message is now built in two places. Instead of adding a check, could you move the existing one above the TGenericObject check?
foreach ($union_type->getAtomicTypes() as $atomic_type) {
if ($atomic_type instanceof TNamedObject
&& !isset($related_classes[strtolower($atomic_type->value)])
) {
$storage->docblock_issues[] = new InvalidDocblock(
$tag . ' must include the name of ' . $related_name . ', got ' . $atomic_type->getId(),
new CodeLocation($this->file_scanner, $node, null, true),
);
continue;
}
if (!$atomic_type instanceof TGenericObject) {
// has invalid class ...
continue;
}
$generic_class_lc = strtolower($atomic_type->value);
if ($this->reportStarArgument($storage, $node, $atomic_type, $tag)) {(the comment above the check can go too). Could you also add the no-argument cases for the other two tags, which take the same path?
'useTagNamingAnotherTraitWithoutTypeArguments' => [
'code' => '<?php
/** @template T */
trait T1 {}
trait T2 {}
final class C {
/** @use T2 */
use T1;
}',
'error_message' => '@template-use must include the name of a used trait, got T2',
],
'extendsTagNamingAnotherClassWithoutTypeArguments' => [
'code' => '<?php
/** @template T */
class P {}
final class Q {}
/** @extends Q */
final class C extends P {}',
'error_message' => '@template-extends must include the name of an extended class, got Q',
],…meo#6096 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@implementsnaming an interface the class doesn't implement reports a misleadinghas invalid classwhen the interface has no type arguments, and the message for the generic case calls the interface a class (@use: "an used class").Before
After
Fixes #6096