From 6df5bda8f2d6f3132d0840f96ce2dc553936ee16 Mon Sep 17 00:00:00 2001 From: Timothy J Warren Date: Wed, 3 Mar 2021 20:23:12 -0500 Subject: [PATCH] Attempt to fix CI tests --- Dockerfile | 2 +- src/Enum/Highlight.php | 1 + src/functions.php | 33 ++++++++++++++++++--------------- test.php | 1 + 4 files changed, 21 insertions(+), 16 deletions(-) diff --git a/Dockerfile b/Dockerfile index 0e918bc..1778874 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,4 +3,4 @@ FROM php:8-cli-alpine RUN apk add --no-cache --virtual .persistent-deps libffi-dev \ && docker-php-ext-configure ffi --with-ffi \ && docker-php-ext-install ffi \ - && apk add --no-cache php8-phpdbg + && apk add --no-cache --repository=http://dl-cdn.alpinelinux.org/alpine/edge/testing/ php8-phpdbg diff --git a/src/Enum/Highlight.php b/src/Enum/Highlight.php index c9c4b09..ed37fed 100644 --- a/src/Enum/Highlight.php +++ b/src/Enum/Highlight.php @@ -19,4 +19,5 @@ class Highlight { public const DELIMITER = 9; public const INVALID = 10; public const MATCH = 11; + public const IDENTIFIER = 12; } \ No newline at end of file diff --git a/src/functions.php b/src/functions.php index 2692d77..39463a9 100644 --- a/src/functions.php +++ b/src/functions.php @@ -274,12 +274,13 @@ function syntax_to_color(int $hl): int Highlight::KEYWORD1 => Color::FG_YELLOW, Highlight::KEYWORD2 => Color::FG_GREEN, Highlight::STRING => Color::FG_MAGENTA, - Highlight::NUMBER => Color::FG_RED, + Highlight::NUMBER => Color::FG_BRIGHT_RED, Highlight::OPERATOR => Color::FG_BRIGHT_GREEN, Highlight::VARIABLE => Color::FG_BRIGHT_CYAN, Highlight::DELIMITER => Color::FG_BLUE, Highlight::INVALID => Color::BG_BRIGHT_RED, Highlight::MATCH => Color::INVERT, + Highlight::IDENTIFIER => Color::FG_BRIGHT_WHITE, default => Color::FG_WHITE, }; } @@ -386,16 +387,7 @@ function get_file_syntax_map(): array 'PHP', ['.php', 'kilo'], [ - '?php', '$this', '__halt_compiler', 'abstract', 'and', 'array', 'as', 'break', - 'callable', 'case', 'catch', 'class', 'clone', 'const', 'continue', 'declare', - 'default', 'die', 'do', 'echo', 'else', 'elseif', 'empty', 'enddeclare', 'endfor', - 'endforeach', 'endif', 'endswitch', 'endwhile', 'eval', 'exit', 'extends', - 'final', 'finally', 'for', 'foreach', 'function', 'global', 'goto', 'if', 'implements', - 'include', 'include_once', 'instanceof', 'insteadof', 'interface', 'isset', 'list', - 'namespace', 'new', 'or', 'print', 'private', 'protected', 'public', 'require', 'require_once', - 'return', 'static', 'switch', 'throw', 'trait', 'try', 'unset', 'use', 'var', 'while', 'xor', - 'yield', 'yield from', '__CLASS__', '__DIR__', '__FILE__', '__FUNCTION__', '__LINE__', - '__METHOD__', '__NAMESPACE__', '__TRAIT__', + '?php', '$this', '__halt_compiler' ], [ 'int', 'float', 'bool', 'string', 'true', 'TRUE', 'false', 'FALSE', 'null', 'NULL', @@ -499,12 +491,17 @@ function php_token_to_highlight(int $token): int T_END_HEREDOC => Highlight::DELIMITER, // Number literals and magic constants + T_CLASS_C, T_DIR, - T_TRAIT_C, T_DNUMBER, T_LNUMBER, T_FILE, - T_FUNC_C => Highlight::NUMBER, + T_FUNC_C, + T_LINE, + T_METHOD_C, + T_NS_C, + T_NUM_STRING, + T_TRAIT_C => Highlight::NUMBER, // String literals T_CONSTANT_ENCAPSED_STRING, T_ENCAPSED_AND_WHITESPACE => Highlight::STRING, @@ -593,18 +590,24 @@ function php_token_to_highlight(int $token): int T_INCLUDE, T_INCLUDE_ONCE, T_INTERFACE, - T_NAMESPACE, + T_ISSET, + T_LIST, T_MATCH, + T_NAMESPACE, T_NEW, + T_PRINT, T_PRIVATE, T_PUBLIC, T_PROTECTED, + T_REQUIRE, + T_REQUIRE_ONCE, T_RETURN, T_STATIC, T_SWITCH, T_THROW, T_TRAIT, T_TRY, + T_UNSET, T_USE, T_VAR, T_WHILE, @@ -612,7 +615,7 @@ function php_token_to_highlight(int $token): int T_YIELD_FROM => Highlight::KEYWORD1, // Not string literals, but identifiers, keywords, etc. - // T_STRING => Highlight::KEYWORD2, + T_STRING => Highlight::IDENTIFIER, // Types and casts T_ARRAY_CAST, diff --git a/test.php b/test.php index 49361d0..529dc91 100644 --- a/test.php +++ b/test.php @@ -89,6 +89,7 @@ $y = [ ]; // Multi-line ternary statement +#{Attribute] $q = ($x !== 2) ? 'yes' : 'no';