Skip to content

Commit

Permalink
NEXT-19598 - Adjust hook class visibilities
Browse files Browse the repository at this point in the history
  • Loading branch information
keulinho committed Apr 27, 2023
1 parent f1c8bf6 commit 0bad13b
Show file tree
Hide file tree
Showing 63 changed files with 121 additions and 12 deletions.
6 changes: 6 additions & 0 deletions changelog/_unreleased/2023-04-26-hook-class-visibilities.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
title: Adjusted hook class visibilities
issue: NEXT-19598
---
# Core
* Changed all abstract Hook classes to be `@internal` and all concrete Hook classes to be `@final`, you should only rely on the concrete hooks and not add hooks yourself.
3 changes: 0 additions & 3 deletions coding-guidelines/core/decorator-pattern.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,6 @@ In this case you should mark the service as follows:
- if you want that developers can call public functions of your service but should not extend it, mark all classes as `@final`

```php
/**
* @final You can use this service, and we keep the api stable, but you should not extend it
*/
abstract class AbstractRuleLoader
{
abstract public function load(Context $context): RuleCollection;
Expand Down
1 change: 0 additions & 1 deletion phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,6 @@ parameters:
# Internal deprecations of Shopware are handled in other places
- '#deprecated.*class Shopware\\#'
- '#deprecated.*interface Shopware\\#'
- '#extends @final class Shopware\\Core\\Framework\\Script\\Execution\\Hook\.#'

- # tests are allowed to add dummy classes in the same file
message: '#Multiple class\/interface\/trait is not allowed in single file#'
Expand Down
3 changes: 0 additions & 3 deletions src/Core/Checkout/Cart/AbstractRuleLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@
use Shopware\Core\Framework\Context;
use Shopware\Core\Framework\Log\Package;

/**
* @final
*/
#[Package('checkout')]
abstract class AbstractRuleLoader
{
Expand Down
2 changes: 2 additions & 0 deletions src/Core/Checkout/Cart/Hook/CartHook.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
* @hook-use-case cart_manipulation
*
* @since 6.4.8.0
*
* @final
*/
#[Package('checkout')]
class CartHook extends Hook implements CartAware
Expand Down
2 changes: 2 additions & 0 deletions src/Core/Checkout/Payment/Hook/PaymentMethodRouteHook.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
* @hook-use-case data_loading
*
* @since 6.5.0.0
*
* @final
*/
#[Package('checkout')]
class PaymentMethodRouteHook extends StoreApiRequestHook
Expand Down
2 changes: 2 additions & 0 deletions src/Core/Checkout/Shipping/Hook/ShippingMethodRouteHook.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
* @hook-use-case data_loading
*
* @since 6.5.0.0
*
* @final
*/
#[Package('checkout')]
class ShippingMethodRouteHook extends StoreApiRequestHook
Expand Down
2 changes: 2 additions & 0 deletions src/Core/Content/Product/Hook/Pricing/ProductPricingHook.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
* @hook-use-case product
*
* @since 6.5.1.0
*
* @final
*/
#[Package('inventory')]
class ProductPricingHook extends Hook implements SalesChannelContextAware
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
* @hook-use-case custom_endpoint
*
* @since 6.4.9.0
*
* @final
*/
#[Package('core')]
class CacheInvalidationHook extends Hook
Expand Down
2 changes: 2 additions & 0 deletions src/Core/Framework/App/Event/Hooks/AppActivatedHook.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
* @hook-use-case app_lifecycle
*
* @since 6.4.9.0
*
* @final
*/
#[Package('core')]
class AppActivatedHook extends AppLifecycleHook implements AppSpecificHook
Expand Down
2 changes: 2 additions & 0 deletions src/Core/Framework/App/Event/Hooks/AppDeactivatedHook.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
* @hook-use-case app_lifecycle
*
* @since 6.4.9.0
*
* @final
*/
#[Package('core')]
class AppDeactivatedHook extends AppLifecycleHook implements AppSpecificHook
Expand Down
2 changes: 2 additions & 0 deletions src/Core/Framework/App/Event/Hooks/AppDeletedHook.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
* @hook-use-case app_lifecycle
*
* @since 6.4.9.0
*
* @final
*/
#[Package('core')]
class AppDeletedHook extends AppLifecycleHook implements AppSpecificHook
Expand Down
2 changes: 2 additions & 0 deletions src/Core/Framework/App/Event/Hooks/AppInstalledHook.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
* @hook-use-case app_lifecycle
*
* @since 6.4.9.0
*
* @final
*/
#[Package('core')]
class AppInstalledHook extends AppLifecycleHook implements AppSpecificHook
Expand Down
2 changes: 1 addition & 1 deletion src/Core/Framework/App/Event/Hooks/AppLifecycleHook.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use Shopware\Core\System\SystemConfig\Facade\SystemConfigFacadeHookFactory;

/**
* @internal
* @internal only rely on the concrete hook implementations
*/
#[Package('core')]
abstract class AppLifecycleHook extends Hook
Expand Down
2 changes: 2 additions & 0 deletions src/Core/Framework/App/Event/Hooks/AppUpdatedHook.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
* @hook-use-case app_lifecycle
*
* @since 6.4.9.0
*
* @final
*/
#[Package('core')]
class AppUpdatedHook extends AppLifecycleHook implements AppSpecificHook
Expand Down
2 changes: 2 additions & 0 deletions src/Core/Framework/Script/Api/ApiHook.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
* @hook-use-case custom_endpoint
*
* @since 6.4.9.0
*
* @final
*/
#[Package('core')]
class ApiHook extends Hook implements StoppableHook
Expand Down
2 changes: 2 additions & 0 deletions src/Core/Framework/Script/Api/StoreApiCacheKeyHook.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
* @hook-use-case custom_endpoint
*
* @since 6.4.9.0
*
* @final
*/
#[Package('core')]
class StoreApiCacheKeyHook extends OptionalFunctionHook implements SalesChannelContextAware, StoppableHook
Expand Down
2 changes: 2 additions & 0 deletions src/Core/Framework/Script/Api/StoreApiHook.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
* @hook-use-case custom_endpoint
*
* @since 6.4.9.0
*
* @final
*/
#[Package('core')]
class StoreApiHook extends InterfaceHook implements SalesChannelContextAware
Expand Down
2 changes: 2 additions & 0 deletions src/Core/Framework/Script/Api/StoreApiResponseHook.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
* @hook-use-case custom_endpoint
*
* @since 6.4.9.0
*
* @final
*/
#[Package('core')]
class StoreApiResponseHook extends FunctionHook implements SalesChannelContextAware, StoppableHook
Expand Down
2 changes: 1 addition & 1 deletion src/Core/Framework/Script/Execution/FunctionHook.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use Shopware\Core\Framework\Log\Package;

/**
* @internal
* @internal only rely on the concrete implementations
*/
#[Package('core')]
abstract class FunctionHook extends Hook
Expand Down
2 changes: 1 addition & 1 deletion src/Core/Framework/Script/Execution/Hook.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use Shopware\Core\Framework\Log\Package;

/**
* @final
* @internal only rely on the concrete hook implementations
*/
#[Package('core')]
abstract class Hook
Expand Down
2 changes: 1 addition & 1 deletion src/Core/Framework/Script/Execution/InterfaceHook.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use Shopware\Core\Framework\Log\Package;

/**
* @internal
* @internal only rely on the concrete implementations
*/
#[Package('core')]
abstract class InterfaceHook extends Hook
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
/**
* Marker that a function does not need to be implemented by a script
*
* @internal
* @internal only rely on the concrete implementations
*/
#[Package('core')]
abstract class OptionalFunctionHook extends FunctionHook
Expand Down
3 changes: 3 additions & 0 deletions src/Core/System/SalesChannel/StoreApiRequestHook.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
use Shopware\Core\Framework\Script\Execution\Hook;
use Shopware\Core\System\SystemConfig\Facade\SystemConfigFacadeHookFactory;

/**
* @internal only rely on the concrete implementations
*/
#[Package('core')]
abstract class StoreApiRequestHook extends Hook implements SalesChannelContextAware
{
Expand Down
2 changes: 2 additions & 0 deletions src/Storefront/Framework/Script/Api/StorefrontHook.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
* @hook-use-case custom_endpoint
*
* @since 6.4.9.0
*
* @final
*/
#[Package('core')]
class StorefrontHook extends Hook implements SalesChannelContextAware, StoppableHook
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
* @hook-use-case data_loading
*
* @since 6.4.8.0
*
* @final
*/
#[Package('customer-order')]
class CustomerGroupRegistrationPageLoadedHook extends PageLoadedHook
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
* @hook-use-case data_loading
*
* @since 6.4.8.0
*
* @final
*/
#[Package('customer-order')]
class AccountGuestLoginPageLoadedHook extends PageLoadedHook
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
* @hook-use-case data_loading
*
* @since 6.4.8.0
*
* @final
*/
#[Package('customer-order')]
class AccountLoginPageLoadedHook extends PageLoadedHook
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
* @hook-use-case data_loading
*
* @since 6.4.8.0
*
* @final
*/
#[Package('customer-order')]
class AccountEditOrderPageLoadedHook extends PageLoadedHook
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
* @hook-use-case data_loading
*
* @since 6.4.8.0
*
* @final
*/
#[Package('customer-order')]
class AccountOrderDetailPageLoadedHook extends PageLoadedHook
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
* @hook-use-case data_loading
*
* @since 6.4.8.0
*
* @final
*/
#[Package('customer-order')]
class AccountOrderPageLoadedHook extends PageLoadedHook
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
* @hook-use-case data_loading
*
* @since 6.4.8.0
*
* @final
*/
#[Package('customer-order')]
class AccountOverviewPageLoadedHook extends PageLoadedHook
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
* @hook-use-case data_loading
*
* @since 6.4.8.0
*
* @final
*/
#[Package('storefront')]
class AccountPaymentMethodPageLoadedHook extends PageLoadedHook
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
* @hook-use-case data_loading
*
* @since 6.4.8.0
*
* @final
*/
#[Package('customer-order')]
class AccountProfilePageLoadedHook extends PageLoadedHook
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
* @hook-use-case data_loading
*
* @since 6.4.13.0
*
* @final
*/
#[Package('customer-order')]
class AccountRecoverPasswordPageLoadedHook extends PageLoadedHook
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
* @hook-use-case data_loading
*
* @since 6.4.8.0
*
* @final
*/
#[Package('customer-order')]
class AccountRegisterPageLoadedHook extends PageLoadedHook
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
* @hook-use-case data_loading
*
* @since 6.4.8.0
*
* @final
*/
#[Package('storefront')]
class AddressDetailPageLoadedHook extends PageLoadedHook
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
* @hook-use-case data_loading
*
* @since 6.4.8.0
*
* @final
*/
#[Package('storefront')]
class AddressBookWidgetLoadedHook extends PageLoadedHook
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
* @hook-use-case data_loading
*
* @since 6.4.8.0
*
* @final
*/
#[Package('storefront')]
class AddressListingPageLoadedHook extends PageLoadedHook
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
* @hook-use-case data_loading
*
* @since 6.4.8.0
*
* @final
*/
#[Package('storefront')]
class CheckoutCartPageLoadedHook extends PageLoadedHook
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
* @hook-use-case data_loading
*
* @since 6.4.8.0
*
* @final
*/
#[Package('storefront')]
class CheckoutConfirmPageLoadedHook extends PageLoadedHook
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
* @hook-use-case data_loading
*
* @since 6.4.8.0
*
* @final
*/
#[Package('storefront')]
class CheckoutFinishPageLoadedHook extends PageLoadedHook
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
* @hook-use-case data_loading
*
* @since 6.4.8.0
*
* @final
*/
#[Package('storefront')]
class CheckoutInfoWidgetLoadedHook extends PageLoadedHook
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
* @hook-use-case data_loading
*
* @since 6.4.8.0
*
* @final
*/
#[Package('storefront')]
class CheckoutOffcanvasWidgetLoadedHook extends PageLoadedHook
Expand Down
Loading

0 comments on commit 0bad13b

Please sign in to comment.