Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
}
},
"require": {
"php": ">=7.2",
"php": ">=8.2",
"ext-openssl": "*",
"evenement/evenement": "^3.0.1"
}
Expand Down
8 changes: 4 additions & 4 deletions src/BaseFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

trait BaseFilter
{
/** @var Rule Base filter */
private $baseFilter;
/** @var ?Rule Base filter */
private ?Rule $baseFilter = null;

/**
* Get whether a base filter has been set
Expand All @@ -24,7 +24,7 @@ public function hasBaseFilter(): bool
*
* @return ?Rule
*/
public function getBaseFilter()
public function getBaseFilter(): ?Rule
{
return $this->baseFilter;
}
Expand All @@ -36,7 +36,7 @@ public function getBaseFilter()
*
* @return $this
*/
public function setBaseFilter(?Rule $baseFilter = null): self
public function setBaseFilter(?Rule $baseFilter = null): static
{
$this->baseFilter = $baseFilter;

Expand Down
10 changes: 5 additions & 5 deletions src/Contract/Filterable.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ interface Filterable
*
* @return Filter\Chain
*/
public function getFilter();
public function getFilter(): Filter\Chain;

/**
* Add a filter to the query
Expand All @@ -23,7 +23,7 @@ public function getFilter();
*
* @return $this
*/
public function filter(Filter\Rule $filter);
public function filter(Filter\Rule $filter): static;

/**
* Add a filter to the query
Expand All @@ -35,7 +35,7 @@ public function filter(Filter\Rule $filter);
*
* @return $this
*/
public function orFilter(Filter\Rule $filter);
public function orFilter(Filter\Rule $filter): static;

/**
* Add a filter to the query
Expand All @@ -47,7 +47,7 @@ public function orFilter(Filter\Rule $filter);
*
* @return $this
*/
public function notFilter(Filter\Rule $filter);
public function notFilter(Filter\Rule $filter): static;

/**
* Add a filter to the query
Expand All @@ -59,5 +59,5 @@ public function notFilter(Filter\Rule $filter);
*
* @return $this
*/
public function orNotFilter(Filter\Rule $filter);
public function orNotFilter(Filter\Rule $filter): static;
}
24 changes: 12 additions & 12 deletions src/Contract/Paginatable.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,46 +11,46 @@ interface Paginatable extends Countable
*
* @return bool
*/
public function hasLimit();
public function hasLimit(): bool;

/**
* Get the limit
*
* @return int|null
* @return ?int
*/
public function getLimit();
public function getLimit(): ?int;

/**
* Set the limit
*
* @param int|null $limit Maximum number of items to return. If you want to disable the limit,
* it is best practice to use null or a negative value
* @param ?int $limit Maximum number of items to return. If you want to disable the limit,
* it is best practice to use null or a negative value
*
* @return $this
*/
public function limit($limit);
public function limit(?int $limit): static;

/**
* Get whether an offset is set
*
* @return bool
*/
public function hasOffset();
public function hasOffset(): bool;

/**
* Get the offset
*
* @return int|null
* @return ?int
*/
public function getOffset();
public function getOffset(): ?int;

/**
* Set the offset
*
* @param int|null $offset Start result set after this many rows. If you want to disable the offset,
* it is best practice to use null or a negative value
* @param ?int $offset Start result set after this many rows. If you want to disable the offset,
* it is best practice to use null or a negative value
*
* @return $this
*/
public function offset($offset);
public function offset(?int $offset): static;
}
2 changes: 1 addition & 1 deletion src/Contract/PluginLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ interface PluginLoader
*
* @return string|false FQN of the plugin's class if found, false otherwise
*/
public function load($name);
public function load(string $name): string|false;
}
30 changes: 18 additions & 12 deletions src/Contract/Translator.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ interface Translator
* Translate a message
*
* @param string $message
* @param string $context Message context
* @param ?string $context Message context
*
* @return string Translated message or original message if no translation is found
*/
public function translate($message, $context = null);
public function translate(string $message, ?string $context = null): string;

/**
* Translate a message in the given domain
Expand All @@ -24,11 +24,11 @@ public function translate($message, $context = null);
*
* @param string $domain
* @param string $message
* @param string $context Message context
* @param ?string $context Message context
*
* @return string Translated message or original message if no translation is found
*/
public function translateInDomain($domain, $message, $context = null);
public function translateInDomain(string $domain, string $message, ?string $context = null): string;

/**
* Translate a plural message
Expand All @@ -37,13 +37,13 @@ public function translateInDomain($domain, $message, $context = null);
* That is also the case if no translation is found.
*
* @param string $singular Singular message
* @param string $plural Plural message
* @param int $number Number to decide between the returned singular and plural forms
* @param string $context Message context
* @param string $plural Plural message
* @param int $number Number to decide between the returned singular and plural forms
* @param ?string $context Message context
*
* @return string Translated message or original message if no translation is found
*/
public function translatePlural($singular, $plural, $number, $context = null);
public function translatePlural(string $singular, string $plural, int $number, ?string $context = null): string;

/**
* Translate a plural message in the given domain
Expand All @@ -55,11 +55,17 @@ public function translatePlural($singular, $plural, $number, $context = null);
*
* @param string $domain
* @param string $singular Singular message
* @param string $plural Plural message
* @param int $number Number to decide between the returned singular and plural forms
* @param string $context Message context
* @param string $plural Plural message
* @param int $number Number to decide between the returned singular and plural forms
* @param ?string $context Message context
*
* @return string Translated message or original message if no translation is found
*/
public function translatePluralInDomain($domain, $singular, $plural, $number, $context = null);
public function translatePluralInDomain(
string $domain,
string $singular,
string $plural,
int $number,
?string $context = null
): string;
}
14 changes: 7 additions & 7 deletions src/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
class Data
{
/** @var array<string, mixed> */
protected $data = [];
protected array $data = [];

/**
* Check whether there's any data
*
* @return bool
*/
public function isEmpty()
public function isEmpty(): bool
{
return empty($this->data);
}
Expand All @@ -24,7 +24,7 @@ public function isEmpty()
*
* @return bool
*/
public function has($name)
public function has(string $name): bool
{
return array_key_exists($name, $this->data);
}
Expand All @@ -37,7 +37,7 @@ public function has($name)
*
* @return mixed
*/
public function get($name, $default = null)
public function get(string $name, mixed $default = null): mixed
{
if ($this->has($name)) {
return $this->data[$name];
Expand All @@ -54,7 +54,7 @@ public function get($name, $default = null)
*
* @return $this
*/
public function set($name, $value)
public function set(string $name, mixed $value): static
{
$this->data[$name] = $value;

Expand All @@ -68,7 +68,7 @@ public function set($name, $value)
*
* @return $this
*/
public function merge(self $with)
public function merge(self $with): static
{
$this->data = array_merge($this->data, $with->data);

Expand All @@ -80,7 +80,7 @@ public function merge(self $with)
*
* @return $this
*/
public function clear()
public function clear(): static
{
$this->data = [];

Expand Down
8 changes: 4 additions & 4 deletions src/Events.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ trait Events
}

/** @var array */
protected $eventsEmittedOnce = [];
protected array $eventsEmittedOnce = [];

/**
* @param string $event
* @param array $arguments
*/
protected function emitOnce($event, array $arguments = [])
protected function emitOnce(string $event, array $arguments = []): void
{
if (! isset($this->eventsEmittedOnce[$event])) {
$this->eventsEmittedOnce[$event] = true;
Expand All @@ -31,15 +31,15 @@ protected function emitOnce($event, array $arguments = [])
* @param callable $listener
* @return $this
*/
public function on($event, callable $listener)
public function on($event, callable $listener): static
{
$this->assertValidEvent($event);
$this->evenementUnvalidatedOn($event, $listener);

return $this;
}

protected function assertValidEvent($event)
protected function assertValidEvent(string $event): void
{
if (! $this->isValidEvent($event)) {
throw new InvalidArgumentException("$event is not a valid event");
Expand Down
Loading
Loading