Skip to content

Commit c39dd8b

Browse files
author
Guillaume Chehami
committed
ref#184 checking if class implements Symfony\Component\Form\FormTypeInterface instead of checking the classname to determinate if the class is a form
1 parent 5924447 commit c39dd8b

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

src/Visitor/Php/Symfony/FormTrait.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,12 @@ trait FormTrait
2323
*/
2424
private function isFormType(Node $node): bool
2525
{
26-
// only Traverse *Type
26+
// isFormType true if it implements FormTypeInterface
2727
if ($node instanceof Stmt\Class_) {
28-
$this->isFormType = 'Type' === substr($node->name, -4);
28+
$this->isFormType = in_array(
29+
'Symfony\Component\Form\FormTypeInterface',
30+
array_map(fn($interface) => $interface->toString(), $node->implements ?? [])
31+
);
2932
}
3033

3134
return $this->isFormType;

0 commit comments

Comments
 (0)