Skip to content

Commit

Permalink
Add configuration helper classes, (#12)
Browse files Browse the repository at this point in the history
* Add configuration helper classes, update compiler pass and rework some small bits

* Fix CS

* Fix test failure
  • Loading branch information
pkly authored Feb 3, 2023
1 parent bd34865 commit 634e9c4
Show file tree
Hide file tree
Showing 6 changed files with 318 additions and 84 deletions.
2 changes: 1 addition & 1 deletion src/Attributes/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ abstract class Event
*
* @var non-empty-list<class-string>|null
*/
public array|null $entity = null;
public readonly array|null $entity;

/**
* @see Events
Expand Down
18 changes: 9 additions & 9 deletions src/Attributes/SubEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ class SubEvent
* If this annotation is placed on an event class called "FooBarEvent" and the label is "StatusChanged" then
* the final short name of the class will be "FooBarStatusChangedEvent"
*/
public string $label;
public readonly string $label;

/**
* @var non-empty-list<class-string>|null
*/
public array|null $entity;
public readonly array|null $entity;

/**
* List of fields to be used for searching for changes.
Expand Down Expand Up @@ -53,15 +53,15 @@ class SubEvent
* @var string|array<array-key, string|array{0: mixed, 1?: mixed}|null>
* @deprecated use {@link SubEvent::$changes} instead
*/
public string|array $fields;
public readonly string|array $fields;

/**
* If all fields are required to fire event
*
* <span style="color: yellow">WARNING:</span> This setting is ignored if {@link SubEvent::$types} does not include either of {@link Events::postUpdate} or {@link Events::preUpdate}
* or if the current event type is not one of the ones specified above!
*/
public bool $allMode = true;
public readonly bool $allMode;

/**
* Additional requirements for the object to have for the event to pass.
Expand All @@ -70,9 +70,9 @@ class SubEvent
*
* <span style="color: yellow">WARNING:</span> Either this field or {@link SubEvent::$fields} is required!
*
* @var array<mixed, mixed>
* @var array<string, mixed>
*/
public array $requirements = [];
public readonly array $requirements;

/**
* Types of event that will cause this event to run, before even running the other checks.
Expand All @@ -81,21 +81,21 @@ class SubEvent
*
* @see Events
*/
public array $types = [];
public readonly array $types;

/**
* This event's priority, if higher the faster it will fire.
*
* Suggested values between 2048 and -2048
*/
public int $priority = 0;
public readonly int $priority;

/**
* @param string $label
* @param string|array<array-key, string|array{0: mixed, 1?: mixed}|null> $fields
* @param non-empty-list<class-string>|null $entity
* @param bool $allMode
* @param array<mixed, mixed> $requirements
* @param array<string, mixed> $requirements
* @param list<string> $types
* @param int $priority
* @param list<Change> $changes list of field changes
Expand Down
Loading

0 comments on commit 634e9c4

Please sign in to comment.