php-mode icon indicating copy to clipboard operation
php-mode copied to clipboard

Add individual faces

Open minikN opened this issue 4 years ago • 1 comments

Hello, this PR is adding a lot of new faces to php-mode. Let me explain what I have added. The following faces (and accompanying regex) have been added:

Classes

  • php-class-declaration: will fontify the words class, trait, interface.
  • php-class-declaration-spec: will fontify the words implements, extends.
  • php-namespace-declaration: will fontify the word namespace.
  • php-import-declaration: will fontify the words use ... as ....
  • php-class-modifier: will fontify abstract, final keywords in class declaration.

Methods

  • php-method-modifier: will fontify abstract, final keywords in method declaration.
  • php-method-access: will fontify private, protected, public in method declaration.
  • php-method-static: will fontify static keyword in method declaration.
  • php-return-type-colon: will fontify : in front of return type declaration.

Properties

  • php-property-access: will fontify private, protected, public in property declaration.
  • php-property-static: will fontify static keyword in property declaration.
  • php-property-const: will fontify const keyword in property declaration.

Statements

  • php-block-statement: will fontify if, elseif, for, foreach, while, declare, switch and catch keywords.
  • php-flow-control-statement: will fontify break, continue, die, exit, goto, return and throw keywords.
  • php-print-statement: will fontify echo, print and var_dump keywords.
  • php-include-statement: will fontify include, include_once, require and require_once keywords.

Other Stuff

  • php-constant-keyword: will fontify true, false and null.
  • php-function-keyword: will fontify function in ... function name(....
  • php-number: will fontify integers and floats (13, 4.3, ...)
  • php-string-quote: will fontify the string delimiters (', ")
  • php-block-delimiter: will fontify block delimiters ((, [, {, ), ], })
  • php-type-operator: will fontify insteadof and instanceof keywords.
  • php-string-op: will fontify . for string concatenation. I also bootstrapped that in my last PR but somehow forgot to actually implement it.

Default styles

The faces php-type-operator, php-block-delimiter and php-number inherit from default. The face php-string-quote inherits from php-string. All other faces inherit from php-keyword

So by default, everything should look the same.

Known issues

  • when applying a different style to php-string-qoute in comparison to php-string, occurences of string delimiters inside of the string will also be colored differently.
  • as usual, I believe most of the regex could be optimized in many ways. I'm open for suggestions as this is not my strong suite.
  • I know that insteadof is no type operator and therefore should not have been grouped in the type-operator face. However, since it's so similar to instanceof I put it in anyway.

minikN avatar Jan 03 '20 09:01 minikN

Is this still being worked on? Just wondering.

minikN avatar Oct 06 '20 15:10 minikN