Skip to content

Commit 90df969

Browse files
noofaqNyholm
authored andcommitted
Fatal Error from FormTypeImplicit when using method call from variable (#105)
* Issue #104 : calling method contained in variable (in Form context) causes parsing process to raise "Catchable Fatal Error: Object of class PhpParser\Node\Expr\Variable could not be converted to string" * Issue #104 : code style fix * Issue #104 : code style fix * changes requested by @Nyholm during review
1 parent 565f243 commit 90df969

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

Changelog.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ The change log describes what is "Added", "Removed", "Changed" or "Fixed" betwee
44

55
## UNRELEASED
66

7+
## 1.5.2
8+
9+
### Fixed
10+
11+
- Fixed Fatal Error in FormTypeImplicit when using method call from variable
12+
713
## 1.5.1
814

915
### Fixed

src/Visitor/Php/Symfony/FormTypeLabelImplicit.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ public function enterNode(Node $node)
3232
$domain = null;
3333
// use add() function and look at first argument and if that's a string
3434
if ($node instanceof Node\Expr\MethodCall
35+
&& (!is_object($node->name) || method_exists($node->name, '__toString'))
3536
&& ('add' === (string) $node->name || 'create' === (string) $node->name)
3637
&& $node->args[0]->value instanceof Node\Scalar\String_) {
3738
$skipLabel = false;
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
namespace Translation\Extractor\Tests\Resources\Php\Symfony;
4+
5+
class Issue104Type
6+
{
7+
public function buildForm(FormBuilderInterface $builder, array $options)
8+
{
9+
$model = new \stdClass();
10+
$setter = 'setMethod';
11+
$model->$setter(null);
12+
}
13+
}

0 commit comments

Comments
 (0)