Problem/Motivation
On #3485896: Hook ordering across OOP, procedural and with extra types i.e replace hook_module_implements_alter it was suggested making the following change on the Hook attribute, but in initial review phpstan failed. Back then, it was something like OrderBefore|OrderAfter|null and ? doesn't work with multiple types. But now that we've got OrderInterface and that's the only option, the ? works just fine.
Steps to reproduce
Proposed resolution
- public OrderInterface|null $order = NULL,
+ public ?OrderInterface $order = NULL,
Remaining tasks
User interface changes
Introduced terminology
API changes
None, these are equivalent type specifications. This is basically just a code style change.
Data model changes
Release notes snippet
Issue fork drupal-3521612
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
- 3521612-explore-type-hinting
changes, plain diff MR !12069
Comments
Comment #2
nicxvan commentedComment #4
donquixote commentedThis is a code style change, fully equivalent to original code (except support for some old php versions), so it does not really tighten anything.
Changing title.
In general I am ok with this change.
Comment #5
dwwI made the same suggestion at #3523159: Add order parameter to FormAlter attribute so +1 for me. Will RTBC when the pipeline is green.
x-posted a title change, but thankfully d.o prevented that. 😅 Even more accurate title now. 😂
Comment #6
dwwPipeline is now green. Trivial change. Summary and title are clear.
Comment #7
dwwSaving credit for everyone.
Comment #8
dwwEven more clear summary. 😅
Comment #10
larowlanCommitted to 11.x and pushed.
Glad I'm wasn't going mad when I questioned this during review. That issue already had me questioning my 25 years of PHP experience with its use of array_is_list and array_replace, two functions I'd never used before.
Comment #12
dwwThanks!