Skip to content

Commit 5a99435

Browse files
committed
Add support for array, binary and unset typecasts (fixes textmate#11)
1 parent ef4e376 commit 5a99435

File tree

2 files changed

+47
-22
lines changed

2 files changed

+47
-22
lines changed

Syntaxes/PHP.plist

Lines changed: 34 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1687,28 +1687,6 @@
16871687
<key>include</key>
16881688
<string>#strings</string>
16891689
</dict>
1690-
<dict>
1691-
<key>match</key>
1692-
<string>(?i)\b(real|double|float|int(eger)?|bool(ean)?|string|class|clone|var|function|interface|parent|self|object)\b</string>
1693-
<key>name</key>
1694-
<string>storage.type.php</string>
1695-
</dict>
1696-
<dict>
1697-
<key>match</key>
1698-
<string>(?i)\b(global|abstract|const|extends|implements|final|p(r(ivate|otected)|ublic)|static)\b</string>
1699-
<key>name</key>
1700-
<string>storage.modifier.php</string>
1701-
</dict>
1702-
<dict>
1703-
<key>include</key>
1704-
<string>#object</string>
1705-
</dict>
1706-
<dict>
1707-
<key>match</key>
1708-
<string>;</string>
1709-
<key>name</key>
1710-
<string>punctuation.terminator.expression.php</string>
1711-
</dict>
17121690
<dict>
17131691
<key>captures</key>
17141692
<dict>
@@ -1769,6 +1747,40 @@
17691747
</dict>
17701748
</array>
17711749
</dict>
1750+
<dict>
1751+
<key>captures</key>
1752+
<dict>
1753+
<key>1</key>
1754+
<dict>
1755+
<key>name</key>
1756+
<string>storage.type.php</string>
1757+
</dict>
1758+
</dict>
1759+
<key>match</key>
1760+
<string>(?i)\s*\(\s*(array|real|double|float|int(eger)?|bool(ean)?|string|object|binary|unset)\s*\)</string>
1761+
</dict>
1762+
<dict>
1763+
<key>match</key>
1764+
<string>(?i)\b(array|real|double|float|int(eger)?|bool(ean)?|string|class|clone|var|function|interface|parent|self|object)\b</string>
1765+
<key>name</key>
1766+
<string>storage.type.php</string>
1767+
</dict>
1768+
<dict>
1769+
<key>match</key>
1770+
<string>(?i)\b(global|abstract|const|extends|implements|final|p(r(ivate|otected)|ublic)|static)\b</string>
1771+
<key>name</key>
1772+
<string>storage.modifier.php</string>
1773+
</dict>
1774+
<dict>
1775+
<key>include</key>
1776+
<string>#object</string>
1777+
</dict>
1778+
<dict>
1779+
<key>match</key>
1780+
<string>;</string>
1781+
<key>name</key>
1782+
<string>punctuation.terminator.expression.php</string>
1783+
</dict>
17721784
<dict>
17731785
<key>include</key>
17741786
<string>#heredoc</string>

Tests/test-cases.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -687,4 +687,17 @@ function foo(
687687
if (true and false) {}
688688
if (true or (true and false)) {}
689689

690+
$blah = (binary) $foo;
691+
$blah = (int) $foo;
692+
$blah = (integer) $foo;
693+
$blah = (bool) $foo;
694+
$blah = (boolean) $foo;
695+
$blah = (float) $foo;
696+
$blah = (double) $foo;
697+
$blah = (real) $foo;
698+
$blah = (string) $foo;
699+
$blah = (array) $foo;
700+
$blah = (object) $foo;
701+
$blah = (unset) $foo;
702+
690703
?>

0 commit comments

Comments
 (0)