Skip to content

Commit

Permalink
Fix g11n code extraction using short array syntax.
Browse files Browse the repository at this point in the history
  • Loading branch information
mariuswilms committed Jun 23, 2016
1 parent da58ca8 commit c84e7ac
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
- Calculation queries returning no results at all, do not error out, but
return `null` now.

- Extraction of translation tokens using context together with short array syntax
is now fully supported.

## v1.0.0

(This includes changes from 1.0.0-beta on only.)
Expand Down
8 changes: 4 additions & 4 deletions g11n/catalog/adapter/Code.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,14 +139,14 @@ protected function _parsePhp($file) {
if (!is_array($token)) {
$token = array(0 => null, 1 => $token, 2 => null);
}
if ($token[1] === '(') {
if ($token[1] === '[' || $token[1] === '(') {
$open++;
} elseif ($token[1] === ')' && --$open === 0) {
} elseif (($token[1] === ']' || $token[1] === ')') && --$open === 0) {
break;
}
if ($token[0] === T_ARRAY || $token[1] === '[') {
if ($token[1] === '[' || $token[0] === T_ARRAY) {
$depth++;
} elseif ($depth > 1 && ($token[1] === ')' || $token[1] === ']')) {
} elseif ($depth > 1 && ($token[1] === ']' || $token[1] === ')')) {
$depth--;
}
if ($depth === 1 && $open === 2) {
Expand Down

0 comments on commit c84e7ac

Please sign in to comment.