-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[DomCrawler] [5.0] add type-hint whenever possible #32329
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
[DomCrawler] [5.0] add type-hint whenever possible #32329
Conversation
e809256
to
c8a3972
Compare
* | ||
* @return array The list of fields as [string] Fully qualified name => (mixed) value) | ||
*/ | ||
private function walk(array $array, $base = '', array &$output = []) | ||
private function walk(array $array, ?string $base = '', array &$output = []) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't ?string
be instead string
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is null
actually allowed ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if we don't allow null, it break lots of test:
TypeError: Argument 2 passed to Symfony\Component\DomCrawler\FormFieldRegistry::walk() must be of the type string, null given, called in /home/hamza/projet/contrib/symfony/src/Symfony/Component/DomCrawler/FormFieldRegistry.php on line 133
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, it means that we need to ensure that $this->base
cannot be null
but an empty string instead. Or we need to change the calling code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can set the default value of $this->base
to an empty string, that's the proposal I've pushed.
* | ||
* @return array The list of fields as [string] Fully qualified name => (mixed) value) | ||
*/ | ||
private function walk(array $array, $base = '', array &$output = []) | ||
private function walk(array $array, ?string $base = '', array &$output = []) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is null
actually allowed ?
c8a3972
to
a4ed068
Compare
* | ||
* @return array The list of fields as [string] Fully qualified name => (mixed) value) | ||
*/ | ||
private function walk(array $array, $base = '', array &$output = []) | ||
private function walk(array $array, ?string $base = '', array &$output = []) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, it means that we need to ensure that $this->base
cannot be null
but an empty string instead. Or we need to change the calling code.
a4ed068
to
580b126
Compare
done @fabpot |
Thank you @Simperfit. |
…erfit) This PR was merged into the 5.0-dev branch. Discussion ---------- [DomCrawler] [5.0] add type-hint whenever possible | Q | A | ------------- | --- | Branch? | 5.0 | Bug fix? | no | New feature? | no <!-- please update src/**/CHANGELOG.md files --> | BC breaks? | no <!-- see https://symfony.com/bc --> | Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Tests pass? | yes <!-- please add some, will be required by reviewers --> | Fixed tickets | Contribute to #32179 <!-- #-prefixed issue number(s), if any --> | License | MIT | Doc PR | none <!-- required for new features --> <!-- Replace this notice by a short README for your feature/bugfix. This will help people understand your PR and can be used as a start for the documentation. Additionally (see https://symfony.com/roadmap): - Bug fixes must be submitted against the lowest maintained branch where they apply (lowest branches are regularly merged to upper ones so they get the fixes too). - Features and deprecations must be submitted against branch 4.4. - Legacy code removals go to the master branch. --> Add type hint to DomCrawler Commits ------- 580b126 [DomCrawler] [5.0] add type-hint whenever possible
Add type hint to DomCrawler