Simplify PHPDoc comments in Notyf integration

Remove verbose documentation pattern references and redundant
explanations, keeping only essential type annotations.
This commit is contained in:
Younes ENNAJI
2026-01-15 22:51:25 +01:00
parent 611fda9c61
commit ea164fde17
11 changed files with 8 additions and 239 deletions
+2 -1
View File
@@ -37,6 +37,7 @@ if (!\function_exists('Flasher\Noty\Prime\noty')) {
* buttons?: string[], * buttons?: string[],
* visibilityControl?: bool, * visibilityControl?: bool,
* } $options * } $options
* @param 'success'|'info'|'warning'|'error'|'alert'|'information' $type
* *
* @phpstan-return ($message is empty ? NotyInterface : Envelope) * @phpstan-return ($message is empty ? NotyInterface : Envelope)
*/ */
@@ -48,6 +49,6 @@ if (!\function_exists('Flasher\Noty\Prime\noty')) {
return $factory; return $factory;
} }
return $factory->flash($type, $message, $options, $title); // @phpstan-ignore-line return $factory->flash($type, $message, $options, $title);
} }
} }
+2 -1
View File
@@ -36,6 +36,7 @@ if (!function_exists('noty')) {
* buttons?: string[], * buttons?: string[],
* visibilityControl?: bool, * visibilityControl?: bool,
* } $options * } $options
* @param 'success'|'info'|'warning'|'error'|'alert'|'information' $type
* *
* @phpstan-return ($message is empty ? NotyInterface : Envelope) * @phpstan-return ($message is empty ? NotyInterface : Envelope)
*/ */
@@ -47,6 +48,6 @@ if (!function_exists('noty')) {
return $factory; return $factory;
} }
return $factory->flash($type, $message, $options, $title); // @phpstan-ignore-line return $factory->flash($type, $message, $options, $title);
} }
} }
-28
View File
@@ -10,29 +10,6 @@ use Flasher\Prime\Stamp\StampInterface;
use Illuminate\Support\Facades\Facade; use Illuminate\Support\Facades\Facade;
/** /**
* Notyf - Laravel facade for Notyf notifications.
*
* This facade provides a static interface to Notyf's functionality within Laravel,
* following Laravel's facade pattern. It offers comprehensive IDE autocompletion
* for all Notyf builder methods.
*
* Design patterns:
* - Facade: Provides a simplified, static interface to a complex subsystem
* - Proxy: Acts as a proxy to the underlying Notyf service
*
* Usage examples:
* ```php
* // Simple notification
* Notyf::success('Operation completed successfully');
*
* // Chained configuration
* Notyf::duration(3000)
* ->dismissible(true)
* ->position('x', 'right')
* ->position('y', 'top')
* ->success('Record saved');
* ```
*
* @method static NotyfBuilder success(string $message, array<string, mixed> $options = array()) * @method static NotyfBuilder success(string $message, array<string, mixed> $options = array())
* @method static NotyfBuilder error(string $message, array<string, mixed> $options = array()) * @method static NotyfBuilder error(string $message, array<string, mixed> $options = array())
* @method static NotyfBuilder warning(string $message, array<string, mixed> $options = array()) * @method static NotyfBuilder warning(string $message, array<string, mixed> $options = array())
@@ -57,11 +34,6 @@ use Illuminate\Support\Facades\Facade;
*/ */
final class Notyf extends Facade final class Notyf extends Facade
{ {
/**
* Get the registered name of the component.
*
* @return string The service container binding key for Notyf
*/
protected static function getFacadeAccessor(): string protected static function getFacadeAccessor(): string
{ {
return 'flasher.notyf'; return 'flasher.notyf';
@@ -7,24 +7,8 @@ namespace Flasher\Notyf\Laravel;
use Flasher\Laravel\Support\PluginServiceProvider; use Flasher\Laravel\Support\PluginServiceProvider;
use Flasher\Notyf\Prime\NotyfPlugin; use Flasher\Notyf\Prime\NotyfPlugin;
/**
* FlasherNotyfServiceProvider - Laravel service provider for Notyf integration.
*
* This service provider registers the Notyf plugin with Laravel's service container.
* It extends the base plugin service provider to inherit common registration logic
* while providing the Notyf-specific plugin implementation.
*
* Design patterns:
* - Service Provider: Implements Laravel's service provider pattern
* - Factory Method: Creates the plugin instance
*/
final class FlasherNotyfServiceProvider extends PluginServiceProvider final class FlasherNotyfServiceProvider extends PluginServiceProvider
{ {
/**
* Creates the Notyf plugin instance.
*
* @return NotyfPlugin The Notyf plugin instance
*/
public function createPlugin(): NotyfPlugin public function createPlugin(): NotyfPlugin
{ {
return new NotyfPlugin(); return new NotyfPlugin();
-18
View File
@@ -7,28 +7,10 @@ namespace Flasher\Notyf\Prime;
use Flasher\Prime\Factory\NotificationFactory; use Flasher\Prime\Factory\NotificationFactory;
/** /**
* Notyf - Factory implementation for Notyf.js notifications.
*
* This class implements the notification factory for Notyf.js, creating
* specialized notification builders configured for Notyf's specific features.
* It serves as the primary entry point for creating Notyf notifications.
*
* Design patterns:
* - Factory: Creates specialized notification builders
* - Bridge: Connects PHPFlasher's notification system to Notyf.js
* - Composition: Delegates to NotyfBuilder for construction details
*
* @mixin \Flasher\Notyf\Prime\NotyfBuilder * @mixin \Flasher\Notyf\Prime\NotyfBuilder
*/ */
final class Notyf extends NotificationFactory implements NotyfInterface final class Notyf extends NotificationFactory implements NotyfInterface
{ {
/**
* {@inheritdoc}
*
* Creates a new Notyf-specific notification builder.
*
* @return NotyfBuilder A builder configured for Notyf.js notifications
*/
public function createNotificationBuilder(): NotyfBuilder public function createNotificationBuilder(): NotyfBuilder
{ {
return new NotyfBuilder('notyf', $this->storageManager); return new NotyfBuilder('notyf', $this->storageManager);
-55
View File
@@ -7,18 +7,6 @@ namespace Flasher\Notyf\Prime;
use Flasher\Prime\Notification\NotificationBuilder; use Flasher\Prime\Notification\NotificationBuilder;
/** /**
* NotyfBuilder - Builder implementation for Notyf.js notifications.
*
* This class provides a fluent interface for configuring Notyf.js notifications.
* It extends the core notification builder with Notyf-specific options and
* features, focusing on Notyf's minimalist approach with fewer options than other
* notification libraries.
*
* Design patterns:
* - Builder: Provides a fluent interface for constructing complex objects
* - Fluent Interface: Methods return $this for method chaining
* - Type Safety: Uses PHPStan annotations for compile-time type checking
*
* @phpstan-type NotificationType "success"|"info"|"warning"|"error" * @phpstan-type NotificationType "success"|"info"|"warning"|"error"
* @phpstan-type OptionsType array{ * @phpstan-type OptionsType array{
* duration?: int, * duration?: int,
@@ -33,15 +21,6 @@ use Flasher\Prime\Notification\NotificationBuilder;
*/ */
final class NotyfBuilder extends NotificationBuilder final class NotyfBuilder extends NotificationBuilder
{ {
/**
* Sets the notification display duration.
*
* Number of milliseconds before hiding the notification. Use 0 for infinite duration.
*
* @param int $duration Duration in milliseconds
*
* @return self The builder instance
*/
public function duration(int $duration): self public function duration(int $duration): self
{ {
$this->option('duration', $duration); $this->option('duration', $duration);
@@ -49,13 +28,6 @@ final class NotyfBuilder extends NotificationBuilder
return $this; return $this;
} }
/**
* Sets whether to show the notification with a ripple effect.
*
* @param bool $ripple Whether to enable ripple effect
*
* @return self The builder instance
*/
public function ripple(bool $ripple = true): self public function ripple(bool $ripple = true): self
{ {
$this->option('ripple', $ripple); $this->option('ripple', $ripple);
@@ -64,18 +36,7 @@ final class NotyfBuilder extends NotificationBuilder
} }
/** /**
* Sets the notification position in the viewport.
*
* Viewport location where notifications are rendered.
*
* @param "x"|"y" $position Specifies the axis: 'x' for horizontal, 'y' for vertical
* @param "left"|"center"|"right"|"top"|"bottom" $value Position value, dependent on the axis:
* - If $position is 'x', $value must be 'left', 'center' or 'right'
* - If $position is 'y', $value must be 'top', 'center' or 'bottom'
*
* @phpstan-param ($position is 'x' ? "left"|"center"|"right" : "top"|"center"|"bottom") $value * @phpstan-param ($position is 'x' ? "left"|"center"|"right" : "top"|"center"|"bottom") $value
*
* @return self The builder instance
*/ */
public function position(string $position, string $value): self public function position(string $position, string $value): self
{ {
@@ -87,15 +48,6 @@ final class NotyfBuilder extends NotificationBuilder
return $this; return $this;
} }
/**
* Sets whether to allow users to dismiss the notification.
*
* Whether to allow users to dismiss the notification with a button.
*
* @param bool $dismissible Whether to make the notification dismissible
*
* @return self The builder instance
*/
public function dismissible(bool $dismissible): self public function dismissible(bool $dismissible): self
{ {
$this->option('dismissible', $dismissible); $this->option('dismissible', $dismissible);
@@ -103,13 +55,6 @@ final class NotyfBuilder extends NotificationBuilder
return $this; return $this;
} }
/**
* Sets the background color of the notification.
*
* @param string $background CSS color value for the notification background
*
* @return self The builder instance
*/
public function background(string $background): self public function background(string $background): self
{ {
$this->option('background', $background); $this->option('background', $background);
-11
View File
@@ -7,17 +7,6 @@ namespace Flasher\Notyf\Prime;
use Flasher\Prime\Factory\NotificationFactoryInterface; use Flasher\Prime\Factory\NotificationFactoryInterface;
/** /**
* NotyfInterface - Contract for Notyf notification factories.
*
* This interface defines the contract for Notyf notification factories.
* It extends the core notification factory interface to ensure compatibility
* with PHPFlasher's notification system, while allowing IDE completion for
* Notyf-specific methods through the mixin annotation.
*
* Design patterns:
* - Interface Segregation: Provides a specific interface for Notyf functionality
* - Contract: Defines a contract for creating Notyf notifications
*
* @mixin \Flasher\Notyf\Prime\NotyfBuilder * @mixin \Flasher\Notyf\Prime\NotyfBuilder
*/ */
interface NotyfInterface extends NotificationFactoryInterface interface NotyfInterface extends NotificationFactoryInterface
+2 -39
View File
@@ -6,57 +6,25 @@ namespace Flasher\Notyf\Prime;
use Flasher\Prime\Plugin\Plugin; use Flasher\Prime\Plugin\Plugin;
/**
* NotyfPlugin - Plugin definition for Notyf.js integration with PHPFlasher.
*
* This class defines the core plugin configuration for the Notyf.js notification
* library integration. It specifies the required JavaScript and CSS assets,
* factory class, and service identifiers for dependency injection containers.
*
* Design patterns:
* - Plugin: Implements the plugin pattern for extending core functionality
* - Registry: Registers the plugin's assets and identifiers with the core system
* - Metadata: Provides metadata about the plugin's requirements
*/
final class NotyfPlugin extends Plugin final class NotyfPlugin extends Plugin
{ {
/**
* {@inheritdoc}
*
* Returns the plugin's unique identifier.
*/
public function getAlias(): string public function getAlias(): string
{ {
return 'notyf'; return 'notyf';
} }
/**
* {@inheritdoc}
*
* Returns the factory class responsible for creating Notyf notifications.
*/
public function getFactory(): string public function getFactory(): string
{ {
return Notyf::class; return Notyf::class;
} }
/**
* {@inheritdoc}
*
* Returns the service alias for dependency injection containers.
*/
public function getServiceAliases(): string public function getServiceAliases(): string
{ {
return NotyfInterface::class; return NotyfInterface::class;
} }
/** /**
* {@inheritdoc} * @return string[]
*
* Returns the required JavaScript files for Notyf.js integration.
* Compared to other libraries, Notyf has a minimal footprint with just one script.
*
* @return string[] Array of script paths
*/ */
public function getScripts(): array public function getScripts(): array
{ {
@@ -66,12 +34,7 @@ final class NotyfPlugin extends Plugin
} }
/** /**
* {@inheritdoc} * @return string[]
*
* Returns the required CSS files for Notyf.js styling.
* Notyf has a minimal footprint with just one stylesheet.
*
* @return string[] Array of stylesheet paths
*/ */
public function getStyles(): array public function getStyles(): array
{ {
+1 -27
View File
@@ -8,25 +8,8 @@ use Flasher\Prime\Container\FlasherContainer;
use Flasher\Prime\Notification\Envelope; use Flasher\Prime\Notification\Envelope;
use Flasher\Prime\Notification\Type; use Flasher\Prime\Notification\Type;
/*
* Namespace-specific helper functions for Notyf notifications.
*
* This file provides a namespace-specific helper function that simplifies
* the creation of Notyf notifications from code that uses imports.
*
* Design pattern: Facade - Provides a simplified interface to a complex subsystem
*/
if (!\function_exists('Flasher\Notyf\Prime\notyf')) { if (!\function_exists('Flasher\Notyf\Prime\notyf')) {
/** /**
* Creates a Notyf notification or returns the Notyf factory.
*
* This function simplifies the process of creating Notyf notifications.
* When called with no arguments, it returns an instance of NotyfInterface.
* When called with arguments, it creates a Notyf notification and returns an Envelope.
*
* @param string|null $message the message content of the notification
* @param "success"|"info"|"warning"|"error" $type The type of the notification (e.g., success, error, warning, info).
* @param array{ * @param array{
* duration?: int, * duration?: int,
* ripple?: bool, * ripple?: bool,
@@ -36,18 +19,9 @@ if (!\function_exists('Flasher\Notyf\Prime\notyf')) {
* }, * },
* dismissible?: bool, * dismissible?: bool,
* background?: string, * background?: string,
* } $options additional options for the Notyf notification * } $options
* @param string|null $title the title of the notification
*
* @return Envelope|NotyfInterface Returns an Envelope containing the notification details when arguments are provided.
* Returns an instance of NotyfInterface when no arguments are provided.
* *
* @phpstan-return ($message is empty ? NotyfInterface : Envelope) * @phpstan-return ($message is empty ? NotyfInterface : Envelope)
*
* Usage:
* 1. Without arguments - Get the Notyf factory: $notyf = notyf();
* 2. With arguments - Create and return a Notyf notification:
* notyf('Message', Type::SUCCESS, ['option' => 'value'], 'Title');
*/ */
function notyf(?string $message = null, string $type = Type::SUCCESS, array $options = [], ?string $title = null): Envelope|NotyfInterface function notyf(?string $message = null, string $type = Type::SUCCESS, array $options = [], ?string $title = null): Envelope|NotyfInterface
{ {
+1 -27
View File
@@ -7,25 +7,8 @@ use Flasher\Prime\Container\FlasherContainer;
use Flasher\Prime\Notification\Envelope; use Flasher\Prime\Notification\Envelope;
use Flasher\Prime\Notification\Type; use Flasher\Prime\Notification\Type;
/*
* Global helper functions for Notyf notifications.
*
* This file provides a global helper function that simplifies
* the creation of Notyf notifications from any PHP code.
*
* Design pattern: Facade - Provides a simplified interface to a complex subsystem
*/
if (!function_exists('notyf')) { if (!function_exists('notyf')) {
/** /**
* Creates a Notyf notification or returns the Notyf factory.
*
* This function simplifies the process of creating Notyf notifications.
* When called with no arguments, it returns an instance of NotyfInterface.
* When called with arguments, it creates a Notyf notification and returns an Envelope.
*
* @param string|null $message the message content of the notification
* @param "success"|"info"|"warning"|"error" $type The type of the notification (e.g., success, error, warning, info).
* @param array{ * @param array{
* duration?: int, * duration?: int,
* ripple?: bool, * ripple?: bool,
@@ -35,18 +18,9 @@ if (!function_exists('notyf')) {
* }, * },
* dismissible?: bool, * dismissible?: bool,
* background?: string, * background?: string,
* } $options additional options for the Notyf notification * } $options
* @param string|null $title the title of the notification
*
* @return Envelope|NotyfInterface Returns an Envelope containing the notification details when arguments are provided.
* Returns an instance of NotyfInterface when no arguments are provided.
* *
* @phpstan-return ($message is empty ? NotyfInterface : Envelope) * @phpstan-return ($message is empty ? NotyfInterface : Envelope)
*
* Usage:
* 1. Without arguments - Get the Notyf factory: $notyf = notyf();
* 2. With arguments - Create and return a Notyf notification:
* notyf('Message', Type::SUCCESS, ['option' => 'value'], 'Title');
*/ */
function notyf(?string $message = null, string $type = Type::SUCCESS, array $options = [], ?string $title = null): Envelope|NotyfInterface function notyf(?string $message = null, string $type = Type::SUCCESS, array $options = [], ?string $title = null): Envelope|NotyfInterface
{ {
@@ -8,24 +8,8 @@ use Flasher\Notyf\Prime\NotyfPlugin;
use Flasher\Prime\Plugin\PluginInterface; use Flasher\Prime\Plugin\PluginInterface;
use Flasher\Symfony\Support\PluginBundle; use Flasher\Symfony\Support\PluginBundle;
/**
* FlasherNotyfSymfonyBundle - Symfony bundle for Notyf integration.
*
* This bundle registers the Notyf plugin with Symfony's service container.
* It extends the base plugin bundle to inherit common registration logic
* while providing the Notyf-specific plugin implementation.
*
* Design patterns:
* - Bundle: Implements Symfony's bundle pattern for packaging functionality
* - Factory Method: Creates the plugin instance
*/
final class FlasherNotyfSymfonyBundle extends PluginBundle // Symfony\Component\HttpKernel\Bundle\Bundle final class FlasherNotyfSymfonyBundle extends PluginBundle // Symfony\Component\HttpKernel\Bundle\Bundle
{ {
/**
* Creates the Notyf plugin instance.
*
* @return PluginInterface The Notyf plugin instance
*/
public function createPlugin(): PluginInterface public function createPlugin(): PluginInterface
{ {
return new NotyfPlugin(); return new NotyfPlugin();