Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
'nullable_type_declaration_for_default_null_value' => true,
// Operators - when multiline - must always be at the beginning or at the end of the line.
'operator_linebreak' => true,
// Sort union types and intersection types using configured order.
'ordered_types' => true,
// Calls to PHPUnit\Framework\TestCase static methods must all be of the same type, either $this->, self:: or static::
'php_unit_test_case_static_method_calls' => ['call_type' => 'self'],
// PHPDoc annotation descriptions should not be a sentence.
Expand All @@ -44,12 +46,16 @@
'phpdoc_var_annotation_correct_order' => true,
// @var and @type annotations of classy properties should not contain the name.
'phpdoc_var_without_name' => true,
// There MUST NOT be more than one property or constant declared per statement.
'single_class_element_per_statement' => true,
// Convert double quotes to single quotes for simple strings.
'single_quote' => true,
// Arguments lists, array destructuring lists, arrays that are multi-line, match-lines and parameters lists must have a trailing comma.
// removed "match" and "parameters" for PHP7
// see https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/issues/8308
'trailing_comma_in_multiline' => ['after_heredoc' => true, 'elements' => ['arguments', 'array_destructuring', 'arrays']],
// A single space or none should be around union type and intersection type operators.
'types_spaces' => true,
])
->setFinder(
PhpCsFixer\Finder::create()
Expand Down
9 changes: 7 additions & 2 deletions app/code/core/Mage/Admin/Model/Resource/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,8 @@ public function delete(Mage_Core_Model_Abstract $user)
/**
* TODO: unify _saveRelations() and add() methods, they make same things
*
* @throws Mage_Core_Exception
* @throws Zend_Db_Adapter_Exception
* @return $this|Mage_Core_Model_Abstract
*/
public function _saveRelations(Mage_Core_Model_Abstract $user)
Expand Down Expand Up @@ -232,9 +234,12 @@ public function _saveRelations(Mage_Core_Model_Abstract $user)
}

$adapter->commit();
} catch (Mage_Core_Exception|Exception $e) {
} catch (Mage_Core_Exception $mageCoreException) {
$adapter->rollBack();
throw $e;
throw $mageCoreException;
} catch (Exception $exception) {
$adapter->rollBack();
throw $exception;
}

return $this;
Expand Down
6 changes: 4 additions & 2 deletions app/code/core/Mage/Api/Model/Server/Adapter/Soap.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,10 @@ public function run()
$this->_soap->handle(),
),
);
} catch (Zend_Soap_Server_Exception|Exception $e) {
$this->fault($e->getCode(), $e->getMessage());
} catch (Zend_Soap_Server_Exception $zendSoapServerException) {
$this->fault($zendSoapServerException->getCode(), $zendSoapServerException->getMessage());
} catch (Exception $exception) {
$this->fault($exception->getCode(), $exception->getMessage());
}
}

Expand Down
6 changes: 4 additions & 2 deletions app/code/core/Mage/Api/Model/Server/V2/Adapter/Soap.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,10 @@ public function run()
->setHeader('Content-Type', 'text/xml; charset=' . $apiConfigCharset)
->setHeader('Content-Length', strlen($content), true)
->setBody($content);
} catch (Zend_Soap_Server_Exception|Exception $e) {
$this->fault($e->getCode(), $e->getMessage());
} catch (Zend_Soap_Server_Exception $zendSoapServerException) {
$this->fault($zendSoapServerException->getCode(), $zendSoapServerException->getMessage());
} catch (Exception $exception) {
$this->fault($exception->getCode(), $exception->getMessage());
}
}

Expand Down
6 changes: 4 additions & 2 deletions app/code/core/Mage/Api/Model/Server/Wsi/Adapter/Soap.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,10 @@ public function run()
->setHeader('Content-Type', 'text/xml; charset=' . $apiConfigCharset)
->setHeader('Content-Length', strlen($content), true)
->setBody($content);
} catch (Zend_Soap_Server_Exception|Exception $e) {
$this->fault($e->getCode(), $e->getMessage());
} catch (Zend_Soap_Server_Exception $zendSoapServerException) {
$this->fault($zendSoapServerException->getCode(), $zendSoapServerException->getMessage());
} catch (Exception $exception) {
$this->fault($exception->getCode(), $exception->getMessage());
}
}

Expand Down
6 changes: 4 additions & 2 deletions app/code/core/Mage/Catalog/Model/Category/Api.php
Original file line number Diff line number Diff line change
Expand Up @@ -274,8 +274,10 @@ public function create($parentId, $categoryData, $store = null)
}

$category->save();
} catch (Mage_Core_Exception|Exception $e) {
$this->_fault('data_invalid', $e->getMessage());
} catch (Mage_Core_Exception $mageCoreException) {
$this->_fault('data_invalid', $mageCoreException->getMessage());
} catch (Exception $exception) {
$this->_fault('data_invalid', $exception->getMessage());
}

return $category->getId();
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/Base/DefaultConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ final class DefaultConfigTest extends TestCase
/**
* @dataProvider provideGetStoreConfig
*/
public function testGetStoreConfig(string $expectedResult, string $path, bool|int|Mage_Core_Model_Store|null|string $store = null): void
public function testGetStoreConfig(string $expectedResult, string $path, null|bool|int|Mage_Core_Model_Store|string $store = null): void
{
self::assertSame($expectedResult, Mage::getStoreConfig($path, $store));
}
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/Mage/Admin/Model/BlockTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public static function setUpBeforeClass(): void
* @group Model
* @throws Exception
*/
public function testValidate(bool|array $expectedResult, array $methods): void
public function testValidate(array|bool $expectedResult, array $methods): void
{
$mock = $this->getMockWithCalledMethods(Subject::class, $methods);

Expand Down
2 changes: 1 addition & 1 deletion tests/unit/Mage/Admin/Model/VariableTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public static function setUpBeforeClass(): void
* @group Model
* @throws Exception
*/
public function testValidate(bool|array $expectedResult, array $methods): void
public function testValidate(array|bool $expectedResult, array $methods): void
{
$mock = $this->getMockWithCalledMethods(Subject::class, $methods);

Expand Down
2 changes: 1 addition & 1 deletion tests/unit/Mage/AdminNotification/Model/InboxTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public static function setUpBeforeClass(): void
* @dataProvider provideGetSeverities
* @group Model
*/
public function testGetSeverities(array|string|null $expectedResult, ?int $severity): void
public function testGetSeverities(null|array|string $expectedResult, ?int $severity): void
{
self::assertSame($expectedResult, self::$subject->getSeverities($severity));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function setUp(): void
* @dataProvider provideGetStoreId
* @group Model
*/
public function testGetStoreId(?int $expectedResult, int|string|null $withStoreId): void
public function testGetStoreId(?int $expectedResult, null|int|string $withStoreId): void
{
if ($withStoreId) {
self::$subject->setStoreId($withStoreId);
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/Mage/Cms/Block/Widget/Page/LinkTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function testGetTitle(string $expectedResult, array $data): void
* @group Block
* @throws Mage_Core_Model_Store_Exception
*/
public function testGetAnchorText(bool|string|null $expectedResult, array $data): void
public function testGetAnchorText(null|bool|string $expectedResult, array $data): void
{
self::$subject->setData($data);

Expand Down
2 changes: 1 addition & 1 deletion tests/unit/Mage/Core/Helper/DataTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public function testValidateKey(): void
*/
public function testFormatTimezoneDate(
string $expectedResult,
string|int|null $data,
null|int|string $data,
string $format = Mage_Core_Model_Locale::FORMAT_TYPE_SHORT,
bool $showTime = false,
bool $useTimezone = false # disable timezone by default for tests
Expand Down
6 changes: 3 additions & 3 deletions tests/unit/Mage/Core/Model/AppTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public static function setUpBeforeClass(): void
* @dataProvider provideGetStore
* @group Model
*/
public function testGetStore(Mage_Core_Model_Store|int|string|bool|null $id): void
public function testGetStore(null|bool|int|Mage_Core_Model_Store|string $id): void
{
try {
self::assertInstanceOf(Mage_Core_Model_Store::class, self::$subject->getStore($id));
Expand All @@ -47,7 +47,7 @@ public function testGetStore(Mage_Core_Model_Store|int|string|bool|null $id): vo
* @dataProvider provideGetWebsite
* @group Model
*/
public function testGetWebsite(Mage_Core_Model_Website|int|string|bool|null $id): void
public function testGetWebsite(null|bool|int|Mage_Core_Model_Website|string $id): void
{
try {
self::assertInstanceOf(Mage_Core_Model_Website::class, self::$subject->getWebsite($id));
Expand All @@ -62,7 +62,7 @@ public function testGetWebsite(Mage_Core_Model_Website|int|string|bool|null $id)
* @dataProvider provideGetGroup
* @group Model
*/
public function testGetGroup(Mage_Core_Model_Store_Group|int|string|bool|null $id): void
public function testGetGroup(null|bool|int|Mage_Core_Model_Store_Group|string $id): void
{
try {
self::assertInstanceOf(Mage_Core_Model_Store_Group::class, self::$subject->getGroup($id));
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/Mage/GiftMessage/Helper/MessageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public static function setUpBeforeClass(): void
*
* @group Helper
*/
public function testIsMessagesAvailable(string $type, Varien_Object $entity, bool|int|Mage_Core_Model_Store|null|string $store = null): void
public function testIsMessagesAvailable(string $type, Varien_Object $entity, null|bool|int|Mage_Core_Model_Store|string $store = null): void
{
self::assertIsBool(self::$subject->isMessagesAvailable($type, $entity, $store));
}
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/Mage/Rule/Model/AbstractTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public function testLoadPost(array $data = []): void
* @dataProvider provideValidateData
* @group Model
*/
public function testValidate(bool|array $expectedResul, ?array $data = null): void
public function testValidate(array|bool $expectedResul, ?array $data = null): void
{
$object = new Varien_Object($data);
try {
Expand All @@ -119,7 +119,7 @@ public function testValidate(bool|array $expectedResul, ?array $data = null): vo
* @dataProvider provideValidateData
* @group Model
*/
public function testValidateData(bool|array $expectedResul, ?array $data = null): void
public function testValidateData(array|bool $expectedResul, ?array $data = null): void
{
if (PHP_VERSION_ID >= 80300 && version_compare(InstalledVersions::getPrettyVersion('shardj/zf1-future'), '1.24.2', '<=')) {
self::markTestSkipped('see https://github.com/Shardj/zf1-future/pull/465');
Expand Down
Loading