Skip to content

Commit

Permalink
Use strict in_array checks in formatter (#110)
Browse files Browse the repository at this point in the history
* Use strict in_array checks in formatter

* Use strict in_array checks in formatter

* Use strict in_array checks in formatter

* Upgrade multi-tester

* Update multitester.yml
  • Loading branch information
kylekatarnls committed Sep 7, 2023
1 parent 36d20f0 commit d8e0a30
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 13 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/multitester.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ jobs:
uses: actions/cache@v2
with:
path: vendor
key: ${{ runner.os }}-php-multi-${{ matrix.php }}-${{ hashFiles('**/composer.lock') }}
key: ${{ runner.os }}-php-multi-v2-${{ matrix.php }}-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-multi-${{ matrix.php }}-
${{ runner.os }}-php-multi-v2-${{ matrix.php }}-
- name: Install dependencies
if: steps.composer-cache.outputs.cache-hit != 'true'
run: |
composer config version 1.9.0
composer require kylekatarnls/multi-tester:^1.1 --no-update --no-interaction
composer require kylekatarnls/multi-tester:^2.3 --no-update --no-interaction
composer update --prefer-dist --prefer-${{ matrix.setup }} --no-progress --no-interaction
- name: Run test suites
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"nodejs-php-fallback/uglify": "^1.0.4",
"nodejs-php-fallback/stylus": "^1.0.4",
"cebe/markdown": "^1.1",
"kylekatarnls/multi-tester": "^1.4"
"kylekatarnls/multi-tester": "^2.3"
},
"replace": {
"phug/ast": "self.version",
Expand Down
2 changes: 1 addition & 1 deletion src/Phug/Formatter/Formatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/Phug/Formatter/Formatter/AbstractFormat.php
Original file line number Diff line number Diff line change
Expand Up @@ -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"
: '';

Expand Down Expand Up @@ -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;
}
}
Expand Down Expand Up @@ -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;',
' }',
' }',
Expand Down Expand Up @@ -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;',
Expand Down
2 changes: 1 addition & 1 deletion src/Phug/Formatter/Formatter/Element/CodeElement.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public function needAccolades()
$this->isCodeBlockOpening() &&
!$this->hasBlockContent()
)
) && !in_array(end($tokens), [';', '{']);
) && !in_array(end($tokens), [';', '{'], true);
}

/**
Expand Down
6 changes: 3 additions & 3 deletions src/Phug/Formatter/Formatter/Format/XmlFormat.php
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
Expand Down Expand Up @@ -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 '';
}
}
Expand Down

0 comments on commit d8e0a30

Please sign in to comment.