Permalink
Browse files

Match return types in function declarations

Before these were passed back to the basic grammar, now match the valid items specifically.
  • Loading branch information...
infininight committed Mar 27, 2018
1 parent 706c680 commit 8f05764681d51cd0b13db1e36810d74913c86bfc
Showing with 48 additions and 1 deletion.
  1. +48 −1 Syntaxes/PHP.plist
View
@@ -1919,14 +1919,61 @@
<key>contentName</key>
<string>meta.function.arguments.php</string>
<key>end</key>
- <string>(\))</string>
+ <string>(?ix)
+ (\)) # Close arguments
+ (?: # Optional return type
+ \s*(:)\s*
+ (\?)?
+ (?:
+ (array|bool|float|int|string) # scalar-type
+ | (callable|iterable) # base-type-declaration
+ | (void)
+ | ([a-z_0-9\\]*[a-z_][a-z_0-9]*) # qualified-name
+ )
+ )?
+ </string>
<key>endCaptures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>punctuation.definition.parameters.end.php</string>
</dict>
+ <key>2</key>
+ <dict>
+ <key>name</key>
+ <string>punctuation.separator.return-type.php</string>
+ </dict>
+ <key>3</key>
+ <dict>
+ <key>name</key>
+ <string>storage.modifier.nullable.php</string>
+ </dict>
+ <key>4</key>
+ <dict>
+ <key>name</key>
+ <string>storage.type.$4.php</string>
+ </dict>
+ <key>5</key>
+ <dict>
+ <key>name</key>
+ <string>storage.modifier.$5.php</string>
+ </dict>
+ <key>6</key>
+ <dict>
+ <key>name</key>
+ <string>storage.type.void.php</string>
+ </dict>
+ <key>7</key>
+ <dict>
+ <key>patterns</key>
+ <array>
+ <dict>
+ <key>include</key>
+ <string>#class-name</string>
+ </dict>
+ </array>
+ </dict>
</dict>
<key>name</key>
<string>meta.function.php</string>

0 comments on commit 8f05764

Please sign in to comment.