Remove ineffective final keyword
This commit is contained in:
parent
ad37644ff0
commit
7b79f60005
|
@ -39,7 +39,7 @@ trait Getter
|
||||||
*
|
*
|
||||||
* @throws \InvalidArgumentException
|
* @throws \InvalidArgumentException
|
||||||
*/
|
*/
|
||||||
final public function __get(string $property): mixed
|
public function __get(string $property): mixed
|
||||||
{
|
{
|
||||||
$method = '_get' . ucfirst($property);
|
$method = '_get' . ucfirst($property);
|
||||||
if (
|
if (
|
||||||
|
@ -59,7 +59,7 @@ trait Getter
|
||||||
*
|
*
|
||||||
* @return bool Whether the class property is set and not empty
|
* @return bool Whether the class property is set and not empty
|
||||||
*/
|
*/
|
||||||
final public function __isset(string $property): bool
|
public function __isset(string $property): bool
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$value = $this->__get($property);
|
$value = $this->__get($property);
|
||||||
|
|
|
@ -74,7 +74,7 @@ trait Queue /* implements \ArrayAccess, \Countable, \SeekableIterator */
|
||||||
*
|
*
|
||||||
* @return bool Whether the variable is an allowed type
|
* @return bool Whether the variable is an allowed type
|
||||||
*/
|
*/
|
||||||
final protected function isAllowedType(mixed $var): bool
|
protected function isAllowedType(mixed $var): bool
|
||||||
{
|
{
|
||||||
if (empty($this->allowedTypes)) {
|
if (empty($this->allowedTypes)) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -100,7 +100,7 @@ trait Queue /* implements \ArrayAccess, \Countable, \SeekableIterator */
|
||||||
*
|
*
|
||||||
* @return bool Whether the given index is in valid range
|
* @return bool Whether the given index is in valid range
|
||||||
*/
|
*/
|
||||||
final protected function isIndexInRange(int $offset, bool $allowAppend = false): bool
|
protected function isIndexInRange(int $offset, bool $allowAppend = false): bool
|
||||||
{
|
{
|
||||||
$options = [
|
$options = [
|
||||||
'options' => [
|
'options' => [
|
||||||
|
@ -119,7 +119,7 @@ trait Queue /* implements \ArrayAccess, \Countable, \SeekableIterator */
|
||||||
*
|
*
|
||||||
* @return bool Whether the given index is valid
|
* @return bool Whether the given index is valid
|
||||||
*/
|
*/
|
||||||
final public function offsetExists(mixed $offset): bool
|
public function offsetExists(mixed $offset): bool
|
||||||
{
|
{
|
||||||
return isset($this->queue[$offset]);
|
return isset($this->queue[$offset]);
|
||||||
}
|
}
|
||||||
|
@ -132,7 +132,7 @@ trait Queue /* implements \ArrayAccess, \Countable, \SeekableIterator */
|
||||||
*
|
*
|
||||||
* @return ?mixed The queue's element at given index or NULL
|
* @return ?mixed The queue's element at given index or NULL
|
||||||
*/
|
*/
|
||||||
final public function offsetGet(mixed $offset): mixed
|
public function offsetGet(mixed $offset): mixed
|
||||||
{
|
{
|
||||||
return $this->queue[$offset] ?? null;
|
return $this->queue[$offset] ?? null;
|
||||||
}
|
}
|
||||||
|
@ -150,7 +150,7 @@ trait Queue /* implements \ArrayAccess, \Countable, \SeekableIterator */
|
||||||
* @throws \InvalidArgumentException
|
* @throws \InvalidArgumentException
|
||||||
* @throws \OutOfRangeException
|
* @throws \OutOfRangeException
|
||||||
*/
|
*/
|
||||||
final public function offsetSet(mixed $offset, mixed $value): void
|
public function offsetSet(mixed $offset, mixed $value): void
|
||||||
{
|
{
|
||||||
if (is_null($offset)) {
|
if (is_null($offset)) {
|
||||||
$offset = count($this->queue);
|
$offset = count($this->queue);
|
||||||
|
@ -171,7 +171,7 @@ trait Queue /* implements \ArrayAccess, \Countable, \SeekableIterator */
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
final public function offsetUnset(mixed $offset): void
|
public function offsetUnset(mixed $offset): void
|
||||||
{
|
{
|
||||||
if ($this->isIndexInRange($offset)) {
|
if ($this->isIndexInRange($offset)) {
|
||||||
array_splice($this->queue, $offset, 1, []);
|
array_splice($this->queue, $offset, 1, []);
|
||||||
|
@ -187,7 +187,7 @@ trait Queue /* implements \ArrayAccess, \Countable, \SeekableIterator */
|
||||||
*
|
*
|
||||||
* @return int The number of items in the queue
|
* @return int The number of items in the queue
|
||||||
*/
|
*/
|
||||||
final public function count(): int
|
public function count(): int
|
||||||
{
|
{
|
||||||
return count($this->queue);
|
return count($this->queue);
|
||||||
}
|
}
|
||||||
|
@ -198,7 +198,7 @@ trait Queue /* implements \ArrayAccess, \Countable, \SeekableIterator */
|
||||||
*
|
*
|
||||||
* @return mixed|null The queue's current element or NULL
|
* @return mixed|null The queue's current element or NULL
|
||||||
*/
|
*/
|
||||||
final public function current(): mixed
|
public function current(): mixed
|
||||||
{
|
{
|
||||||
return $this->queue[$this->index] ?? null;
|
return $this->queue[$this->index] ?? null;
|
||||||
}
|
}
|
||||||
|
@ -209,7 +209,7 @@ trait Queue /* implements \ArrayAccess, \Countable, \SeekableIterator */
|
||||||
*
|
*
|
||||||
* @return int The queue's current index
|
* @return int The queue's current index
|
||||||
*/
|
*/
|
||||||
final public function key(): int
|
public function key(): int
|
||||||
{
|
{
|
||||||
return $this->index;
|
return $this->index;
|
||||||
}
|
}
|
||||||
|
@ -220,7 +220,7 @@ trait Queue /* implements \ArrayAccess, \Countable, \SeekableIterator */
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
final public function next(): void
|
public function next(): void
|
||||||
{
|
{
|
||||||
++$this->index;
|
++$this->index;
|
||||||
}
|
}
|
||||||
|
@ -231,7 +231,7 @@ trait Queue /* implements \ArrayAccess, \Countable, \SeekableIterator */
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
final public function rewind(): void
|
public function rewind(): void
|
||||||
{
|
{
|
||||||
$this->index = 0;
|
$this->index = 0;
|
||||||
}
|
}
|
||||||
|
@ -242,7 +242,7 @@ trait Queue /* implements \ArrayAccess, \Countable, \SeekableIterator */
|
||||||
*
|
*
|
||||||
* @return bool Whether the queue's current index is valid
|
* @return bool Whether the queue's current index is valid
|
||||||
*/
|
*/
|
||||||
final public function valid(): bool
|
public function valid(): bool
|
||||||
{
|
{
|
||||||
return isset($this->queue[$this->index]);
|
return isset($this->queue[$this->index]);
|
||||||
}
|
}
|
||||||
|
@ -257,7 +257,7 @@ trait Queue /* implements \ArrayAccess, \Countable, \SeekableIterator */
|
||||||
*
|
*
|
||||||
* @throws \OutOfBoundsException
|
* @throws \OutOfBoundsException
|
||||||
*/
|
*/
|
||||||
final public function seek(int $offset): void
|
public function seek(int $offset): void
|
||||||
{
|
{
|
||||||
if (!$this->isIndexInRange($offset)) {
|
if (!$this->isIndexInRange($offset)) {
|
||||||
throw new \OutOfBoundsException('Invalid index to seek: ' . $offset);
|
throw new \OutOfBoundsException('Invalid index to seek: ' . $offset);
|
||||||
|
@ -271,7 +271,7 @@ trait Queue /* implements \ArrayAccess, \Countable, \SeekableIterator */
|
||||||
*
|
*
|
||||||
* @return array The list of the queue's allowed element types
|
* @return array The list of the queue's allowed element types
|
||||||
*/
|
*/
|
||||||
final protected function _getAllowedTypes(): array
|
protected function _getAllowedTypes(): array
|
||||||
{
|
{
|
||||||
return $this->allowedTypes;
|
return $this->allowedTypes;
|
||||||
}
|
}
|
||||||
|
@ -282,7 +282,7 @@ trait Queue /* implements \ArrayAccess, \Countable, \SeekableIterator */
|
||||||
*
|
*
|
||||||
* @param string[] $allowedTypes Allowed types of queue's elements
|
* @param string[] $allowedTypes Allowed types of queue's elements
|
||||||
*/
|
*/
|
||||||
final public function __construct(array $allowedTypes = [])
|
public function __construct(array $allowedTypes = [])
|
||||||
{
|
{
|
||||||
$this->allowedTypes = $allowedTypes;
|
$this->allowedTypes = $allowedTypes;
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,7 @@ trait Setter
|
||||||
*
|
*
|
||||||
* @throws \InvalidArgumentException
|
* @throws \InvalidArgumentException
|
||||||
*/
|
*/
|
||||||
final public function __set(string $property, mixed $value): void
|
public function __set(string $property, mixed $value): void
|
||||||
{
|
{
|
||||||
$method = '_set' . ucfirst($property);
|
$method = '_set' . ucfirst($property);
|
||||||
if (
|
if (
|
||||||
|
@ -62,7 +62,7 @@ trait Setter
|
||||||
*
|
*
|
||||||
* @throws \InvalidArgumentException
|
* @throws \InvalidArgumentException
|
||||||
*/
|
*/
|
||||||
final public function __unset(string $property): void
|
public function __unset(string $property): void
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$this->__set($property, null);
|
$this->__set($property, null);
|
||||||
|
|
|
@ -38,7 +38,7 @@ trait Singleton
|
||||||
/**
|
/**
|
||||||
* Get a singleton instance of this class.
|
* Get a singleton instance of this class.
|
||||||
*/
|
*/
|
||||||
final public static function getInstance(): self
|
public static function getInstance(): self
|
||||||
{
|
{
|
||||||
if (!isset(static::$singleton)) {
|
if (!isset(static::$singleton)) {
|
||||||
$reflectionClass = new \ReflectionClass(get_called_class());
|
$reflectionClass = new \ReflectionClass(get_called_class());
|
||||||
|
@ -56,7 +56,7 @@ trait Singleton
|
||||||
/**
|
/**
|
||||||
* This is a singleton class, thus cloning is prohibited.
|
* This is a singleton class, thus cloning is prohibited.
|
||||||
*/
|
*/
|
||||||
final private function __clone(): void
|
private function __clone(): void
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue