Skip to content

Releases: php-strictus/strictus

v1.3.0 - Union Types Support

23 Jun 13:21
Compare
Choose a tag to compare

What's Changed

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

13 Jun 09:25
9304fd0
Compare
Choose a tag to compare

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

12 Jun 09:20
52fa9b5
Compare
Choose a tag to compare

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

1.0.0: Merge pull request #8 from WendellAdriel/test-suite-actions

05 Feb 20:26
7092aed
Compare
Choose a tag to compare