-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Switch annotations for controls/validations to php8 attribute
- Loading branch information
Showing
18 changed files
with
239 additions
and
233 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php declare (strict_types = 1); | ||
|
||
namespace Wedo\Api\Attributes; | ||
|
||
use Attribute; | ||
|
||
#[Attribute] | ||
class ChoiceControlItems | ||
{ | ||
|
||
/** @var mixed[] */ | ||
public array $items; | ||
|
||
public bool $useKeys; | ||
|
||
/** | ||
* @param mixed[] $items | ||
*/ | ||
public function __construct(array $items, bool $useKeys = false) | ||
{ | ||
$this->items = $items; | ||
$this->useKeys = $useKeys; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php declare (strict_types = 1); | ||
|
||
namespace Wedo\Api\Attributes; | ||
|
||
use Attribute; | ||
|
||
#[Attribute] | ||
class ContainerType | ||
{ | ||
|
||
/** @var class-string */ | ||
public string $value; | ||
|
||
/** | ||
* @param class-string $value | ||
*/ | ||
public function __construct(string $value) | ||
{ | ||
$this->value = $value; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php declare (strict_types = 1); | ||
|
||
namespace Wedo\Api\Attributes; | ||
|
||
use Attribute; | ||
|
||
#[Attribute] | ||
class Control | ||
{ | ||
|
||
public const TEXT = 'Text'; | ||
public const PASSWORD = 'Password'; | ||
public const TEXT_AREA = 'TextArea'; | ||
public const EMAIL = 'Email'; | ||
public const INTEGER = 'Integer'; | ||
public const UPLOAD = 'Upload'; | ||
public const MULTI_UPLOAD = 'MultiUpload'; | ||
public const HIDDEN = 'Hidden'; | ||
public const CHECKBOX = 'Checkbox'; | ||
public const RADIO_LIST = 'RadioList'; | ||
public const CHECKBOX_LIST = 'CheckboxList'; | ||
public const SELECT = 'Select'; | ||
public const MULTI_SELECT = 'MultiSelect'; | ||
public const IMAGE = 'Image'; | ||
public const CONTAINER = 'Container'; | ||
|
||
public string $value; | ||
|
||
public function __construct(string $value) | ||
{ | ||
$this->value = $value; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php declare (strict_types = 1); | ||
|
||
namespace Wedo\Api\Attributes; | ||
|
||
use Attribute; | ||
|
||
#[Attribute] | ||
class RequiredRule | ||
{ | ||
|
||
public bool $required; | ||
|
||
public function __construct(bool $required = true) | ||
{ | ||
$this->required = $required; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php declare (strict_types = 1); | ||
|
||
namespace Wedo\Api\Attributes; | ||
|
||
use Attribute; | ||
|
||
#[Attribute(Attribute::IS_REPEATABLE | Attribute::TARGET_PROPERTY)] | ||
class ValidationRule | ||
{ | ||
|
||
/** @var callable|string */ | ||
public $validator; | ||
|
||
public string|object|null $errorMessage; | ||
|
||
public mixed $args; | ||
|
||
public function __construct(callable|string $validator, string|object|null $errorMessage = null, mixed $args = null) | ||
{ | ||
$this->validator = $validator; | ||
$this->errorMessage = $errorMessage; | ||
$this->args = $args; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.