Skip to content

Commit

Permalink
Removed covariance marker from container types, removed redundant doc…
Browse files Browse the repository at this point in the history
…block overrides causing type clashes

Note: we assume laminas/laminas-stdlib#78 will be merged first.
  • Loading branch information
Ocramius committed Dec 3, 2022
1 parent 1a57017 commit 22dceb8
Show file tree
Hide file tree
Showing 11 changed files with 31 additions and 46 deletions.
19 changes: 4 additions & 15 deletions src/AbstractContainer.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
* Additionally, expiries may be absolute TTLs or measured in "hops", which
* are based on how many times the key or container were accessed.
*
* @template-covariant TKey of string
* @template-covariant TValue
* @template TKey of string
* @template TValue
* @template-extends ArrayObject<TKey, TValue>
*/
abstract class AbstractContainer extends ArrayObject
Expand Down Expand Up @@ -462,14 +462,7 @@ public function offsetUnset($key)
unset($storage[$name][$key]);
}

/**
* Exchange the current array with another array or object.
*
* @see ArrayObject::exchangeArray()
*
* @param array|object $input
* @return array Returns the old array
*/
/** @inheritDoc */
public function exchangeArray($input)
{
// handle arrayobject, iterators and the like:
Expand Down Expand Up @@ -605,11 +598,7 @@ public function setExpirationHops($hops, $vars = null)
return $this;
}

/**
* Creates a copy of the specific container name
*
* @return array
*/
/** @inheritDoc */
public function getArrayCopy()
{
$storage = $this->verifyNamespace();
Expand Down
4 changes: 2 additions & 2 deletions src/Container.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
* Additionally, expiries may be absolute TTLs or measured in "hops", which
* are based on how many times the key or container were accessed.
*
* @template-covariant TKey of string
* @template-covariant TValue
* @template TKey of string
* @template TValue
* @template-extends AbstractContainer<TKey, TValue>
*/
class Container extends AbstractContainer
Expand Down
22 changes: 9 additions & 13 deletions src/Storage/AbstractSessionArrayStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
*
* @see ReturnTypeWillChange
*
* @template-covariant TKey of string
* @template-covariant TValue
* @template TKey of array-key
* @template TValue
* @template-implements IteratorAggregate<TKey, TValue>
* @template-implements StorageInterface<TKey, TValue>
*/
Expand Down Expand Up @@ -198,11 +198,7 @@ public function unserialize($session)
return unserialize($session);
}

/**
* Get Iterator
*
* @return ArrayIterator
*/
/** @inheritDoc */
#[ReturnTypeWillChange]
public function getIterator()
{
Expand Down Expand Up @@ -252,7 +248,7 @@ public function isImmutable()
* Lock this storage instance, or a key within it
*
* @param null|int|string $key
* @return ArrayStorage
* @return $this
*/
public function lock($key = null)
{
Expand Down Expand Up @@ -309,7 +305,7 @@ public function isLocked($key = null)
* Unlock an object or key marked as locked
*
* @param null|int|string $key
* @return ArrayStorage
* @return $this
*/
public function unlock($key = null)
{
Expand Down Expand Up @@ -353,7 +349,7 @@ public function unlock($key = null)
* @param string $key
* @param mixed $value
* @param bool $overwriteArray Whether to overwrite or merge array values; by default, merges
* @return ArrayStorage
* @return $this
* @throws Exception\RuntimeException
*/
public function setMetadata($key, $value, $overwriteArray = false)
Expand Down Expand Up @@ -417,7 +413,7 @@ public function getMetadata($key = null)
* Clear the storage object or a subkey of the object
*
* @param null|int|string $key
* @return ArrayStorage
* @return $this
* @throws Exception\RuntimeException
*/
public function clear($key = null)
Expand Down Expand Up @@ -452,7 +448,7 @@ public function getRequestAccessTime()
* Set the request access time
*
* @param float $time
* @return ArrayStorage
* @return $this
*/
protected function setRequestAccessTime($time)
{
Expand All @@ -465,7 +461,7 @@ protected function setRequestAccessTime($time)
* Cast the object to an array
*
* @param bool $metaData Whether to include metadata
* @return array
* @return array<TKey, TValue>
*/
public function toArray($metaData = false)
{
Expand Down
4 changes: 2 additions & 2 deletions src/Storage/ArrayStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
*
* @see ReturnTypeWillChange
*
* @template-covariant TKey of string
* @template-covariant TValue
* @template TKey of array-key
* @template TValue
* @template-extends ArrayObject<TKey, TValue>
* @template-implements StorageInterface<TKey, TValue>
*/
Expand Down
4 changes: 2 additions & 2 deletions src/Storage/SessionArrayStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
/**
* Session storage in $_SESSION'
*
* @template-covariant TKey of array-key
* @template-covariant TValue
* @template TKey of array-key
* @template TValue
* @template-extends AbstractSessionArrayStorage<TKey, TValue>
*/
class SessionArrayStorage extends AbstractSessionArrayStorage
Expand Down
4 changes: 2 additions & 2 deletions src/Storage/SessionStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
* Replaces the $_SESSION superglobal with an ArrayObject that allows for
* property access, metadata storage, locking, and immutability.
*
* @template-covariant TKey
* @template-covariant TValue
* @template TKey of array-key
* @template TValue
* @template-extends ArrayStorage<TKey, TValue>
*/
class SessionStorage extends ArrayStorage
Expand Down
4 changes: 2 additions & 2 deletions src/Storage/StorageInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
* Defines the minimum requirements for handling userland, in-script session
* storage (e.g., the $_SESSION superglobal array).
*
* @template-covariant TKey of array-key
* @template-covariant TValue
* @template TKey of array-key
* @template TValue
* @template-extends Traversable<TKey, TValue>
* @template-extends ArrayAccess<TKey, TValue>
*/
Expand Down
4 changes: 2 additions & 2 deletions src/Validator/AbstractValidatorChainEM3.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ public function __construct(StorageInterface $storage)
* @param int $priority
* @return CallbackHandler
*/
public function attach($eventName, callable $callback, $priority = 1)
public function attach($eventName, callable $listener, $priority = 1)
{
return $this->attachValidator($eventName, $callback, $priority);
return $this->attachValidator($eventName, $listener, $priority);
}
}
4 changes: 2 additions & 2 deletions src/ValidatorChain.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ public function __construct(protected StorageInterface $storage)
* @param int $priority
* @return callable
*/
public function attach($eventName, callable $callback, $priority = 1)
public function attach($eventName, callable $listener, $priority = 1)
{
return $this->attachValidator($eventName, $callback, $priority);
return $this->attachValidator($eventName, $listener, $priority);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions test/TestAsset/Php81CompatibleStorageInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
use Laminas\Session\Storage\StorageInterface;

/**
* @template-covariant TKey of array-key
* @template-covariant TValue
* @template TKey of array-key
* @template TValue
* @template-extends StorageInterface<TKey, TValue>
*/
interface Php81CompatibleStorageInterface extends StorageInterface
Expand Down
4 changes: 2 additions & 2 deletions test/TestAsset/TestContainer.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
use Laminas\Session\AbstractContainer;

/**
* @template-covariant TKey of string
* @template-covariant TValue
* @template TKey of string
* @template TValue
* @template-extends AbstractContainer<TKey, TValue>
*/
class TestContainer extends AbstractContainer
Expand Down

0 comments on commit 22dceb8

Please sign in to comment.