diff --git a/phpstan.neon b/phpstan.neon index c6bd6c87..f7d5cddf 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,5 +1,5 @@ parameters: - level: 6 + level: 7 paths: - src - tests diff --git a/rector.php b/rector.php index 52463c2c..a01199a1 100644 --- a/rector.php +++ b/rector.php @@ -24,6 +24,7 @@ SwitchNegatedTernaryRector::class, DisallowedEmptyRuleFixerRector::class, \Rector\Php81\Rector\Array_\FirstClassCallableRector::class, + ExplicitBoolCompareRector::class, ]); $rectorConfig->rule(InlineConstructorDefaultToPropertyRector::class); diff --git a/src/Bootstrap/AbstractBootstrap.php b/src/Bootstrap/AbstractBootstrap.php index b2530691..4fc68340 100644 --- a/src/Bootstrap/AbstractBootstrap.php +++ b/src/Bootstrap/AbstractBootstrap.php @@ -107,9 +107,4 @@ final public function setContainer(ContainerInterface $container): void { $this->container = $container; } - - final protected function getPluginPath(): string - { - return $this->container->getParameter('kernel.root_dir') . DIRECTORY_SEPARATOR . $this->plugin->getPath(); - } } diff --git a/src/Bootstrap/Database.php b/src/Bootstrap/Database.php index 39f02584..62598ce4 100644 --- a/src/Bootstrap/Database.php +++ b/src/Bootstrap/Database.php @@ -20,6 +20,7 @@ class Database extends AbstractBootstrap public function injectServices(): void { + /* @phpstan-ignore-next-line */ $this->connection = $this->container->get(Connection::class); } diff --git a/src/Bootstrap/PaymentMethods.php b/src/Bootstrap/PaymentMethods.php index 9a811d03..28304380 100644 --- a/src/Bootstrap/PaymentMethods.php +++ b/src/Bootstrap/PaymentMethods.php @@ -67,8 +67,11 @@ class PaymentMethods extends AbstractBootstrap public function injectServices(): void { + /* @phpstan-ignore-next-line */ $this->paymentRepository = $this->container->get('payment_method.repository'); + /* @phpstan-ignore-next-line */ $this->paymentMethodDefinition = $this->container->get(PaymentMethodDefinition::class); + /* @phpstan-ignore-next-line */ $this->connection = $this->container->get(Connection::class); } diff --git a/src/Bootstrap/PluginConfiguration.php b/src/Bootstrap/PluginConfiguration.php index 7a300ab0..bf0cfd0e 100644 --- a/src/Bootstrap/PluginConfiguration.php +++ b/src/Bootstrap/PluginConfiguration.php @@ -18,6 +18,7 @@ class PluginConfiguration extends AbstractBootstrap public function injectServices(): void { + /* @phpstan-ignore-next-line */ $this->configService = $this->container->get(SystemConfigService::class); } diff --git a/src/Components/AdminOrders/Controller/TokenController.php b/src/Components/AdminOrders/Controller/TokenController.php index 165ee61b..e073dad6 100644 --- a/src/Components/AdminOrders/Controller/TokenController.php +++ b/src/Components/AdminOrders/Controller/TokenController.php @@ -61,6 +61,7 @@ public function login(Request $request): Response ], ], $context); + /** @var array{scheme: string, host: string, path: ?string} $urlInfo */ $urlInfo = parse_url((string) $saleChannelDomain->getUrl()); $routerContext = $this->router->getContext(); $routerContext diff --git a/src/Components/Checkout/SalesChannel/HandlePaymentMethodRoute.php b/src/Components/Checkout/SalesChannel/HandlePaymentMethodRoute.php index 64097b00..418ee369 100644 --- a/src/Components/Checkout/SalesChannel/HandlePaymentMethodRoute.php +++ b/src/Components/Checkout/SalesChannel/HandlePaymentMethodRoute.php @@ -50,7 +50,7 @@ public function load(Request $request, SalesChannelContext $context): HandlePaym return $this->innerService->load($request, $context); } - $orderId = $request->request->get('orderId'); + $orderId = $request->request->getAlnum('orderId'); $paymentHandlerIdentifier = null; $order = null; diff --git a/src/Components/DeviceFingerprint/Subscriber/DeviceFingerprintSubscriber.php b/src/Components/DeviceFingerprint/Subscriber/DeviceFingerprintSubscriber.php index a36307c7..91fa63eb 100644 --- a/src/Components/DeviceFingerprint/Subscriber/DeviceFingerprintSubscriber.php +++ b/src/Components/DeviceFingerprint/Subscriber/DeviceFingerprintSubscriber.php @@ -50,11 +50,13 @@ public static function getSubscribedEvents(): array ]; } + /** + * @param BuildEvent $buildEvent + */ public function onPaymentRequest(BuildEvent $buildEvent): void { /** @var PaymentRequestData $requestData */ $requestData = $buildEvent->getRequestData(); - /** @var Head $head */ $head = $buildEvent->getBuildData(); $ratepayData = RequestHelper::getRatepayData($requestData->getRequestDataBag()); diff --git a/src/Components/InstallmentCalculator/Controller/InstallmentRoute.php b/src/Components/InstallmentCalculator/Controller/InstallmentRoute.php index 801b4621..b31cdd8f 100644 --- a/src/Components/InstallmentCalculator/Controller/InstallmentRoute.php +++ b/src/Components/InstallmentCalculator/Controller/InstallmentRoute.php @@ -41,9 +41,8 @@ public function __construct( ], methods: ['GET'])] public function calculateInstallment(Request $request, SalesChannelContext $salesChannelContext, ?string $orderId = null): InstallmentCalculationResponse { - $type = $request->query->get('type'); - $value = (int) $request->query->get('value'); - $value = $value ?: 1; // RATESWSX-186: fix that no "0" values can be provided + $type = $request->query->getAlpha('type'); + $value = $request->query->getInt('value', 1); // RATESWSX-186: fix that no "0" values can be provided if ($orderId) { $order = $this->orderRepository->search(CriteriaHelper::getCriteriaForOrder($orderId), $salesChannelContext->getContext())->first(); diff --git a/src/Components/InstallmentCalculator/Service/InstallmentService.php b/src/Components/InstallmentCalculator/Service/InstallmentService.php index 603451a6..af815729 100644 --- a/src/Components/InstallmentCalculator/Service/InstallmentService.php +++ b/src/Components/InstallmentCalculator/Service/InstallmentService.php @@ -148,7 +148,7 @@ public function calculateInstallmentOffline(InstallmentCalculatorContext $contex throw new InstallmentCalculationException('Please verify if the payment method is available.'); } - /** @var array{0: InstallmentBuilder, 1: int|float}|array{} $amountBuilders */ + /** @var array{0: InstallmentBuilder, 1: int|float}[]|array{} $amountBuilders */ $amountBuilders = []; foreach ($installmentBuilders as $installmentBuilder) { diff --git a/src/Components/InstallmentCalculator/Subscriber/BuildPaymentSubscriber.php b/src/Components/InstallmentCalculator/Subscriber/BuildPaymentSubscriber.php index 62ebf1c0..67e156e7 100644 --- a/src/Components/InstallmentCalculator/Subscriber/BuildPaymentSubscriber.php +++ b/src/Components/InstallmentCalculator/Subscriber/BuildPaymentSubscriber.php @@ -13,6 +13,7 @@ use Exception; use InvalidArgumentException; +use JsonException; use RatePAY\Model\Request\SubModel\Content\Payment; use RatePAY\Model\Request\SubModel\Content\Payment\InstallmentDetails; use RatePAY\Model\Request\SubModel\Content\ShoppingBasket; @@ -52,6 +53,10 @@ public static function getSubscribedEvents(): array ]; } + /** + * @param BuildEvent $event + * @throws JsonException + */ public function buildPayment(BuildEvent $event): void { /** @var PaymentRequestData $requestData */ @@ -112,6 +117,10 @@ public function buildPayment(BuildEvent $event): void } } + /** + * @param BuildEvent $event + * @return BuildEvent + */ public function buildShoppingBasket(BuildEvent $event): BuildEvent { /** @var OrderOperationData $requestData */ diff --git a/src/Components/InstallmentCalculator/Subscriber/ProductPageSubscriber.php b/src/Components/InstallmentCalculator/Subscriber/ProductPageSubscriber.php index a3581490..ea0478d3 100644 --- a/src/Components/InstallmentCalculator/Subscriber/ProductPageSubscriber.php +++ b/src/Components/InstallmentCalculator/Subscriber/ProductPageSubscriber.php @@ -49,8 +49,14 @@ public function addRatepayData(ProductPageLoadedEvent $event): void } $billingCountyId = $this->getConfig('BillingCountry'); - $billingCountry = $this->countryRepository->search(new Criteria([$billingCountyId]), $event->getContext())->first(); $shippingCountyId = $this->getConfig('ShippingCountry'); + $paymentMethodId = $this->getConfig('PaymentMethod'); + + if (!is_string($billingCountyId) || !is_string($shippingCountyId) || !is_string($paymentMethodId)) { + return; + } + + $billingCountry = $this->countryRepository->search(new Criteria([$billingCountyId]), $event->getContext())->first(); $shippingCountry = $this->countryRepository->search(new Criteria([$shippingCountyId]), $event->getContext())->first(); if (!$billingCountry instanceof CountryEntity || !$shippingCountry instanceof CountryEntity) { return; @@ -58,8 +64,6 @@ public function addRatepayData(ProductPageLoadedEvent $event): void $currency = $event->getSalesChannelContext()->getCurrency(); - $paymentMethodId = $this->getConfig('PaymentMethod'); - $product = $event->getPage()->getProduct(); // this is a little bit tricky. we need to support the following cases: normal price, configurable price, advanced/tier pricing diff --git a/src/Components/OrderManagement/Service/LineItemFactory.php b/src/Components/OrderManagement/Service/LineItemFactory.php index 66f63eff..00271682 100644 --- a/src/Components/OrderManagement/Service/LineItemFactory.php +++ b/src/Components/OrderManagement/Service/LineItemFactory.php @@ -56,7 +56,7 @@ public function createLineItem(OrderEntity $orderEntity, string $label, float $g ->setPayload([]) ->setPriceDefinition(new QuantityPriceDefinition( $grossAmount, - new TaxRuleCollection([new TaxRule($taxRate, 100)]), + new TaxRuleCollection([new TaxRule((float) $taxRate, 100)]), 1 )); $lineItem->addExtension(OrderConverter::ORIGINAL_ID, new IdStruct($lineItem->getId())); diff --git a/src/Components/ProfileConfig/Controller/ProfileConfigController.php b/src/Components/ProfileConfig/Controller/ProfileConfigController.php index 63e367fd..5ea0c7de 100644 --- a/src/Components/ProfileConfig/Controller/ProfileConfigController.php +++ b/src/Components/ProfileConfig/Controller/ProfileConfigController.php @@ -32,7 +32,7 @@ public function __construct( #[Route(path: '/reload-config', name: 'ratepay.profile.config.reload', methods: ['POST'])] public function reloadProfileConfiguration(Request $request): Response { - if ($id = $request->request->get('id')) { + if ($id = $request->request->getAlnum('id')) { try { $configs = $this->profileManagement->refreshProfileConfigs([$id]); $profileConfig = $configs->get($id); diff --git a/src/Components/RatepayApi/Dto/CheckoutOperationInterface.php b/src/Components/RatepayApi/Dto/CheckoutOperationInterface.php index 49ba6488..d219266a 100644 --- a/src/Components/RatepayApi/Dto/CheckoutOperationInterface.php +++ b/src/Components/RatepayApi/Dto/CheckoutOperationInterface.php @@ -11,7 +11,6 @@ namespace Ratepay\RpayPayments\Components\RatepayApi\Dto; use Shopware\Core\Checkout\Customer\CustomerEntity; -use Shopware\Core\Checkout\Order\Aggregate\OrderCustomer\OrderCustomerEntity; use Shopware\Core\Framework\Validation\DataBag\DataBag; use Shopware\Core\System\SalesChannel\SalesChannelContext; @@ -23,8 +22,5 @@ public function getSalesChannelContext(): SalesChannelContext; public function getRequestDataBag(): DataBag; - /** - * @return OrderCustomerEntity|CustomerEntity - */ - public function getCustomer(); + public function getCustomer(): CustomerEntity; } diff --git a/src/Components/RatepayApi/Dto/PaymentRequestData.php b/src/Components/RatepayApi/Dto/PaymentRequestData.php index 0709cad9..d05b1fef 100644 --- a/src/Components/RatepayApi/Dto/PaymentRequestData.php +++ b/src/Components/RatepayApi/Dto/PaymentRequestData.php @@ -11,6 +11,7 @@ namespace Ratepay\RpayPayments\Components\RatepayApi\Dto; +use InvalidArgumentException; use Shopware\Core\Checkout\Customer\CustomerEntity; use Shopware\Core\Checkout\Order\Aggregate\OrderTransaction\OrderTransactionEntity; use Shopware\Core\Checkout\Order\OrderEntity; @@ -74,8 +75,8 @@ public function getPaymentMethodId(): string return $this->getOrder()->getTransactions()->last()->getPaymentMethodId(); } - public function getCustomer(): ?CustomerEntity + public function getCustomer(): CustomerEntity { - return $this->getOrder()->getOrderCustomer()->getCustomer(); + return $this->getOrder()->getOrderCustomer()?->getCustomer() ?: throw new InvalidArgumentException('customer has not been loaded for order'); } } diff --git a/src/Components/RatepayApi/Event/BuildEvent.php b/src/Components/RatepayApi/Event/BuildEvent.php index 22878252..7927134a 100644 --- a/src/Components/RatepayApi/Event/BuildEvent.php +++ b/src/Components/RatepayApi/Event/BuildEvent.php @@ -11,11 +11,18 @@ namespace Ratepay\RpayPayments\Components\RatepayApi\Event; +use RatePAY\Model\Request\SubModel\AbstractModel; use Ratepay\RpayPayments\Components\RatepayApi\Dto\AbstractRequestData; use Symfony\Contracts\EventDispatcher\Event; +/** + * @template T of AbstractModel + */ class BuildEvent extends Event { + /** + * @param T|null $buildData + */ public function __construct( private readonly AbstractRequestData $requestData, private readonly ?object $buildData = null @@ -27,6 +34,9 @@ public function getRequestData(): AbstractRequestData return $this->requestData; } + /** + * @return T|null + */ public function getBuildData(): ?object { return $this->buildData; diff --git a/src/Components/RatepayApi/Factory/AbstractFactory.php b/src/Components/RatepayApi/Factory/AbstractFactory.php index aeb9d3cb..4bdae100 100644 --- a/src/Components/RatepayApi/Factory/AbstractFactory.php +++ b/src/Components/RatepayApi/Factory/AbstractFactory.php @@ -12,10 +12,14 @@ namespace Ratepay\RpayPayments\Components\RatepayApi\Factory; use InvalidArgumentException; +use RatePAY\Model\Request\SubModel\AbstractModel; use Ratepay\RpayPayments\Components\RatepayApi\Dto\AbstractRequestData; use Ratepay\RpayPayments\Components\RatepayApi\Event\BuildEvent; use Symfony\Contracts\EventDispatcher\EventDispatcherInterface; +/** + * @template ReturnType of AbstractModel|null + */ abstract class AbstractFactory { public function __construct( @@ -23,6 +27,9 @@ public function __construct( ) { } + /** + * @return ReturnType + */ final public function getData(AbstractRequestData $requestData): ?object { if (!$this->isSupported($requestData)) { @@ -31,8 +38,8 @@ final public function getData(AbstractRequestData $requestData): ?object $data = $this->_getData($requestData); if ($data !== null) { - /** @var BuildEvent $event */ - $event = $this->eventDispatcher->dispatch(new BuildEvent($requestData, $data), static::class); + $event = new BuildEvent($requestData, $data); + $this->eventDispatcher->dispatch($event, static::class); $data = $event->getBuildData(); } @@ -41,5 +48,8 @@ final public function getData(AbstractRequestData $requestData): ?object abstract protected function isSupported(AbstractRequestData $requestData): bool; + /** + * @return ReturnType + */ abstract protected function _getData(AbstractRequestData $requestData): ?object; } diff --git a/src/Components/RatepayApi/Factory/CustomerFactory.php b/src/Components/RatepayApi/Factory/CustomerFactory.php index ff93d3c9..9694e693 100644 --- a/src/Components/RatepayApi/Factory/CustomerFactory.php +++ b/src/Components/RatepayApi/Factory/CustomerFactory.php @@ -38,7 +38,7 @@ use Symfony\Component\EventDispatcher\EventDispatcherInterface; /** - * @method Customer getData(CheckoutOperationInterface $requestData) + * @extends AbstractFactory */ class CustomerFactory extends AbstractFactory { @@ -150,7 +150,7 @@ protected function _getData(AbstractRequestData $requestData): ?object } } - if ($requestData instanceof PaymentRequestData && $requestDataBag->has('bankData')) { + if ($requestDataBag->has('bankData')) { /** @var RequestDataBag $bankData */ $bankData = $requestDataBag->get('bankData'); $bankAccount = new BankAccount(); diff --git a/src/Components/RatepayApi/Factory/ExternalFactory.php b/src/Components/RatepayApi/Factory/ExternalFactory.php index b608435d..aeab12ee 100644 --- a/src/Components/RatepayApi/Factory/ExternalFactory.php +++ b/src/Components/RatepayApi/Factory/ExternalFactory.php @@ -19,7 +19,7 @@ use Shopware\Core\Checkout\Order\Aggregate\OrderDelivery\OrderDeliveryEntity; /** - * @method External getData(AbstractRequestData $requestData) + * @extends AbstractFactory */ class ExternalFactory extends AbstractFactory { diff --git a/src/Components/RatepayApi/Factory/HeadFactory.php b/src/Components/RatepayApi/Factory/HeadFactory.php index 34dd4bf7..8dfbc7ca 100644 --- a/src/Components/RatepayApi/Factory/HeadFactory.php +++ b/src/Components/RatepayApi/Factory/HeadFactory.php @@ -24,7 +24,7 @@ use Symfony\Contracts\EventDispatcher\EventDispatcherInterface; /** - * @method Head getData(AbstractRequestData $requestData) + * @extends AbstractFactory */ class HeadFactory extends AbstractFactory { diff --git a/src/Components/RatepayApi/Factory/InvoiceFactory.php b/src/Components/RatepayApi/Factory/InvoiceFactory.php index 41ef7a39..1c850109 100644 --- a/src/Components/RatepayApi/Factory/InvoiceFactory.php +++ b/src/Components/RatepayApi/Factory/InvoiceFactory.php @@ -17,7 +17,7 @@ use Shopware\Core\Checkout\Document\DocumentEntity; /** - * @method Invoicing getData(AbstractRequestData $requestData) + * @extends AbstractFactory */ class InvoiceFactory extends AbstractFactory { diff --git a/src/Components/RatepayApi/Factory/PaymentFactory.php b/src/Components/RatepayApi/Factory/PaymentFactory.php index 4a969991..0693a972 100644 --- a/src/Components/RatepayApi/Factory/PaymentFactory.php +++ b/src/Components/RatepayApi/Factory/PaymentFactory.php @@ -16,7 +16,7 @@ use Ratepay\RpayPayments\Components\RatepayApi\Dto\PaymentRequestData; /** - * @method Payment getData(PaymentRequestData $requestData) + * @extends AbstractFactory */ class PaymentFactory extends AbstractFactory { diff --git a/src/Components/RatepayApi/Factory/ShoppingBasketFactory.php b/src/Components/RatepayApi/Factory/ShoppingBasketFactory.php index 6a99893a..7ef70018 100644 --- a/src/Components/RatepayApi/Factory/ShoppingBasketFactory.php +++ b/src/Components/RatepayApi/Factory/ShoppingBasketFactory.php @@ -21,7 +21,6 @@ use Ratepay\RpayPayments\Components\RatepayApi\Dto\AbstractRequestData; use Ratepay\RpayPayments\Components\RatepayApi\Dto\OperationDataWithBasket; use Ratepay\RpayPayments\Components\RatepayApi\Dto\OrderOperationData; -use Ratepay\RpayPayments\Components\RatepayApi\Dto\PaymentRequestData; use Ratepay\RpayPayments\Components\RatepayApi\Exception\EmptyBasketException; use Shopware\Core\Checkout\Cart\LineItem\LineItem; use Shopware\Core\Checkout\Cart\Price\Struct\CalculatedPrice; @@ -30,7 +29,7 @@ use Shopware\Core\Checkout\Order\Aggregate\OrderLineItem\OrderLineItemEntity; /** - * @method ShoppingBasket getData(PaymentRequestData|OrderOperationData $requestData) + * @extends AbstractFactory */ class ShoppingBasketFactory extends AbstractFactory { diff --git a/src/Components/RatepayApi/Service/Request/AbstractRequest.php b/src/Components/RatepayApi/Service/Request/AbstractRequest.php index bb724f00..43d28c8f 100644 --- a/src/Components/RatepayApi/Service/Request/AbstractRequest.php +++ b/src/Components/RatepayApi/Service/Request/AbstractRequest.php @@ -173,8 +173,8 @@ private function _getRequestHead(AbstractRequestData $requestData): Head { $head = $this->getRequestHead($requestData); - /** @var BuildEvent $event */ - $event = $this->eventDispatcher->dispatch(new BuildEvent($requestData, $head), static::class . self::EVENT_BUILD_HEAD); + $event = new BuildEvent($requestData, $head); + $this->eventDispatcher->dispatch($event, static::class . self::EVENT_BUILD_HEAD); return $event->getBuildData(); } @@ -196,8 +196,8 @@ private function _getRequestContent(AbstractRequestData $requestData): ?Content { $content = $this->getRequestContent($requestData); - /** @var BuildEvent $event */ - $event = $this->eventDispatcher->dispatch(new BuildEvent($requestData, $content), static::class . self::EVENT_BUILD_CONTENT); + $event = new BuildEvent($requestData, $content); + $this->eventDispatcher->dispatch($event, static::class . self::EVENT_BUILD_CONTENT); return $event->getBuildData(); } diff --git a/src/Components/RedirectException/DependencyInjection/subscriber.xml b/src/Components/RedirectException/DependencyInjection/subscriber.xml index 8fa616fe..17c166c6 100644 --- a/src/Components/RedirectException/DependencyInjection/subscriber.xml +++ b/src/Components/RedirectException/DependencyInjection/subscriber.xml @@ -8,9 +8,8 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> - + - diff --git a/src/Components/RedirectException/Subscriber/RedirectExceptionListener.php b/src/Components/RedirectException/Subscriber/RedirectExceptionListener.php index 08afac28..4df8db0d 100644 --- a/src/Components/RedirectException/Subscriber/RedirectExceptionListener.php +++ b/src/Components/RedirectException/Subscriber/RedirectExceptionListener.php @@ -32,7 +32,9 @@ class RedirectExceptionListener implements EventSubscriberInterface { public function __construct( private readonly ContainerInterface $container, - private readonly OrderTransactionStateHandler $orderTransactionStateHandler + private readonly OrderTransactionStateHandler $orderTransactionStateHandler, + private readonly RequestTransformerInterface $requestTransformer, + private readonly HttpKernelInterface $kernel ) { } @@ -87,7 +89,7 @@ public function onKernelException(ExceptionEvent $event): void $router->getContext()->setMethod($method); // reset method $attributes = array_merge( - $this->container->get(RequestTransformerInterface::class)->extractInheritableAttributes($event->getRequest()), + $this->requestTransformer->extractInheritableAttributes($event->getRequest()), $route, $throwable->getQueryParams(), [ @@ -96,8 +98,7 @@ public function onKernelException(ExceptionEvent $event): void ); $subRequest = $event->getRequest()->duplicate($route, null, $attributes); - $response = $this->container->get('http_kernel') - ->handle($subRequest, HttpKernelInterface::SUB_REQUEST); + $response = $this->kernel->handle($subRequest, HttpKernelInterface::SUB_REQUEST); $event->setResponse($response); $event->allowCustomResponseCode(); } diff --git a/src/Core/PluginConfigService.php b/src/Core/PluginConfigService.php index 5334b3b4..b7bb04d6 100644 --- a/src/Core/PluginConfigService.php +++ b/src/Core/PluginConfigService.php @@ -35,7 +35,9 @@ public function getDeviceFingerprintSnippetId(): string public function getPluginConfiguration(): array { - return $this->systemConfigService->get('RpayPayments.config', null) ?: []; + $config = $this->systemConfigService->get('RpayPayments.config', null); + + return is_array($config) ? $config : []; } public function isAutoOperationBasedOnDeliveryStatusEnabled(): bool diff --git a/src/RpayPayments.php b/src/RpayPayments.php index 61b24f15..7bb8bbae 100644 --- a/src/RpayPayments.php +++ b/src/RpayPayments.php @@ -145,7 +145,7 @@ public function build(ContainerBuilder $containerBuilder): void ]; $loader = new XmlFileLoader($containerBuilder, new FileLocator(__DIR__)); - foreach (array_filter(glob(__DIR__ . '/Components/*'), 'is_dir') as $dir) { + foreach (array_filter(array_values(glob(__DIR__ . '/Components/*') ?: []), 'is_dir') as $dir) { foreach ($componentContainerFiles as $fileName) { $file = $dir . '/DependencyInjection/' . $fileName; if (file_exists($file)) { @@ -170,7 +170,12 @@ public function boot(): void { parent::boot(); - FeatureFlagService::loadFeatureFlags($this->container->get(SystemConfigService::class)->get('RpayPayments.config.featureFlags')); + /** @var SystemConfigService $systemConfig */ + $systemConfig = $this->container->get(SystemConfigService::class); + $flags = $systemConfig->get('RpayPayments.config.featureFlags'); + if (is_string($flags)) { + FeatureFlagService::loadFeatureFlags(); + } } /**