Skip to content

Commit b60f14e

Browse files
committed
minor #14097 [2.3] Static Code Analysis for Components (kalessil)
This PR was squashed before being merged into the 2.3 branch (closes #14097). Discussion ---------- [2.3] Static Code Analysis for Components | Q | A | ------------- | --- | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | n/a | License | MIT | Doc PR | n/a Static Code Analysis with Php Inspections (EA Extended), no functional changes: - array_keys/array_values usage as foreach array - foreach value by reference - added unsets to keep scope clear - strstr usage as strpos fixed - array_push miss-use resolved Commits ------- 78cc93c [2.3] Static Code Analysis for Components
2 parents 550479e + ad29500 commit b60f14e

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

Extension/Core/DataTransformer/BaseDateTimeTransformer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@ abstract class BaseDateTimeTransformer implements DataTransformerInterface
4040
*/
4141
public function __construct($inputTimezone = null, $outputTimezone = null)
4242
{
43-
if (!is_string($inputTimezone) && null !== $inputTimezone) {
43+
if (null !== $inputTimezone && !is_string($inputTimezone)) {
4444
throw new UnexpectedTypeException($inputTimezone, 'string');
4545
}
4646

47-
if (!is_string($outputTimezone) && null !== $outputTimezone) {
47+
if (null !== $outputTimezone && !is_string($outputTimezone)) {
4848
throw new UnexpectedTypeException($outputTimezone, 'string');
4949
}
5050

Extension/Core/DataTransformer/DateTimeToArrayTransformer.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@ public function transform($dateTime)
9999
// remove leading zeros
100100
$entry = (string) (int) $entry;
101101
}
102+
// unset reference to keep scope clear
103+
unset($entry);
102104
}
103105

104106
return $result;

Extension/Core/EventListener/MergeCollectionListener.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public function onSubmit(FormEvent $event)
7474
}
7575

7676
// If we are not allowed to change anything, return immediately
77-
if ((!$this->allowAdd && !$this->allowDelete) || $data === $dataToMergeInto) {
77+
if ($data === $dataToMergeInto || (!$this->allowAdd && !$this->allowDelete)) {
7878
$event->setData($dataToMergeInto);
7979

8080
return;

0 commit comments

Comments
 (0)