Skip to content

Commit

Permalink
Prevent crash when getting callerName (#120)
Browse files Browse the repository at this point in the history
* Prevent crash when getting callerName

* Code cleanup

* Added change log
  • Loading branch information
marcw authored and Nyholm committed Jul 9, 2018
1 parent 795676d commit 82fc51a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ The change log describes what is "Added", "Removed", "Changed" or "Fixed" betwee

## UNRELEASED

## 1.7.1

### Fixed

- Error when getting caller name with the `FlashMessage` extractor.

## 1.7.0

### Added
Expand Down
6 changes: 6 additions & 0 deletions src/Visitor/Php/Symfony/FlashMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ public function enterNode(Node $node)
}

$name = (string) $node->name;

// This prevents dealing with some fatal edge cases when getting the callerName
if (!in_array($name, ['addFlash', 'add'])) {
return;
}

$caller = $node->var;
// $caller might be "Node\Expr\New_"
$callerName = isset($caller->name) ? (string) $caller->name : '';
Expand Down

0 comments on commit 82fc51a

Please sign in to comment.