From 708880d5fd94b24aea4914164a8c0af7fa5631bc Mon Sep 17 00:00:00 2001 From: Khoubza Younes Date: Sun, 6 Dec 2020 06:23:34 +0100 Subject: [PATCH] add phpdoc and phpstorm autocomplete --- .phpstorm.meta.php | 15 ++++++++++++--- Factory/AbstractFactory.php | 7 +++++++ Notification/NotificationBuilder.php | 7 ++++--- 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/.phpstorm.meta.php b/.phpstorm.meta.php index aa712a5c..fb5f8527 100644 --- a/.phpstorm.meta.php +++ b/.phpstorm.meta.php @@ -4,11 +4,20 @@ namespace PHPSTORM_META; use Flasher\Prime\Envelope; use Flasher\Prime\Flasher; +use Flasher\Prime\Notification\NotificationInterface; use Flasher\Prime\Presenter\PresenterManager; use Flasher\Prime\Renderer\RendererManager; override(Envelope::get(), type(0)); +override(ManagerInterface::make(0), map(['' => '@'])); -override(Flasher::make(''), map(['' => '@'])); -override(RendererManager::make(''), map(['' => '@'])); -override(PresenterManager::make(''), map(['' => '@'])); +registerArgumentsSet('notificationTypes', + NotificationInterface::TYPE_SUCCESS, + NotificationInterface::TYPE_ERROR, + NotificationInterface::TYPE_INFO, + NotificationInterface::TYPE_INFO, +); + +expectedArguments(NotificationBuilder::type(), 1, argumentsSet('notificationTypes')); +expectedReturnValues(NotificationInterface::setType(), 1, argumentsSet('notificationTypes')); +expectedReturnValues(NotificationInterface::getType(), argumentsSet('notificationTypes')); diff --git a/Factory/AbstractFactory.php b/Factory/AbstractFactory.php index b8bf4d9f..34973cf6 100644 --- a/Factory/AbstractFactory.php +++ b/Factory/AbstractFactory.php @@ -2,11 +2,13 @@ namespace Flasher\Prime\Factory; +use Flasher\Prime\Envelope; use Flasher\Prime\EventDispatcher\EventDispatcherInterface; use Flasher\Prime\Notification\Notification; use Flasher\Prime\Notification\NotificationBuilder; use Flasher\Prime\Notification\NotificationBuilderInterface; use Flasher\Prime\Notification\NotificationInterface; +use Flasher\Prime\Stamp\StampInterface; /** * @method NotificationBuilderInterface type($type, $message = null, array $options = array()) @@ -14,6 +16,9 @@ use Flasher\Prime\Notification\NotificationInterface; * @method NotificationBuilderInterface options($options) * @method NotificationBuilderInterface setOption($name, $value) * @method NotificationBuilderInterface unsetOption($name) + * @method NotificationBuilderInterface handler(string $handler) + * @method NotificationBuilderInterface with(StampInterface[] $stamps) + * @method NotificationBuilderInterface withStamp(StampInterface $stamp) * @method NotificationBuilderInterface priority($priority) * @method NotificationBuilderInterface hops($amount) * @method NotificationBuilderInterface keep() @@ -21,7 +26,9 @@ use Flasher\Prime\Notification\NotificationInterface; * @method NotificationBuilderInterface error($message = null, array $options = array()) * @method NotificationBuilderInterface info($message = null, array $options = array()) * @method NotificationBuilderInterface warning($message = null, array $options = array()) + * @method Envelope dispatch(StampInterface[] $stamps) * @method NotificationInterface getNotification() + * @method NotificationInterface getEnvelope() */ abstract class AbstractFactory implements FlasherFactoryInterface { diff --git a/Notification/NotificationBuilder.php b/Notification/NotificationBuilder.php index 0a28a9a1..898bb9de 100644 --- a/Notification/NotificationBuilder.php +++ b/Notification/NotificationBuilder.php @@ -8,6 +8,7 @@ use Flasher\Prime\EventDispatcher\EventDispatcherInterface; use Flasher\Prime\Stamp\HandlerStamp; use Flasher\Prime\Stamp\HopsStamp; use Flasher\Prime\Stamp\PriorityStamp; +use Flasher\Prime\Stamp\StampInterface; class NotificationBuilder implements NotificationBuilderInterface { @@ -186,7 +187,7 @@ class NotificationBuilder implements NotificationBuilderInterface /** * @inheritDoc */ - public function with($stamps = array()) + public function with(array $stamps = array()) { $this->envelope->with($stamps); @@ -196,9 +197,9 @@ class NotificationBuilder implements NotificationBuilderInterface /** * @inheritDoc */ - public function withStamp($stamps = array()) + public function withStamp(StampInterface $stamp) { - $this->envelope->withStamp($stamps); + $this->envelope->withStamp($stamp); return $this; }