Skip to content

Commit

Permalink
Add template for phpstan
Browse files Browse the repository at this point in the history
  • Loading branch information
Dmytro Dymarchuk committed Apr 7, 2022
1 parent 8137e3a commit 9bd9611
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 24 deletions.
5 changes: 2 additions & 3 deletions src/Propel/Runtime/Collection/ArrayCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,12 @@
*
* @author Francois Zaninotto
*
* @phpstan-template TType of \Propel\Runtime\ActiveRecord\ActiveRecordInterface
* @phpstan-extends \Propel\Runtime\Collection\Collection<TType, array>
* @phpstan-extends \Propel\Runtime\Collection\Collection<array>
*/
class ArrayCollection extends Collection
{
/**
* @phpstan-var TType
* @phpstan-var \Propel\Runtime\ActiveRecord\ActiveRecordInterface
*
* @var \Propel\Runtime\ActiveRecord\ActiveRecordInterface
*/
Expand Down
19 changes: 9 additions & 10 deletions src/Propel/Runtime/Collection/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,14 @@
*
* @author Francois Zaninotto
*
* @phpstan-template TType of \Propel\Runtime\ActiveRecord\ActiveRecordInterface
* @phpstan-template T
* @phpstan-implements \ArrayAccess<string|int, T>
* @phpstan-implements \IteratorAggregate<T>
*/
class Collection implements ArrayAccess, IteratorAggregate, Countable, Serializable
{
/**
* @phpstan-var class-string<TType>
* @phpstan-var class-string<\Propel\Runtime\ActiveRecord\ActiveRecordInterface>
*
* @var string|null
*/
Expand All @@ -59,14 +58,14 @@ class Collection implements ArrayAccess, IteratorAggregate, Countable, Serializa
/**
* The fully qualified classname of the model
*
* @phpstan-var class-string<TType>
* @phpstan-var class-string<\Propel\Runtime\ActiveRecord\ActiveRecordInterface>
*
* @var string|null
*/
protected $fullyQualifiedModel;

/**
* @phpstan-var \Propel\Runtime\Formatter\AbstractFormatter<TType, \Propel\Runtime\Collection\Collection, T>
* @phpstan-var \Propel\Runtime\Formatter\AbstractFormatter<\Propel\Runtime\ActiveRecord\ActiveRecordInterface, \Propel\Runtime\Collection\Collection, T>
*
* @var \Propel\Runtime\Formatter\AbstractFormatter
*/
Expand Down Expand Up @@ -453,7 +452,7 @@ public function search($element)
* Returns an array of objects present in the collection that
* are not presents in the given collection.
*
* @phpstan-param \Propel\Runtime\Collection\Collection<TType, T> $collection
* @phpstan-param \Propel\Runtime\Collection\Collection<T> $collection
*
* @phpstan-return self
*
Expand Down Expand Up @@ -511,7 +510,7 @@ public function unserialize($data): void
/**
* Set the model of the elements in the collection
*
* @phpstan-param class-string<TType> $model
* @phpstan-param class-string<\Propel\Runtime\ActiveRecord\ActiveRecordInterface> $model
*
* @param string $model Name of the Propel object classes stored in the collection
*
Expand All @@ -531,7 +530,7 @@ public function setModel(string $model): void
/**
* Get the model of the elements in the collection
*
* @phpstan-return class-string<TType>
* @phpstan-return class-string<\Propel\Runtime\ActiveRecord\ActiveRecordInterface>
*
* @return string Name of the Propel object class stored in the collection
*/
Expand All @@ -543,7 +542,7 @@ public function getModel(): string
/**
* Get the model of the elements in the collection
*
* @phpstan-return class-string<TType>
* @phpstan-return class-string<\Propel\Runtime\ActiveRecord\ActiveRecordInterface>
*
* @return string Fully qualified Name of the Propel object class stored in the collection
*/
Expand Down Expand Up @@ -571,7 +570,7 @@ public function getTableMapClass(): string
}

/**
* @phpstan-param \Propel\Runtime\Formatter\AbstractFormatter<TType, self, T> $formatter
* @phpstan-param \Propel\Runtime\Formatter\AbstractFormatter<\Propel\Runtime\ActiveRecord\ActiveRecordInterface, self, T> $formatter
*
* @param \Propel\Runtime\Formatter\AbstractFormatter $formatter
*
Expand All @@ -583,7 +582,7 @@ public function setFormatter(AbstractFormatter $formatter): void
}

/**
* @phpstan-return \Propel\Runtime\Formatter\AbstractFormatter<TType, \Propel\Runtime\Collection\Collection, T>
* @phpstan-return \Propel\Runtime\Formatter\AbstractFormatter<\Propel\Runtime\ActiveRecord\ActiveRecordInterface, \Propel\Runtime\Collection\Collection, T>
*
* @return \Propel\Runtime\Formatter\AbstractFormatter
*/
Expand Down
11 changes: 5 additions & 6 deletions src/Propel/Runtime/Collection/ObjectCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@
*
* @author Francois Zaninotto
*
* @phpstan-template TType of \Propel\Runtime\ActiveRecord\ActiveRecordInterface
* @phpstan-template T
* @phpstan-extends \Propel\Runtime\Collection\Collection<TType, T>
* @phpstan-extends \Propel\Runtime\Collection\Collection<T>
*/
class ObjectCollection extends Collection
{
Expand All @@ -40,7 +39,7 @@ class ObjectCollection extends Collection
protected $indexSplHash = [];

/**
* @param array<TType> $data
* @param array<\Propel\Runtime\ActiveRecord\ActiveRecordInterface> $data
*/
public function __construct(array $data = [])
{
Expand Down Expand Up @@ -461,7 +460,7 @@ public function offsetUnset($offset): void
}

/**
* @phpstan-param TType $element
* @phpstan-param \Propel\Runtime\ActiveRecord\ActiveRecordInterface $element
*
* @param mixed $element
*
Expand All @@ -475,7 +474,7 @@ public function removeObject($element): void
}

/**
* @phpstan-param TType $value
* @phpstan-param \Propel\Runtime\ActiveRecord\ActiveRecordInterface $value
*
* @param mixed $value
*
Expand All @@ -499,7 +498,7 @@ public function append($value): void
}

/**
* @phpstan-param TType $value
* @phpstan-param \Propel\Runtime\ActiveRecord\ActiveRecordInterface $value
*
* @param mixed $offset
* @param mixed $value
Expand Down
3 changes: 3 additions & 0 deletions src/Propel/Runtime/Collection/ObjectCombinationCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
* Class for iterating over a list of Propel objects
*
* @author Francois Zaninotto
*
* @phpstan-template T array<\Propel\Runtime\ActiveRecord\ActiveRecordInterface>
* @phpstan-extends \Propel\Runtime\Collection\ObjectCollection<T>
*/
class ObjectCombinationCollection extends ObjectCollection
{
Expand Down
5 changes: 2 additions & 3 deletions src/Propel/Runtime/Collection/OnDemandCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@
*
* @author Francois Zaninotto
*
* @phpstan-template TType of \Propel\Runtime\ActiveRecord\ActiveRecordInterface
* @phpstan-template T of \Propel\Runtime\ActiveRecord\ActiveRecordInterface
* @phpstan-extends \Propel\Runtime\Collection\Collection<TType, T>
* @phpstan-extends \Propel\Runtime\Collection\Collection<T>
*/
class OnDemandCollection extends Collection
{
Expand All @@ -34,7 +33,7 @@ class OnDemandCollection extends Collection
private $lastIterator;

/**
* @phpstan-param \Propel\Runtime\Formatter\OnDemandFormatter<TType, \Propel\Runtime\Collection\OnDemandCollection, T> $formatter
* @phpstan-param \Propel\Runtime\Formatter\OnDemandFormatter<\Propel\Runtime\ActiveRecord\ActiveRecordInterface, \Propel\Runtime\Collection\OnDemandCollection, T> $formatter
*
* @param \Propel\Runtime\Formatter\ObjectFormatter $formatter
* @param \Propel\Runtime\DataFetcher\DataFetcherInterface $dataFetcher
Expand Down
4 changes: 2 additions & 2 deletions src/Propel/Runtime/Formatter/OnDemandFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function init(?BaseModelCriteria $criteria = null, ?DataFetcherInterface
}

/**
* @phpstan-return TColl<T, TReturn>
* @phpstan-return TColl<TReturn>
*
* @param \Propel\Runtime\DataFetcher\DataFetcherInterface|null $dataFetcher
*
Expand Down Expand Up @@ -92,7 +92,7 @@ public function getCollectionClassName(): string
}

/**
* @phpstan-return \Propel\Runtime\Collection\OnDemandCollection<T, TReturn>
* @phpstan-return \Propel\Runtime\Collection\OnDemandCollection<TReturn>
*
* @return \Propel\Runtime\Collection\OnDemandCollection
*/
Expand Down

0 comments on commit 9bd9611

Please sign in to comment.