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

Precise phpdoc of getRootEntities #9778

Merged
merged 3 commits into from
May 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 5 additions & 5 deletions lib/Doctrine/ORM/Query/Expr/From.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*/
class From
{
/** @var string */
/** @var class-string */
protected $from;

/** @var string */
Expand All @@ -21,9 +21,9 @@ class From
protected $indexBy;

/**
* @param string $from The class name.
* @param string $alias The alias of the class.
* @param string $indexBy The index for the from.
* @param class-string $from The class name.
derrabus marked this conversation as resolved.
Show resolved Hide resolved
* @param string $alias The alias of the class.
* @param string $indexBy The index for the from.
*/
public function __construct($from, $alias, $indexBy = null)
{
Expand All @@ -33,7 +33,7 @@ public function __construct($from, $alias, $indexBy = null)
}

/**
* @return string
* @return class-string
*/
public function getFrom()
{
Expand Down
27 changes: 19 additions & 8 deletions lib/Doctrine/ORM/QueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -400,8 +400,10 @@ public function getRootAliases(): array
foreach ($this->dqlParts['from'] as &$fromClause) {
if (is_string($fromClause)) {
$spacePos = strrpos($fromClause, ' ');
$from = substr($fromClause, 0, $spacePos);
$alias = substr($fromClause, $spacePos + 1);

/** @psalm-var class-string $from */
$from = substr($fromClause, 0, $spacePos);
$alias = substr($fromClause, $spacePos + 1);

$fromClause = new Query\Expr\From($from, $alias);
}
Expand Down Expand Up @@ -434,7 +436,7 @@ public function getAllAliases(): array
}

/**
* Gets the root entities of the query. This is the entity aliases involved
* Gets the root entities of the query. This is the entity classes involved
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤔 maybe this was referring to the deprecated but still existing class alias feature? #8818

I don't know if those are resolved at that point.

* in the construction of the query.
*
* <code>
Expand All @@ -446,7 +448,7 @@ public function getAllAliases(): array
* </code>
*
* @return string[]
* @psalm-return list<string>
* @psalm-return list<class-string>
*/
public function getRootEntities(): array
{
Expand All @@ -455,8 +457,10 @@ public function getRootEntities(): array
foreach ($this->dqlParts['from'] as &$fromClause) {
if (is_string($fromClause)) {
$spacePos = strrpos($fromClause, ' ');
$from = substr($fromClause, 0, $spacePos);
$alias = substr($fromClause, $spacePos + 1);

/** @psalm-var class-string $from */
$from = substr($fromClause, 0, $spacePos);
$alias = substr($fromClause, $spacePos + 1);

$fromClause = new Query\Expr\From($from, $alias);
}
Expand Down Expand Up @@ -725,8 +729,8 @@ public function addSelect(mixed ...$select): static
* ->setParameter('user_id', 1);
* </code>
*
* @param string|null $delete The class/type whose instances are subject to the deletion.
* @param string|null $alias The class/type alias used in the constructed query.
* @param class-string|null $delete The class/type whose instances are subject to the deletion.
* @param string|null $alias The class/type alias used in the constructed query.
*
* @return $this
*/
Expand All @@ -752,6 +756,9 @@ public function delete(?string $delete = null, ?string $alias = null): static
* ->where('u.id = ?2');
* </code>
*
* @param class-string|null $update The class/type whose instances are subject to the update.
* @param string|null $alias The class/type alias used in the constructed query.
*
* @return $this
*/
public function update(?string $update = null, ?string $alias = null): static
Expand All @@ -775,6 +782,10 @@ public function update(?string $update = null, ?string $alias = null): static
* ->from('User', 'u');
* </code>
*
* @param class-string $from The class name.
* @param string $alias The alias of the class.
* @param string|null $indexBy The index for the from.
*
* @return $this
*/
public function from(string $from, string $alias, ?string $indexBy = null): static
Expand Down