Skip to content

Commit fb5f95d

Browse files
authored
phpcs-fixer: ordered_types (OpenMage#5065)
* phpcs-fixer: `ordered_types` - see https://cs.symfony.com/doc/rules/class_notation/ordered_types.html * exception
1 parent f026a43 commit fb5f95d

File tree

16 files changed

+42
-23
lines changed

16 files changed

+42
-23
lines changed

.php-cs-fixer.dist.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
'nullable_type_declaration_for_default_null_value' => true,
1919
// Operators - when multiline - must always be at the beginning or at the end of the line.
2020
'operator_linebreak' => true,
21+
// Sort union types and intersection types using configured order.
22+
'ordered_types' => true,
2123
// Calls to PHPUnit\Framework\TestCase static methods must all be of the same type, either $this->, self:: or static::
2224
'php_unit_test_case_static_method_calls' => ['call_type' => 'self'],
2325
// PHPDoc annotation descriptions should not be a sentence.
@@ -44,12 +46,16 @@
4446
'phpdoc_var_annotation_correct_order' => true,
4547
// @var and @type annotations of classy properties should not contain the name.
4648
'phpdoc_var_without_name' => true,
49+
// There MUST NOT be more than one property or constant declared per statement.
50+
'single_class_element_per_statement' => true,
4751
// Convert double quotes to single quotes for simple strings.
4852
'single_quote' => true,
4953
// Arguments lists, array destructuring lists, arrays that are multi-line, match-lines and parameters lists must have a trailing comma.
5054
// removed "match" and "parameters" for PHP7
5155
// see https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/issues/8308
5256
'trailing_comma_in_multiline' => ['after_heredoc' => true, 'elements' => ['arguments', 'array_destructuring', 'arrays']],
57+
// A single space or none should be around union type and intersection type operators.
58+
'types_spaces' => true,
5359
])
5460
->setFinder(
5561
PhpCsFixer\Finder::create()

app/code/core/Mage/Admin/Model/Resource/User.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,8 @@ public function delete(Mage_Core_Model_Abstract $user)
187187
/**
188188
* TODO: unify _saveRelations() and add() methods, they make same things
189189
*
190+
* @throws Mage_Core_Exception
191+
* @throws Zend_Db_Adapter_Exception
190192
* @return $this|Mage_Core_Model_Abstract
191193
*/
192194
public function _saveRelations(Mage_Core_Model_Abstract $user)
@@ -232,9 +234,12 @@ public function _saveRelations(Mage_Core_Model_Abstract $user)
232234
}
233235

234236
$adapter->commit();
235-
} catch (Mage_Core_Exception|Exception $e) {
237+
} catch (Mage_Core_Exception $mageCoreException) {
236238
$adapter->rollBack();
237-
throw $e;
239+
throw $mageCoreException;
240+
} catch (Exception $exception) {
241+
$adapter->rollBack();
242+
throw $exception;
238243
}
239244

240245
return $this;

app/code/core/Mage/Api/Model/Server/Adapter/Soap.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,10 @@ public function run()
153153
$this->_soap->handle(),
154154
),
155155
);
156-
} catch (Zend_Soap_Server_Exception|Exception $e) {
157-
$this->fault($e->getCode(), $e->getMessage());
156+
} catch (Zend_Soap_Server_Exception $zendSoapServerException) {
157+
$this->fault($zendSoapServerException->getCode(), $zendSoapServerException->getMessage());
158+
} catch (Exception $exception) {
159+
$this->fault($exception->getCode(), $exception->getMessage());
158160
}
159161
}
160162

app/code/core/Mage/Api/Model/Server/V2/Adapter/Soap.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,10 @@ public function run()
6666
->setHeader('Content-Type', 'text/xml; charset=' . $apiConfigCharset)
6767
->setHeader('Content-Length', strlen($content), true)
6868
->setBody($content);
69-
} catch (Zend_Soap_Server_Exception|Exception $e) {
70-
$this->fault($e->getCode(), $e->getMessage());
69+
} catch (Zend_Soap_Server_Exception $zendSoapServerException) {
70+
$this->fault($zendSoapServerException->getCode(), $zendSoapServerException->getMessage());
71+
} catch (Exception $exception) {
72+
$this->fault($exception->getCode(), $exception->getMessage());
7173
}
7274
}
7375

app/code/core/Mage/Api/Model/Server/Wsi/Adapter/Soap.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,10 @@ public function run()
8787
->setHeader('Content-Type', 'text/xml; charset=' . $apiConfigCharset)
8888
->setHeader('Content-Length', strlen($content), true)
8989
->setBody($content);
90-
} catch (Zend_Soap_Server_Exception|Exception $e) {
91-
$this->fault($e->getCode(), $e->getMessage());
90+
} catch (Zend_Soap_Server_Exception $zendSoapServerException) {
91+
$this->fault($zendSoapServerException->getCode(), $zendSoapServerException->getMessage());
92+
} catch (Exception $exception) {
93+
$this->fault($exception->getCode(), $exception->getMessage());
9294
}
9395
}
9496

app/code/core/Mage/Catalog/Model/Category/Api.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,8 +274,10 @@ public function create($parentId, $categoryData, $store = null)
274274
}
275275

276276
$category->save();
277-
} catch (Mage_Core_Exception|Exception $e) {
278-
$this->_fault('data_invalid', $e->getMessage());
277+
} catch (Mage_Core_Exception $mageCoreException) {
278+
$this->_fault('data_invalid', $mageCoreException->getMessage());
279+
} catch (Exception $exception) {
280+
$this->_fault('data_invalid', $exception->getMessage());
279281
}
280282

281283
return $category->getId();

tests/unit/Base/DefaultConfigTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ final class DefaultConfigTest extends TestCase
2222
/**
2323
* @dataProvider provideGetStoreConfig
2424
*/
25-
public function testGetStoreConfig(string $expectedResult, string $path, bool|int|Mage_Core_Model_Store|null|string $store = null): void
25+
public function testGetStoreConfig(string $expectedResult, string $path, null|bool|int|Mage_Core_Model_Store|string $store = null): void
2626
{
2727
self::assertSame($expectedResult, Mage::getStoreConfig($path, $store));
2828
}

tests/unit/Mage/Admin/Model/BlockTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public static function setUpBeforeClass(): void
3636
* @group Model
3737
* @throws Exception
3838
*/
39-
public function testValidate(bool|array $expectedResult, array $methods): void
39+
public function testValidate(array|bool $expectedResult, array $methods): void
4040
{
4141
$mock = $this->getMockWithCalledMethods(Subject::class, $methods);
4242

tests/unit/Mage/Admin/Model/VariableTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public static function setUpBeforeClass(): void
3434
* @group Model
3535
* @throws Exception
3636
*/
37-
public function testValidate(bool|array $expectedResult, array $methods): void
37+
public function testValidate(array|bool $expectedResult, array $methods): void
3838
{
3939
$mock = $this->getMockWithCalledMethods(Subject::class, $methods);
4040

tests/unit/Mage/AdminNotification/Model/InboxTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public static function setUpBeforeClass(): void
3737
* @dataProvider provideGetSeverities
3838
* @group Model
3939
*/
40-
public function testGetSeverities(array|string|null $expectedResult, ?int $severity): void
40+
public function testGetSeverities(null|array|string $expectedResult, ?int $severity): void
4141
{
4242
self::assertSame($expectedResult, self::$subject->getSeverities($severity));
4343
}

0 commit comments

Comments
 (0)