Skip to content

Commit

Permalink
Drop Psalm
Browse files Browse the repository at this point in the history
As per our decision during the hackathon
  • Loading branch information
greg0ire committed Dec 16, 2024
1 parent 481d498 commit 8d07b63
Show file tree
Hide file tree
Showing 13 changed files with 83 additions and 150 deletions.
1 change: 0 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,3 @@
phpunit.xml.dist export-ignore
/phpcs.xml.dist export-ignore
/phpstan.neon.dist export-ignore
/psalm.xml.dist export-ignore
2 changes: 1 addition & 1 deletion .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ on:
jobs:
static-analysis:
name: "Static Analysis"
uses: "doctrine/.github/.github/workflows/static-analysis.yml@6.0.0"
uses: "doctrine/.github/.github/workflows/phpstan.yml@6.0.0"
with:
php-version: "8.1"
3 changes: 1 addition & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@
"doctrine/coding-standard": "^12",
"phpstan/phpstan": "^1.8",
"phpstan/phpstan-phpunit": "^1.0",
"phpunit/phpunit": "^10.5",
"vimeo/psalm": "^5.11"
"phpunit/phpunit": "^10.5"
},
"autoload": {
"psr-4": {
Expand Down
63 changes: 0 additions & 63 deletions psalm.xml.dist

This file was deleted.

12 changes: 6 additions & 6 deletions src/AbstractLazyCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@
/**
* Lazy collection that is backed by a concrete collection
*
* @psalm-template TKey of array-key
* @psalm-template T
* @phpstan-template TKey of array-key
* @phpstan-template T
* @template-implements Collection<TKey,T>
*/
abstract class AbstractLazyCollection implements Collection
{
/**
* The backed collection to use
*
* @psalm-var Collection<TKey,T>|null
* @phpstan-var Collection<TKey,T>|null
* @var Collection<mixed>|null
*/
protected Collection|null $collection;
Expand Down Expand Up @@ -305,7 +305,7 @@ public function slice(int $offset, int|null $length = null)
* {@inheritDoc}
*
* @return Traversable<int|string, mixed>
* @psalm-return Traversable<TKey,T>
* @phpstan-return Traversable<TKey,T>
*/
#[ReturnTypeWillChange]
public function getIterator()
Expand Down Expand Up @@ -377,7 +377,7 @@ public function offsetUnset(mixed $offset)
*
* @return bool
*
* @psalm-assert-if-true Collection<TKey,T> $this->collection
* @phpstan-assert-if-true Collection<TKey,T> $this->collection
*/
public function isInitialized()
{
Expand All @@ -389,7 +389,7 @@ public function isInitialized()
*
* @return void
*
* @psalm-assert Collection<TKey,T> $this->collection
* @phpstan-assert Collection<TKey,T> $this->collection
*/
protected function initialize()
{
Expand Down
38 changes: 18 additions & 20 deletions src/ArrayCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,26 +40,26 @@
* serialize a collection use {@link toArray()} and reconstruct the collection
* manually.
*
* @psalm-template TKey of array-key
* @psalm-template T
* @phpstan-template TKey of array-key
* @phpstan-template T
* @template-implements Collection<TKey,T>
* @template-implements Selectable<TKey,T>
* @psalm-consistent-constructor
* @phpstan-consistent-constructor
*/
class ArrayCollection implements Collection, Selectable, Stringable
{
/**
* An array containing the entries of this collection.
*
* @psalm-var array<TKey,T>
* @phpstan-var array<TKey,T>
* @var mixed[]
*/
private array $elements = [];

/**
* Initializes a new ArrayCollection.
*
* @psalm-param array<TKey,T> $elements
* @phpstan-param array<TKey,T> $elements
*/
public function __construct(array $elements = [])
{
Expand Down Expand Up @@ -89,13 +89,13 @@ public function first()
* instance should be created when constructor semantics have changed.
*
* @param array $elements Elements.
* @psalm-param array<K,V> $elements
* @phpstan-param array<K,V> $elements
*
* @return static
* @psalm-return static<K,V>
* @phpstan-return static<K,V>
*
* @psalm-template K of array-key
* @psalm-template V
* @phpstan-template K of array-key
* @phpstan-template V
*/
protected function createFrom(array $elements)
{
Expand Down Expand Up @@ -257,10 +257,10 @@ public function exists(Closure $p)
/**
* {@inheritDoc}
*
* @psalm-param TMaybeContained $element
* @phpstan-param TMaybeContained $element
*
* @return int|string|false
* @psalm-return (TMaybeContained is T ? TKey|false : false)
* @phpstan-return (TMaybeContained is T ? TKey|false : false)
*
* @template TMaybeContained
*/
Expand Down Expand Up @@ -315,8 +315,6 @@ public function set(string|int $key, mixed $value)
/**
* {@inheritDoc}
*
* @psalm-suppress InvalidPropertyAssignmentValue
*
* This breaks assumptions about the template type, but it would
* be a backwards-incompatible change to remove this method
*/
Expand All @@ -337,7 +335,7 @@ public function isEmpty()
* {@inheritDoc}
*
* @return Traversable<int|string, mixed>
* @psalm-return Traversable<TKey, T>
* @phpstan-return Traversable<TKey, T>
*/
#[ReturnTypeWillChange]
public function getIterator()
Expand All @@ -348,12 +346,12 @@ public function getIterator()
/**
* {@inheritDoc}
*
* @psalm-param Closure(T):U $func
* @phpstan-param Closure(T):U $func
*
* @return static
* @psalm-return static<TKey, U>
* @phpstan-return static<TKey, U>
*
* @psalm-template U
* @phpstan-template U
*/
public function map(Closure $func)
{
Expand All @@ -371,10 +369,10 @@ public function reduce(Closure $func, $initial = null)
/**
* {@inheritDoc}
*
* @psalm-param Closure(T, TKey):bool $p
* @phpstan-param Closure(T, TKey):bool $p
*
* @return static
* @psalm-return static<TKey,T>
* @phpstan-return static<TKey,T>
*/
public function filter(Closure $p)
{
Expand Down Expand Up @@ -455,7 +453,7 @@ public function slice(int $offset, int|null $length = null)
return array_slice($this->elements, $offset, $length, true);
}

/** @psalm-return Collection<TKey, T>&Selectable<TKey,T> */
/** @phpstan-return Collection<TKey, T>&Selectable<TKey,T> */
public function matching(Criteria $criteria)
{
$expr = $criteria->getWhereExpression();
Expand Down
30 changes: 15 additions & 15 deletions src/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
* position unless you explicitly positioned it before. Prefer iteration with
* external iterators.
*
* @psalm-template TKey of array-key
* @psalm-template T
* @phpstan-template TKey of array-key
* @phpstan-template T
* @template-extends ReadableCollection<TKey, T>
* @template-extends ArrayAccess<TKey, T>
*/
Expand All @@ -35,7 +35,7 @@ interface Collection extends ReadableCollection, ArrayAccess
* Adds an element at the end of the collection.
*
* @param mixed $element The element to add.
* @psalm-param T $element
* @phpstan-param T $element
*
* @return void we will require a native return type declaration in 3.0
*/
Expand All @@ -52,18 +52,18 @@ public function clear();
* Removes the element at the specified index from the collection.
*
* @param string|int $key The key/index of the element to remove.
* @psalm-param TKey $key
* @phpstan-param TKey $key
*
* @return mixed The removed element or NULL, if the collection did not contain the element.
* @psalm-return T|null
* @phpstan-return T|null
*/
public function remove(string|int $key);

/**
* Removes the specified element from the collection, if it is found.
*
* @param mixed $element The element to remove.
* @psalm-param T $element
* @phpstan-param T $element
*
* @return bool TRUE if this collection contained the specified element, FALSE otherwise.
*/
Expand All @@ -74,8 +74,8 @@ public function removeElement(mixed $element);
*
* @param string|int $key The key/index of the element to set.
* @param mixed $value The element to set.
* @psalm-param TKey $key
* @psalm-param T $value
* @phpstan-param TKey $key
* @phpstan-param T $value
*
* @return void
*/
Expand All @@ -84,34 +84,34 @@ public function set(string|int $key, mixed $value);
/**
* {@inheritDoc}
*
* @psalm-param Closure(T):U $func
* @phpstan-param Closure(T):U $func
*
* @return Collection<mixed>
* @psalm-return Collection<TKey, U>
* @phpstan-return Collection<TKey, U>
*
* @psalm-template U
* @phpstan-template U
*/
public function map(Closure $func);

/**
* {@inheritDoc}
*
* @psalm-param Closure(T, TKey):bool $p
* @phpstan-param Closure(T, TKey):bool $p
*
* @return Collection<mixed> A collection with the results of the filter operation.
* @psalm-return Collection<TKey, T>
* @phpstan-return Collection<TKey, T>
*/
public function filter(Closure $p);

/**
* {@inheritDoc}
*
* @psalm-param Closure(TKey, T):bool $p
* @phpstan-param Closure(TKey, T):bool $p
*
* @return Collection<mixed>[] An array with two elements. The first element contains the collection
* of elements where the predicate returned TRUE, the second element
* contains the collection of elements where the predicate returned FALSE.
* @psalm-return array{0: Collection<TKey, T>, 1: Collection<TKey, T>}
* @phpstan-return array{0: Collection<TKey, T>, 1: Collection<TKey, T>}
*/
public function partition(Closure $p);
}
2 changes: 1 addition & 1 deletion src/Criteria.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
/**
* Criteria for filtering Selectable collections.
*
* @psalm-consistent-constructor
* @phpstan-consistent-constructor
*/
class Criteria
{
Expand Down
Loading

0 comments on commit 8d07b63

Please sign in to comment.