diff --git a/components/prism-phpdoc.js b/components/prism-phpdoc.js index c3913ddb66..136f5988a4 100644 --- a/components/prism-phpdoc.js +++ b/components/prism-phpdoc.js @@ -1,6 +1,6 @@ (function (Prism) { - var typeExpression = /(?:[a-zA-Z]\w*|[|\\[\]])+/.source; + var typeExpression = /(?:\b[a-zA-Z]\w*|[|\\[\]])+/.source; Prism.languages.phpdoc = Prism.languages.extend('javadoclike', { 'parameter': { diff --git a/components/prism-phpdoc.min.js b/components/prism-phpdoc.min.js index 99d7d3aa4c..fe460a5d28 100644 --- a/components/prism-phpdoc.min.js +++ b/components/prism-phpdoc.min.js @@ -1 +1 @@ -!function(a){var e="(?:[a-zA-Z]\\w*|[|\\\\[\\]])+";a.languages.phpdoc=a.languages.extend("javadoclike",{parameter:{pattern:RegExp("(@(?:global|param|property(?:-read|-write)?|var)\\s+(?:"+e+"\\s+)?)\\$\\w+"),lookbehind:!0}}),a.languages.insertBefore("phpdoc","keyword",{"class-name":[{pattern:RegExp("(@(?:global|package|param|property(?:-read|-write)?|return|subpackage|throws|var)\\s+)"+e),lookbehind:!0,inside:{keyword:/\b(?:callback|resource|boolean|integer|double|object|string|array|false|float|mixed|bool|null|self|true|void|int)\b/,punctuation:/[|\\[\]()]/}}]}),a.languages.javadoclike.addSupport("php",a.languages.phpdoc)}(Prism); \ No newline at end of file +!function(a){var e="(?:\\b[a-zA-Z]\\w*|[|\\\\[\\]])+";a.languages.phpdoc=a.languages.extend("javadoclike",{parameter:{pattern:RegExp("(@(?:global|param|property(?:-read|-write)?|var)\\s+(?:"+e+"\\s+)?)\\$\\w+"),lookbehind:!0}}),a.languages.insertBefore("phpdoc","keyword",{"class-name":[{pattern:RegExp("(@(?:global|package|param|property(?:-read|-write)?|return|subpackage|throws|var)\\s+)"+e),lookbehind:!0,inside:{keyword:/\b(?:callback|resource|boolean|integer|double|object|string|array|false|float|mixed|bool|null|self|true|void|int)\b/,punctuation:/[|\\[\]()]/}}]}),a.languages.javadoclike.addSupport("php",a.languages.phpdoc)}(Prism); \ No newline at end of file diff --git a/tests/languages/phpdoc/issue2197.test b/tests/languages/phpdoc/issue2197.test new file mode 100644 index 0000000000..75034cc63f --- /dev/null +++ b/tests/languages/phpdoc/issue2197.test @@ -0,0 +1,16 @@ +/** @var Git_Driver_Gerrit_ProjectCreator_Factory */ + +---------------------------------------------------- + +[ + "/** ", + ["keyword", "@var"], + ["class-name", [ + "Git_Driver_Gerrit_ProjectCreator_Factory" + ]], + " */" +] + +---------------------------------------------------- + +Checks exponential backtracking for types. See #2197.