All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
- Fix conversion of
in()
andnotIn()
to native enums when called with non-arrays
- Support Laravel 11
- Allow Allow installation alongside PHPUnit 11
- Check if value is
int
orstring
in conversion ofEnum::hasValue()
to native enum
- Add conversion of
Enum::hasValue()
to native enum
- Make
php artisan enum:to-native
compatible with rector0.19
- Add PHPStan rule to detect duplicate enum values
- Fix conversion of
Enum::fromKey()
to native enum
- Remove leading backslash in class names passed to
php artisan enum:to-native
- Convert single classes in one step with
php artisan enum:to-native
- Disable timeout of rector calls in
php artisan enum:to-native
- Use command
enum:to-native
for simplified one-step conversion of classes that extendBenSampo\Enum\Enum
to native PHP enums
- Add Rector rules for conversion of classes that extend
BenSampo\Enum\Enum
to native PHP enums
- Deprecate command
enum:to-native
in favor of Rector conversion
- Ensure validation rules are always added #327
- Add command
enum:to-native
to convert a class that extendsBenSampo\Enum\Enum
to a native PHP enum
- Load pipe-string syntax validation translations lazily #324
- Allow
mixed
inEnum::hasValue()
- Preserve whitespace in PHPDocs when running
enum:annotate
command
- Mark
Enum::$key
andEnum::$description
as non-nullable inEnum
and document they are unset inFlaggedEnum
6.3.0 - 2023-01-31
- Support Laravel 10 298
6.2.2 - 2023-01-17
- Fix backtrack regexp error and add Windows EOL support to the annotate command 296
6.2.1 - 2023-01-12
- Fix running
php artisan enum:annotate
on long enum class 294
6.2.0 - 2022-12-07
- Open
EnumServiceProvider
for customization 292
6.1.0 - 2022-10-26
- Eliminate unnecessary abstract class
AbstractAnnotationCommand
283
- Provide more accurate type hints in
Enum
andFlaggedEnum
283 - Accept
FlaggedEnum
instances inQueriesFlaggedEnums
scopes 283
6.0.0 - 2022-08-22
- Allow Description attribute usage on class 270
- Add generic type
TValue
toEnum
class
- Require composer/class-map-generator over composer/composer 268
- Use native types whenever possible
- Throw when calling
Enum::getDescription()
with invalid values - Expect class-string in
InvalidEnumMemberException
constructor
- Leverage late static binding for instantiation methods in PHPStan extension
- Remove
Enum::getInstance()
in favor orEnum::fromValue()
5.3.1 - 2022-06-22
- Narrow property type hints 258
5.3.0 - 2022-04-08
- Return value for invalid enum case when using the
Description
attribute 264
- Type-hint
Enum::$key
andEnum::$description
asstring
- Type-hint
FlaggedEnum::$value
asint
5.2.0 - 2022-03-11
- Publish language definitions to
lang
directory 254
- Restore enum instance from
var_export()
252
5.1.0 - 2022-02-09
- Ability to define enum case descriptions using
Description
attribute.
5.0.0 - 2022-02-09
- Support for Laravel 9
- The
annotate
command now uses composer to parse directories for instances of enums instead ofhanneskod/classtools
- Removed old
CastsEnums
trait. Laravel attribute casting should be used now instead. 247
4.2.0 - 2022-01-31
4.1.0 - 2021-11-16
- Allow package to be installed with PHP 8.1 #233
- Allow
laminas/laminas-code:^4.0
as a dependency #233
4.0.0 - 2021-11-09
- Fixed validation error message localization when using string validation rules #227
- Extend the functionality of the
getKeys()
andgetValues()
methods #223
- Added new method
notIn()
to check whether a value is not in an iterable set of values #232
3.4.2 - 2021-09-09
- Fixed broken enums due to wrapping of long constant names in method annotations #226
3.4.1 - 2021-06-17
- Fixed type issued in PHP 7.3
3.4.0 - 2021-06-17
addAllFlags()
method to flagged enumsremoveAllFlags()
method to flagged enums
- Fixed coercion of flagged enums when the value represents multiple flags
3.3.0 - 2021-02-16
- Update doctrine/dbal requirement from ^2.9 to ^2.9|^3.0 #208
- Allow passing iterables to Enum::in() #212
- fix:
$model->getChanges()
triggered due to strict comparison #187 - Fixed issue in
getFriendlyKeyName
when uppercase key contains non-alpha characters #210
3.2.0 - 2020-12-15
- PHP 8.0 support #203
- Switched from Travis to GitHub Actions
3.1.0 - 2020-10-22
- Improved test equality strictness #185
- fix:
toSelectArray
breaking change + documenttoArray
change #184
3.0.0 - 2020-08-07
- Support for Laravel 8
- Model annotation has been removed in favour of
laravel-ide-helper
#165
2.2.0 - 2020-08-30
- Model attributes which use Laravel 7 native casting now return the enum value when serialized. #162 #163
Enum::toArray()
should no longer be called statically, instead useEnum::asArray()
.
2.1.0 - 2020-07-24
- Allow returning
null
when using native casting #152
2.0.0 - 2020-07-02
- Native attribute casting #131
- Require Laravel 7.5 or higher
- Require PHP 7.2.5 or higher
- Deprecate legacy attribute casting in favor of native casting
1.38.0 - 2020-06-07
- Handle calling magic instantiation methods from within instance methods of the Enum #147
- Add new instantiation methods
Enum::fromKey()
andEnum::fromValue()
#142 - Fixed issue with localized validation messages #141
- Deprecate
Enum::getInstance()
in favor ofEnum::fromValue()
1.37.0 - 2020-04-11
- EnumValue validation rule allows multiple flags for FlaggedEnums
1.36.0 - 2020-03-22
- Validation messages are now pulled from translation files #134
1.35.0 - 2020-03-16
- Added missing pipe validation syntax for enum instance validation #132
1.34.0 - 2020-03-13
- Change order of attributes in
BenSampo\Enum\Enum
, to ensure relational comparison (with <,>) uses the $value attribute. (Ref: https://www.php.net/manual/en/language.oop5.object-comparison.php#98725) #129 - Fix for Lumen when Facade not set #123
1.33.0 - 2020-03-05
- Add Laravel 7.x compatibility
1.32.0 - 2020-02-11
- Add tests and make
EnumMethodReflection
return generating constant values forisInternal
,isDeprecated
, andgetDeprecatedDescription
#121
1.31.0 - 2020-02-09
- Add compatibility with PHPStan
0.12.x
#119 - Changelog started.