Skip to content

Commit

Permalink
[ACCOUNT-2742] fix: deprecation warnings (#448)
Browse files Browse the repository at this point in the history
* fix: finer grained scoping

* fix: hookable trait & shop provider

* fix: log level compat v9

* chore: remove useless confusing tags

* chore: cleanup unused code

* fix: catch throwable
  • Loading branch information
hschoenenberger authored Nov 19, 2024
1 parent b7b7271 commit e9bac9a
Show file tree
Hide file tree
Showing 20 changed files with 138 additions and 309 deletions.
4 changes: 2 additions & 2 deletions .dir-scoped
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ symfony/expression-language
symfony/filesystem
symfony/yaml
psr
monolog
guzzlehttp
league
prestashopcorp
prestashopcorp/oauth2-prestashop
lcobucci
prestashop/module-lib-service-container
prestashop/module-lib-cache-directory-provider
monolog
ramsey/uuid
ralouphie/getallheaders
phpseclib/phpseclib/phpseclib
15 changes: 3 additions & 12 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,30 +27,21 @@
"PrestaShop\\Module\\PsAccounts\\Vendor\\GuzzleHttp\\Psr7\\": "vendor/guzzlehttp/psr7/src",
"PrestaShop\\Module\\PsAccounts\\Vendor\\League\\OAuth2\\Client\\": "vendor/league/oauth2-client/src",
"PrestaShop\\Module\\PsAccounts\\Vendor\\Lcobucci\\JWT\\": "vendor/lcobucci/jwt/src",
"PrestaShop\\Module\\PsAccounts\\Vendor\\Monolog\\": "vendor/monolog/monolog/src/Monolog",
"PrestaShop\\Module\\PsAccounts\\Vendor\\PhpCsFixer\\": "vendor/friendsofphp/php-cs-fixer/src",
"PrestaShop\\Module\\PsAccounts\\Vendor\\PhpCsFixer\\Tests\\": "vendor/friendsofphp/php-cs-fixer/tests",
"PrestaShop\\Module\\PsAccounts\\Vendor\\phpseclib\\": "vendor/phpseclib/phpseclib/phpseclib",
"PrestaShop\\Module\\PsAccounts\\Vendor\\Psr\\Cache\\": "vendor/psr/cache/src",
"PrestaShop\\Module\\PsAccounts\\Vendor\\Psr\\Container\\": "vendor/psr/container/src",
"PrestaShop\\Module\\PsAccounts\\Vendor\\Psr\\Http\\Message\\": "vendor/psr/http-message/src",
"PrestaShop\\Module\\PsAccounts\\Vendor\\Psr\\Log\\": "vendor/psr/log/Psr/Log",
"PrestaShop\\Module\\PsAccounts\\Vendor\\Psr\\SimpleCache\\": "vendor/psr/simple-cache/src",
"PrestaShop\\Module\\PsAccounts\\Vendor\\Ramsey\\Uuid\\": "vendor/ramsey/uuid/src",

"PrestaShop\\Module\\PsAccounts\\Vendor\\Symfony\\Component\\Cache\\": "vendor/symfony/cache",
"PrestaShop\\Module\\PsAccounts\\Vendor\\Symfony\\Component\\Config\\": "vendor/symfony/config",
"PrestaShop\\Module\\PsAccounts\\Vendor\\Symfony\\Component\\Console\\": "vendor/symfony/console",
"PrestaShop\\Module\\PsAccounts\\Vendor\\Symfony\\Component\\Debug\\": "vendor/symfony/debug",
"PrestaShop\\Module\\PsAccounts\\Vendor\\Symfony\\Component\\DependencyInjection\\": "vendor/symfony/dependency-injection",
"PrestaShop\\Module\\PsAccounts\\Vendor\\Symfony\\Component\\EventDispatcher\\": "vendor/symfony/event-dispatcher",
"PrestaShop\\Module\\PsAccounts\\Vendor\\Symfony\\Component\\ExpressionLanguage\\": "vendor/symfony/expression-language",
"PrestaShop\\Module\\PsAccounts\\Vendor\\Symfony\\Component\\Filesystem\\": "vendor/symfony/filesystem",
"PrestaShop\\Module\\PsAccounts\\Vendor\\Symfony\\Component\\Finder\\": "vendor/symfony/finder",
"PrestaShop\\Module\\PsAccounts\\Vendor\\Symfony\\Component\\OptionsResolver\\": "vendor/symfony/options-resolver",
"PrestaShop\\Module\\PsAccounts\\Vendor\\Symfony\\Component\\Process\\": "vendor/symfony/process",
"PrestaShop\\Module\\PsAccounts\\Vendor\\Symfony\\Component\\Stopwatch\\": "vendor/symfony/stopwatch",
"PrestaShop\\Module\\PsAccounts\\Vendor\\Symfony\\Component\\Yaml\\": "vendor/symfony/yaml",
"PrestaShop\\Module\\PsAccounts\\Vendor\\PrestaShop\\ModuleLibServiceContainer\\": "vendor/prestashop/module-lib-service-container/src,",

"PrestaShop\\Module\\PsAccounts\\Vendor\\PrestaShop\\ModuleLibServiceContainer\\": "vendor/prestashop/module-lib-service-container/src",
"PrestaShop\\Module\\PsAccounts\\Vendor\\PrestaShop\\ModuleLibCacheDirectoryProvider\\": "vendor/prestashop/module-lib-cache-directory-provider/src"
},
"classmap": [
Expand Down
10 changes: 0 additions & 10 deletions config/command.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,12 @@ services:
PrestaShop\Module\PsAccounts\Account\CommandHandler\LinkShopHandler:
class: PrestaShop\Module\PsAccounts\Account\CommandHandler\LinkShopHandler
public: true
tags:
- { name: tactician.handler, command: 'PrestaShop\Module\PsAccounts\Domain\Shop\Command\LinkShopCommand' }
arguments:
- '@PrestaShop\Module\PsAccounts\Account\LinkShop'

PrestaShop\Module\PsAccounts\Account\CommandHandler\MigrateAndLinkV4ShopHandler:
class: PrestaShop\Module\PsAccounts\Account\CommandHandler\MigrateAndLinkV4ShopHandler
public: true
tags:
- { name: tactician.handler, command: 'PrestaShop\Module\PsAccounts\Domain\Shop\Command\MigrateAndLinkV4ShopCommand' }
arguments:
- '@PrestaShop\Module\PsAccounts\Api\Client\AccountsClient'
- '@PrestaShop\Module\PsAccounts\Context\ShopContext'
Expand All @@ -20,8 +16,6 @@ services:
PrestaShop\Module\PsAccounts\Account\CommandHandler\DeleteUserShopHandler:
class: PrestaShop\Module\PsAccounts\Account\CommandHandler\DeleteUserShopHandler
public: true
tags:
- { name: tactician.handler, command: 'PrestaShop\Module\PsAccounts\Domain\Shop\Command\DeleteUserShopCommand' }
arguments:
- '@PrestaShop\Module\PsAccounts\Api\Client\AccountsClient'
- '@PrestaShop\Module\PsAccounts\Context\ShopContext'
Expand All @@ -31,8 +25,6 @@ services:
PrestaShop\Module\PsAccounts\Account\CommandHandler\UnlinkShopHandler:
class: PrestaShop\Module\PsAccounts\Account\CommandHandler\UnlinkShopHandler
public: true
tags:
- { name: tactician.handler, command: 'PrestaShop\Module\PsAccounts\Domain\Shop\Command\UnlinkShopCommand' }
arguments:
- '@PrestaShop\Module\PsAccounts\Account\LinkShop'
- '@PrestaShop\Module\PsAccounts\Service\AnalyticsService'
Expand All @@ -41,8 +33,6 @@ services:
PrestaShop\Module\PsAccounts\Account\CommandHandler\UpdateUserShopHandler:
class: PrestaShop\Module\PsAccounts\Account\CommandHandler\UpdateUserShopHandler
public: true
tags:
- { name: tactician.handler, command: 'PrestaShop\Module\PsAccounts\Domain\Shop\Command\UpdateShopCommand' }
arguments:
- '@PrestaShop\Module\PsAccounts\Api\Client\AccountsClient'
- '@PrestaShop\Module\PsAccounts\Context\ShopContext'
Expand Down
4 changes: 2 additions & 2 deletions config/common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ services:
class: PrestaShop\Module\PsAccounts\Vendor\Monolog\Logger
public: true
factory: [ 'PrestaShop\Module\PsAccounts\Log\Logger', 'create' ]
# arguments:
# - '%ps_accounts.log_level%'
arguments:
- '%ps_accounts.log_level%'

PrestaShop\Module\PsAccounts\Provider\OAuth2\ShopProvider:
class: PrestaShop\Module\PsAccounts\Provider\OAuth2\ShopProvider
Expand Down
21 changes: 1 addition & 20 deletions ps_accounts.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ public function __construct()
}

/**
* @return \PrestaShop\Module\PsAccounts\Vendor\Monolog\Logger
* @return \Monolog\Logger
*/
public function getLogger()
{
Expand Down Expand Up @@ -487,22 +487,6 @@ public function getSession()
throw new \Exception('Feature not available');
}

/**
* @deprecated
*
* @return void
*
* @throws PrestaShopException
*
* @phpstan-ignore-next-line
*/
private function autoReonboardOnV5()
{
/** @var \PrestaShop\Module\PsAccounts\Service\PsAccountsService $psAccountsService */
$psAccountsService = $this->getService(\PrestaShop\Module\PsAccounts\Service\PsAccountsService::class);
$psAccountsService->autoReonboardOnV5();
}

/**
* @return void
*
Expand All @@ -521,9 +505,6 @@ public function onModuleReset()
// FIXME: this wont prevent from re-implanting override on reset of module
$uninstaller = new PrestaShop\Module\PsAccounts\Module\Uninstall($this, Db::getInstance());
$uninstaller->deleteAdminTab('AdminLogin');

// $this->installEventBus();
// $this->autoReonboardOnV5();
}
}

Expand Down
17 changes: 10 additions & 7 deletions scoper.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,13 +145,16 @@ static function ($filePath, $prefix, $contents) {
'exclude-namespaces' => [
'~^PrestaShop\\\\OAuth2\\\\Client~',
'~^Composer\\\\~',
'~^Symfony\\Polyfill\\Apcu\\',
'~^Symfony\\Polyfill\\Ctype\\',
'~^Symfony\\Polyfill\\IntlIdn\\',
'~^Symfony\\Polyfill\\IntlNormalizer\\',
'~^Symfony\\Polyfill\\Mbstring\\',
'~^Symfony\\Polyfill\\Php70\\',
'~^Symfony\\Polyfill\\Php72\\',
'Monolog\\',
//'~^Symfony\\\\Component\\\\Config~',
'Symfony\\Component\\Config\\',
'Symfony\\Polyfill\\Apcu\\',
'Symfony\\Polyfill\\Ctype\\',
'Symfony\\Polyfill\\IntlIdn\\',
'Symfony\\Polyfill\\IntlNormalizer\\',
'Symfony\\Polyfill\\Mbstring\\',
'Symfony\\Polyfill\\Php70\\',
'Symfony\\Polyfill\\Php72\\',
],
'exclude-classes' => [],
'exclude-functions' => [
Expand Down
44 changes: 0 additions & 44 deletions src/Account/Command/MigrateAndLinkV4ShopCommand.php

This file was deleted.

75 changes: 0 additions & 75 deletions src/Account/CommandHandler/MigrateAndLinkV4ShopHandler.php

This file was deleted.

3 changes: 2 additions & 1 deletion src/Account/Session/ShopSession.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@ public function refreshToken($refreshToken = null)
$e->getMessage()
));
} catch (IdentityProviderException $e) {
} catch (\Error $e) {
} catch (\Throwable $e) {
/* @phpstan-ignore-next-line */
} catch (\Exception $e) {
}
throw new RefreshTokenException('Unable to refresh shop token : ' . $e->getMessage());
Expand Down
20 changes: 0 additions & 20 deletions src/Api/Client/AccountsClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,26 +152,6 @@ public function deleteUserShop($ownerUid, $shopUid, $ownerToken)
]);
}

/**
* @param string $shopUid
* @param string $shopToken
* @param array $payload
*
* @return array
*/
public function reonboardShop($shopUid, $shopToken, $payload)
{
$this->getClient()->setRoute('v1/shop/' . $shopUid . '/reonboard');

return $this->getClient()->post([
'headers' => $this->getHeaders([
'Authorization' => 'Bearer ' . $shopToken,
'X-Shop-Id' => $shopUid,
]),
'json' => $payload,
]);
}

/**
* @param string $ownerUid
* @param string $shopUid
Expand Down
5 changes: 3 additions & 2 deletions src/Api/Controller/AbstractRestController.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,9 @@ public function postProcess()
'error' => true,
'message' => $e->getMessage(),
], $e->getStatusCode());
} catch (\Error $e) {
} catch (\Throwable $e) {
$this->handleError($e);
/* @phpstan-ignore-next-line */
} catch (\Exception $e) {
$this->handleError($e);
}
Expand Down Expand Up @@ -362,7 +363,7 @@ protected function geolocationManagement($defaultCountry)
}

/**
* @param \Error|\Exception $e
* @param \Throwable|\Exception $e
*
* @return void
*
Expand Down
5 changes: 3 additions & 2 deletions src/Context/ShopContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ public function getConfiguration()
*
* @return mixed
*
* @throws \Exception
* @throws \Throwable|\Exception
*/
public function execInShopContext($shopId, $closure)
{
Expand All @@ -177,7 +177,8 @@ public function execInShopContext($shopId, $closure)

try {
$result = $closure();
} catch (\Error $e) {
} catch (\Throwable $e) {
/* @phpstan-ignore-next-line */
} catch (\Exception $e) {
}
$this->configuration->setShopId($backup);
Expand Down
4 changes: 2 additions & 2 deletions src/DependencyInjection/ContainerProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@
namespace PrestaShop\Module\PsAccounts\DependencyInjection;

use PrestaShop\Module\PsAccounts\Vendor\PrestaShop\ModuleLibCacheDirectoryProvider\Cache\CacheDirectoryProvider;
use PrestaShop\Module\PsAccounts\Vendor\Symfony\Component\Config\ConfigCache;
use PrestaShop\Module\PsAccounts\Vendor\Symfony\Component\Config\FileLocator;
use PrestaShop\Module\PsAccounts\Vendor\Symfony\Component\DependencyInjection\ContainerBuilder;
use PrestaShop\Module\PsAccounts\Vendor\Symfony\Component\DependencyInjection\ContainerInterface;
use PrestaShop\Module\PsAccounts\Vendor\Symfony\Component\DependencyInjection\Dumper\PhpDumper;
use PrestaShop\Module\PsAccounts\Vendor\Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
use Symfony\Component\Config\ConfigCache;
use Symfony\Component\Config\FileLocator;

class ContainerProvider
{
Expand Down
2 changes: 1 addition & 1 deletion src/Hook/Hook.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@

namespace PrestaShop\Module\PsAccounts\Hook;

use Monolog\Logger;
use PrestaShop\Module\PsAccounts\Cqrs\CommandBus;
use PrestaShop\Module\PsAccounts\Vendor\Monolog\Logger;
use Ps_accounts;

abstract class Hook
Expand Down
Loading

0 comments on commit e9bac9a

Please sign in to comment.