From 592d692d2f32315ffcbe910a44beb8cd5971f800 Mon Sep 17 00:00:00 2001 From: kylekatarnls Date: Tue, 29 Aug 2023 09:02:33 +0200 Subject: [PATCH] Use strict in_array checks --- src/Phug/Compiler/Compiler/Element/BlockElement.php | 2 +- .../Compiler/NodeCompiler/ImportNodeCompiler.php | 4 ++-- src/Phug/DependencyInjection/DependencyInjection.php | 2 +- src/Phug/Event/EventManagerTrait.php | 2 +- src/Phug/Formatter/Formatter.php | 2 +- src/Phug/Formatter/Formatter/AbstractFormat.php | 8 ++++---- .../Formatter/Element/AbstractMarkupElement.php | 2 +- src/Phug/Formatter/Formatter/Element/CodeElement.php | 4 ++-- src/Phug/Formatter/Formatter/Format/XmlFormat.php | 10 ++++++---- .../Formatter/Partial/AssignmentHelpersTrait.php | 6 +++--- .../Formatter/Formatter/Partial/HandleVariable.php | 8 ++++---- src/Phug/Invoker/Invoker.php | 2 +- src/Phug/Lexer/Lexer/Partial/IndentStyleTrait.php | 2 +- src/Phug/Lexer/Lexer/Scanner/ConditionalScanner.php | 2 +- src/Phug/Lexer/Lexer/Scanner/KeywordScanner.php | 2 +- src/Phug/Lexer/Lexer/Scanner/TextScanner.php | 2 +- src/Phug/Phug/Phug/Cli.php | 4 ++-- src/Phug/Phug/Phug/Partial/ExtensionsTrait.php | 2 +- src/Phug/Phug/Phug/Partial/FacadeOptionsTrait.php | 2 +- src/Phug/Renderer/Renderer/Adapter/StreamAdapter.php | 2 +- src/Phug/Renderer/Renderer/Partial/AdapterTrait.php | 2 +- .../Renderer/Renderer/Partial/RendererOptionsTrait.php | 2 +- src/Phug/Renderer/Renderer/Profiler/Dump.php | 2 +- src/Phug/Renderer/Renderer/Profiler/ProfilerModule.php | 2 +- src/Phug/Util/Util/Partial/ModuleContainerTrait.php | 6 +++--- src/Phug/Util/Util/Partial/OptionTrait.php | 2 +- src/Phug/Util/Util/Partial/StaticMemberTrait.php | 2 +- tests/Phug/Ast/NodeTest.php | 2 +- tests/Phug/ExtensionTest.php | 6 +++--- 29 files changed, 49 insertions(+), 47 deletions(-) diff --git a/src/Phug/Compiler/Compiler/Element/BlockElement.php b/src/Phug/Compiler/Compiler/Element/BlockElement.php index d32fecad..01760b93 100644 --- a/src/Phug/Compiler/Compiler/Element/BlockElement.php +++ b/src/Phug/Compiler/Compiler/Element/BlockElement.php @@ -51,7 +51,7 @@ public function getName() */ public function addCompiler(CompilerInterface $compiler) { - if (!in_array($compiler, $this->compilers)) { + if (!in_array($compiler, $this->compilers, true)) { $blocks = &$compiler->getBlocksByName($this->name); $blocks[] = $this; $this->compilers[] = $compiler; diff --git a/src/Phug/Compiler/Compiler/NodeCompiler/ImportNodeCompiler.php b/src/Phug/Compiler/Compiler/NodeCompiler/ImportNodeCompiler.php index 45263ff6..70434387 100644 --- a/src/Phug/Compiler/Compiler/NodeCompiler/ImportNodeCompiler.php +++ b/src/Phug/Compiler/Compiler/NodeCompiler/ImportNodeCompiler.php @@ -27,7 +27,7 @@ protected function isPugImport($path) $extensions = $compiler->getOption('extensions'); if ($extension === '') { - return in_array('', $extensions); + return in_array('', $extensions, true); } if (!$compiler->getOption('allow_composite_extensions')) { @@ -135,7 +135,7 @@ public function compileNode(NodeInterface $node, ElementInterface $parent = null 'input', 'meta', 'hr', - ])) { + ], true)) { $yield = $yield->getParent(); } if ($compiler->getImportNode()) { diff --git a/src/Phug/DependencyInjection/DependencyInjection.php b/src/Phug/DependencyInjection/DependencyInjection.php index 525e557a..eecf2939 100644 --- a/src/Phug/DependencyInjection/DependencyInjection.php +++ b/src/Phug/DependencyInjection/DependencyInjection.php @@ -305,7 +305,7 @@ public function get($name, array $exclude = []) return call_user_func_array($this->cache[$cacheKey], func_get_args()); }; $arguments = array_map(function ($dependencyName) use ($exclude, $callee) { - return in_array($dependencyName, $exclude) + return in_array($dependencyName, $exclude, true) ? $callee : $this->get($dependencyName, $exclude); }, $dependency->getDependencies()); diff --git a/src/Phug/Event/EventManagerTrait.php b/src/Phug/Event/EventManagerTrait.php index 61b7ab46..78d7f6f9 100644 --- a/src/Phug/Event/EventManagerTrait.php +++ b/src/Phug/Event/EventManagerTrait.php @@ -50,7 +50,7 @@ public function mergeEventListeners($eventListeners) $listeners->setExtractFlags(ListenerQueue::EXTR_BOTH); foreach ($listeners as $listener) { - if (!in_array($listener['data'], $queue)) { + if (!in_array($listener['data'], $queue, true)) { $this->attach($eventName, $listener['data'], $listener['priority']); } } diff --git a/src/Phug/Formatter/Formatter.php b/src/Phug/Formatter/Formatter.php index 1d1f7eae..307177ab 100644 --- a/src/Phug/Formatter/Formatter.php +++ b/src/Phug/Formatter/Formatter.php @@ -504,7 +504,7 @@ public function formatDependencies() } foreach ($this->mixins->getRequirementsStates() as $key => $value) { - if ($value || $this->mixinsAllRequired || in_array($key, $this->mixinsPreCalled)) { + if ($value || $this->mixinsAllRequired || in_array($key, $this->mixinsPreCalled, true)) { $dependencies .= $this->mixins->get($key); } } diff --git a/src/Phug/Formatter/Formatter/AbstractFormat.php b/src/Phug/Formatter/Formatter/AbstractFormat.php index 10fa316d..d49365cf 100644 --- a/src/Phug/Formatter/Formatter/AbstractFormat.php +++ b/src/Phug/Formatter/Formatter/AbstractFormat.php @@ -248,7 +248,7 @@ public function format($element, $noDebug = false) if (is_a($element, $className)) { $elementCode = $handler($element); $debugCode = $debug ? $this->getDebugInfo($element) : ''; - $glue = mb_strlen($debugCode) && in_array(mb_substr($elementCode, 0, 1), ["\n", "\r"]) + $glue = mb_strlen($debugCode) && in_array(mb_substr($elementCode, 0, 1), ["\n", "\r"], true) ? "\n" : ''; @@ -463,7 +463,7 @@ protected function formatDynamicValue($formattedName, $value) if ($value instanceof ExpressionElement) { $code = strtolower($value->getValue()); - if (in_array($code, ['true', 'false', 'null', 'undefined'])) { + if (in_array($code, ['true', 'false', 'null', 'undefined'], true)) { return $code; } } @@ -770,7 +770,7 @@ protected function formatMixinElement(MixinElement $mixin) ' }', ' }', ' foreach ($__pug_mixin_vars as $__pug_key => &$__pug_value) {', - ' if (!in_array($__pug_key, $__pug_names)) {', + ' if (!in_array($__pug_key, $__pug_names, true)) {', ' $$__pug_key = &$__pug_value;', ' }', ' }', @@ -869,7 +869,7 @@ protected function formatMixinCallElement(MixinCallElement $mixinCall) '$__pug_mixin_vars = [];', 'foreach (array_keys(get_defined_vars()) as $__local_pug_key) {', ' if (mb_substr($__local_pug_key, 0, 6) === \'__pug_\' || '. - 'in_array($__local_pug_key, [\'attributes\', \'block\', \''.$variablesVariable.'\'])) {', + 'in_array($__local_pug_key, [\'attributes\', \'block\', \''.$variablesVariable.'\'], true)) {', ' continue;', ' }', ' $'.$variablesVariable.'[$__local_pug_key] = &$$__local_pug_key;', diff --git a/src/Phug/Formatter/Formatter/Element/AbstractMarkupElement.php b/src/Phug/Formatter/Formatter/Element/AbstractMarkupElement.php index 4f15754c..ae477906 100644 --- a/src/Phug/Formatter/Formatter/Element/AbstractMarkupElement.php +++ b/src/Phug/Formatter/Formatter/Element/AbstractMarkupElement.php @@ -19,7 +19,7 @@ abstract class AbstractMarkupElement extends AbstractAssignmentContainerElement public function belongsTo(array $tagList) { if (is_string($this->getName())) { - return in_array(strtolower($this->getName()), $tagList); + return in_array(strtolower($this->getName()), $tagList, true); } return false; diff --git a/src/Phug/Formatter/Formatter/Element/CodeElement.php b/src/Phug/Formatter/Formatter/Element/CodeElement.php index 7e442385..52b52403 100644 --- a/src/Phug/Formatter/Formatter/Element/CodeElement.php +++ b/src/Phug/Formatter/Formatter/Element/CodeElement.php @@ -82,7 +82,7 @@ public function isCodeBlockOpening() T_TRAIT, T_TRY, T_WHILE, - ]); + ], true); } public function hasBlockContent() @@ -106,7 +106,7 @@ public function needAccolades() $this->isCodeBlockOpening() && !$this->hasBlockContent() ) - ) && !in_array(end($tokens), [';', '{']); + ) && !in_array(end($tokens), [';', '{', true]); } /** diff --git a/src/Phug/Formatter/Formatter/Format/XmlFormat.php b/src/Phug/Formatter/Formatter/Format/XmlFormat.php index 6928e21d..e7b885df 100644 --- a/src/Phug/Formatter/Formatter/Format/XmlFormat.php +++ b/src/Phug/Formatter/Formatter/Format/XmlFormat.php @@ -170,12 +170,12 @@ protected function formatAttributeElement(AttributeElement $element) if ($nonEmptyAttribute && ( !$value || ($value instanceof TextElement && ((string) $value->getValue()) === '') || - (is_string($value) && in_array(trim($value), ['', '""', "''"])) + (is_string($value) && in_array(trim($value), ['', '""', "''"], true)) )) { return ''; } if ($value instanceof ExpressionElement) { - if ($nonEmptyAttribute && in_array(trim($value->getValue()), ['', '""', "''"])) { + if ($nonEmptyAttribute && in_array(trim($value->getValue()), ['', '""', "''"], true)) { return ''; } if (strtolower($value->getValue()) === 'true') { @@ -204,7 +204,7 @@ protected function formatAttributeElement(AttributeElement $element) $formattedValue ); } - if (in_array(strtolower($value->getValue()), ['false', 'null', 'undefined'])) { + if (in_array(strtolower($value->getValue()), ['false', 'null', 'undefined'], true)) { return ''; } } @@ -487,7 +487,9 @@ protected function hasDuplicateAttributeNames(MarkupInterface $element) $names = []; foreach ($element->getAttributes() as $attribute) { $name = $attribute->getName(); - if (($name instanceof ExpressionElement && !$name->hasStaticValue()) || in_array($name, $names)) { + if (($name instanceof ExpressionElement && !$name->hasStaticValue()) || + in_array($name, $names, true) + ) { return true; } diff --git a/src/Phug/Formatter/Formatter/Partial/AssignmentHelpersTrait.php b/src/Phug/Formatter/Formatter/Partial/AssignmentHelpersTrait.php index f5ec8c3b..ea9cc8d4 100644 --- a/src/Phug/Formatter/Formatter/Partial/AssignmentHelpersTrait.php +++ b/src/Phug/Formatter/Formatter/Partial/AssignmentHelpersTrait.php @@ -14,7 +14,7 @@ protected function provideAttributeAssignments() 'get_helper', function ($availableAssignments, $getHelper) { return function (&$attributes, $name, $value) use ($availableAssignments, $getHelper) { - if (!in_array($name, $availableAssignments)) { + if (!in_array($name, $availableAssignments, true)) { return $value; } @@ -143,7 +143,7 @@ protected function provideArrayEscape() 'pattern.html_text_escape', function ($arrayEscape, $escape) { return function ($name, $input) use ($arrayEscape, $escape) { - if (is_array($input) && in_array(strtolower($name), ['class', 'style'])) { + if (is_array($input) && in_array(strtolower($name), ['class', 'style'], true)) { $result = []; foreach ($input as $key => $value) { $result[$escape($key)] = $arrayEscape($name, $value); @@ -183,7 +183,7 @@ protected function provideClassAttributeAssignment() $input = $key; } foreach ($split($input) as $class) { - if (!in_array($class, $classes)) { + if (!in_array($class, $classes, true)) { $classes[] = $class; } } diff --git a/src/Phug/Formatter/Formatter/Partial/HandleVariable.php b/src/Phug/Formatter/Formatter/Partial/HandleVariable.php index 8cf7e28c..8b731c32 100644 --- a/src/Phug/Formatter/Formatter/Partial/HandleVariable.php +++ b/src/Phug/Formatter/Formatter/Partial/HandleVariable.php @@ -24,7 +24,7 @@ private function isInFunctionParams(&$tokens, $index) { $afterOpen = false; for ($i = $index - 1; $i >= 0; $i--) { - if (in_array($tokens[$i], [')', '}'])) { + if (in_array($tokens[$i], [')', '}'], true)) { break; } if ($tokens[$i] === '(') { @@ -34,7 +34,7 @@ private function isInFunctionParams(&$tokens, $index) if ($afterOpen && is_array($tokens[$i]) && in_array($tokens[$i][0], [ T_FUNCTION, T_USE, - ])) { + ], true)) { return true; } } @@ -102,13 +102,13 @@ private function isInExclusionContext(&$tokens, $index) T_COMMENT, T_DOC_COMMENT, T_WHITESPACE, - ])) { + ], true)) { continue; } break; } - if (in_array($tokenId, $exclusions)) { + if (in_array($tokenId, $exclusions, true)) { return true; } } diff --git a/src/Phug/Invoker/Invoker.php b/src/Phug/Invoker/Invoker.php index fefbc0d8..fc8e266e 100644 --- a/src/Phug/Invoker/Invoker.php +++ b/src/Phug/Invoker/Invoker.php @@ -107,7 +107,7 @@ public function remove(array $invokables) $filteredQueue = new ListenerQueue(); foreach ($queue as $invokable) { - if (!in_array($invokable, $invokables)) { + if (!in_array($invokable, $invokables, true)) { $filteredQueue->insert($invokable, 0); } } diff --git a/src/Phug/Lexer/Lexer/Partial/IndentStyleTrait.php b/src/Phug/Lexer/Lexer/Partial/IndentStyleTrait.php index 46de9cfa..19b9aa1d 100644 --- a/src/Phug/Lexer/Lexer/Partial/IndentStyleTrait.php +++ b/src/Phug/Lexer/Lexer/Partial/IndentStyleTrait.php @@ -42,7 +42,7 @@ public function getIndentStyle() */ public function setIndentStyle($indentStyle) { - if (!in_array($indentStyle, [null, Lexer::INDENT_TAB, Lexer::INDENT_SPACE])) { + if (!in_array($indentStyle, [null, Lexer::INDENT_TAB, Lexer::INDENT_SPACE], true)) { throw new \InvalidArgumentException( 'indentStyle needs to be null or one of the INDENT_* constants of the lexer' ); diff --git a/src/Phug/Lexer/Lexer/Scanner/ConditionalScanner.php b/src/Phug/Lexer/Lexer/Scanner/ConditionalScanner.php index afe04a54..931d8106 100644 --- a/src/Phug/Lexer/Lexer/Scanner/ConditionalScanner.php +++ b/src/Phug/Lexer/Lexer/Scanner/ConditionalScanner.php @@ -26,7 +26,7 @@ public function scan(State $state) //Make sure spaces are replaced from `elseif`/`else if` to make a final keyword, "elseif" $token->setName(preg_replace('/[ \t]/', '', $token->getName())); - if ($token->getName() === 'else' && !in_array($token->getSubject(), ['', false, null])) { + if ($token->getName() === 'else' && !in_array($token->getSubject(), ['', false, null], true)) { $state->throwException( 'The `else`-conditional statement can\'t have a subject' ); diff --git a/src/Phug/Lexer/Lexer/Scanner/KeywordScanner.php b/src/Phug/Lexer/Lexer/Scanner/KeywordScanner.php index 680f14a5..6ded4a3c 100644 --- a/src/Phug/Lexer/Lexer/Scanner/KeywordScanner.php +++ b/src/Phug/Lexer/Lexer/Scanner/KeywordScanner.php @@ -24,7 +24,7 @@ public function scan(State $state) )) { $name = $reader->getMatch('name'); - if (in_array($name, $keywords)) { + if (in_array($name, $keywords, true)) { $value = $reader->getMatch('value'); if (mb_substr($value, 0, 1) === ' ') { $value = mb_substr($value, 1); diff --git a/src/Phug/Lexer/Lexer/Scanner/TextScanner.php b/src/Phug/Lexer/Lexer/Scanner/TextScanner.php index 5938085c..2b4fa14e 100644 --- a/src/Phug/Lexer/Lexer/Scanner/TextScanner.php +++ b/src/Phug/Lexer/Lexer/Scanner/TextScanner.php @@ -19,7 +19,7 @@ class TextScanner implements ScannerInterface private function isTextStartToTrim(State $state, $text) { - return in_array(mb_substr((string) $text, 0, 1), [' ', "\t"]) && !$state->isAfterInterpolation(); + return in_array(mb_substr((string) $text, 0, 1), [' ', "\t"], true) && !$state->isAfterInterpolation(); } private function leftTrimValueIfNotAfterInterpolation(State $state, TextToken $token) diff --git a/src/Phug/Phug/Phug/Cli.php b/src/Phug/Phug/Phug/Cli.php index 782f008e..d77f6944 100644 --- a/src/Phug/Phug/Phug/Cli.php +++ b/src/Phug/Phug/Phug/Cli.php @@ -94,7 +94,7 @@ public function run($arguments) return false; } - if (!in_array($method, iterator_to_array($this->getAvailableMethods($customMethods)))) { + if (!in_array($method, iterator_to_array($this->getAvailableMethods($customMethods)), true)) { echo "The method $action is not available as CLI command in the $facade facade.\n"; $this->listAvailableMethods($customMethods); @@ -166,7 +166,7 @@ protected function execute($facade, $method, $arguments, $outputFile) { $callable = [$facade, $method]; $arguments = array_map(function ($argument) { - return in_array(substr((string) $argument, 0, 1), ['[', '{']) + return in_array(substr((string) $argument, 0, 1), ['[', '{'], true) ? json_decode($argument, true) : $argument; }, $arguments); diff --git a/src/Phug/Phug/Phug/Partial/ExtensionsTrait.php b/src/Phug/Phug/Phug/Partial/ExtensionsTrait.php index 9789e2c5..ed41d5f1 100644 --- a/src/Phug/Phug/Phug/Partial/ExtensionsTrait.php +++ b/src/Phug/Phug/Phug/Partial/ExtensionsTrait.php @@ -54,7 +54,7 @@ public static function getExtensionsOptions(array $extensions, array $options = */ public static function hasExtension($extensionClassName) { - return in_array(static::normalizeExtensionClassName($extensionClassName), static::getExtensionIds()); + return in_array(static::normalizeExtensionClassName($extensionClassName), static::getExtensionIds(), true); } /** diff --git a/src/Phug/Phug/Phug/Partial/FacadeOptionsTrait.php b/src/Phug/Phug/Phug/Partial/FacadeOptionsTrait.php index 0312a7a7..c4629bc7 100644 --- a/src/Phug/Phug/Phug/Partial/FacadeOptionsTrait.php +++ b/src/Phug/Phug/Phug/Partial/FacadeOptionsTrait.php @@ -36,7 +36,7 @@ protected static function isOptionMethod($method) 'setOptionsRecursive', 'setOptionsDefaults', 'unsetOption', - ]); + ], true); } protected static function getFacadeOptions() diff --git a/src/Phug/Renderer/Renderer/Adapter/StreamAdapter.php b/src/Phug/Renderer/Renderer/Adapter/StreamAdapter.php index c9653f13..38314f88 100644 --- a/src/Phug/Renderer/Renderer/Adapter/StreamAdapter.php +++ b/src/Phug/Renderer/Renderer/Adapter/StreamAdapter.php @@ -31,7 +31,7 @@ protected function setRenderingFile($__pug_php) { $stream = $this->getOption('stream_name').$this->getOption('stream_suffix'); - if (!in_array($stream, stream_get_wrappers())) { + if (!in_array($stream, stream_get_wrappers(), true)) { stream_register_wrapper($stream, Template::class); } diff --git a/src/Phug/Renderer/Renderer/Partial/AdapterTrait.php b/src/Phug/Renderer/Renderer/Partial/AdapterTrait.php index 332ef0df..a132728a 100644 --- a/src/Phug/Renderer/Renderer/Partial/AdapterTrait.php +++ b/src/Phug/Renderer/Renderer/Partial/AdapterTrait.php @@ -145,7 +145,7 @@ private function getSandboxCall(&$source, $method, $path, $input, callable $getS $adapter->displayCached($path, $input, $getSource, $parameters); }; - return in_array($method, ['display', 'displayFile']) + return in_array($method, ['display', 'displayFile'], true) ? $display() : $adapter->captureBuffer($display); } diff --git a/src/Phug/Renderer/Renderer/Partial/RendererOptionsTrait.php b/src/Phug/Renderer/Renderer/Partial/RendererOptionsTrait.php index fd8796f1..f8546c4f 100644 --- a/src/Phug/Renderer/Renderer/Partial/RendererOptionsTrait.php +++ b/src/Phug/Renderer/Renderer/Partial/RendererOptionsTrait.php @@ -63,7 +63,7 @@ protected function enableModule($moduleClassName, $className, ModuleContainerInt { /* @var ModuleContainerInterface $this */ - if (in_array($className, class_implements($moduleClassName)) && + if (in_array($className, class_implements($moduleClassName), true) && !$container->hasModule($moduleClassName) ) { $container->addModule($moduleClassName); diff --git a/src/Phug/Renderer/Renderer/Profiler/Dump.php b/src/Phug/Renderer/Renderer/Profiler/Dump.php index a783b805..d3e0b4fb 100644 --- a/src/Phug/Renderer/Renderer/Profiler/Dump.php +++ b/src/Phug/Renderer/Renderer/Profiler/Dump.php @@ -102,7 +102,7 @@ private function dumpValue($object, $deep, $maxDeep = 3) 'string', 'resource', 'NULL', - ])) { + ], true)) { return var_export($object, true); } diff --git a/src/Phug/Renderer/Renderer/Profiler/ProfilerModule.php b/src/Phug/Renderer/Renderer/Profiler/ProfilerModule.php index 83961ae7..2439a9cb 100644 --- a/src/Phug/Renderer/Renderer/Profiler/ProfilerModule.php +++ b/src/Phug/Renderer/Renderer/Profiler/ProfilerModule.php @@ -85,7 +85,7 @@ public function initialize() $this->eventDump = $this->getContainer()->getOption('profiler.dump_event'); - if (in_array($this->eventDump, ['var_dump', 'print_r'])) { + if (in_array($this->eventDump, ['var_dump', 'print_r'], true)) { $function = $this->eventDump; $this->eventDump = function ($value) use ($function) { return $this->getFunctionDump($value, $function); diff --git a/src/Phug/Util/Util/Partial/ModuleContainerTrait.php b/src/Phug/Util/Util/Partial/ModuleContainerTrait.php index e0f3356f..0ea30c8d 100644 --- a/src/Phug/Util/Util/Partial/ModuleContainerTrait.php +++ b/src/Phug/Util/Util/Partial/ModuleContainerTrait.php @@ -27,7 +27,7 @@ trait ModuleContainerTrait public function hasModule($module) { return $module instanceof ModuleInterface - ? in_array($module, $this->modules) + ? in_array($module, $this->modules, true) : isset($this->modules[$module]); } @@ -69,7 +69,7 @@ public function getStaticModules() public function addModule($module) { if ($module instanceof ModuleInterface) { - if (in_array($module, $this->modules)) { + if (in_array($module, $this->modules, true)) { throw new InvalidArgumentException( 'This occurrence of '.get_class($module).' is already registered.' ); @@ -142,7 +142,7 @@ public function addModules(array $modules) public function removeModule($module) { if ($module instanceof ModuleInterface) { - if (!in_array($module, $this->modules)) { + if (!in_array($module, $this->modules, true)) { throw new InvalidArgumentException( 'This occurrence of '.get_class($module).' is not registered.' ); diff --git a/src/Phug/Util/Util/Partial/OptionTrait.php b/src/Phug/Util/Util/Partial/OptionTrait.php index da82b989..1d68c3ba 100644 --- a/src/Phug/Util/Util/Partial/OptionTrait.php +++ b/src/Phug/Util/Util/Partial/OptionTrait.php @@ -91,7 +91,7 @@ private function setOptionArrays(array $arrays, $functionName) private function mergeOptionValue($name, $current, $addedValue, $functionName) { - if ($functionName === $this->recursiveReplaceFunction && in_array($name, $this->nonDeepOptions)) { + if ($functionName === $this->recursiveReplaceFunction && in_array($name, $this->nonDeepOptions, true)) { $functionName = $this->replaceFunction; } diff --git a/src/Phug/Util/Util/Partial/StaticMemberTrait.php b/src/Phug/Util/Util/Partial/StaticMemberTrait.php index f3938096..090a0465 100644 --- a/src/Phug/Util/Util/Partial/StaticMemberTrait.php +++ b/src/Phug/Util/Util/Partial/StaticMemberTrait.php @@ -19,7 +19,7 @@ public function hasStaticMember($member) return count($tokens) === 1 && is_array($tokens[0]) && - in_array($tokens[0][0], [T_CONSTANT_ENCAPSED_STRING, T_DNUMBER, T_LNUMBER]); + in_array($tokens[0][0], [T_CONSTANT_ENCAPSED_STRING, T_DNUMBER, T_LNUMBER], true); } return false; diff --git a/tests/Phug/Ast/NodeTest.php b/tests/Phug/Ast/NodeTest.php index de36059e..a5e0add3 100644 --- a/tests/Phug/Ast/NodeTest.php +++ b/tests/Phug/Ast/NodeTest.php @@ -595,7 +595,7 @@ public function testFind() $nameIn = function ($node, $names) { $pieces = preg_split('`[/\\\\]`', get_class($node)); - return in_array(end($pieces), $names); + return in_array(end($pieces), $names, true); }; self::assertSame([$a, $b, $c], $a->findArray(function ($node) use ($nameIn) { diff --git a/tests/Phug/ExtensionTest.php b/tests/Phug/ExtensionTest.php index 0cdb0c8d..2dc22f3e 100644 --- a/tests/Phug/ExtensionTest.php +++ b/tests/Phug/ExtensionTest.php @@ -80,13 +80,13 @@ public function testImplement() */ public function testAddModuleAsExtension() { - $compilerHas1 = in_array(CompilerModule::class, Phug::getRenderer()->getCompiler()->getOption('modules')); + $compilerHas1 = in_array(CompilerModule::class, Phug::getRenderer()->getCompiler()->getOption('modules'), true); $has1 = Phug::hasExtension(CompilerModule::class); Phug::addExtension(CompilerModule::class); - $compilerHas2 = in_array(CompilerModule::class, Phug::getRenderer()->getCompiler()->getOption('modules')); + $compilerHas2 = in_array(CompilerModule::class, Phug::getRenderer()->getCompiler()->getOption('modules'), true); $has2 = Phug::hasExtension(CompilerModule::class); Phug::removeExtension(CompilerModule::class); - $compilerHas3 = in_array(CompilerModule::class, Phug::getRenderer()->getCompiler()->getOption('modules')); + $compilerHas3 = in_array(CompilerModule::class, Phug::getRenderer()->getCompiler()->getOption('modules'), true); $has3 = Phug::hasExtension(CompilerModule::class); self::assertFalse($has1);