Skip to content

Commit

Permalink
refactor: Deprecate Enlight_Event_Subscriber*
Browse files Browse the repository at this point in the history
and fix most remaining phpstan errors of Enlight\Event
  • Loading branch information
aragon999 committed Aug 27, 2023
1 parent f56e358 commit b436792
Show file tree
Hide file tree
Showing 16 changed files with 88 additions and 240 deletions.
180 changes: 0 additions & 180 deletions .phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -2660,36 +2660,6 @@ parameters:
count: 1
path: engine/Library/Enlight/Controller/Router.php

-
message: "#^Method Enlight_Event_EventArgs\\:\\:__construct\\(\\) has parameter \\$args with no value type specified in iterable type array\\.$#"
count: 1
path: engine/Library/Enlight/Event/EventArgs.php

-
message: "#^Method Enlight_Event_EventArgs\\:\\:getReturn\\(\\) has no return type specified\\.$#"
count: 1
path: engine/Library/Enlight/Event/EventArgs.php

-
message: "#^Method Enlight_Event_EventArgs\\:\\:setName\\(\\) has parameter \\$name with no type specified\\.$#"
count: 1
path: engine/Library/Enlight/Event/EventArgs.php

-
message: "#^Method Enlight_Event_EventArgs\\:\\:setName\\(\\) should return string but return statement is missing\\.$#"
count: 1
path: engine/Library/Enlight/Event/EventArgs.php

-
message: "#^Method Enlight_Event_EventArgs\\:\\:setReturn\\(\\) has parameter \\$return with no type specified\\.$#"
count: 1
path: engine/Library/Enlight/Event/EventArgs.php

-
message: "#^PHPDoc tag @param for parameter \\$args with type array\\|null is not subtype of native type array\\.$#"
count: 1
path: engine/Library/Enlight/Event/EventArgs.php

-
message: "#^Method Enlight_Event_EventHandler\\:\\:__construct\\(\\) has parameter \\$plugin with no type specified\\.$#"
count: 1
Expand Down Expand Up @@ -2720,111 +2690,11 @@ parameters:
count: 1
path: engine/Library/Enlight/Event/EventHandler.php

-
message: "#^Method Enlight_Event_EventManager\\:\\:buildEventArgs\\(\\) has parameter \\$eventArgs with no value type specified in iterable type array\\.$#"
count: 1
path: engine/Library/Enlight/Event/EventManager.php

-
message: "#^Method Enlight_Event_EventManager\\:\\:collect\\(\\) has parameter \\$collection with generic class Doctrine\\\\Common\\\\Collections\\\\ArrayCollection but does not specify its types\\: TKey, T$#"
count: 1
path: engine/Library/Enlight/Event/EventManager.php

-
message: "#^Method Enlight_Event_EventManager\\:\\:collect\\(\\) has parameter \\$eventArgs with no value type specified in iterable type array\\.$#"
count: 1
path: engine/Library/Enlight/Event/EventManager.php

-
message: "#^Method Enlight_Event_EventManager\\:\\:collect\\(\\) return type with generic class Doctrine\\\\Common\\\\Collections\\\\ArrayCollection does not specify its types\\: TKey, T$#"
count: 1
path: engine/Library/Enlight/Event/EventManager.php

-
message: "#^Method Enlight_Event_EventManager\\:\\:filter\\(\\) has parameter \\$eventArgs with no value type specified in iterable type array\\.$#"
count: 1
path: engine/Library/Enlight/Event/EventManager.php

-
message: "#^Method Enlight_Event_EventManager\\:\\:getEvents\\(\\) return type has no value type specified in iterable type array\\.$#"
count: 1
path: engine/Library/Enlight/Event/EventManager.php

-
message: "#^Method Enlight_Event_EventManager\\:\\:getListeners\\(\\) has parameter \\$event with no type specified\\.$#"
count: 1
path: engine/Library/Enlight/Event/EventManager.php

-
message: "#^Method Enlight_Event_EventManager\\:\\:notify\\(\\) has parameter \\$eventArgs with no value type specified in iterable type array\\.$#"
count: 1
path: engine/Library/Enlight/Event/EventManager.php

-
message: "#^Method Enlight_Event_EventManager\\:\\:notifyUntil\\(\\) has parameter \\$eventArgs with no value type specified in iterable type array\\.$#"
count: 1
path: engine/Library/Enlight/Event/EventManager.php

-
message: "#^Method Enlight_Event_EventManager\\:\\:registerSubscriber\\(\\) has no return type specified\\.$#"
count: 1
path: engine/Library/Enlight/Event/EventManager.php

-
message: "#^Method Enlight_Event_Handler\\:\\:__construct\\(\\) has parameter \\$event with no type specified\\.$#"
count: 1
path: engine/Library/Enlight/Event/Handler.php

-
message: "#^Method Enlight_Event_Handler\\:\\:execute\\(\\) has no return type specified\\.$#"
count: 1
path: engine/Library/Enlight/Event/Handler.php

-
message: "#^Method Enlight_Event_Handler_Default\\:\\:execute\\(\\) has no return type specified\\.$#"
count: 1
path: engine/Library/Enlight/Event/Handler/Default.php

-
message: "#^Method Enlight_Event_Handler_Default\\:\\:toArray\\(\\) return type has no value type specified in iterable type array\\.$#"
count: 1
path: engine/Library/Enlight/Event/Handler/Default.php

-
message: "#^Parameter \\#1 \\$listener of method Enlight_Event_Handler_Default\\:\\:setListener\\(\\) expects array\\<int, object\\|string\\>\\|\\(callable\\(\\)\\: mixed\\), array\\<int, \\(callable\\(\\)\\: mixed\\)\\|object\\|string\\>\\|\\(callable\\(\\)\\: mixed\\) given\\.$#"
count: 1
path: engine/Library/Enlight/Event/Handler/Default.php

-
message: "#^Parameter \\#1 \\$position of method Enlight_Event_Handler\\:\\:setPosition\\(\\) expects int, int\\|null given\\.$#"
count: 1
path: engine/Library/Enlight/Event/Handler/Default.php

-
message: "#^Method Enlight_Event_Handler_Plugin\\:\\:execute\\(\\) has no return type specified\\.$#"
count: 1
path: engine/Library/Enlight/Event/Handler/Plugin.php

-
message: "#^Method Enlight_Event_Handler_Plugin\\:\\:toArray\\(\\) return type has no value type specified in iterable type array\\.$#"
count: 1
path: engine/Library/Enlight/Event/Handler/Plugin.php

-
message: "#^Parameter \\#1 \\$position of method Enlight_Event_Handler\\:\\:setPosition\\(\\) expects int, int\\|null given\\.$#"
count: 1
path: engine/Library/Enlight/Event/Handler/Plugin.php

-
message: "#^Unreachable statement \\- code above always terminates\\.$#"
count: 1
path: engine/Library/Enlight/Event/Handler/Plugin.php

-
message: "#^Method Enlight_Event_Subscriber\\:\\:getListeners\\(\\) return type has no value type specified in iterable type array\\.$#"
count: 1
path: engine/Library/Enlight/Event/Subscriber.php

-
message: "#^Method Enlight_Event_Subscriber_Array\\:\\:__construct\\(\\) has parameter \\$options with no value type specified in iterable type array\\.$#"
count: 1
Expand Down Expand Up @@ -2885,46 +2755,6 @@ parameters:
count: 1
path: engine/Library/Enlight/Event/Subscriber/Config.php

-
message: "#^Access to an undefined property Enlight_Config\\:\\:\\$listener\\.$#"
count: 1
path: engine/Library/Enlight/Event/Subscriber/Plugin.php

-
message: "#^Access to an undefined property Enlight_Config\\:\\:\\$listeners\\.$#"
count: 2
path: engine/Library/Enlight/Event/Subscriber/Plugin.php

-
message: "#^Access to an undefined property Enlight_Config\\:\\:\\$name\\.$#"
count: 1
path: engine/Library/Enlight/Event/Subscriber/Plugin.php

-
message: "#^Access to an undefined property Enlight_Config\\:\\:\\$plugin\\.$#"
count: 1
path: engine/Library/Enlight/Event/Subscriber/Plugin.php

-
message: "#^Access to an undefined property Enlight_Config\\:\\:\\$position\\.$#"
count: 1
path: engine/Library/Enlight/Event/Subscriber/Plugin.php

-
message: "#^Method Enlight_Event_Subscriber_Plugin\\:\\:__construct\\(\\) has parameter \\$namespace with no type specified\\.$#"
count: 1
path: engine/Library/Enlight/Event/Subscriber/Plugin.php

-
message: "#^Method Enlight_Event_Subscriber_Plugin\\:\\:toArray\\(\\) return type has no value type specified in iterable type array\\.$#"
count: 1
path: engine/Library/Enlight/Event/Subscriber/Plugin.php

-
message: "#^Method Enlight_Hook_HookArgs\\:\\:__construct\\(\\) has parameter \\$args with no value type specified in iterable type array\\.$#"
count: 1
path: engine/Library/Enlight/Hook/HookArgs.php

-
message: "#^Method Enlight_Hook_HookArgs\\:\\:__construct\\(\\) has parameter \\$subject with no type specified\\.$#"
count: 1
Expand Down Expand Up @@ -3165,11 +2995,6 @@ parameters:
count: 1
path: engine/Library/Enlight/Plugin/Namespace/Config.php

-
message: "#^Parameter \\#2 \\$options of class Enlight_Event_Subscriber_Plugin constructor expects null, Enlight_Config given\\.$#"
count: 1
path: engine/Library/Enlight/Plugin/Namespace/Config.php

-
message: "#^Method Enlight_Plugin_Namespace_Loader\\:\\:load\\(\\) should return Enlight_Plugin_PluginCollection but return statement is missing\\.$#"
count: 1
Expand Down Expand Up @@ -15075,11 +14900,6 @@ parameters:
count: 1
path: engine/Shopware/Components/ContainerAwareEventManager.php

-
message: "#^Method Shopware\\\\Components\\\\ContainerAwareEventManager\\:\\:getListeners\\(\\) has parameter \\$eventName with no type specified\\.$#"
count: 1
path: engine/Shopware/Components/ContainerAwareEventManager.php

-
message: "#^Method Shopware\\\\Components\\\\ContainerAwareEventManager\\:\\:lazyLoad\\(\\) has no return type specified\\.$#"
count: 1
Expand Down
4 changes: 0 additions & 4 deletions .phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,6 @@ parameters:
message: '#Property Shopware\\Models\\.*::\$.* is never written, only read#'
path: engine/Shopware/Models

- # Giving "test" as construct parameter sets up a test storage
message: '#Parameter \#1 \$options of class Enlight_Event_Subscriber_Config constructor expects array\|null, string given#'
path: tests/Unit/Components/Event/SubscriberConfigTest.php

- # The Symfony extension does not correctly recognize the helper type. see: https://github.com/phpstan/phpstan-symfony/issues/239
message: '#Call to an undefined method Symfony\\Component\\Console\\Helper\\HelperInterface::ask\(\)#'
paths:
Expand Down
2 changes: 1 addition & 1 deletion engine/Library/Enlight/.php-cs-fixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
'no_alias_functions' => true,
'no_useless_else' => true,
'no_useless_return' => true,
'no_superfluous_phpdoc_tags' => true,
'no_superfluous_phpdoc_tags' => ['allow_mixed' => true],
'nullable_type_declaration_for_default_null_value' => true,
'operator_linebreak' => ['only_booleans' => true],
'ordered_class_elements' => true,
Expand Down
10 changes: 8 additions & 2 deletions engine/Library/Enlight/Event/EventArgs.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class Enlight_Event_EventArgs extends Enlight_Collection_ArrayCollection
/**
* The Enlight_Event_EventArgs class constructor expects the name of the event.
*
* @param array|null $args
* @param array<string|int, mixed> $args
*/
public function __construct(array $args = [])
{
Expand Down Expand Up @@ -95,7 +95,9 @@ public function isProcessed()
/**
* Setter method for the event name property.
*
* @return string
* @param string $name
*
* @return void
*/
public function setName($name)
{
Expand All @@ -115,6 +117,8 @@ public function getName()
/**
* Setter method for the return property.
*
* @param mixed $return
*
* @return void
*/
public function setReturn($return)
Expand All @@ -124,6 +128,8 @@ public function setReturn($return)

/**
* Getter method for the return property.
*
* @return mixed
*/
public function getReturn()
{
Expand Down
2 changes: 1 addition & 1 deletion engine/Library/Enlight/Event/EventHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
* @copyright Copyright (c) 2011, shopware AG (http://www.shopware.de)
* @license http://enlight.de/license New BSD License
*
* @deprecated in Shopware 5.6, will be removed in 5.8. Please use `Enlight_Event_Handler_Default` or `SubscriberInterface::getSubscribedEvents` instead.
* @deprecated in Shopware 5.6, will be removed in 5.8. Please use `SubscriberInterface::getSubscribedEvents` instead.
*/
class Enlight_Event_EventHandler extends Enlight_Event_Handler_Default
{
Expand Down
Loading

0 comments on commit b436792

Please sign in to comment.