Skip to content

Commit

Permalink
[PHP] Fix function calls with array identifiers (#3937)
Browse files Browse the repository at this point in the history
  • Loading branch information
deathaxe authored Mar 1, 2024
1 parent 8216ae0 commit bb57a3a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
4 changes: 3 additions & 1 deletion PHP/PHP Source.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -1626,14 +1626,15 @@ contexts:
- function-call-identifier
- unqualified-function-name
# Function invocation with function name as variable
- match: ((\$+){{identifier}})\s*(?=\()
- match: ((\$+){{identifier}})\s*(?=(?:\[.*?\]\s*)?\()
scope: meta.function-call.identifier.php
captures:
1: variable.other.php
2: punctuation.definition.variable.php
push:
- maybe-item-access
- function-call-arguments
- maybe-item-access

qualified-path-meta:
- meta_include_prototype: false
Expand Down Expand Up @@ -1665,6 +1666,7 @@ contexts:

function-call-arguments:
- meta_include_prototype: false
- meta_content_scope: meta.function-call.identifier.php
- match: (\()\s*(\.\.\.)\s*(\))
scope: meta.function-call.arguments.php meta.group.php
captures:
Expand Down
20 changes: 20 additions & 0 deletions PHP/tests/syntax_test_php.php
Original file line number Diff line number Diff line change
Expand Up @@ -2033,6 +2033,26 @@ function ($array, $item) {
);
// <- punctuation.section.group.end

$array['callback'](first: 'first', second: 'second');
// <- meta.function-call.identifier.php variable.other.php punctuation.definition.variable.php
//^^^^ meta.function-call.identifier.php - meta.item-access
// ^^^^^^^^^^^^ meta.function-call.identifier.php meta.item-access.php
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function-call.arguments.php meta.group.php
//^^^^ variable.other.php
// ^ punctuation.section.brackets.begin.php
// ^^^^^^^^^^ meta.string.php string.quoted.single.php
// ^ punctuation.section.brackets.end.php
// ^ punctuation.section.group.begin.php
// ^^^^^ variable.parameter.named.php
// ^ keyword.operator.assignment.php
// ^^^^^^^ meta.string.php string.quoted.single.php
// ^ punctuation.separator.sequence.php
// ^^^^^^ variable.parameter.named.php
// ^ keyword.operator.assignment.php
// ^^^^^^^^ meta.string.php string.quoted.single.php
// ^ punctuation.section.group.end.php
// ^ punctuation.terminator.statement.php

nested( static function ( { } );
// ^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function-call.arguments.php meta.group.php
// ^^^^^^^^^ meta.function.php
Expand Down

0 comments on commit bb57a3a

Please sign in to comment.