Skip to content

Commit

Permalink
(chore) Replace className with scope and use match
Browse files Browse the repository at this point in the history
  • Loading branch information
wkania authored and joshgoebel committed Dec 16, 2021
1 parent bc5a10f commit 093b67f
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions src/languages/php.js
Expand Up @@ -13,22 +13,22 @@ Category: common
export default function(hljs) {
const regex = hljs.regex;
const VARIABLE = {
className: 'variable',
begin: '\\$+[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*' +
scope: 'variable',
match: '\\$+[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*' +
// negative look-ahead tries to avoid matching patterns that are not
// Perl at all like $ident$, @ident@, etc.
`(?![A-Za-z0-9])(?![$])`
};
const PREPROCESSOR = {
className: 'meta',
scope: 'meta',
variants: [
{ begin: /<\?php/, relevance: 10 }, // boost for obvious PHP
{ begin: /<\?[=]?/ },
{ begin: /\?>/ } // end php tag
]
};
const SUBST = {
className: 'subst',
scope: 'subst',
variants: [
{ begin: /\$\w+/ },
{ begin: /\{\$/, end: /\}/ }
Expand All @@ -49,15 +49,15 @@ export default function(hljs) {
// list of valid whitespaces because non-breaking space might be part of a name
const WHITESPACE = '[ \t\n]';
const STRING = {
className: 'string',
scope: 'string',
variants: [
DOUBLE_QUOTED,
SINGLE_QUOTED,
HEREDOC
]
};
const NUMBER = {
className: 'number',
scope: 'number',
variants: [
{ begin: `\\b0[bB][01]+(?:_[01]+)*\\b` }, // Binary w/ underscore support
{ begin: `\\b0[oO][0-7]+(?:_[0-7]+)*\\b` }, // Octals w/ underscore support
Expand Down Expand Up @@ -374,8 +374,8 @@ export default function(hljs) {
},
PREPROCESSOR,
{
className: 'variable.language',
begin: /\$this\b/
scope: 'variable.language',
match: /\$this\b/
},
VARIABLE,
FUNCTION_INVOKE,
Expand All @@ -390,7 +390,7 @@ export default function(hljs) {
},
CONSTRUCTOR_CALL,
{
className: 'function',
scope: 'function',
relevance: 0,
beginKeywords: 'fn function', end: /[;{]/, excludeEnd: true,
illegal: '[$%\\[]',
Expand All @@ -404,7 +404,7 @@ export default function(hljs) {
endsParent: true
},
{
className: 'params',
scope: 'params',
begin: '\\(', end: '\\)',
excludeBegin: true,
excludeEnd: true,
Expand All @@ -420,7 +420,7 @@ export default function(hljs) {
]
},
{
className: 'class',
scope: 'class',
variants: [
{ beginKeywords: "enum", illegal: /[($"]/ },
{ beginKeywords: "class interface trait", illegal: /[:($"]/ }
Expand Down

0 comments on commit 093b67f

Please sign in to comment.