Strict typing in Doctrine\ORM, disconnect Doctrine\Common#7130
Strict typing in Doctrine\ORM, disconnect Doctrine\Common#7130Majkl578 wants to merge 13 commits intodoctrine:masterfrom
Conversation
fd6c6c9 to
ac31815
Compare
| * {@inheritDoc} | ||
| */ | ||
| public function createQuery($dql = '') : Query | ||
| public function createQuery(string $dql = '') : Query |
There was a problem hiding this comment.
While introducing BC breaks for the next major release, should we keep the default empty string? Does it make sense to have that? Or is this part of a later discussion?
There was a problem hiding this comment.
Adding parameter type is not a BC break.
At this time I don't want to change logic or accepted types too much where not needed, otherwise the PR(s) would be pain to review. That's also why I i.e. didn't improve typing for QueryBuilder and parameter binding/types in general.
There was a problem hiding this comment.
Oh, right. Type widening in PHP 7.2. PHP 7.2 will be minimum version. I totally forgot that.
| }, | ||
| "conflict": { | ||
| "phpspec/prophecy": "<1.7.5" | ||
| }, |
There was a problem hiding this comment.
You are blocking potential users of prophecy < 1.7.5 even if they don't intend to test doctrine
There was a problem hiding this comment.
So instead of how requiring it in the require-dev section ?
There was a problem hiding this comment.
Technically legit, but no one is supposed to use dev-master now so it's not a real issue. This is mostly to make CI work with lowest dependencies as well (too bad there is no conflict-dev section).
There was a problem hiding this comment.
It doesn't make any sense to have a conflict-dev, as if you install the dev dependencies, it means you cloned the doctrine repo and working directly on it (you can't install dev dependencies of a dependency...). So making it into the dev section of the requirement and removing the conflict makes sense IMO.
There was a problem hiding this comment.
So instead of how requiring it in the
require-devsection ?
Nope, let's please not do that.
Users will be perfectly fine as long as they upgrade all their dependencies as they should be doing
ostrolucky
left a comment
There was a problem hiding this comment.
Be careful about $hydrationMode, it can be a string for custom hydrators, see here. Yes, int in docblock was wrong all the time.
I've not highlighted all references, it became too much and would just clutter this PR
lib/Doctrine/ORM/AbstractQuery.php
Outdated
| * @return mixed | ||
| */ | ||
| private function executeIgnoreQueryCache($parameters = null, $hydrationMode = null) | ||
| private function executeIgnoreQueryCache(?iterable $parameters = null, ?int $hydrationMode = null) |
There was a problem hiding this comment.
$hydrationMode can be string for custom hydrators
lib/Doctrine/ORM/AbstractQuery.php
Outdated
| * @return mixed | ||
| */ | ||
| public function getResult($hydrationMode = self::HYDRATE_OBJECT) | ||
| public function getResult(int $hydrationMode = self::HYDRATE_OBJECT) |
There was a problem hiding this comment.
$hydrationMode can be string for custom hydrators
lib/Doctrine/ORM/AbstractQuery.php
Outdated
| * @return mixed | ||
| */ | ||
| public function execute($parameters = null, $hydrationMode = null) | ||
| public function execute(?iterable $parameters = null, ?int $hydrationMode = null) |
There was a problem hiding this comment.
$hydrationMode can be string for custom hydrators
lib/Doctrine/ORM/AbstractQuery.php
Outdated
| * @return mixed | ||
| */ | ||
| private function executeUsingQueryCache($parameters = null, $hydrationMode = null) | ||
| private function executeUsingQueryCache(?iterable $parameters = null, ?int $hydrationMode = null) |
There was a problem hiding this comment.
$hydrationMode can be string for custom hydrators
ac31815 to
e004a4e
Compare
|
@ostrolucky Thanks, adressed. Probably something to look into later to remove |
| * | ||
| * @return object | ||
| */ | ||
| public function getEntity() |
There was a problem hiding this comment.
You removed return type annotation without adding return type. Same for following methods in this class
No idea how to make this clearer for readers. |
Errata: I got a better idea here. Let's try this upgrade path:
That's a sufficient |
|
Also: I'm working on |
Initial round of strict typing.
TODO
UPGRADE-STRICT-API.mdwith diff-like list of changes.