diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index c3e6558878..432374f52c 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -290,11 +290,6 @@ parameters: count: 1 path: src/Propel/Generator/Model/ForeignKey.php - - - message: "#^Strict comparison using \\=\\=\\= between int\\<1, max\\> and 0 will always evaluate to false\\.$#" - count: 1 - path: src/Propel/Generator/Model/MappingModel.php - - message: "#^If condition is always true\\.$#" count: 1 @@ -411,7 +406,7 @@ parameters: path: src/Propel/Generator/Util/QuickBuilder.php - - message: "#^Access to an undefined property Propel\\\\Runtime\\\\ActiveQuery\\\\BaseModelCriteria\\:\\:\\$useAliasInSQL\\.$#" + message: "#^Access to an undefined property Propel\\\\Runtime\\\\ActiveQuery\\\\BaseModelCriteria\\\\:\\:\\$useAliasInSQL\\.$#" count: 1 path: src/Propel/Runtime/ActiveQuery/BaseModelCriteria.php @@ -421,7 +416,7 @@ parameters: path: src/Propel/Runtime/ActiveQuery/BaseModelCriteria.php - - message: "#^Call to an undefined method Propel\\\\Runtime\\\\ActiveQuery\\\\BaseModelCriteria\\:\\:find\\(\\)\\.$#" + message: "#^Call to an undefined method Propel\\\\Runtime\\\\ActiveQuery\\\\BaseModelCriteria\\\\:\\:find\\(\\)\\.$#" count: 1 path: src/Propel/Runtime/ActiveQuery/BaseModelCriteria.php @@ -436,22 +431,22 @@ parameters: path: src/Propel/Runtime/ActiveQuery/Criteria.php - - message: "#^Access to an undefined property Propel\\\\Runtime\\\\ActiveQuery\\\\Criteria\\:\\:\\$currentAlias\\.$#" + message: "#^Call to an undefined method Propel\\\\Runtime\\\\Adapter\\\\AdapterInterface\\:\\:applyLock\\(\\)\\.$#" count: 1 path: src/Propel/Runtime/ActiveQuery/Criteria.php - - message: "#^Access to an undefined property Propel\\\\Runtime\\\\ActiveQuery\\\\Criteria\\:\\:\\$foundMatch\\.$#" + message: "#^Access to an undefined property Propel\\\\Runtime\\\\ActiveQuery\\\\Criteria\\:\\:\\$currentAlias\\.$#" count: 1 path: src/Propel/Runtime/ActiveQuery/Criteria.php - - message: "#^Call to an undefined method Propel\\\\Runtime\\\\Adapter\\\\AdapterInterface\\:\\:cleanupSQL\\(\\)\\.$#" + message: "#^Access to an undefined property Propel\\\\Runtime\\\\ActiveQuery\\\\Criteria\\:\\:\\$foundMatch\\.$#" count: 1 path: src/Propel/Runtime/ActiveQuery/Criteria.php - - message: "#^Call to an undefined method Propel\\\\Runtime\\\\Adapter\\\\AdapterInterface\\:\\:applyLock\\(\\)\\.$#" + message: "#^Call to an undefined method Propel\\\\Runtime\\\\Adapter\\\\AdapterInterface\\:\\:cleanupSQL\\(\\)\\.$#" count: 1 path: src/Propel/Runtime/ActiveQuery/Criteria.php @@ -525,16 +520,31 @@ parameters: count: 1 path: src/Propel/Runtime/ActiveQuery/ModelCriteria.php + - + message: "#^Call to an undefined static method Propel\\\\Runtime\\\\Map\\\\TableMap\\\\:\\:addSelectColumns\\(\\)\\.$#" + count: 1 + path: src/Propel/Runtime/ActiveQuery/ModelCriteria.php + - message: "#^Call to an undefined method Propel\\\\Runtime\\\\Map\\\\TableMap\\:\\:addSelectColumns\\(\\)\\.$#" count: 1 path: src/Propel/Runtime/ActiveQuery/ModelCriteria.php + - + message: "#^Call to an undefined method Propel\\\\Runtime\\\\ActiveRecord\\\\ActiveRecordInterface\\:\\:setByName\\(\\)\\.$#" + count: 1 + path: src/Propel/Runtime/ActiveQuery/ModelCriteria.php + - message: "#^Variable \\$sql might not be defined\\.$#" count: 1 path: src/Propel/Runtime/ActiveQuery/ModelCriteria.php + - + message: "#^Call to an undefined method iterable\\&TColl of Propel\\\\Runtime\\\\Collection\\\\Collection\\:\\:save\\(\\)\\.$#" + count: 1 + path: src/Propel/Runtime/ActiveQuery/ModelCriteria.php + - message: "#^Call to function is_array\\(\\) with object will always evaluate to false\\.$#" count: 1 @@ -576,45 +586,70 @@ parameters: path: src/Propel/Runtime/Adapter/Pdo/SqliteAdapter.php - - message: "#^Call to an undefined method Propel\\\\Runtime\\\\ActiveRecord\\\\ActiveRecordInterface\\:\\:clear\\(\\)\\.$#" + message: "#^Call to an undefined method T of Propel\\\\Runtime\\\\ActiveRecord\\\\ActiveRecordInterface\\:\\:clear\\(\\)\\.$#" count: 2 path: src/Propel/Runtime/Collection/ArrayCollection.php - - message: "#^Call to an undefined method Propel\\\\Runtime\\\\ActiveRecord\\\\ActiveRecordInterface\\:\\:fromArray\\(\\)\\.$#" + message: "#^Call to an undefined method T of Propel\\\\Runtime\\\\ActiveRecord\\\\ActiveRecordInterface\\:\\:fromArray\\(\\)\\.$#" count: 3 path: src/Propel/Runtime/Collection/ArrayCollection.php - - message: "#^Call to an undefined method Propel\\\\Runtime\\\\ActiveRecord\\\\ActiveRecordInterface\\:\\:isPrimaryKeyNull\\(\\)\\.$#" + message: "#^Call to an undefined method T of Propel\\\\Runtime\\\\ActiveRecord\\\\ActiveRecordInterface\\:\\:isPrimaryKeyNull\\(\\)\\.$#" count: 1 path: src/Propel/Runtime/Collection/ArrayCollection.php - - message: "#^Call to an undefined method Propel\\\\Runtime\\\\ActiveRecord\\\\ActiveRecordInterface\\:\\:setNew\\(\\)\\.$#" + message: "#^Call to an undefined method T of Propel\\\\Runtime\\\\ActiveRecord\\\\ActiveRecordInterface\\:\\:setNew\\(\\)\\.$#" count: 1 path: src/Propel/Runtime/Collection/ArrayCollection.php - - message: "#^Call to an undefined method Propel\\\\Runtime\\\\ActiveRecord\\\\ActiveRecordInterface\\:\\:save\\(\\)\\.$#" + message: "#^Call to an undefined method T of Propel\\\\Runtime\\\\ActiveRecord\\\\ActiveRecordInterface\\:\\:save\\(\\)\\.$#" count: 1 path: src/Propel/Runtime/Collection/ArrayCollection.php - - message: "#^Call to an undefined method Propel\\\\Runtime\\\\ActiveRecord\\\\ActiveRecordInterface\\:\\:setDeleted\\(\\)\\.$#" + message: "#^Call to an undefined method T of Propel\\\\Runtime\\\\ActiveRecord\\\\ActiveRecordInterface\\:\\:setDeleted\\(\\)\\.$#" count: 1 path: src/Propel/Runtime/Collection/ArrayCollection.php - - message: "#^Call to an undefined method Propel\\\\Runtime\\\\ActiveRecord\\\\ActiveRecordInterface\\:\\:delete\\(\\)\\.$#" + message: "#^Call to an undefined method T of Propel\\\\Runtime\\\\ActiveRecord\\\\ActiveRecordInterface\\:\\:delete\\(\\)\\.$#" count: 1 path: src/Propel/Runtime/Collection/ArrayCollection.php - - message: "#^Call to an undefined method Propel\\\\Runtime\\\\ActiveRecord\\\\ActiveRecordInterface\\:\\:toArray\\(\\)\\.$#" + message: "#^Call to an undefined method T of Propel\\\\Runtime\\\\ActiveRecord\\\\ActiveRecordInterface\\:\\:toArray\\(\\)\\.$#" count: 1 path: src/Propel/Runtime/Collection/ArrayCollection.php + - + message: "#^Property Propel\\\\Runtime\\\\Collection\\\\Collection\\:\\:\\$model \\(class\\-string\\\\) does not accept default value of type string\\.$#" + count: 1 + path: src/Propel/Runtime/Collection/Collection.php + + - + message: "#^Property Propel\\\\Runtime\\\\Collection\\\\Collection\\:\\:\\$fullyQualifiedModel \\(class\\-string\\\\) does not accept default value of type string\\.$#" + count: 1 + path: src/Propel/Runtime/Collection/Collection.php + + - + message: "#^Call to an undefined method Propel\\\\Runtime\\\\Collection\\\\Collection\\\\:\\:fromArray\\(\\)\\.$#" + count: 1 + path: src/Propel/Runtime/Collection/Collection.php + + - + message: "#^Call to an undefined method Propel\\\\Runtime\\\\Collection\\\\Collection\\\\:\\:toArray\\(\\)\\.$#" + count: 1 + path: src/Propel/Runtime/Collection/Collection.php + + - + message: "#^Class Propel\\\\Runtime\\\\Collection\\\\CollectionIterator @extends tag contains incompatible type ArrayIterator&iterable\\\\.$#" + count: 1 + path: src/Propel/Runtime/Collection/CollectionIterator.php + - message: "#^Call to an undefined method Propel\\\\Runtime\\\\ActiveRecord\\\\ActiveRecordInterface\\:\\:save\\(\\)\\.$#" count: 1 @@ -641,27 +676,37 @@ parameters: path: src/Propel/Runtime/Collection/ObjectCollection.php - - message: "#^Call to an undefined method Propel\\\\Runtime\\\\ActiveRecord\\\\ActiveRecordInterface\\:\\:getPrimaryKey\\(\\)\\.$#" + message: "#^Call to an undefined method T of Propel\\\\Runtime\\\\ActiveRecord\\\\ActiveRecordInterface\\:\\:initRelation\\(\\)\\.$#" count: 1 + path: src/Propel/Runtime/Collection/ObjectCollection.php + + - + message: "#^Array \\(array\\\\) does not accept object\\.$#" + count: 3 + path: src/Propel/Runtime/Collection/ObjectCollection.php + + - + message: "#^Argument of an invalid type Propel\\\\Runtime\\\\ActiveRecord\\\\ActiveRecordInterface supplied for foreach, only iterables are supported\\.$#" + count: 2 path: src/Propel/Runtime/Collection/ObjectCombinationCollection.php - - message: "#^Call to an undefined method Propel\\\\Runtime\\\\ActiveRecord\\\\ActiveRecordInterface\\:\\:hashCode\\(\\)\\.$#" + message: "#^Call to an undefined method Propel\\\\Runtime\\\\ActiveRecord\\\\ActiveRecordInterface\\:\\:getPrimaryKey\\(\\)\\.$#" count: 1 path: src/Propel/Runtime/Collection/ObjectCombinationCollection.php - - message: "#^Call to an undefined method Propel\\\\Runtime\\\\ActiveRecord\\\\ActiveRecordInterface\\:\\:toArray\\(\\)\\.$#" + message: "#^Parameter \\#1 \\$value of method Propel\\\\Runtime\\\\Collection\\\\Collection\\\\:\\:push\\(\\) expects Propel\\\\Runtime\\\\ActiveRecord\\\\ActiveRecordInterface, array given\\.$#" count: 1 - path: src/Propel/Runtime/Collection/OnDemandCollection.php + path: src/Propel/Runtime/Collection/ObjectCombinationCollection.php - - message: "#^Return type \\(Propel\\\\Runtime\\\\Collection\\\\OnDemandIterator\\) of method Propel\\\\Runtime\\\\Collection\\\\OnDemandCollection\\:\\:getIterator\\(\\) should be compatible with return type \\(Propel\\\\Runtime\\\\Collection\\\\CollectionIterator\\) of method Propel\\\\Runtime\\\\Collection\\\\Collection\\:\\:getIterator\\(\\)$#" + message: "#^Call to an undefined method Propel\\\\Runtime\\\\ActiveRecord\\\\ActiveRecordInterface\\:\\:hashCode\\(\\)\\.$#" count: 1 - path: src/Propel/Runtime/Collection/OnDemandCollection.php + path: src/Propel/Runtime/Collection/ObjectCombinationCollection.php - - message: "#^Method Propel\\\\Runtime\\\\Collection\\\\OnDemandCollection\\:\\:getIterator\\(\\) should return Propel\\\\Runtime\\\\Collection\\\\OnDemandIterator but returns Iterator\\.$#" + message: "#^Call to an undefined method Propel\\\\Runtime\\\\ActiveRecord\\\\ActiveRecordInterface\\:\\:toArray\\(\\)\\.$#" count: 1 path: src/Propel/Runtime/Collection/OnDemandCollection.php @@ -671,49 +716,54 @@ parameters: path: src/Propel/Runtime/Connection/ProfilerStatementWrapper.php - - message: "#^Return type \\(array\\) of method Propel\\\\Runtime\\\\Formatter\\\\ArrayFormatter\\:\\:formatRecord\\(\\) should be compatible with return type \\(Propel\\\\Runtime\\\\ActiveRecord\\\\ActiveRecordInterface\\) of method Propel\\\\Runtime\\\\Formatter\\\\AbstractFormatter\\:\\:formatRecord\\(\\)$#" + message: "#^Call to an undefined method T of Propel\\\\Runtime\\\\ActiveRecord\\\\ActiveRecordInterface\\:\\:hydrate\\(\\)\\.$#" count: 1 - path: src/Propel/Runtime/Formatter/ArrayFormatter.php + path: src/Propel/Runtime/Formatter/AbstractFormatter.php - - message: "#^Call to an undefined method Propel\\\\Runtime\\\\ActiveRecord\\\\ActiveRecordInterface\\:\\:toArray\\(\\)\\.$#" + message: "#^Call to an undefined method T of Propel\\\\Runtime\\\\ActiveRecord\\\\ActiveRecordInterface\\:\\:toArray\\(\\)\\.$#" count: 3 path: src/Propel/Runtime/Formatter/ArrayFormatter.php - - message: "#^Call to an undefined static method Propel\\\\Runtime\\\\Map\\\\TableMap\\:\\:getPrimaryKeyHashFromRow\\(\\)\\.$#" + message: "#^Call to an undefined static method Propel\\\\Runtime\\\\Map\\\\TableMap\\\\:\\:getPrimaryKeyHashFromRow\\(\\)\\.$#" count: 1 path: src/Propel/Runtime/Formatter/ArrayFormatter.php - - message: "#^Call to an undefined method Propel\\\\Runtime\\\\ActiveRecord\\\\ActiveRecordInterface\\:\\:isPrimaryKeyNull\\(\\)\\.$#" + message: "#^Call to an undefined method T of Propel\\\\Runtime\\\\ActiveRecord\\\\ActiveRecordInterface\\:\\:isPrimaryKeyNull\\(\\)\\.$#" count: 1 path: src/Propel/Runtime/Formatter/ArrayFormatter.php - - message: "#^Call to an undefined method Propel\\\\Runtime\\\\ActiveRecord\\\\ActiveRecordInterface\\:\\:getPrimaryKey\\(\\)\\.$#" + message: "#^Call to an undefined method T of Propel\\\\Runtime\\\\ActiveRecord\\\\ActiveRecordInterface\\:\\:getPrimaryKey\\(\\)\\.$#" + count: 1 + path: src/Propel/Runtime/Formatter/ObjectFormatter.php + + - + message: "#^Call to an undefined method Propel\\\\Runtime\\\\Map\\\\TableMap\\\\:\\:populateObject\\(\\)\\.$#" count: 1 path: src/Propel/Runtime/Formatter/ObjectFormatter.php - message: "#^Call to an undefined method Propel\\\\Runtime\\\\Map\\\\TableMap\\:\\:populateObject\\(\\)\\.$#" - count: 2 + count: 1 path: src/Propel/Runtime/Formatter/ObjectFormatter.php - - message: "#^Call to an undefined method Propel\\\\Runtime\\\\ActiveRecord\\\\ActiveRecordInterface\\:\\:isPrimaryKeyNull\\(\\)\\.$#" + message: "#^Call to an undefined method T of Propel\\\\Runtime\\\\ActiveRecord\\\\ActiveRecordInterface\\:\\:setVirtualColumn\\(\\)\\.$#" count: 1 - path: src/Propel/Runtime/Formatter/OnDemandFormatter.php + path: src/Propel/Runtime/Formatter/ObjectFormatter.php - - message: "#^Call to an undefined method Propel\\\\Runtime\\\\ActiveRecord\\\\ActiveRecordInterface\\:\\:setVirtualColumn\\(\\)\\.$#" + message: "#^Call to an undefined method T of Propel\\\\Runtime\\\\ActiveRecord\\\\ActiveRecordInterface\\:\\:isPrimaryKeyNull\\(\\)\\.$#" count: 1 path: src/Propel/Runtime/Formatter/OnDemandFormatter.php - - message: "#^Return type \\(array\\) of method Propel\\\\Runtime\\\\Formatter\\\\SimpleArrayFormatter\\:\\:formatRecord\\(\\) should be compatible with return type \\(Propel\\\\Runtime\\\\ActiveRecord\\\\ActiveRecordInterface\\) of method Propel\\\\Runtime\\\\Formatter\\\\AbstractFormatter\\:\\:formatRecord\\(\\)$#" + message: "#^Call to an undefined method T of Propel\\\\Runtime\\\\ActiveRecord\\\\ActiveRecordInterface\\:\\:setVirtualColumn\\(\\)\\.$#" count: 1 - path: src/Propel/Runtime/Formatter/SimpleArrayFormatter.php + path: src/Propel/Runtime/Formatter/OnDemandFormatter.php - message: "#^Call to an undefined method Propel\\\\Runtime\\\\ActiveRecord\\\\ActiveRecordInterface\\:\\:toArray\\(\\)\\.$#" diff --git a/phpstan.neon b/phpstan.neon index 8088d8b5e1..9bab7d4767 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -20,7 +20,6 @@ parameters: - '%rootDir%/../../../src/Propel/Generator/Command/Helper/ConsoleHelper.php' - '%rootDir%/../../../src/Propel/Generator/Command/InitCommand.php' ignoreErrors: - - '#Call to an undefined method .+Collection::.+Array\(\)#' - '#Class .+TreeBuilder constructor invoked with 0 parameters, 1-3 required#' - message: "#^Call to an undefined method Symfony\\\\Component\\\\Config\\\\Definition\\\\Builder\\\\TreeBuilder\\:\\:root\\(\\)\\.$#" diff --git a/src/Propel/Runtime/ActiveQuery/BaseModelCriteria.php b/src/Propel/Runtime/ActiveQuery/BaseModelCriteria.php index faca9e502a..8220c074ce 100644 --- a/src/Propel/Runtime/ActiveQuery/BaseModelCriteria.php +++ b/src/Propel/Runtime/ActiveQuery/BaseModelCriteria.php @@ -16,15 +16,22 @@ use Propel\Runtime\Propel; use Traversable; +/** + * @phpstan-template T of \Propel\Runtime\ActiveRecord\ActiveRecordInterface + * @phpstan-template TColl of \Propel\Runtime\Collection\Collection + * @phpstan-template TReturn + */ class BaseModelCriteria extends Criteria implements IteratorAggregate { /** * @var string|null + * @phpstan-var class-string */ protected $modelName; /** * @var string|null + * @phpstan-var class-string<\Propel\Runtime\Map\TableMap> */ protected $modelTableMapName; @@ -35,6 +42,8 @@ class BaseModelCriteria extends Criteria implements IteratorAggregate /** * @var \Propel\Runtime\Map\TableMap + * + * @phpstan-var \Propel\Runtime\Map\TableMap */ protected $tableMap; @@ -62,6 +71,8 @@ class BaseModelCriteria extends Criteria implements IteratorAggregate * @param string|null $dbName The dabase name * @param string|null $modelName The phpName of a model, e.g. 'Book' * @param string|null $modelAlias The alias for the model in this query, e.g. 'b' + * + * @phpstan-param class-string $modelName */ public function __construct($dbName = null, $modelName = null, $modelAlias = null) { @@ -112,6 +123,11 @@ public function setWith($with) * @throws \Propel\Runtime\Exception\InvalidArgumentException * * @return $this The current object, for fluid interface + * + * @phpstan-template AColl of \Propel\Runtime\Collection\Collection + * @phpstan-template AReturn + * @phpstan-param \Propel\Runtime\Formatter\AbstractFormatter|class-string<\Propel\Runtime\Formatter\AbstractFormatter> $formatter + * @phpstan-return $this */ public function setFormatter($formatter) { @@ -147,6 +163,8 @@ public function getFormatter() /** * Returns the name of the class for this model criteria * + * @phpstan-return class-string + * * @return string */ public function getModelName() @@ -158,6 +176,8 @@ public function getModelName() * Sets the model name. * This also sets `this->modelTableMapName` and `this->tableMap`. * + * @phpstan-param class-string $modelName + * * @param string $modelName * * @return $this The current object, for fluid interface @@ -180,6 +200,8 @@ public function setModelName($modelName) } /** + * @phpstan-return class-string + * * @return string */ public function getFullyQualifiedModelName() @@ -240,6 +262,8 @@ public function getModelShortName() /** * Returns the TableMap object for this Criteria * + * @phpstan-return \Propel\Runtime\Map\TableMap + * * @return \Propel\Runtime\Map\TableMap */ public function getTableMap() @@ -254,6 +278,8 @@ public function getTableMap() * constructed on a Propel\Runtime\Collection\PropelCollection. * Compulsory for implementation of \IteratorAggregate. * + * @phpstan-return \Traversable + * * @throws \Propel\Runtime\Exception\LogicException * * @return \Traversable diff --git a/src/Propel/Runtime/ActiveQuery/Criteria.php b/src/Propel/Runtime/ActiveQuery/Criteria.php index bedffb2884..dbcc1724fa 100644 --- a/src/Propel/Runtime/ActiveQuery/Criteria.php +++ b/src/Propel/Runtime/ActiveQuery/Criteria.php @@ -187,6 +187,8 @@ class Criteria /** * @var \Propel\Runtime\ActiveQuery\Criteria[] + * + * @phpstan-var array */ protected $selectQueries = []; diff --git a/src/Propel/Runtime/ActiveQuery/ModelCriteria.php b/src/Propel/Runtime/ActiveQuery/ModelCriteria.php index 131471db97..c681216283 100644 --- a/src/Propel/Runtime/ActiveQuery/ModelCriteria.php +++ b/src/Propel/Runtime/ActiveQuery/ModelCriteria.php @@ -49,6 +49,10 @@ * @method \Propel\Runtime\ActiveQuery\ModelCriteria innerJoin($relation) Adds a INNER JOIN clause to the query * * @author François Zaninotto + * + * @phpstan-template T of \Propel\Runtime\ActiveRecord\ActiveRecordInterface + * @phpstan-template TColl of \Propel\Runtime\Collection\Collection + * @phpstan-template TReturn */ class ModelCriteria extends BaseModelCriteria { @@ -64,6 +68,8 @@ class ModelCriteria extends BaseModelCriteria /** * @var \Propel\Runtime\ActiveQuery\ModelCriteria|null + * + * @phpstan-var self|null */ protected $primaryCriteria; @@ -434,6 +440,8 @@ public function offset($offset) * @throws \Propel\Runtime\Exception\PropelException * * @return $this The current object, for fluid interface + * + * @phpstan-return $this, mixed[]> */ public function select($columnArray) { @@ -784,6 +792,10 @@ public function withColumn($clause, $name = null) * @throws \Propel\Runtime\Exception\PropelException * * @return \Propel\Runtime\ActiveQuery\ModelCriteria The secondary criteria object + * + * @phpstan-template TRel of \Propel\Runtime\ActiveRecord\ActiveRecordInterface + * @phpstan-param class-string $secondaryCriteriaClass + * @phpstan-return ModelCriteria */ public function useQuery($relationName, $secondaryCriteriaClass = null) { @@ -858,6 +870,8 @@ public function mergeWith(Criteria $criteria, $operator = null) * The ModelCriteria's Model and alias 'all the properties set by construct) will remain. * * @return $this The primary criteria object + * + * @phpstan-return $this, T> */ public function clear() { @@ -878,6 +892,8 @@ public function clear() * @param \Propel\Runtime\ActiveQuery\Join $previousJoin The previousJoin for this ModelCriteria * * @return void + * + * @phpstan-param ModelCriteria $criteria */ public function setPrimaryCriteria(ModelCriteria $criteria, Join $previousJoin) { @@ -1066,6 +1082,8 @@ protected function preSelect(ConnectionInterface $con) * @param \Propel\Runtime\Connection\ConnectionInterface|null $con an optional connection object * * @return \Propel\Runtime\Collection\ObjectCollection|\Propel\Runtime\ActiveRecord\ActiveRecordInterface[]|mixed the list of results, formatted by the current formatter + * + * @phpstan-return TColl */ public function find(?ConnectionInterface $con = null) { @@ -1089,6 +1107,8 @@ public function find(?ConnectionInterface $con = null) * * Does not work with ->with()s containing one-to-many relations. * + * @phpstan-return T|mixed + * * @param \Propel\Runtime\Connection\ConnectionInterface|null $con an optional connection object * * @return mixed the result, formatted by the current formatter @@ -1807,7 +1827,9 @@ public function doUpdate($updateValues, ConnectionInterface $con, $forceIndividu { if ($forceIndividualSaves) { // Update rows one by one - $objects = $this->setFormatter(ModelCriteria::FORMAT_OBJECT)->find($con); + /** @phpstan-var \Propel\Runtime\Formatter\AbstractFormatter */ + $classString = ModelCriteria::FORMAT_OBJECT; + $objects = $this->setFormatter($classString)->find($con); foreach ($objects as $object) { foreach ($updateValues as $key => $value) { $object->setByName($key, $value); @@ -2117,7 +2139,9 @@ public function configureSelectColumns() // select() needs the PropelSimpleArrayFormatter if no formatter given if ($this->formatter === null) { - $this->setFormatter('\Propel\Runtime\Formatter\SimpleArrayFormatter'); + /** @phpstan-var \Propel\Runtime\Formatter\SimpleArrayFormatter */ + $classString = '\Propel\Runtime\Formatter\SimpleArrayFormatter'; + $this->setFormatter($classString); } // clear only the selectColumns, clearSelectColumns() clears asColumns too diff --git a/src/Propel/Runtime/Collection/ArrayCollection.php b/src/Propel/Runtime/Collection/ArrayCollection.php index b4821503a2..7bc7a675d3 100644 --- a/src/Propel/Runtime/Collection/ArrayCollection.php +++ b/src/Propel/Runtime/Collection/ArrayCollection.php @@ -15,11 +15,15 @@ * Class for iterating over a list of Propel objects stored as arrays * * @author Francois Zaninotto + * + * @phpstan-template T of \Propel\Runtime\ActiveRecord\ActiveRecordInterface + * @phpstan-extends Collection */ class ArrayCollection extends Collection { /** * @var object + * @phpstan-var T */ protected $workerObject; @@ -148,6 +152,7 @@ public function fromArray($arr) public function toArray($keyColumn = null, $usePrefix = false) { $ret = []; + /** @var array $element */ foreach ($this as $key => $element) { $key = $keyColumn === null ? $key : $element[$keyColumn]; $key = $usePrefix ? ($this->getModel() . '_' . $key) : $key; @@ -190,6 +195,7 @@ public function getArrayCopy($keyColumn = null, $usePrefix = false) public function toKeyValue($keyColumn, $valueColumn) { $ret = []; + /** @var array $obj */ foreach ($this as $obj) { $ret[$obj[$keyColumn]] = $obj[$valueColumn]; } @@ -201,6 +207,8 @@ public function toKeyValue($keyColumn, $valueColumn) * @throws \Propel\Runtime\Exception\PropelException * * @return \Propel\Runtime\ActiveRecord\ActiveRecordInterface + * + * @phpstan-return T */ protected function getWorkerObject() { diff --git a/src/Propel/Runtime/Collection/Collection.php b/src/Propel/Runtime/Collection/Collection.php index f180b4523d..fe574cc4c0 100644 --- a/src/Propel/Runtime/Collection/Collection.php +++ b/src/Propel/Runtime/Collection/Collection.php @@ -36,11 +36,17 @@ * @method string toCSV(bool $usePrefix = true, bool $includeLazyLoadColumns = true) Export the collection to a CSV string * * @author Francois Zaninotto + * + * @phpstan-template TType of \Propel\Runtime\ActiveRecord\ActiveRecordInterface + * @phpstan-template T + * @phpstan-implements \ArrayAccess + * @phpstan-implements \IteratorAggregate */ class Collection implements ArrayAccess, IteratorAggregate, Countable, Serializable { /** * @var string + * @phpstan-var class-string */ protected $model = ''; @@ -48,16 +54,19 @@ class Collection implements ArrayAccess, IteratorAggregate, Countable, Serializa * The fully qualified classname of the model * * @var string + * @phpstan-var class-string */ protected $fullyQualifiedModel = ''; /** * @var \Propel\Runtime\Formatter\AbstractFormatter + * @phpstan-var \Propel\Runtime\Formatter\AbstractFormatter */ protected $formatter; /** * @var array + * @phpstan-var T[] */ protected $data = []; @@ -68,6 +77,8 @@ class Collection implements ArrayAccess, IteratorAggregate, Countable, Serializa /** * @param array $data + * + * @phpstan-param T[] $data */ public function __construct($data = []) { @@ -78,6 +89,8 @@ public function __construct($data = []) * @param mixed $value * * @return void + * + * @phpstan-param T $value */ public function append($value) { @@ -98,6 +111,8 @@ public function offsetExists($offset) * @param mixed $offset * * @return mixed + * + * @phpstan-return T|void */ public function &offsetGet($offset) { @@ -111,6 +126,8 @@ public function &offsetGet($offset) * @param mixed $value * * @return void + * + * @phpstan-param T $value */ public function offsetSet($offset, $value) { @@ -135,6 +152,8 @@ public function offsetUnset($offset) * @param array $input * * @return void + * + * @phpstan-param T[] $input */ public function exchangeArray($input) { @@ -145,6 +164,8 @@ public function exchangeArray($input) * Get the data in the collection * * @return array + * + * @phpstan-return T[] */ public function getData() { @@ -153,6 +174,8 @@ public function getData() /** * @return array + * + * @phpstan-return T[] */ public function getArrayCopy() { @@ -165,6 +188,8 @@ public function getArrayCopy() * @param array $data * * @return void + * + * @phpstan-param T[] $data */ public function setData($data) { @@ -172,7 +197,9 @@ public function setData($data) } /** - * @return \Propel\Runtime\Collection\CollectionIterator + * @return \Iterator + * + * @phpstan-return \Iterator */ public function getIterator() { @@ -193,6 +220,8 @@ public function count() * Get the first element in the collection * * @return mixed + * + * @phpstan-return T|null */ public function getFirst() { @@ -239,6 +268,8 @@ public function isEmpty() * @throws \Propel\Runtime\Exception\UnexpectedValueException * * @return mixed The element + * + * @phpstan-return T */ public function get($key) { @@ -246,6 +277,7 @@ public function get($key) throw new UnexpectedValueException(sprintf('Unknown key %s.', $key)); } + /** @phpstan-var T */ return $this->offsetGet($key); } @@ -253,6 +285,8 @@ public function get($key) * Pops an element off the end of the collection * * @return mixed The popped element + * + * @phpstan-return T|null */ public function pop() { @@ -271,6 +305,8 @@ public function pop() * Pops an element off the beginning of the collection * * @return mixed The popped element + * + * @phpstan-return T|null */ public function shift() { @@ -289,6 +325,8 @@ public function shift() * @param mixed $value the element to prepend * * @return void + * + * @phpstan-param T $value */ public function push($value) { @@ -301,6 +339,8 @@ public function push($value) * @param mixed $value the element to prepend * * @return int The number of new elements in the array + * + * @phpstan-param T $value */ public function prepend($value) { @@ -321,6 +361,8 @@ public function prepend($value) * @param mixed $value * * @return void + * + * @phpstan-param T $value */ public function set($key, $value) { @@ -362,6 +404,8 @@ public function clear() * @param mixed $element * * @return bool + * + * @phpstan-param T $element */ public function contains($element) { @@ -374,6 +418,8 @@ public function contains($element) * @param mixed $element * * @return mixed Returns the key for the element if it is found in the collection, FALSE otherwise + * + * @phpstan-param T $element */ public function search($element) { @@ -387,6 +433,10 @@ public function search($element) * @param \Propel\Runtime\Collection\Collection $collection A Propel collection. * * @return \Propel\Runtime\Collection\Collection An array of Propel objects from the collection that are not presents in the given collection. + * + * @phpstan-param Collection $collection + * + * @phpstan-return self */ public function diff(Collection $collection) { @@ -436,6 +486,8 @@ public function unserialize($data) /** * Set the model of the elements in the collection * + * @phpstan-param class-string $model + * * @param string $model Name of the Propel object classes stored in the collection * * @return void @@ -453,6 +505,8 @@ public function setModel($model) /** * Get the model of the elements in the collection * + * @phpstan-return class-string + * * @return string Name of the Propel object class stored in the collection */ public function getModel() @@ -463,6 +517,8 @@ public function getModel() /** * Get the model of the elements in the collection * + * @phpstan-return class-string + * * @return string Fully qualified Name of the Propel object class stored in the collection */ public function getFullyQualifiedModel() @@ -471,6 +527,8 @@ public function getFullyQualifiedModel() } /** + * @phpstan-return class-string<\Propel\Runtime\Map\TableMap> + * * @throws \Propel\Runtime\Collection\Exception\ModelNotFoundException * * @return string @@ -487,6 +545,8 @@ public function getTableMapClass() } /** + * @phpstan-param \Propel\Runtime\Formatter\AbstractFormatter $formatter + * * @param \Propel\Runtime\Formatter\AbstractFormatter $formatter * * @return void @@ -497,6 +557,8 @@ public function setFormatter(AbstractFormatter $formatter) } /** + * @phpstan-return \Propel\Runtime\Formatter\AbstractFormatter + * * @return \Propel\Runtime\Formatter\AbstractFormatter */ public function getFormatter() diff --git a/src/Propel/Runtime/Collection/CollectionIterator.php b/src/Propel/Runtime/Collection/CollectionIterator.php index 775f237a4e..3027c64539 100644 --- a/src/Propel/Runtime/Collection/CollectionIterator.php +++ b/src/Propel/Runtime/Collection/CollectionIterator.php @@ -12,11 +12,15 @@ /** * Iterator class for iterating over Collection data + * + * @phpstan-template T of \Propel\Runtime\ActiveRecord\ActiveRecordInterface + * @phpstan-extends ArrayIterator */ class CollectionIterator extends ArrayIterator { /** * @var \Propel\Runtime\Collection\Collection + * @phpstan-var \Propel\Runtime\Collection\Collection */ protected $collection; @@ -28,6 +32,8 @@ class CollectionIterator extends ArrayIterator /** * Constructor * + * @phpstan-param \Propel\Runtime\Collection\Collection $collection + * * @param \Propel\Runtime\Collection\Collection $collection */ public function __construct(Collection $collection) @@ -41,6 +47,8 @@ public function __construct(Collection $collection) /** * Returns the collection instance * + * @phpstan-return \Propel\Runtime\Collection\Collection + * * @return \Propel\Runtime\Collection\Collection */ public function getCollection() @@ -77,6 +85,8 @@ public function getPosition() * Move the internal pointer to the beginning of the list * And get the first element in the collection * + * @phpstan-return T|null + * * @return mixed */ public function getFirst() @@ -103,6 +113,8 @@ public function isFirst() * Move the internal pointer backward * And get the previous element in the collection * + * @phpstan-return T|null + * * @return mixed */ public function getPrevious() @@ -119,6 +131,8 @@ public function getPrevious() /** * Get the current element in the collection * + * @phpstan-return T|null + * * @return mixed */ public function getCurrent() @@ -130,6 +144,8 @@ public function getCurrent() * Move the internal pointer forward * And get the next element in the collection * + * @phpstan-return T|null + * * @return mixed */ public function getNext() @@ -143,6 +159,8 @@ public function getNext() * Move the internal pointer to the end of the list * And get the last element in the collection * + * @phpstan-return T|null + * * @return mixed */ public function getLast() diff --git a/src/Propel/Runtime/Collection/ObjectCollection.php b/src/Propel/Runtime/Collection/ObjectCollection.php index 58a69ade0d..6736a3c4ba 100644 --- a/src/Propel/Runtime/Collection/ObjectCollection.php +++ b/src/Propel/Runtime/Collection/ObjectCollection.php @@ -20,6 +20,9 @@ * Class for iterating over a list of Propel objects * * @author Francois Zaninotto + * + * @phpstan-template T of \Propel\Runtime\ActiveRecord\ActiveRecordInterface + * @phpstan-extends Collection */ class ObjectCollection extends Collection { @@ -34,6 +37,8 @@ class ObjectCollection extends Collection protected $indexSplHash = []; /** + * @phpstan-param array $data + * * @param array $data */ public function __construct($data = []) @@ -54,6 +59,8 @@ public function exchangeArray($input) } /** + * @phpstan-param array $data + * * @param array $data * * @return void @@ -459,6 +466,8 @@ public function removeObject($element) } /** + * @phpstan-param T|mixed $value + * * @param mixed $value * * @return void diff --git a/src/Propel/Runtime/Collection/OnDemandCollection.php b/src/Propel/Runtime/Collection/OnDemandCollection.php index 2d6c41bd22..040ff5149d 100644 --- a/src/Propel/Runtime/Collection/OnDemandCollection.php +++ b/src/Propel/Runtime/Collection/OnDemandCollection.php @@ -18,15 +18,22 @@ * Class for iterating over a statement and returning one Propel object at a time * * @author Francois Zaninotto + * + * @phpstan-template T of \Propel\Runtime\ActiveRecord\ActiveRecordInterface + * @phpstan-extends ObjectCollection */ -class OnDemandCollection extends Collection +class OnDemandCollection extends ObjectCollection { /** - * @var \Iterator + * @phpstan-var \Propel\Runtime\Collection\OnDemandIterator + * + * @var \Propel\Runtime\Collection\OnDemandIterator */ private $lastIterator; /** + * @phpstan-param \Propel\Runtime\Formatter\OnDemandFormatter $formatter + * * @param \Propel\Runtime\Formatter\ObjectFormatter $formatter * @param \Propel\Runtime\DataFetcher\DataFetcherInterface $dataFetcher * @@ -110,6 +117,8 @@ public function fromArray($arr) // IteratorAggregate Interface /** + * @phpstan-return \Propel\Runtime\Collection\OnDemandIterator + * * @return \Propel\Runtime\Collection\OnDemandIterator */ public function getIterator() @@ -247,7 +256,7 @@ public function exchangeArray($input) * * @return array */ - public function getArrayCopy() + public function getArrayCopy($keyColumn = null, $usePrefix = false) { throw new PropelException('The On Demand Collection does not allow access by offset'); } diff --git a/src/Propel/Runtime/Collection/OnDemandIterator.php b/src/Propel/Runtime/Collection/OnDemandIterator.php index 75ab01d59a..468fc4f528 100644 --- a/src/Propel/Runtime/Collection/OnDemandIterator.php +++ b/src/Propel/Runtime/Collection/OnDemandIterator.php @@ -18,11 +18,15 @@ * Class for iterating over a statement and returning one Propel object at a time * * @author Francois Zaninotto + * + * @phpstan-template T of \Propel\Runtime\ActiveRecord\ActiveRecordInterface + * @phpstan-implements Iterator */ class OnDemandIterator implements Iterator { /** * @var \Propel\Runtime\Formatter\ObjectFormatter + * @phpstan-var \Propel\Runtime\Formatter\ObjectFormatter */ protected $formatter; @@ -52,7 +56,9 @@ class OnDemandIterator implements Iterator protected $enableInstancePoolingOnFinish; /** - * @param \Propel\Runtime\Formatter\ObjectFormatter $formatter + * @phpstan-param \Propel\Runtime\Formatter\OnDemandFormatter $formatter + * + * @param \Propel\Runtime\Formatter\OnDemandFormatter $formatter * @param \Propel\Runtime\DataFetcher\DataFetcherInterface $dataFetcher */ public function __construct(AbstractFormatter $formatter, DataFetcherInterface $dataFetcher) @@ -91,6 +97,8 @@ public function count() * Gets the current Model object in the collection * This is where the hydration takes place. * + * @phpstan-return T + * * @see ObjectFormatter::getAllObjectsFromRow() * * @return \Propel\Runtime\ActiveRecord\ActiveRecordInterface diff --git a/src/Propel/Runtime/Formatter/AbstractFormatter.php b/src/Propel/Runtime/Formatter/AbstractFormatter.php index 73ecb89bb0..eb84d006d8 100644 --- a/src/Propel/Runtime/Formatter/AbstractFormatter.php +++ b/src/Propel/Runtime/Formatter/AbstractFormatter.php @@ -18,6 +18,10 @@ * Abstract class for query formatter * * @author Francois Zaninotto + * + * @phpstan-template T of ActiveRecordInterface + * @phpstan-template TColl of \Propel\Runtime\Collection\Collection + * @phpstan-template TReturn */ abstract class AbstractFormatter { @@ -27,12 +31,14 @@ abstract class AbstractFormatter protected $dbName; /** - * @var string|null + * @var string + * @phpstan-var class-string */ protected $class; /** * @var \Propel\Runtime\Map\TableMap|null + * @phpstan-var \Propel\Runtime\Map\TableMap|null */ protected $tableMap; @@ -64,6 +70,8 @@ abstract class AbstractFormatter /** * @param \Propel\Runtime\ActiveQuery\BaseModelCriteria|null $criteria * @param \Propel\Runtime\DataFetcher\DataFetcherInterface|null $dataFetcher + * + * @phpstan-param BaseModelCriteria $criteria */ public function __construct(?BaseModelCriteria $criteria = null, ?DataFetcherInterface $dataFetcher = null) { @@ -102,6 +110,11 @@ public function getDataFetcher() * @param \Propel\Runtime\DataFetcher\DataFetcherInterface|null $dataFetcher * * @return $this The current formatter object + * + * @phpstan-template AColl of \Propel\Runtime\Collection\Collection + * @phpstan-template AReturn + * @phpstan-param BaseModelCriteria $criteria + * @phpstan-return $this */ public function init(BaseModelCriteria $criteria, ?DataFetcherInterface $dataFetcher = null) { @@ -141,6 +154,8 @@ public function getDbName() * @param string $class * * @return void + * + * @phpstan-param class-string $class */ public function setClass($class) { @@ -149,7 +164,9 @@ public function setClass($class) } /** - * @return string|null + * @return string + * + * @phpstan-return class-string */ public function getClass() { @@ -214,6 +231,8 @@ public function hasLimit() * Returns a Collection object or a simple array. * * @return \Propel\Runtime\Collection\Collection|array + * + * @phpstan-return TColl|array */ protected function getCollection() { @@ -231,6 +250,8 @@ protected function getCollection() } /** + * @phpstan-return null|class-string> + * * @return string|null */ public function getCollectionClassName() @@ -241,6 +262,10 @@ public function getCollectionClassName() /** * Formats an ActiveRecord object * + * @phpstan-param T|null $record + * + * @phpstan-return T|null|array + * * @param \Propel\Runtime\ActiveRecord\ActiveRecordInterface|null $record the object to format * * @return \Propel\Runtime\ActiveRecord\ActiveRecordInterface The original record @@ -282,6 +307,8 @@ public function checkInit() } /** + * @phpstan-return \Propel\Runtime\Map\TableMap + * * @return \Propel\Runtime\Map\TableMap */ public function getTableMap() @@ -312,6 +339,9 @@ protected function isWithOneToMany() * @param int $col The start column for the hydration (modified) * * @return \Propel\Runtime\ActiveRecord\ActiveRecordInterface + * + * @phpstan-param class-string $class + * @phpstan-return T */ public function getSingleObjectFromRow($row, $class, &$col = 0) { diff --git a/src/Propel/Runtime/Formatter/ArrayFormatter.php b/src/Propel/Runtime/Formatter/ArrayFormatter.php index 4409fd2296..05fbcb6dd5 100644 --- a/src/Propel/Runtime/Formatter/ArrayFormatter.php +++ b/src/Propel/Runtime/Formatter/ArrayFormatter.php @@ -18,6 +18,10 @@ * format() returns a ArrayCollection of associative arrays * * @author Francois Zaninotto + * + * @phpstan-template T of ActiveRecordInterface + * @phpstan-template TColl of \Propel\Runtime\Collection\ArrayCollection + * @phpstan-extends AbstractFormatter */ class ArrayFormatter extends AbstractFormatter { @@ -73,6 +77,17 @@ public function format(?DataFetcherInterface $dataFetcher = null) return $collection; } + /** + * @return \Propel\Runtime\Collection\ArrayCollection + * + * @phpstan-return TColl + */ + public function getCollection() + { + /** @phpstan-var TColl */ + return parent::getCollection(); + } + /** * @return string|null */ @@ -122,6 +137,8 @@ public function formatOne(?DataFetcherInterface $dataFetcher = null) * @param \Propel\Runtime\ActiveRecord\ActiveRecordInterface|null $record the object to format * * @return array The original record turned into an array + * + * @phpstan-param T|null $record */ public function formatRecord(?ActiveRecordInterface $record = null) { diff --git a/src/Propel/Runtime/Formatter/ObjectFormatter.php b/src/Propel/Runtime/Formatter/ObjectFormatter.php index 9641901369..a17374ea84 100644 --- a/src/Propel/Runtime/Formatter/ObjectFormatter.php +++ b/src/Propel/Runtime/Formatter/ObjectFormatter.php @@ -16,11 +16,16 @@ * format() returns a ObjectCollection of Propel model objects * * @author Francois Zaninotto + * + * @phpstan-template T of \Propel\Runtime\ActiveRecord\ActiveRecordInterface + * @phpstan-template TColl of \Propel\Runtime\Collection\ObjectCollection + * @phpstan-extends AbstractFormatter */ class ObjectFormatter extends AbstractFormatter { /** - * @var array + * @var \Propel\Runtime\ActiveRecord\ActiveRecordInterface[] + * @phpstan-var array */ protected $objects = []; @@ -29,7 +34,9 @@ class ObjectFormatter extends AbstractFormatter * * @throws \Propel\Runtime\Exception\LogicException * - * @return array|\Propel\Runtime\Collection\Collection + * @return \Propel\Runtime\Collection\ObjectCollection + * + * @phpstan-return \Propel\Runtime\Collection\ObjectCollection */ public function format(?DataFetcherInterface $dataFetcher = null) { @@ -68,7 +75,20 @@ public function format(?DataFetcherInterface $dataFetcher = null) } /** - * @return string|null + * @return \Propel\Runtime\Collection\ObjectCollection + * + * @phpstan-return TColl + */ + public function getCollection() + { + /** @phpstan-var TColl */ + return parent::getCollection(); + } + + /** + * @phpstan-return class-string> + * + * @return string */ public function getCollectionClassName() { @@ -81,6 +101,8 @@ public function getCollectionClassName() * @throws \Propel\Runtime\Exception\LogicException * * @return \Propel\Runtime\ActiveRecord\ActiveRecordInterface|null + * + * @phpstan-return T|null */ public function formatOne(?DataFetcherInterface $dataFetcher = null) { @@ -121,11 +143,14 @@ public function isObjectFormatter() * as returned by DataFetcher::fetch() * * @return \Propel\Runtime\ActiveRecord\ActiveRecordInterface + * + * @phpstan-return T */ public function getAllObjectsFromRow($row) { // main object [$obj, $col] = $this->getTableMap()->populateObject($row, 0, $this->getDataFetcher()->getIndexType()); + /** @phpstan-var T $obj */ $pk = $obj->getPrimaryKey(); $serializedPk = serialize($pk); diff --git a/src/Propel/Runtime/Formatter/OnDemandFormatter.php b/src/Propel/Runtime/Formatter/OnDemandFormatter.php index eb0fc2bfe3..a22fbffb4a 100644 --- a/src/Propel/Runtime/Formatter/OnDemandFormatter.php +++ b/src/Propel/Runtime/Formatter/OnDemandFormatter.php @@ -19,6 +19,10 @@ * This formatter consumes less memory than the ObjectFormatter, but doesn't use Instance Pool * * @author Francois Zaninotto + * + * @phpstan-template T of \Propel\Runtime\ActiveRecord\ActiveRecordInterface + * @phpstan-template TColl of \Propel\Runtime\Collection\OnDemandCollection + * @phpstan-extends ObjectFormatter */ class OnDemandFormatter extends ObjectFormatter { @@ -28,12 +32,17 @@ class OnDemandFormatter extends ObjectFormatter protected $isSingleTableInheritance = false; /** - * @param \Propel\Runtime\ActiveQuery\BaseModelCriteria|null $criteria + * @param \Propel\Runtime\ActiveQuery\BaseModelCriteria $criteria * @param \Propel\Runtime\DataFetcher\DataFetcherInterface|null $dataFetcher * * @return $this + * + * @phpstan-template AColl of \Propel\Runtime\Collection\Collection + * @phpstan-template AReturn + * @phpstan-param BaseModelCriteria $criteria + * @phpstan-return $this */ - public function init(?BaseModelCriteria $criteria = null, ?DataFetcherInterface $dataFetcher = null) + public function init(BaseModelCriteria $criteria, ?DataFetcherInterface $dataFetcher = null) { parent::init($criteria, $dataFetcher); @@ -47,7 +56,9 @@ public function init(?BaseModelCriteria $criteria = null, ?DataFetcherInterface * * @throws \Propel\Runtime\Exception\LogicException * - * @return array|\Propel\Runtime\Collection\Collection|\Propel\Runtime\Collection\OnDemandCollection + * @return \Propel\Runtime\Collection\OnDemandCollection + * + * @phpstan-return TColl */ public function format(?DataFetcherInterface $dataFetcher = null) { @@ -69,7 +80,9 @@ public function format(?DataFetcherInterface $dataFetcher = null) } /** - * @return string|null + * @return string + * + * @phpstan-return class-string> */ public function getCollectionClassName() { @@ -78,6 +91,8 @@ public function getCollectionClassName() /** * @return \Propel\Runtime\Collection\OnDemandCollection + * + * @phpstan-return TColl */ public function getCollection() { @@ -98,6 +113,8 @@ public function getCollection() * @param array $row associative array with data * * @return \Propel\Runtime\ActiveRecord\ActiveRecordInterface + * + * @phpstan-return T */ public function getAllObjectsFromRow($row) { diff --git a/src/Propel/Runtime/Formatter/SimpleArrayFormatter.php b/src/Propel/Runtime/Formatter/SimpleArrayFormatter.php index 499976b362..88a94d18c0 100644 --- a/src/Propel/Runtime/Formatter/SimpleArrayFormatter.php +++ b/src/Propel/Runtime/Formatter/SimpleArrayFormatter.php @@ -18,6 +18,10 @@ * or an array * * @author Benjamin Runnels + * + * @phpstan-template T of ActiveRecordInterface + * @phpstan-template TColl of \Propel\Runtime\Collection\ArrayCollection + * @phpstan-extends AbstractFormatter */ class SimpleArrayFormatter extends AbstractFormatter { diff --git a/src/Propel/Runtime/Map/TableMap.php b/src/Propel/Runtime/Map/TableMap.php index 5175239d5d..31f1144d55 100644 --- a/src/Propel/Runtime/Map/TableMap.php +++ b/src/Propel/Runtime/Map/TableMap.php @@ -20,6 +20,8 @@ * @author John D. McNally (Torque) * @author Daniel Rall (Torque) * @author William Durand + * + * @phpstan-template T of \Propel\Runtime\ActiveRecord\ActiveRecordInterface */ class TableMap { @@ -92,6 +94,7 @@ class TableMap * The ClassName for this table * * @var string + * @phpstan-var class-string */ protected $classname; @@ -260,6 +263,8 @@ public function getPhpName() * Set the ClassName of the Table. Could be useful for calling * tableMap and Object methods dynamically. * + * @phpstan-param class-string $classname + * * @param string $classname The ClassName * * @return void @@ -282,6 +287,8 @@ public function getClassName() /** * Get the Collection ClassName to this table. * + * @phpstan-return class-string<\Propel\Runtime\Collection\ObjectCollection> + * * @return string */ public function getCollectionClassName()