diff --git a/composer.json b/composer.json index 6fcd68c..e6c98a3 100644 --- a/composer.json +++ b/composer.json @@ -16,11 +16,12 @@ "minimum-stability": "stable", "require": { "php": "^7.4 || ^8.0.0", - "symfony/console": "^5.4", "jrosset/betterphptoken": "^1.0", "jrosset/collections": "^2.3", "jrosset/extendedmonolog": "^1.1", - "psr/log": "^1.1" + "psr/log": "^1.1", + "symfony/console": "^5.4", + "voku/arrayy": "^7.9" }, "autoload": { "psr-4": { diff --git a/src/CliProgram/AutoDiscovery/AutoDiscoverySpotsList.php b/src/CliProgram/AutoDiscovery/AutoDiscoverySpotsList.php new file mode 100644 index 0000000..2556d25 --- /dev/null +++ b/src/CliProgram/AutoDiscovery/AutoDiscoverySpotsList.php @@ -0,0 +1,19 @@ + + */ +class AutoDiscoverySpotsList extends AbstractCollection { + /** + * @inheritDoc + */ + public function getType (): string { + return IAutoDiscoverySpot::class; + } +} \ No newline at end of file diff --git a/src/CliProgram/AutoDiscovery/TAutoDiscoveryApplication.php b/src/CliProgram/AutoDiscovery/TAutoDiscoveryApplication.php index 815a455..c50601a 100644 --- a/src/CliProgram/AutoDiscovery/TAutoDiscoveryApplication.php +++ b/src/CliProgram/AutoDiscovery/TAutoDiscoveryApplication.php @@ -2,26 +2,23 @@ namespace jrosset\CliProgram\AutoDiscovery; -use jrosset\Collections\Collection; -use jrosset\Collections\ICollection; - /** * An application with command auto discovery */ trait TAutoDiscoveryApplication { /** - * @var ICollection The list of discovery spots + * @var AutoDiscoverySpotsList The list of discovery spots */ - private ICollection $autoDiscoverySpots; + private AutoDiscoverySpotsList $autoDiscoverySpots; /** * The list of discovery spots * - * @return ICollection The list of discovery spots + * @return AutoDiscoverySpotsList The list of discovery spots */ - public function getAutoDiscoverySpots (): ICollection { + public function getAutoDiscoverySpots (): AutoDiscoverySpotsList { if (!isset($this->autoDiscoverySpots)) { - $this->autoDiscoverySpots = new Collection(); + $this->autoDiscoverySpots = new AutoDiscoverySpotsList(); } return $this->autoDiscoverySpots; } diff --git a/src/CliProgram/AutoPrefix/AutoPrefixManagersList.php b/src/CliProgram/AutoPrefix/AutoPrefixManagersList.php new file mode 100644 index 0000000..ebd1822 --- /dev/null +++ b/src/CliProgram/AutoPrefix/AutoPrefixManagersList.php @@ -0,0 +1,19 @@ + + */ +class AutoPrefixManagersList extends AbstractCollection { + /** + * @inheritDoc + */ + public function getType (): string { + return IAutoPrefixManager::class; + } +} \ No newline at end of file diff --git a/src/CliProgram/AutoPrefix/TAutoPrefixManagement.php b/src/CliProgram/AutoPrefix/TAutoPrefixManagement.php index 3c1dc87..c749c43 100644 --- a/src/CliProgram/AutoPrefix/TAutoPrefixManagement.php +++ b/src/CliProgram/AutoPrefix/TAutoPrefixManagement.php @@ -2,8 +2,6 @@ namespace jrosset\CliProgram\AutoPrefix; -use jrosset\Collections\Collection; -use jrosset\Collections\ICollection; use Symfony\Component\Console\Command\Command; /** @@ -11,18 +9,18 @@ use Symfony\Component\Console\Command\Command; */ trait TAutoPrefixManagement { /** - * @var ICollection The lists of manager for commands auto prefix + * @var AutoPrefixManagersList The lists of manager for commands auto prefix */ - private ICollection $autoPrefixManagers; + private AutoPrefixManagersList $autoPrefixManagers; /** * The lists of manager for commands auto prefix * - * @return ICollection The lists of manager for commands auto prefix + * @return AutoPrefixManagersList The lists of manager for commands auto prefix */ - public function getAutoPrefixManagers (): ICollection { + public function getAutoPrefixManagers (): AutoPrefixManagersList { if (!isset($this->autoPrefixManagers)) { - $this->autoPrefixManagers = new Collection(); + $this->autoPrefixManagers = new AutoPrefixManagersList(); } return $this->autoPrefixManagers; } diff --git a/src/CliProgram/Validation/Validators/DirectoryValidator.php b/src/CliProgram/Validation/Validators/DirectoryValidator.php index c4ecdf3..8c79258 100644 --- a/src/CliProgram/Validation/Validators/DirectoryValidator.php +++ b/src/CliProgram/Validation/Validators/DirectoryValidator.php @@ -3,8 +3,6 @@ namespace jrosset\CliProgram\Validation\Validators; use InvalidArgumentException; -use jrosset\Collections\Collection; -use jrosset\Collections\ICollection; use Stringable; /** @@ -14,14 +12,14 @@ class DirectoryValidator implements IValidator { use TInternalValueValidator; /** - * @var ICollection The options + * @var FilesystemValidationOptionsList The options */ - private ICollection $options; + private FilesystemValidationOptionsList $options; /** * Initialization * - * @param ICollection|int[]|int|null $options The options + * @param FilesystemValidationOptionsList|FilesystemValidationOption[]|FilesystemValidationOption|null $options The options */ public function __construct ($options = null) { $this->setOptions($options); @@ -82,30 +80,30 @@ class DirectoryValidator implements IValidator { /** * The options * - * @return ICollection The options + * @return FilesystemValidationOptionsList The options */ - public function getOptions (): ICollection { + public function getOptions (): FilesystemValidationOptionsList { return $this->options; } /** * Replace the options * - * @param ICollection|int[]|int|null $options The options + * @param FilesystemValidationOptionsList|FilesystemValidationOption[]|FilesystemValidationOption|null $options The options * * @return $this */ public function setOptions ($options = null): self { - if ($options instanceof ICollection) { + if ($options instanceof FilesystemValidationOptionsList) { $this->options = $options; } elseif (is_int($options)) { - $this->options = new Collection([$options]); + $this->options = new FilesystemValidationOptionsList([$options]); } elseif (is_array($options)) { - $this->options = new Collection($options); + $this->options = new FilesystemValidationOptionsList($options); } elseif ($options === null) { - $this->options = new Collection(); + $this->options = new FilesystemValidationOptionsList(); } else { throw new InvalidArgumentException(); diff --git a/src/CliProgram/Validation/Validators/FileValidator.php b/src/CliProgram/Validation/Validators/FileValidator.php index d9dfbd3..6772d1e 100644 --- a/src/CliProgram/Validation/Validators/FileValidator.php +++ b/src/CliProgram/Validation/Validators/FileValidator.php @@ -3,7 +3,6 @@ namespace jrosset\CliProgram\Validation\Validators; use InvalidArgumentException; -use jrosset\Collections\ICollection; /** * An argument/option value validator for a file path @@ -17,8 +16,8 @@ class FileValidator extends DirectoryValidator { /** * Initialization * - * @param string|null $extensionsPattern The allowed extensions (regex pattern) - * @param ICollection|int[]|int|null $options The options + * @param string|null $extensionsPattern The allowed extensions (regex pattern) + * @param FilesystemValidationOptionsList|FilesystemValidationOption[]|FilesystemValidationOption|null $options The options */ public function __construct (?string $extensionsPattern = null, $options = null) { parent::__construct($options); diff --git a/src/CliProgram/Validation/Validators/FilesystemValidationOptionsList.php b/src/CliProgram/Validation/Validators/FilesystemValidationOptionsList.php new file mode 100644 index 0000000..df457f2 --- /dev/null +++ b/src/CliProgram/Validation/Validators/FilesystemValidationOptionsList.php @@ -0,0 +1,19 @@ + + */ +class FilesystemValidationOptionsList extends AbstractCollection { + /** + * @inheritDoc + */ + public function getType (): string { + return 'int'; + } +} \ No newline at end of file diff --git a/src/CliProgram/Validation/Validators/ListValidator.php b/src/CliProgram/Validation/Validators/ListValidator.php index e8a6df7..d0d0dad 100644 --- a/src/CliProgram/Validation/Validators/ListValidator.php +++ b/src/CliProgram/Validation/Validators/ListValidator.php @@ -2,8 +2,7 @@ namespace jrosset\CliProgram\Validation\Validators; -use jrosset\Collections\Collection; -use jrosset\Collections\ICollection; +use Arrayy\Type\StringCollection; /** * An argument/option value validator based on a list of value @@ -17,17 +16,17 @@ class ListValidator implements IValidator { use TInternalValueValidator; /** - * @var ICollection The list of allowed values + * @var StringCollection The list of allowed values */ - private ICollection $allowedValues; + private StringCollection $allowedValues; /** * Create a validator * - * @param ICollection|null $allowedValues The list of allowed values + * @param StringCollection|null $allowedValues The list of allowed values */ - public function __construct (?ICollection $allowedValues = null) { - $this->setAllowedValues($allowedValues ?? new Collection()); + public function __construct (?StringCollection $allowedValues = null) { + $this->setAllowedValues($allowedValues ?? new StringCollection()); } /** @@ -44,19 +43,19 @@ class ListValidator implements IValidator { /** * The list of allowed values * - * @return ICollection The list of allowed values + * @return StringCollection The list of allowed values */ - public function getAllowedValues (): ICollection { + public function getAllowedValues (): StringCollection { return $this->allowedValues; } /** * Set the list of allowed values * - * @param ICollection $allowedValues The list of allowed values + * @param StringCollection $allowedValues The list of allowed values * * @return $this */ - public function setAllowedValues (ICollection $allowedValues): self { + public function setAllowedValues (StringCollection $allowedValues): self { $this->allowedValues = $allowedValues; return $this; }