Skip to content
Prev Previous commit
Next Next commit
fix: non-capturing groups in patterns
  • Loading branch information
TomPavelec committed Oct 12, 2020
commit a18e8a2ca1ab1783a73e86f962fd5c81115f68ca
19 changes: 10 additions & 9 deletions components/prism-php.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,19 @@
Prism.languages.insertBefore('php', 'class-name', {
'variable': /\$+(?:\w+\b|(?={))/i,
'package': {
pattern: /(namespace\s+|use\s+(function\s+)?)(\\*\b[a-zA-Z_][\w]*)+\b(?!\\)/i,
pattern: /(namespace\s+|use\s+(?:function\s+)?)(?:\\*\b[a-zA-Z_][\w]*)+\b(?!\\)/i,
lookbehind: true,
inside: {
punctuation: /\\/
}
},
'type type-casting': {
pattern: /(?<=\(\s*)\b(?:bool|boolean|int|integer|float|string|object|array(?!\s*\())\b(?=\s*\))/i,
greedy: true
pattern: /(\(\s*)\b(?:bool|boolean|int|integer|float|string|object|array(?!\s*\())\b(?=\s*\))/i,
greedy: true,
lookbehind: true
},
'type type-hint': {
pattern: /(?<=[(,?]\s*)\b(?:bool|boolean|int|integer|float|string|object|array(?!\s*\()|mixed|self|static)\b(?=\s*\$)/i,
pattern: /([(,?]\s*)\b(?:bool|boolean|int|integer|float|string|object|array(?!\s*\()|mixed|self|static)\b(?=\s*\$)/i,
greedy: true,
lookbehind: true
},
Expand Down Expand Up @@ -147,14 +148,14 @@

Prism.languages.insertBefore('php', 'keyword', {
'keyword static-context': {
pattern: /\b(parent|self|static)(?=\s*::)/i,
pattern: /\b(?:parent|self|static)(?=\s*::)/i,
greedy: true
}
});

Prism.languages.insertBefore('php', 'boolean', {
'class-name class-name-fully-qualified': {
pattern: /(\b(?:extends|implements|instanceof|new(?!\s+self|\s+static))\s+|\bcatch\s+\()(\\*\b[a-zA-Z_][\w]*)+\b(?!\\)/i,
pattern: /(\b(?:extends|implements|instanceof|new(?!\s+self|\s+static))\s+|\bcatch\s+\()(?:\\*\b[a-zA-Z_][\w]*)+\b(?!\\)/i,
greedy: true,
inside: {
punctuation: /\\/
Expand All @@ -166,7 +167,7 @@
greedy: true,
},
'class-name class-name-fully-qualified static-context': {
pattern: /(\\*\b[a-zA-Z_][\w]*)+\b(?!\\)(?=\s*::)/i,
pattern: /(?:\\*\b[a-zA-Z_][\w]*)+\b(?!\\)(?=\s*::)/i,
greedy: true,
inside: {
punctuation: /\\/
Expand All @@ -178,7 +179,7 @@
lookbehind: true
},
'class-name class-name-fully-qualified type-hint': {
pattern: /([(,?]\s*)(\\*\b[a-zA-Z_][\w]*)+\b(?!\\)(?=\s*\$)/i,
pattern: /([(,?]\s*)(?:\\*\b[a-zA-Z_][\w]*)+\b(?!\\)(?=\s*\$)/i,
greedy: true,
inside: {
punctuation: /\\/
Expand All @@ -191,7 +192,7 @@
lookbehind: true
},
'class-name class-name-fully-qualified return-type': {
pattern: /(\)\s*:\s*\?*\s*)(\\*\b[a-zA-Z_][\w]*)+\b(?!\\)/i,
pattern: /(\)\s*:\s*\?*\s*)(?:\\*\b[a-zA-Z_][\w]*)+\b(?!\\)/i,
greedy: true,
inside: {
punctuation: /\\/
Expand Down
2 changes: 1 addition & 1 deletion components/prism-php.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.