From 7c3d6303633b3576d0218b2f30a8e88a35cf1228 Mon Sep 17 00:00:00 2001 From: Anton Vasiliev <1695147@gmail.com> Date: Sat, 28 Oct 2023 23:26:51 +0100 Subject: [PATCH] #2407 - Fix CS --- Library/Backend/Backend.php | 19 +++++++++---------- Library/CompilerFile.php | 2 +- Library/Passes/LocalContextPass.php | 6 +++--- Library/Passes/SkipVariantInit.php | 4 +--- 4 files changed, 14 insertions(+), 17 deletions(-) diff --git a/Library/Backend/Backend.php b/Library/Backend/Backend.php index b5187a826..6d03c484a 100644 --- a/Library/Backend/Backend.php +++ b/Library/Backend/Backend.php @@ -27,7 +27,6 @@ use Zephir\Variable\Globals; use Zephir\Variable\Variable; -use function in_array; use function Zephir\add_slashes; class Backend @@ -116,8 +115,8 @@ public function initVar(Variable $variable, CompilationContext $context, $useCod public function getVariableCode(Variable $variable): string { if ($variable->isDoublePointer() - || in_array($variable->getName(), ['this_ptr', 'return_value']) - || in_array($variable->getType(), ['int', 'long'])) { + || \in_array($variable->getName(), ['this_ptr', 'return_value']) + || \in_array($variable->getType(), ['int', 'long'])) { return $variable->getName(); } @@ -337,7 +336,7 @@ public function onPostCompile(Method $method, CompilationContext $context): void public function generateInitCode(&$groupVariables, $type, $pointer, Variable $variable) { - $isComplex = in_array($type, ['variable', 'string', 'array', 'resource', 'callable', 'object', 'mixed'], true); + $isComplex = \in_array($type, ['variable', 'string', 'array', 'resource', 'callable', 'object', 'mixed'], true); if ($isComplex && !$variable->isDoublePointer()) { $groupVariables[] = $variable->getName(); @@ -640,7 +639,7 @@ public function addArrayEntry(Variable $variable, $key, $value, CompilationConte $var = $context->symbolTable->getVariableForRead($key->getCode(), $context); $typeKey = $var->getType(); } - if (in_array($typeKey, ['int', 'uint', 'long', 'ulong'])) { + if (\in_array($typeKey, ['int', 'uint', 'long', 'ulong'])) { $keyType = 'index'; } } @@ -765,16 +764,16 @@ public function arrayIssetFetch2(Variable $target, Variable $var, $resolvedExpr, if (!($resolvedExpr instanceof Variable)) { if ('string' === $resolvedExpr->getType()) { return new CompiledExpression('bool', 'zephir_array_isset_string_fetch('.$code.', SS("'.$resolvedExpr->getCode().'"), '.$flags.')', $expression); - } elseif (in_array($resolvedExpr->getType(), ['int', 'uint', 'long'])) { + } elseif (\in_array($resolvedExpr->getType(), ['int', 'uint', 'long'])) { return new CompiledExpression('bool', 'zephir_array_isset_long_fetch('.$code.', '.$resolvedExpr->getCode().', '.$flags.')', $expression); } else { $resolvedExpr = $context->symbolTable->getVariableForRead($resolvedExpr->getCode(), $context); } } - if (in_array($resolvedExpr->getType(), ['int', 'long'])) { + if (\in_array($resolvedExpr->getType(), ['int', 'long'])) { return new CompiledExpression('bool', 'zephir_array_isset_long_fetch('.$code.', '.$this->getVariableCode($resolvedExpr).', '.$flags.')', $expression); - } elseif (in_array($resolvedExpr->getType(), ['variable', 'mixed', 'string'])) { + } elseif (\in_array($resolvedExpr->getType(), ['variable', 'mixed', 'string'])) { return new CompiledExpression('bool', 'zephir_array_isset_fetch('.$code.', '.$this->getVariableCode($resolvedExpr).', '.$flags.')', $expression); } @@ -983,7 +982,7 @@ public function resolveValue($value, CompilationContext $context): Variable | bo $value = $this->getVariableCode($tempVariable); } else { if ($value instanceof CompiledExpression) { - if (in_array($value->getType(), ['array', 'variable', 'mixed'])) { + if (\in_array($value->getType(), ['array', 'variable', 'mixed'])) { $value = $context->symbolTable->getVariableForWrite($value->getCode(), $context); } else { return $value->getCode(); @@ -1414,7 +1413,7 @@ public function arrayFetch(Variable $var, Variable $src, $index, $flags, $arrayA $arrayAccess['right'] ); } - if ($isVariable && in_array($index->getType(), ['variable', 'string', 'mixed'])) { + if ($isVariable && \in_array($index->getType(), ['variable', 'string', 'mixed'])) { $output = 'zephir_array_fetch('.$this->getVariableCode($var).', '.$this->getVariableCode($src).', '.$this->getVariableCode($index).', '.$flags.', "'.Compiler::getShortUserPath($arrayAccess['file']).'", '.$arrayAccess['line'].');'; } else { if ($isVariable) { diff --git a/Library/CompilerFile.php b/Library/CompilerFile.php index b3722bb9c..03c4042f0 100644 --- a/Library/CompilerFile.php +++ b/Library/CompilerFile.php @@ -893,7 +893,7 @@ public function applyClassHeaders(CompilationContext $compilationContext) $separators = str_repeat('../', \count(explode('\\', $classDefinition->getCompleteName())) - 1); - $code = PHP_EOL; + $code = PHP_EOL; $code .= '#ifdef HAVE_CONFIG_H'.PHP_EOL; $code .= '#include "'.$separators.'ext_config.h"'.PHP_EOL; $code .= '#endif'.PHP_EOL; diff --git a/Library/Passes/LocalContextPass.php b/Library/Passes/LocalContextPass.php index aee0d9563..395fc75fb 100644 --- a/Library/Passes/LocalContextPass.php +++ b/Library/Passes/LocalContextPass.php @@ -57,9 +57,9 @@ public function declareVariables(array $statement): void foreach ($statement['variables'] as $variable) { if (isset($variable['expr'])) { if ( - 'string' === $variable['expr']['type'] || - 'empty-array' === $variable['expr']['type'] || - 'array' === $variable['expr']['type'] + 'string' === $variable['expr']['type'] + || 'empty-array' === $variable['expr']['type'] + || 'array' === $variable['expr']['type'] ) { $this->variables[$variable['variable']] = false; continue; diff --git a/Library/Passes/SkipVariantInit.php b/Library/Passes/SkipVariantInit.php index 9864cc534..1fd968bac 100644 --- a/Library/Passes/SkipVariantInit.php +++ b/Library/Passes/SkipVariantInit.php @@ -15,8 +15,6 @@ use Zephir\StatementsBlock; -use function count; - /** * In 'if'/'else' statements sometimes dynamical variables are initialized in every branch * Same case in 'switch' statements @@ -95,7 +93,7 @@ public function getVariables(): array } $variables = []; - $numberBranches = count($this->branches); + $numberBranches = \count($this->branches); foreach ($variableStats as $variable => $number) { if ($number == $numberBranches) { $variables[] = $variable;