Skip to content

Commit

Permalink
[TASK] Bump friendsofphp/php-cs-fixer:^3.37.1
Browse files Browse the repository at this point in the history
Also align rules with core

> composer req --dev friendsofphp/php-cs-fixer:^3.37.1
> Build/Scripts/runTests.sh -p 8.1 -s cgl

Releases: main, 7
  • Loading branch information
lolli42 committed Oct 30, 2023
1 parent 809cbb7 commit 4ee0895
Show file tree
Hide file tree
Showing 33 changed files with 81 additions and 54 deletions.
35 changes: 22 additions & 13 deletions Build/php-cs-fixer/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,27 +19,33 @@
->setRiskyAllowed(true)
->setRules([
'@DoctrineAnnotation' => true,
'@PSR2' => true,
// @todo: Switch to @PER-CS2.0 once php-cs-fixer's todo list is done: https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/issues/7247
'@PER-CS1.0' => true,
'array_syntax' => ['syntax' => 'short'],
'blank_line_after_opening_tag' => true,
'braces' => ['allow_single_line_closure' => true],
'cast_spaces' => ['space' => 'none'],
'compact_nullable_typehint' => true,
// @todo: Can be dropped once we enable @PER-CS2.0
'concat_space' => ['spacing' => 'one'],
'declare_equal_normalize' => ['space' => 'none'],
'declare_parentheses' => true,
'dir_constant' => true,
'function_typehint_space' => true,
'lowercase_cast' => true,
'method_argument_space' => ['on_multiline' => 'ensure_fully_multiline'],
// @todo: Can be dropped once we enable @PER-CS2.0
'function_declaration' => [
'closure_fn_spacing' => 'none',
],
'function_to_constant' => ['functions' => ['get_called_class', 'get_class', 'get_class_this', 'php_sapi_name', 'phpversion', 'pi']],
'type_declaration_spaces' => true,
'global_namespace_import' => ['import_classes' => false, 'import_constants' => false, 'import_functions' => false],
'list_syntax' => ['syntax' => 'short'],
// @todo: Can be dropped once we enable @PER-CS2.0
'method_argument_space' => true,
'modernize_strpos' => true,
'modernize_types_casting' => true,
'native_function_casing' => true,
'new_with_braces' => true,
'no_alias_functions' => true,
'no_blank_lines_after_phpdoc' => true,
'no_empty_phpdoc' => true,
'no_empty_statement' => true,
'no_extra_blank_lines' => true,
'no_leading_import_slash' => true,
'no_leading_namespace_whitespace' => true,
'no_null_property_initialization' => true,
'no_short_bool_cast' => true,
Expand All @@ -49,8 +55,8 @@
'no_unneeded_control_parentheses' => true,
'no_unused_imports' => true,
'no_useless_else' => true,
'no_whitespace_in_blank_line' => true,
'ordered_imports' => true,
'no_useless_nullsafe_operator' => true,
'ordered_imports' => ['imports_order' => ['class', 'function', 'const'], 'sort_algorithm' => 'alpha'],
'php_unit_construct' => ['assertions' => ['assertEquals', 'assertSame', 'assertNotEquals', 'assertNotSame']],
'php_unit_mock_short_will_return' => true,
'php_unit_test_case_static_method_calls' => ['call_type' => 'self'],
Expand All @@ -63,8 +69,11 @@
'phpdoc_types_order' => ['null_adjustment' => 'always_last', 'sort_algorithm' => 'none'],
'return_type_declaration' => ['space_before' => 'none'],
'single_quote' => true,
'single_space_around_construct' => true,
'single_line_comment_style' => ['comment_types' => ['hash']],
'single_trait_insert_per_statement' => true,
// @todo: Can be dropped once we enable @PER-CS2.0
'single_line_empty_body' => true,
'trailing_comma_in_multiline' => ['elements' => ['arrays']],
'whitespace_after_comma_in_array' => true,
'whitespace_after_comma_in_array' => ['ensure_single_space' => true],
'yoda_style' => ['equal' => false, 'identical' => false, 'less_and_greater' => false],
]);
6 changes: 3 additions & 3 deletions Classes/Composer/ComposerPackageManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ private function getPackageFromPath(string $path): ?PackageInfo
*/
private function processMonoRepository(): void
{
if (! ($this->rootPackage()?->isMonoRepository() ?? false)) {
if (!($this->rootPackage()?->isMonoRepository() ?? false)) {
return;
}

Expand Down Expand Up @@ -374,7 +374,7 @@ private function getPackageComposerJson(string $path): ?array
}
try {
return json_decode((string)file_get_contents($composerFile), true, JSON_THROW_ON_ERROR);
} catch(\Throwable) {
} catch (\Throwable) {
// skipped
}
return null;
Expand Down Expand Up @@ -490,7 +490,7 @@ private function split(string $path): array
if (str_starts_with($path, '/')) {
$root .= '/';
$path = $length > 1 ? substr($path, 1) : '';
} elseif ($length > 1 && ctype_alpha($path[0]) && ':' === $path[1]) {
} elseif ($length > 1 && ctype_alpha($path[0]) && $path[1] === ':') {
if ($length === 2) {
// Windows special case: "C:"
$root .= $path . '/';
Expand Down
9 changes: 4 additions & 5 deletions Classes/Composer/PackageInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ public function __construct(
private readonly string $extensionKey,
private readonly ?array $info = null,
private readonly ?array $extEmConf = null,
) {
}
) {}

public function getName(): string
{
Expand Down Expand Up @@ -96,12 +95,12 @@ public function getExtensionKey(): string

public function getVendorDir(): string
{
return (string)($this?->info['config']['vendor-dir'] ?? '');
return (string)($this->info['config']['vendor-dir'] ?? '');
}

public function getWebDir(): string
{
return (string)($this?->info['extra']['typo3/cms']['web-dir'] ?? '');
return (string)($this->info['extra']['typo3/cms']['web-dir'] ?? '');
}

/**
Expand All @@ -113,7 +112,7 @@ public function getReplacesPackageNames(): array
if ($this->isMonoRepository()) {
// Monorepo root composer.json replaces core system extension. We do not want that happen, so
// ignore only replaced core extensions.
$keys = array_filter($keys, static fn ($value) => !str_starts_with($value, 'typo3/cms-'));
$keys = array_filter($keys, static fn($value) => !str_starts_with($value, 'typo3/cms-'));
}
return $keys;
}
Expand Down
1 change: 1 addition & 0 deletions Classes/Core/Acceptance/Extension/BackendEnvironment.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

declare(strict_types=1);

namespace TYPO3\TestingFramework\Core\Acceptance\Extension;

/*
Expand Down
1 change: 1 addition & 0 deletions Classes/Core/Acceptance/Helper/AbstractModalDialog.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

declare(strict_types=1);

namespace TYPO3\TestingFramework\Core\Acceptance\Helper;

/*
Expand Down
4 changes: 2 additions & 2 deletions Classes/Core/Acceptance/Helper/AbstractPageTree.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

declare(strict_types=1);

namespace TYPO3\TestingFramework\Core\Acceptance\Helper;

/*
Expand All @@ -16,7 +17,6 @@
* The TYPO3 project - inspiring people to share!
*/

use AcceptanceTester;
use Facebook\WebDriver\Remote\RemoteWebElement;

/**
Expand All @@ -31,7 +31,7 @@ abstract class AbstractPageTree
public static $treeItemAnchorSelector = 'text.node-name';

/**
* @var AcceptanceTester
* @var \AcceptanceTester
*/
protected $tester;

Expand Down
1 change: 1 addition & 0 deletions Classes/Core/Acceptance/Helper/Acceptance.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

declare(strict_types=1);

namespace TYPO3\TestingFramework\Core\Acceptance\Helper;

/*
Expand Down
1 change: 1 addition & 0 deletions Classes/Core/Acceptance/Helper/Login.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

declare(strict_types=1);

namespace TYPO3\TestingFramework\Core\Acceptance\Helper;

/*
Expand Down
1 change: 1 addition & 0 deletions Classes/Core/Acceptance/Helper/Topbar.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

declare(strict_types=1);

namespace TYPO3\TestingFramework\Core\Acceptance\Helper;

/*
Expand Down
1 change: 1 addition & 0 deletions Classes/Core/Acceptance/Step/FrameSteps.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

declare(strict_types=1);

namespace TYPO3\TestingFramework\Core\Acceptance\Step;

/*
Expand Down
1 change: 1 addition & 0 deletions Classes/Core/AccessibleProxyTrait.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

declare(strict_types=1);

namespace TYPO3\TestingFramework\Core;

/*
Expand Down
3 changes: 2 additions & 1 deletion Classes/Core/BaseTestCase.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

declare(strict_types=1);

namespace TYPO3\TestingFramework\Core;

/*
Expand Down Expand Up @@ -75,7 +76,7 @@ protected function tearDown(): void
self::fail(
'tearDown() integrity check found changed error_reporting. Before was '
. $backupErrorReporting . ' compared to current ' . $currentErrorReporting . ' in '
. '"' . get_class($this) . '".'
. '"' . static::class . '".'
. 'Please check and verify that this is intended and add proper cleanup to the test.'
);
}
Expand Down
5 changes: 2 additions & 3 deletions Classes/Core/Exception.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

declare(strict_types=1);

namespace TYPO3\TestingFramework\Core;

/*
Expand All @@ -20,6 +21,4 @@
* An exception - Thrown in abstract test cases to mark
* a test configuration or setup error.
*/
class Exception extends \Exception
{
}
class Exception extends \Exception {}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

declare(strict_types=1);

namespace TYPO3\TestingFramework\Core\Functional\Framework\Constraint\RequestSection;

/*
Expand Down Expand Up @@ -109,7 +110,7 @@ protected function getNonMatchingValues(array $records)
$values = $this->values;

foreach ($records as $recordIdentifier => $recordData) {
if (strpos($recordIdentifier, $this->table . ':') !== 0) {
if (!str_starts_with($recordIdentifier, $this->table . ':')) {
continue;
}
if (isset($recordData[$this->field])
Expand All @@ -131,7 +132,7 @@ protected function getRemainingRecords(array $records)
$values = $this->values;

foreach ($records as $recordIdentifier => $recordData) {
if (strpos($recordIdentifier, $this->table . ':') !== 0) {
if (!str_starts_with($recordIdentifier, $this->table . ':')) {
unset($records[$recordIdentifier]);
continue;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

declare(strict_types=1);

namespace TYPO3\TestingFramework\Core\Functional\Framework\Constraint\RequestSection;

/*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

declare(strict_types=1);

namespace TYPO3\TestingFramework\Core\Functional\Framework\Constraint\RequestSection;

/*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

declare(strict_types=1);

namespace TYPO3\TestingFramework\Core\Functional\Framework\Constraint\RequestSection;

/*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

declare(strict_types=1);

namespace TYPO3\TestingFramework\Core\Functional\Framework\Constraint\RequestSection;

/*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

declare(strict_types=1);

namespace TYPO3\TestingFramework\Core\Functional\Framework\Constraint\RequestSection;

/*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

declare(strict_types=1);

namespace TYPO3\TestingFramework\Core\Functional\Framework\DataHandling;

/*
Expand Down Expand Up @@ -164,7 +165,7 @@ public function modifyRecords(int $pageId, array $tableRecordData)
if ($recordData['uid'] === '__NEW') {
$currentUid = $this->getUniqueIdForNewRecords();
}
if (strpos((string)$currentUid, 'NEW') === 0) {
if (str_starts_with((string)$currentUid, 'NEW')) {
$recordData['pid'] = $pageId;
}
unset($recordData['uid']);
Expand Down Expand Up @@ -482,7 +483,7 @@ protected function resolvePreviousUid(array $recordData, $previousUid): array
return $recordData;
}
foreach ($recordData as $fieldName => $fieldValue) {
if (strpos((string)$fieldValue, '__previousUid') === false) {
if (!str_contains((string)$fieldValue, '__previousUid')) {
continue;
}
$recordData[$fieldName] = str_replace('__previousUid', $previousUid, $fieldValue);
Expand All @@ -501,7 +502,7 @@ protected function resolveNextUid(array $recordData, $nextUid): array
return $recordData;
}
foreach ($recordData as $fieldName => $fieldValue) {
if (is_array($fieldValue) || strpos((string)$fieldValue, '__nextUid') === false) {
if (is_array($fieldValue) || !str_contains((string)$fieldValue, '__nextUid')) {
continue;
}
$recordData[$fieldName] = str_replace('__nextUid', $nextUid, $fieldValue);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

declare(strict_types=1);

namespace TYPO3\TestingFramework\Core\Functional\Framework\DataHandling\Scenario;

/*
Expand Down Expand Up @@ -477,7 +478,7 @@ private function setInDataMap(
// current item did not have any values in data map, use last identifer
if ($currentIndex === false && !empty($identifiers)) {
$values['pid'] = '-' . $identifiers[count($identifiers) - 1];
// current item does have values in data map, use previous identifier
// current item does have values in data map, use previous identifier
} elseif ($currentIndex > 0) {
$previousIndex = $identifiers[$currentIndex - 1];
$values['pid'] = '-' . $identifiers[$previousIndex];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

declare(strict_types=1);

namespace TYPO3\TestingFramework\Core\Functional\Framework\DataHandling\Scenario;

/*
Expand Down Expand Up @@ -117,10 +118,10 @@ function ($value) {
if (!is_string($value)) {
return $value;
}
if (strpos($value, 'NEW') === 0) {
if (str_starts_with($value, 'NEW')) {
return $this->dataHandler->substNEWwithIDs[$value] ?? $value;
}
if (strpos($value, '-NEW') === 0) {
if (str_starts_with($value, '-NEW')) {
return $this->dataHandler->substNEWwithIDs[substr($value, 1)] ?? $value;
}
return $value;
Expand Down Expand Up @@ -151,10 +152,10 @@ function ($value) {
if (!is_string($value)) {
return $value;
}
if (strpos($value, 'NEW') === 0) {
if (str_starts_with($value, 'NEW')) {
return $this->dataHandler->substNEWwithIDs[$value] ?? $value;
}
if (strpos($value, '-NEW') === 0) {
if (str_starts_with($value, '-NEW')) {
return $this->dataHandler->substNEWwithIDs[substr($value, 1)] ?? $value;
}
return $value;
Expand Down
Loading

0 comments on commit 4ee0895

Please sign in to comment.