Skip to content

Commit

Permalink
[TASK] Bump friendsofphp/php-cs-fixer:^3.37.1 (#515) (#516)
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 authored Oct 30, 2023
1 parent 5c61903 commit 240bc93
Show file tree
Hide file tree
Showing 32 changed files with 77 additions and 59 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],
]);
4 changes: 2 additions & 2 deletions Classes/Composer/ComposerPackageManager.php
Original file line number Diff line number Diff line change
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 $t) {
} catch (\Throwable $t) {
// 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
1 change: 1 addition & 0 deletions Classes/Composer/ExtensionTestEnvironment.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

declare(strict_types=1);

namespace TYPO3\TestingFramework\Composer;

/*
Expand Down
2 changes: 1 addition & 1 deletion Classes/Composer/PackageInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,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
4 changes: 1 addition & 3 deletions Classes/Core/Acceptance/Extension/BackendEnvironment.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,4 @@ class_alias(BackendEnvironmentCodeceptionFive::class, 'TYPO3\\TestingFramework\\
class_alias(BackendEnvironmentCodeceptionFour::class, 'TYPO3\\TestingFramework\\Core\\Acceptance\\Extension\\BackendEnvironmentCoreConditionalParent');
}

abstract class BackendEnvironment extends BackendEnvironmentCoreConditionalParent
{
}
abstract class BackendEnvironment extends BackendEnvironmentCoreConditionalParent {}
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
3 changes: 2 additions & 1 deletion 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 Expand Up @@ -111,7 +112,7 @@ public function assertEmptyBrowserConsole()
*/
protected function isJSError($logEntryLevel, $message)
{
return $logEntryLevel === 'SEVERE' && strpos($message, 'ERR_PROXY_CONNECTION_FAILED') === false;
return $logEntryLevel === 'SEVERE' && !str_contains($message, 'ERR_PROXY_CONNECTION_FAILED');
}

/**
Expand Down
4 changes: 1 addition & 3 deletions Classes/Core/Acceptance/Helper/Login.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,4 @@ class_alias(LoginCodeceptionFive::class, 'TYPO3\\TestingFramework\\Core\\Accepta
class_alias(LoginCodeceptionFour::class, 'TYPO3\\TestingFramework\\Core\\Acceptance\\Helper\\LoginConditionalParent');
}

class Login extends LoginConditionalParent
{
}
class Login extends LoginConditionalParent {}
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
1 change: 1 addition & 0 deletions Classes/Core/DatabaseConnectionWrapper.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
4 changes: 1 addition & 3 deletions Classes/Core/Exception.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,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
Expand Up @@ -108,7 +108,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 @@ -130,7 +130,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\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 @@ -494,7 +495,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 @@ -513,7 +514,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;

/*
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
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
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\Snapshot;

/*
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\Snapshot;

/*
Expand All @@ -26,7 +27,7 @@ class DatabaseSnapshot
/**
* Data up to 10 MiB is kept in memory
*/
private const VALUE_IN_MEMORY_THRESHOLD = 1024**2 * 10;
private const VALUE_IN_MEMORY_THRESHOLD = 1024 ** 2 * 10;

private static $instance;
private string $sqliteDir;
Expand Down
1 change: 1 addition & 0 deletions Classes/Core/Functional/Framework/FrameworkState.php
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;

/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public function jsonSerialize(): array
{
return array_merge(
get_object_vars($this),
['__type' => get_class($this)]
['__type' => static::class]
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ public function getInstruction(string $identifier): ?AbstractInstruction
return $this->instructions[$identifier] ?? null;
}

public function withParsedBody(?array $parsedBody=null): InternalRequest
public function withParsedBody(?array $parsedBody = null): InternalRequest
{
$target = clone $this;
$target->parsedBody = $parsedBody;
Expand Down
2 changes: 1 addition & 1 deletion Classes/Core/Functional/Framework/Frontend/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
*/
class Response
{
const STATUS_Failure = 'failure';
public const STATUS_Failure = 'failure';

/**
* @var string
Expand Down
Loading

0 comments on commit 240bc93

Please sign in to comment.