Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add phpstan template annotations to collection/criteria lib objects #1657

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
126 changes: 88 additions & 38 deletions phpstan-baseline.neon

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -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\\(\\)\\.$#"
Expand Down
26 changes: 26 additions & 0 deletions src/Propel/Runtime/ActiveQuery/BaseModelCriteria.php
Original file line number Diff line number Diff line change
Expand Up @@ -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<T>
*/
protected $modelName;

/**
* @var string|null
* @phpstan-var class-string<\Propel\Runtime\Map\TableMap<T>>
*/
protected $modelTableMapName;

Expand All @@ -35,6 +42,8 @@ class BaseModelCriteria extends Criteria implements IteratorAggregate

/**
* @var \Propel\Runtime\Map\TableMap
*
* @phpstan-var \Propel\Runtime\Map\TableMap<T>
*/
protected $tableMap;

Expand Down Expand Up @@ -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<T> $modelName
*/
public function __construct($dbName = null, $modelName = null, $modelAlias = null)
{
Expand Down Expand Up @@ -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<T, AColl, AReturn>|class-string<\Propel\Runtime\Formatter\AbstractFormatter> $formatter
* @phpstan-return $this<T, AColl, AReturn>
*/
public function setFormatter($formatter)
{
Expand Down Expand Up @@ -147,6 +163,8 @@ public function getFormatter()
/**
* Returns the name of the class for this model criteria
*
* @phpstan-return class-string<T>
*
* @return string
*/
public function getModelName()
Expand All @@ -158,6 +176,8 @@ public function getModelName()
* Sets the model name.
* This also sets `this->modelTableMapName` and `this->tableMap`.
*
* @phpstan-param class-string<T> $modelName
*
* @param string $modelName
*
* @return $this The current object, for fluid interface
Expand All @@ -180,6 +200,8 @@ public function setModelName($modelName)
}

/**
* @phpstan-return class-string<T>
*
* @return string
*/
public function getFullyQualifiedModelName()
Expand Down Expand Up @@ -240,6 +262,8 @@ public function getModelShortName()
/**
* Returns the TableMap object for this Criteria
*
* @phpstan-return \Propel\Runtime\Map\TableMap<T>
*
* @return \Propel\Runtime\Map\TableMap
*/
public function getTableMap()
Expand All @@ -254,6 +278,8 @@ public function getTableMap()
* constructed on a Propel\Runtime\Collection\PropelCollection.
* Compulsory for implementation of \IteratorAggregate.
*
* @phpstan-return \Traversable<T>
*
* @throws \Propel\Runtime\Exception\LogicException
*
* @return \Traversable
Expand Down
2 changes: 2 additions & 0 deletions src/Propel/Runtime/ActiveQuery/Criteria.php
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,8 @@ class Criteria

/**
* @var \Propel\Runtime\ActiveQuery\Criteria[]
*
* @phpstan-var array<string,\Propel\Runtime\ActiveQuery\Criteria>
*/
protected $selectQueries = [];

Expand Down
Loading