Skip to content

Commit

Permalink
better support for app
Browse files Browse the repository at this point in the history
  • Loading branch information
QuentinGab committed Aug 18, 2024
1 parent 752a69f commit e29a373
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Services/SearchCode/PhpParserService.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public static function scanCode(string $code): array
$node->var instanceof FuncCall &&
static::isFunCallTo($node->var, 'app', 'abstract', 0, 'translator')
) {
return in_array($node->name->name, ['get']);
return in_array($node->name->name, ['get', 'has', 'hasForLocale', 'choice']);
}

if ($node instanceof StaticCall && $node->class->name === Lang::class) {
Expand Down
4 changes: 4 additions & 0 deletions tests/Unit/PhpParserServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
"<?php \Illuminate\Support\Facades\Lang::has(key: 'messages.dummy.class');",
"<?php \Illuminate\Support\Facades\Lang::hasForLocale(key: 'messages.dummy.class');",
"<?php \Illuminate\Support\Facades\Lang::choice(key: 'messages.dummy.class');",
"<?php app('translator')->get('messages.dummy.class');",
"<?php app('translator')->has('messages.dummy.class');",
"<?php app('translator')->hasForLocale('messages.dummy.class');",
"<?php app('translator')->choice('messages.dummy.class');",
]);

it('finds all occurences of __ in blade code', function (string $code) {
Expand Down

0 comments on commit e29a373

Please sign in to comment.