Releases: php-strictus/strictus
Releases · php-strictus/strictus
v1.3.0 - Union Types Support
What's Changed
- Union types by @hungthai1401 in #20
Full Changelog: v1.2.0...v1.3.0
Extended Docs
use Strictus\Enums\Type;
$unionTypesVariable = Strictus::union([Type::INT, Type::STRING], 'foo');
echo $unionTypesVariable->value; //foo
echo $unionTypesVariable(); //foo
// Update variable
$unionTypesVariable->value = 100;
echo $unionTypesVariable->value; //100
// Thrown an exception if the value is wrong union types
$unionTypesVariable->value = false; //StrictusTypeException
v1.2.0 - Immutable Variables
Changes
- Added support for creating immutable variables
- Added PHPStan integration
Extended Docs
If you want to create immutable variables, you can use the ->immutable()
method. If you try to assign a new value to an Immutable Variable, an Strictus\Exceptions\ImmutableStrictusException
exception will be thrown:
$immutableScore = Strictus::int(100)->immutable();
$immutableScore(50); //ImmutableStrictusException
$immutableScore->value = 50; //ImmutableStrictusException
v1.1.0 - Added Enum Support
Changes
- Added support for Enums
Extended Docs
//instantiates an enum
$role = Strictus::enum(Role::class, Role::CONTRIBUTOR);
class CalculatorClass
{
//...
}
enum Role
{
case CONTRIBUTOR;
}
You can use the following methods to create Enums:
Type | Nullable | Method |
---|---|---|
Enum Type | No | Strictus::enum($enumType, $value) |
Enum Type | Yes | Strictus::enum($enumType, $value, true) |
Enum Type | Yes | Strictus::nullableEnum($enumType, $value) |
New Contributors
- Thai Nguyen Hung (@hungthai1401) - #12
1.0.0: Merge pull request #8 from WendellAdriel/test-suite-actions
The Initial Release of Strictus