diff --git a/bin/cs b/bin/cs index e8757cc..9531563 100755 --- a/bin/cs +++ b/bin/cs @@ -6,7 +6,7 @@ declare(strict_types = 1); passthru( escapeshellarg(__DIR__ . '/../vendor/bin/phpcs') . ' ' . escapeshellarg('--standard=' . __DIR__ . '/../tools/cs/ruleset.xml') - . ' --parallel=1 --extensions=php,phpt --encoding=utf-8 --tab-width=4 --colors -sp' + . ' --parallel=1 --extensions=php,phpt --encoding=utf-8 --tab-width=4 --colors -sp --runtime-set php_version 080100' . ' ' . __DIR__ . '/../src' . ' ' diff --git a/src/CountryCode.php b/src/CountryCode.php index 6e9dffe..6dfefcd 100644 --- a/src/CountryCode.php +++ b/src/CountryCode.php @@ -10,6 +10,7 @@ * ISO-3166-1 Alpha 2 country code enum * * @see https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2 + * @extends \SmartEmailing\Types\Enum */ final class CountryCode extends Enum implements ToStringInterface { diff --git a/src/CurrencyCode.php b/src/CurrencyCode.php index 77170f2..59cfd67 100644 --- a/src/CurrencyCode.php +++ b/src/CurrencyCode.php @@ -8,6 +8,8 @@ /** * ISO-4217 three-letter ("Alpha-3") + * + * @extends \SmartEmailing\Types\Enum */ final class CurrencyCode extends Enum implements ToStringInterface { diff --git a/src/Enum.php b/src/Enum.php index 75ceec2..892e088 100644 --- a/src/Enum.php +++ b/src/Enum.php @@ -8,11 +8,14 @@ use ReflectionClass; use ReflectionClassConstant; +/** + * @template T + */ abstract class Enum { /** - * @var mixed + * @var T */ private $value; @@ -22,7 +25,7 @@ abstract class Enum private static array $instances = []; /** - * @var array + * @var array> */ private static array $availableValues = []; @@ -52,11 +55,17 @@ final public static function get( return self::$instances[$index]; } - public function getValue(): mixed + /** + * @return T + */ + public function getValue() { return $this->value; } + /** + * @param self $that + */ public function equals( self $that ): bool @@ -93,7 +102,7 @@ public static function checkValue( } /** - * @return array + * @return array */ public static function getAvailableValues(): array { @@ -130,6 +139,9 @@ public static function isValidValue( return \in_array($value, self::getAvailableValues(), true); } + /** + * @param self $that + */ protected function checkSameEnum( self $that ): void @@ -140,7 +152,7 @@ protected function checkSameEnum( } /** - * @param array $availableValues + * @param array $availableValues */ protected static function checkAvailableValues( array $availableValues @@ -218,7 +230,7 @@ private static function getValueIndex( } /** - * @return array + * @return array */ private static function getEnumConstants(): array { diff --git a/src/FieldOfApplication.php b/src/FieldOfApplication.php index 849687e..4c77b7f 100644 --- a/src/FieldOfApplication.php +++ b/src/FieldOfApplication.php @@ -6,6 +6,9 @@ use SmartEmailing\Types\ExtractableTraits\EnumExtractableTrait; +/** + * @extends \SmartEmailing\Types\Enum + */ final class FieldOfApplication extends Enum { diff --git a/src/Guid.php b/src/Guid.php index fdbf0aa..640e989 100644 --- a/src/Guid.php +++ b/src/Guid.php @@ -39,7 +39,7 @@ public static function fromHex32( return self::from( \sprintf( '%s%s-%s-%s-%s-%s%s%s', - ...$parts + ...$parts // phpcs:disable SlevomatCodingStandard.PHP.OptimizedFunctionsWithoutUnpacking.UnpackingUsed ) ); } diff --git a/src/HttpMethod.php b/src/HttpMethod.php index 4802787..47f8133 100644 --- a/src/HttpMethod.php +++ b/src/HttpMethod.php @@ -4,16 +4,16 @@ namespace SmartEmailing\Types; -use SmartEmailing\Types\Comparable\ComparableInterface; -use SmartEmailing\Types\Comparable\StringComparableTrait; use SmartEmailing\Types\ExtractableTraits\EnumExtractableTrait; -final class HttpMethod extends Enum implements ToStringInterface, ComparableInterface +/** + * @extends \SmartEmailing\Types\Enum + */ +final class HttpMethod extends Enum implements ToStringInterface { use EnumExtractableTrait; use ToStringTrait; - use StringComparableTrait; public const GET = 'GET'; diff --git a/src/LawfulBasisForProcessing.php b/src/LawfulBasisForProcessing.php index 34337b7..22f416a 100644 --- a/src/LawfulBasisForProcessing.php +++ b/src/LawfulBasisForProcessing.php @@ -11,6 +11,7 @@ * * @package SmartEmailing\Types * @see https://ico.org.uk/for-organisations/guide-to-the-general-data-protection-regulation-gdpr/lawful-basis-for-processing/ + * @extends \SmartEmailing\Types\Enum */ final class LawfulBasisForProcessing extends Enum { diff --git a/src/Relation.php b/src/Relation.php index bf9396d..199c687 100644 --- a/src/Relation.php +++ b/src/Relation.php @@ -6,6 +6,9 @@ use SmartEmailing\Types\ExtractableTraits\EnumExtractableTrait; +/** + * @extends \SmartEmailing\Types\Enum + */ final class Relation extends Enum { diff --git a/src/TimeUnit.php b/src/TimeUnit.php index f1e732f..927be3c 100644 --- a/src/TimeUnit.php +++ b/src/TimeUnit.php @@ -6,6 +6,9 @@ use SmartEmailing\Types\ExtractableTraits\EnumExtractableTrait; +/** + * @extends \SmartEmailing\Types\Enum + */ final class TimeUnit extends Enum implements ToStringInterface { diff --git a/tests/EnumTest.phpt b/tests/EnumTest.phpt index 3894921..4a30583 100644 --- a/tests/EnumTest.phpt +++ b/tests/EnumTest.phpt @@ -10,6 +10,9 @@ use Tester\TestCase; require __DIR__ . '/bootstrap.php'; +/** + * @extends \SmartEmailing\Types\Enum + */ final class SimpleEnum extends Enum {