Skip to content

Commit

Permalink
Fix php stan issues (#19)
Browse files Browse the repository at this point in the history
* Fix phpstan issues level 1

CS-5648

* Fix phpstan issues level 5

CS-5648

* Fix phpstan issues level 6

CS-5648

* Fix phpcbf

CS-5648

* Fix phpcbf

CS-5648

* Fix phpcbf

CS-5648

* Fix phpcbf

CS-5648

* Fix Property SeQura\Core\BusinessLogic\Bootstrap\Aspect\Aspects:: has unknown class SeQura\Core\BusinessLogic\Bootstrap\Aspect\T as its type.

* Fix propety types at Infrastructure/TaskExecution/TaskRunnerWakeupService.php

* Add guard for type

* Remove ignores and fix typo

* Declare @throw Exception if we are catching it

* Fix phpcbf

---------

Co-authored-by: Mikel Martin <[email protected]>
  • Loading branch information
MarijaIv and m1k3lm authored Oct 10, 2024
1 parent 33291c6 commit 2004488
Show file tree
Hide file tree
Showing 181 changed files with 1,045 additions and 814 deletions.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"require-dev": {
"phpunit/phpunit": "8.5.14",
"phpcompatibility/php-compatibility": "*",
"phpstan/phpstan": "^1.11"
"phpstan/phpstan": "^1.12"
},
"prefer-stable": true,
"config": {
Expand All @@ -38,4 +38,4 @@
},
"preferred-install": "dist"
}
}
}
14 changes: 7 additions & 7 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
parameters:
level: 1
level: 6
errorFormat: table
treatPhpDocTypesAsCertain: false
paths:
Expand Down
43 changes: 32 additions & 11 deletions src/BusinessLogic/AdminAPI/AdminAPI.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,11 @@ protected function __construct()
/**
* Gets an AdminAPI instance.
*
* @return AdminAPI
* @return Aspects
*/
public static function get(): object
{

return Aspects::run(new ErrorHandlingAspect())->beforeEachMethodOfInstance(new AdminAPI());
}

Expand All @@ -43,13 +44,15 @@ public static function get(): object
*
* @param string $storeId
*
* @return ConnectionController
* @return object
*/
public function connection(string $storeId): object
{

return Aspects
::run(new ErrorHandlingAspect())
->andRun(new StoreContextAspect($storeId))

->beforeEachMethodOfService(ConnectionController::class);
}

Expand All @@ -58,13 +61,15 @@ public function connection(string $storeId): object
*
* @param string $storeId
*
* @return StoreController
* @return object
*/
public function store(string $storeId): object
{

return Aspects
::run(new ErrorHandlingAspect())
->andRun(new StoreContextAspect($storeId))

->beforeEachMethodOfService(StoreController::class);
}

Expand All @@ -73,13 +78,15 @@ public function store(string $storeId): object
*
* @param string $storeId
*
* @return CountryConfigurationController
* @return object
*/
public function countryConfiguration(string $storeId): object
{

return Aspects
::run(new ErrorHandlingAspect())
->andRun(new StoreContextAspect($storeId))

->beforeEachMethodOfService(CountryConfigurationController::class);
}

Expand All @@ -88,13 +95,15 @@ public function countryConfiguration(string $storeId): object
*
* @param string $storeId
*
* @return PromotionalWidgetsController
* @return object
*/
public function widgetConfiguration(string $storeId): object
{

return Aspects
::run(new ErrorHandlingAspect())
->andRun(new StoreContextAspect($storeId))

->beforeEachMethodOfService(PromotionalWidgetsController::class);
}

Expand All @@ -103,13 +112,15 @@ public function widgetConfiguration(string $storeId): object
*
* @param string $storeId
*
* @return PaymentMethodsController
* @return object
*/
public function paymentMethods(string $storeId): object
{

return Aspects
::run(new ErrorHandlingAspect())
->andRun(new StoreContextAspect($storeId))

->beforeEachMethodOfService(PaymentMethodsController::class);
}

Expand All @@ -118,13 +129,15 @@ public function paymentMethods(string $storeId): object
*
* @param string $storeId
*
* @return GeneralSettingsController
* @return object
*/
public function generalSettings(string $storeId): object
{

return Aspects
::run(new ErrorHandlingAspect())
->andRun(new StoreContextAspect($storeId))

->beforeEachMethodOfService(GeneralSettingsController::class);
}

Expand All @@ -133,13 +146,15 @@ public function generalSettings(string $storeId): object
*
* @param string $storeId
*
* @return OrderStatusSettingsController
* @return object
*/
public function orderStatusSettings(string $storeId): object
{

return Aspects
::run(new ErrorHandlingAspect())
->andRun(new StoreContextAspect($storeId))

->beforeEachMethodOfService(OrderStatusSettingsController::class);
}

Expand All @@ -148,13 +163,15 @@ public function orderStatusSettings(string $storeId): object
*
* @param string $storeId
*
* @return TransactionLogsController
* @return object
*/
public function transactionLogs(string $storeId): object
{

return Aspects
::run(new ErrorHandlingAspect())
->andRun(new StoreContextAspect($storeId))

->beforeEachMethodOfService(TransactionLogsController::class);
}

Expand All @@ -163,13 +180,15 @@ public function transactionLogs(string $storeId): object
*
* @param string $storeId
*
* @return IntegrationController
* @return object
*/
public function integration(string $storeId): object
{

return Aspects
::run(new ErrorHandlingAspect())
->andRun(new StoreContextAspect($storeId))

->beforeEachMethodOfService(IntegrationController::class);
}

Expand All @@ -178,13 +197,15 @@ public function integration(string $storeId): object
*
* @param string $storeId
*
* @return DisconnectController
* @return object
*/
public function disconnect(string $storeId): object
{

return Aspects
::run(new ErrorHandlingAspect())
->andRun(new StoreContextAspect($storeId))

->beforeEachMethodOfService(DisconnectController::class);
}
}
25 changes: 13 additions & 12 deletions src/BusinessLogic/AdminAPI/Aspects/ErrorHandlingAspect.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use SeQura\Core\BusinessLogic\Domain\Translations\Model\BaseTranslatableUnhandledException;
use SeQura\Core\BusinessLogic\SeQuraAPI\Exceptions\HttpApiInvalidUrlParameterException;
use SeQura\Core\BusinessLogic\SeQuraAPI\Exceptions\HttpApiUnauthorizedException;
use SeQura\Core\Infrastructure\Logger\LogContextData;
use SeQura\Core\Infrastructure\Logger\Logger;
use Throwable;

Expand All @@ -33,9 +34,9 @@ public function applyOn(callable $callee, array $params = [])
$e->getMessage(),
'Core',
[
'message' => $e->getMessage(),
'type' => get_class($e),
'trace' => $e->getTraceAsString(),
new LogContextData('message', $e->getMessage()),
new LogContextData('type', get_class($e)),
new LogContextData('trace', $e->getTraceAsString()),
]
);

Expand All @@ -45,9 +46,9 @@ public function applyOn(callable $callee, array $params = [])
$e->getMessage(),
'Core',
[
'message' => $e->getMessage(),
'type' => get_class($e),
'trace' => $e->getTraceAsString(),
new LogContextData('message', $e->getMessage()),
new LogContextData('type', get_class($e)),
new LogContextData('trace', $e->getTraceAsString()),
]
);

Expand All @@ -57,9 +58,9 @@ public function applyOn(callable $callee, array $params = [])
$e->getMessage(),
'Core',
[
'message' => $e->getMessage(),
'type' => get_class($e),
'trace' => $e->getTraceAsString(),
new LogContextData('message', $e->getMessage()),
new LogContextData('type', get_class($e)),
new LogContextData('trace', $e->getTraceAsString()),
]
);

Expand All @@ -69,9 +70,9 @@ public function applyOn(callable $callee, array $params = [])
'Unhandled error occurred.',
'Core',
[
'message' => $e->getMessage(),
'type' => get_class($e),
'trace' => $e->getTraceAsString(),
new LogContextData('message', $e->getMessage()),
new LogContextData('type', get_class($e)),
new LogContextData('trace', $e->getTraceAsString()),
]
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
class CountryConfigurationRequest extends Request
{
/**
* @var array
* @var string[]
*/
protected $countryConfigurations;

/**
* @param array $countryConfigurations
* @param string[] $countryConfigurations
*/
public function __construct(array $countryConfigurations)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
class OrderStatusSettingsRequest extends Request
{
/**
* @var array
* @var string[]
*/
protected $orderStatusMappings;

/**
* @param array $orderStatusMappings
* @param string[] $orderStatusMappings
*/
public function __construct(array $orderStatusMappings)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ class WidgetSettingsRequest extends Request
* @param bool $showInstallmentsInCartPage
* @param string $miniWidgetSelector
* @param string $widgetConfiguration
* @param array $messages
* @param array $messagesBelowLimit
* @param string[] $messages
* @param string[] $messagesBelowLimit
*/
public function __construct(
bool $enabled,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
*/
class WidgetConfiguratorResponse extends Response
{
/**
* @var mixed
*/
protected $widgetConfigurator;

/**
Expand Down
7 changes: 5 additions & 2 deletions src/BusinessLogic/AdminAPI/Response/ErrorResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
*
* @package SeQura\Core\BusinessLogic\AdminAPI\Response
*/
/**
* @phpstan-consistent-constructor
*/
class ErrorResponse extends Response
{
/**
Expand All @@ -34,8 +37,8 @@ public function __construct(Throwable $error)
/**
* Implementation is swallowing all undefined calls to avoid undefined method call exceptions when
*
* @param $methodName
* @param $arguments
* @param string $methodName
* @param mixed[] $arguments
*
* @see ErrorHandlingAspect already hanled the API call exception but because of chaining calle will trigger
* API controller messages on instance of the @see self.
Expand Down
2 changes: 1 addition & 1 deletion src/BusinessLogic/AdminAPI/Response/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function isSuccessful(): bool
/**
* Transforms response to array.
*
* @return array Array representation of response object.
* @return mixed[] Array representation of response object.
*/
abstract public function toArray(): array;
}
Loading

0 comments on commit 2004488

Please sign in to comment.