diff --git a/core/oql/build/PHP/LexerGenerator/Lexer.php b/core/oql/build/PHP/LexerGenerator/Lexer.php index 8b1731d06..3d6833e3d 100644 --- a/core/oql/build/PHP/LexerGenerator/Lexer.php +++ b/core/oql/build/PHP/LexerGenerator/Lexer.php @@ -182,14 +182,14 @@ class PHP_LexerGenerator_Lexer $this->token = self::COMMENTEND; return true; } - if (preg_match('/\G%([a-z]+)/', $this->data, $token, null, $this->N)) { + if (preg_match('/\G%([a-z]+)/', $this->data, $token, 0, $this->N)) { $this->value = $token[1]; $this->N += strlen($token[1]) + 1; $this->state = 'DeclarePI'; $this->token = self::PI; return true; } - if (preg_match('/\G[a-zA-Z_][a-zA-Z0-9_]*/', $this->data, $token, null, $this->N)) { + if (preg_match('/\G[a-zA-Z_][a-zA-Z0-9_]*/', $this->data, $token, 0, $this->N)) { $this->value = $token[0]; $this->token = self::PATTERN; $this->N += strlen($token[0]); @@ -216,7 +216,7 @@ class PHP_LexerGenerator_Lexer if ($this->data[$this->N] == '{') { return $this->lexCode(); } - if (!preg_match("/\G[^\n]+/", $this->data, $token, null, $this->N)) { + if (!preg_match("/\G[^\n]+/", $this->data, $token, 0, $this->N)) { $this->error('Unexpected end of file'); return false; } @@ -242,7 +242,7 @@ class PHP_LexerGenerator_Lexer if ($this->data[$this->N] == '{') { return $this->lexCode(); } - if (!preg_match("/\G[^\n]+/", $this->data, $token, null, $this->N)) { + if (!preg_match("/\G[^\n]+/", $this->data, $token, 0, $this->N)) { $this->error('Unexpected end of file'); return false; } @@ -406,7 +406,7 @@ class PHP_LexerGenerator_Lexer if ($this->data[$this->N] == '\'') { return $this->lexQuote('\''); } - if (preg_match('/\G%([a-zA-Z_]+)/', $this->data, $token, null, $this->N)) { + if (preg_match('/\G%([a-zA-Z_]+)/', $this->data, $token, 0, $this->N)) { $this->value = $token[1]; $this->N += strlen($token[1]) + 1; $this->state = 'DeclarePIRule'; @@ -419,7 +419,7 @@ class PHP_LexerGenerator_Lexer if ($this->data[$this->N] == '"') { return $this->lexQuote(); } - if (preg_match('/\G[a-zA-Z_][a-zA-Z0-9_]*/', $this->data, $token, null, $this->N)) { + if (preg_match('/\G[a-zA-Z_][a-zA-Z0-9_]*/', $this->data, $token, 0, $this->N)) { $this->value = $token[0]; $this->N += strlen($token[0]); $this->token = self::SUBPATTERN; diff --git a/core/oql/build/PHP/LexerGenerator/Parser.php b/core/oql/build/PHP/LexerGenerator/Parser.php index 0362ebba2..005b80a72 100644 --- a/core/oql/build/PHP/LexerGenerator/Parser.php +++ b/core/oql/build/PHP/LexerGenerator/Parser.php @@ -33,17 +33,19 @@ class PHP_LexerGenerator_ParseryyToken implements ArrayAccess return $this->_string; } - function offsetExists($offset) + function offsetExists($offset): bool { return isset($this->metadata[$offset]); } + // Return type mixed is not supported by PHP 7.4, we can remove the following PHP attribute and add the return type once iTop min PHP version is PHP 8.0+ + #[\ReturnTypeWillChange] function offsetGet($offset) { return $this->metadata[$offset]; } - function offsetSet($offset, $value) + function offsetSet($offset, $value): void { if ($offset === null) { if (isset($value[0])) { @@ -66,7 +68,7 @@ class PHP_LexerGenerator_ParseryyToken implements ArrayAccess } } - function offsetUnset($offset) + function offsetUnset($offset): void { unset($this->metadata[$offset]); } @@ -278,7 +280,7 @@ class PHP_LexerGenerator_Parser#line 171 "Parser.php" $match = false; foreach ($yy_yymore_patterns[' . $this->token . '] as $index => $rule) { if (preg_match(\'/\' . $rule . \'/' . $this->patternFlags . '\', - ' . $this->input . ', $yymatches, null, ' . $this->counter . ')) { + ' . $this->input . ', $yymatches, 0, ' . $this->counter . ')) { $yymatches = array_filter($yymatches, \'strlen\'); // remove empty sub-patterns if ($match) { if (strlen($yymatches[0]) > strlen($match[0][0])) { @@ -350,7 +352,7 @@ class PHP_LexerGenerator_Parser#line 171 "Parser.php" $pattern . '\';' . "\n"); fwrite($this->out, ' do { - if (preg_match($yy_global_pattern,' . $this->input . ', $yymatches, null, ' . + if (preg_match($yy_global_pattern,' . $this->input . ', $yymatches, 0, ' . $this->counter . ')) { $yysubmatches = $yymatches; @@ -408,7 +410,7 @@ class PHP_LexerGenerator_Parser#line 171 "Parser.php" } $yysubmatches = array(); if (preg_match(\'/\' . $yy_yymore_patterns[' . $this->token . '][1] . \'/' . $this->patternFlags . '\', - ' . $this->input . ', $yymatches, null, ' . $this->counter .')) { + ' . $this->input . ', $yymatches, 0, ' . $this->counter .')) { $yysubmatches = $yymatches; $yymatches = array_filter($yymatches, \'strlen\'); // remove empty sub-patterns next($yymatches); // skip global match diff --git a/core/oql/build/PHP/LexerGenerator/Parser.y b/core/oql/build/PHP/LexerGenerator/Parser.y index cfa96d688..401f12e8e 100644 --- a/core/oql/build/PHP/LexerGenerator/Parser.y +++ b/core/oql/build/PHP/LexerGenerator/Parser.y @@ -187,7 +187,7 @@ require_once 'PHP/LexerGenerator/Exception.php'; $match = false; foreach ($yy_yymore_patterns[' . $this->token . '] as $index => $rule) { if (preg_match(\'/\' . $rule . \'/' . $this->patternFlags . '\', - ' . $this->input . ', $yymatches, null, ' . $this->counter . ')) { + ' . $this->input . ', $yymatches, 0, ' . $this->counter . ')) { $yymatches = array_filter($yymatches, \'strlen\'); // remove empty sub-patterns if ($match) { if (strlen($yymatches[0]) > strlen($match[0][0])) { @@ -259,7 +259,7 @@ require_once 'PHP/LexerGenerator/Exception.php'; $pattern . '\';' . "\n"); fwrite($this->out, ' do { - if (preg_match($yy_global_pattern,' . $this->input . ', $yymatches, null, ' . + if (preg_match($yy_global_pattern,' . $this->input . ', $yymatches, 0, ' . $this->counter . ')) { $yysubmatches = $yymatches; @@ -317,7 +317,7 @@ require_once 'PHP/LexerGenerator/Exception.php'; } $yysubmatches = array(); if (preg_match(\'/\' . $yy_yymore_patterns[' . $this->token . '][1] . \'/' . $this->patternFlags . '\', - ' . $this->input . ', $yymatches, null, ' . $this->counter .')) { + ' . $this->input . ', $yymatches, 0, ' . $this->counter .')) { $yysubmatches = $yymatches; $yymatches = array_filter($yymatches, \'strlen\'); // remove empty sub-patterns next($yymatches); // skip global match diff --git a/core/oql/build/PHP/LexerGenerator/Regex/Lexer.php b/core/oql/build/PHP/LexerGenerator/Regex/Lexer.php index f21839d50..b34531694 100644 --- a/core/oql/build/PHP/LexerGenerator/Regex/Lexer.php +++ b/core/oql/build/PHP/LexerGenerator/Regex/Lexer.php @@ -110,7 +110,7 @@ class PHP_LexerGenerator_Regex_Lexer $yy_global_pattern = '/\G(\\\\\\\\)|\G([^[\\\\^$.|()?*+{}]+)|\G(\\\\[][{}*.^$|?()+])|\G(\\[)|\G(\\|)|\G(\\\\[frnt]|\\\\x[0-9a-fA-F][0-9a-fA-F]?|\\\\[0-7][0-7][0-7]|\\\\x\\{[0-9a-fA-F]+\\})|\G(\\\\[0-9][0-9])|\G(\\\\[abBGcedDsSwW0C]|\\\\c\\\\)|\G(\\^)|\G(\\\\A)|\G(\\))|\G(\\$)|\G(\\*\\?|\\+\\?|[*?+]|\\{[0-9]+\\}|\\{[0-9]+,\\}|\\{[0-9]+,[0-9]+\\})|\G(\\\\[zZ])|\G(\\(\\?)|\G(\\()|\G(\\.)|\G(\\\\[1-9])|\G(\\\\p\\{\\^?..?\\}|\\\\P\\{..?\\}|\\\\X)|\G(\\\\p\\{C[cfnos]?|L[lmotu]?|M[cen]?|N[dlo]?|P[cdefios]?|S[ckmo]?|Z[lps]?\\})|\G(\\\\p\\{\\^C[cfnos]?|L[lmotu]?|M[cen]?|N[dlo]?|P[cdefios]?|S[ckmo]?|Z[lps]?\\})|\G(\\\\p[CLMNPSZ])|\G(\\\\)/'; do { - if (preg_match($yy_global_pattern,$this->input, $yymatches, null, $this->N)) { + if (preg_match($yy_global_pattern,$this->input, $yymatches, 0, $this->N)) { $yysubmatches = $yymatches; $yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns if (!count($yymatches)) { @@ -180,7 +180,7 @@ class PHP_LexerGenerator_Regex_Lexer } $yysubmatches = array(); if (preg_match('/' . $yy_yymore_patterns[$this->token][1] . '/', - $this->input, $yymatches, null, $this->N)) { + $this->input, $yymatches, 0, $this->N)) { $yysubmatches = $yymatches; $yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns next($yymatches); // skip global match @@ -360,7 +360,7 @@ class PHP_LexerGenerator_Regex_Lexer $yy_global_pattern = '/\G(\\^)|\G(\\])|\G(.)/'; do { - if (preg_match($yy_global_pattern,$this->input, $yymatches, null, $this->N)) { + if (preg_match($yy_global_pattern,$this->input, $yymatches, 0, $this->N)) { $yysubmatches = $yymatches; $yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns if (!count($yymatches)) { @@ -410,7 +410,7 @@ class PHP_LexerGenerator_Regex_Lexer } $yysubmatches = array(); if (preg_match('/' . $yy_yymore_patterns[$this->token][1] . '/', - $this->input, $yymatches, null, $this->N)) { + $this->input, $yymatches, 0, $this->N)) { $yysubmatches = $yymatches; $yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns next($yymatches); // skip global match @@ -497,7 +497,7 @@ class PHP_LexerGenerator_Regex_Lexer $yy_global_pattern = '/\G(\\\\\\\\)|\G(\\])|\G(\\\\[frnt]|\\\\x[0-9a-fA-F][0-9a-fA-F]?|\\\\[0-7][0-7][0-7]|\\\\x\\{[0-9a-fA-F]+\\})|\G(\\\\[bacedDsSwW0C]|\\\\c\\\\|\\\\x\\{[0-9a-fA-F]+\\}|\\\\[0-7][0-7][0-7]|\\\\x[0-9a-fA-F][0-9a-fA-F]?)|\G(\\\\[0-9][0-9])|\G(\\\\[1-9])|\G(\\\\[]\.\-\^])|\G(-(?!]))|\G([^\-\\\\])|\G(\\\\)|\G(.)/'; do { - if (preg_match($yy_global_pattern,$this->input, $yymatches, null, $this->N)) { + if (preg_match($yy_global_pattern,$this->input, $yymatches, 0, $this->N)) { $yysubmatches = $yymatches; $yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns if (!count($yymatches)) { @@ -555,7 +555,7 @@ class PHP_LexerGenerator_Regex_Lexer } $yysubmatches = array(); if (preg_match('/' . $yy_yymore_patterns[$this->token][1] . '/', - $this->input, $yymatches, null, $this->N)) { + $this->input, $yymatches, 0, $this->N)) { $yysubmatches = $yymatches; $yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns next($yymatches); // skip global match @@ -678,7 +678,7 @@ class PHP_LexerGenerator_Regex_Lexer $yy_global_pattern = '/\G(\\\\\\\\)|\G(\\\\\\])|\G(\\\\[bacedDsSwW0C]|\\\\c\\\\|\\\\x\\{[0-9a-fA-F]+\\}|\\\\[0-7][0-7][0-7]|\\\\x[0-9a-fA-F][0-9a-fA-F]?)|\G(\\\\[0-9][0-9])|\G(\\\\[1-9])|\G([^\-\\\\])|\G(\\\\)/'; do { - if (preg_match($yy_global_pattern,$this->input, $yymatches, null, $this->N)) { + if (preg_match($yy_global_pattern,$this->input, $yymatches, 0, $this->N)) { $yysubmatches = $yymatches; $yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns if (!count($yymatches)) { @@ -732,7 +732,7 @@ class PHP_LexerGenerator_Regex_Lexer } $yysubmatches = array(); if (preg_match('/' . $yy_yymore_patterns[$this->token][1] . '/', - $this->input, $yymatches, null, $this->N)) { + $this->input, $yymatches, 0, $this->N)) { $yysubmatches = $yymatches; $yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns next($yymatches); // skip global match @@ -842,7 +842,7 @@ class PHP_LexerGenerator_Regex_Lexer $yy_global_pattern = '/\G([imsxUX]+-[imsxUX]+|[imsxUX]+|-[imsxUX]+)|\G(:)|\G(\\))|\G(P<[^>]+>)|\G(<=)|\G()|\G(\\(\\?)|\G(#[^)]+)|\G(R)|\G(.)/'; do { - if (preg_match($yy_global_pattern,$this->input, $yymatches, null, $this->N)) { + if (preg_match($yy_global_pattern,$this->input, $yymatches, 0, $this->N)) { $yysubmatches = $yymatches; $yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns if (!count($yymatches)) { @@ -902,7 +902,7 @@ class PHP_LexerGenerator_Regex_Lexer } $yysubmatches = array(); if (preg_match('/' . $yy_yymore_patterns[$this->token][1] . '/', - $this->input, $yymatches, null, $this->N)) { + $this->input, $yymatches, 0, $this->N)) { $yysubmatches = $yymatches; $yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns next($yymatches); // skip global match diff --git a/core/oql/build/PHP/LexerGenerator/Regex/Parser.php b/core/oql/build/PHP/LexerGenerator/Regex/Parser.php index 4e1faf1fd..4c7876004 100644 --- a/core/oql/build/PHP/LexerGenerator/Regex/Parser.php +++ b/core/oql/build/PHP/LexerGenerator/Regex/Parser.php @@ -33,17 +33,19 @@ class PHP_LexerGenerator_Regex_yyToken implements ArrayAccess return $this->_string; } - function offsetExists($offset) + function offsetExists($offset): bool { return isset($this->metadata[$offset]); } + // Return type mixed is not supported by PHP 7.4, we can remove the following PHP attribute and add the return type once iTop min PHP version is PHP 8.0+ + #[\ReturnTypeWillChange] function offsetGet($offset) { return $this->metadata[$offset]; } - function offsetSet($offset, $value) + function offsetSet($offset, $value): void { if ($offset === null) { if (isset($value[0])) { @@ -66,7 +68,7 @@ class PHP_LexerGenerator_Regex_yyToken implements ArrayAccess } } - function offsetUnset($offset) + function offsetUnset($offset): void { unset($this->metadata[$offset]); } diff --git a/core/oql/oql-lexer.php b/core/oql/oql-lexer.php index 3744c0742..42ca53cce 100644 --- a/core/oql/oql-lexer.php +++ b/core/oql/oql-lexer.php @@ -235,7 +235,7 @@ class OQLLexerRaw $match = false; foreach ($yy_yymore_patterns[$this->token] as $index => $rule) { if (preg_match('/' . $rule . '/', - $this->data, $yymatches, null, $this->count)) { + $this->data, $yymatches, 0, $this->count)) { $yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns if ($match) { if (strlen($yymatches[0]) > strlen($match[0][0])) {