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

setHint returning invalid type #463

Open
fliespl opened this issue Jul 15, 2023 · 2 comments
Open

setHint returning invalid type #463

fliespl opened this issue Jul 15, 2023 · 2 comments

Comments

@fliespl
Copy link

fliespl commented Jul 15, 2023

I am using doctrine/orm 2.14.1 and even though #393 mentions it being fixed I think this was only for setLockMode.

Repro:

                ->getQuery()
                ->setHint(Query::HINT_FORCE_PARTIAL_LOAD, true)
                ->getOneOrNullResult(AbstractQuery::HYDRATE_OBJECT);

Dumped type: mixed

While removing setHint I see proper type.

@ruudk
Copy link
Contributor

ruudk commented Nov 30, 2023

I have the same issue. It's related to setHint.

In doctrine/orm#10238 they only fix it for setHydrationMode.

I think because \Doctrine\ORM\Query::setHint inherits from \Doctrine\ORM\AbstractQuery::setHint. On the parent, it does do @return $this. But somehow PHPStan doesn't understand the {@inheritDoc} on the Query.

https://github.com/doctrine/orm/blob/212edaa80bf0669da6ccd7b4697d696e1ffceac8/lib/Doctrine/ORM/Query.php#L747-L755

https://github.com/doctrine/orm/blob/212edaa80bf0669da6ccd7b4697d696e1ffceac8/lib/Doctrine/ORM/AbstractQuery.php#L1023-L1036

When I manually add it to \Doctrine\ORM\Query::setHint it does work.

@VincentLanglet Do you know what this could be? Should I create a PR for doctrine/orm where we change \Doctrine\ORM\Query::setHint to this?

 /**
  * {@inheritDoc}
+ *
+ * @return $this
  */
 public function setHint($name, $value): self
 {
     $this->state = self::STATE_DIRTY;

     return parent::setHint($name, $value);
 }

Or is there some interference somewhere else? Maybe a stub inside this repository?

@VincentLanglet
Copy link
Contributor

I think because \Doctrine\ORM\Query::setHint inherits from \Doctrine\ORM\AbstractQuery::setHint. On the parent, it does do @return $this. But somehow PHPStan doesn't understand the {@inheritDoc} on the Query.

doctrine/orm@212edaa/lib/Doctrine/ORM/Query.php#L747-L755

doctrine/orm@212edaa/lib/Doctrine/ORM/AbstractQuery.php#L1023-L1036

When I manually add it to \Doctrine\ORM\Query::setHint it does work.

@VincentLanglet Do you know what this could be? Should I create a PR for doctrine/orm where we change \Doctrine\ORM\Query::setHint to this?

No idea, @ondrejmirtes certainly know better about such phpdoc interferences

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants