Automated Drupal 11 compatibility fixes for entity_embed

Created on 17 March 2024, 11 months ago

Problem/Motivation

Hello project maintainers,

This is an automated issue to help make this module compatible with Drupal 11.

Changes will periodically be added to this issue that remove deprecated API uses. To stop further changes from being posted, change the status to anything other than Active, Needs review, Needs work or Reviewed and tested by the community. Alternatively, you can remove the "ProjectUpdateBotD11" tag from the issue to stop the bot from posting updates.

The changes will be posted by the Project Update Bot official user account. This account will not receive any issue credit contributions for itself or any company.

Proposed resolution

You have a few options for how to use this issue:

  1. Accept automated changes until this issue is closed

    If this issue is left open (status of Active, Needs review, Needs work or Reviewed and tested by the community) and the "ProjectUpdateBotD11" tag is left on this issue, new changes will be posted periodically if new deprecation fixes are needed.

    As the Drupal Rector project improves and is able to fix more deprecated API uses, the changes posted here will cover more of the deprecated API uses in the module.

    Patches and/or merge requests posted by others are ignored by the bot, and general human interactions in the issue do not stop the bot from posting updates, so feel free to use this issue to refine bot changes. The bot will still post new changes then if there is a change in the new generated patch compared to the changes that the bot posted last. Those changes are then up to humans to integrate.

  2. Leave open but stop new automated changes.

    If you want to use this issue as a starting point to remove deprecated API uses but then don't want new automated changes, remove the "ProjectUpdateBotD11" tag from the issue and use it like any other issue (the status does not matter then). If you want to receive automated changes again, add back the "ProjectUpdateBotD11" tag.

  3. Close it and don't use it

    If the maintainers of this project don't find this issue useful, they can close this issue (any status besides Active, Needs review, Needs work and Reviewed and tested by the community) and no more automated changes will be posted here.

    If the issue is reopened, then new automated changes will be posted.

    If you are using another issue(s) to work on Drupal 11 compatibility it would be very useful to other contributors to add those issues as "Related issues" when closing this issue.

Remaining tasks

Using the patches

  1. Apply the latest patch in the comments by Project Update Bot or human contributors that made it better.
  2. Thoroughly test the patch. These patches are automatically generated so they haven't been tested manually or automatically.
  3. Provide feedback about how the testing went. If you can improve the patch, post an updated patch here.

Using the merge request

  1. Review the merge request and test it.
  2. Thoroughly test the changes. These changes are automatically generated so they haven't been tested manually or automatically.
  3. Provide feedback about how the testing went. If you can improve the merge request, create a new branch and merge request and work from there.

Warning: The 'project-update-bot-only' branch will always be overwritten. Do not work in that branch!

Providing feedback

If there are problems with one of the changes posted by the Project Update Bot , such as it does not correctly replace a deprecation, you can file an issue in the Drupal Rector issue queue . For other issues with the bot, for instance if the issue summary created by the bot is unclear, use the Project analysis issue queue .

📌 Task
Status

Needs review

Version

1.5

Component

Code

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @project update bot
  • This is an automated patch generated using Upgrade Status and Drupal Rector. Please see the issue summary for more details. A merge request is also openend and updated.

    It is important that any automated tests available are run and that you manually test the changes.

    Drupal 11 Compatibility

    According to the Upgrade Status module , even with these changes, this module is not yet compatible with Drupal 11.

    Currently Drupal Rector, version 0.20.1, cannot fix all Drupal 11 compatibility problems.

    Therefore these changes did not update the info.yml file for Drupal 11 compatibility.

    Leaving this issue open, even after committing the current patch, will allow the Project Update Bot to post additional Drupal 11 compatibility fixes as they become available in Drupal Rector.

    Debug info

    Bot run #11-121090

    This patch was created using these packages:

    1. drupal/upgrade_status: 4.1.0
    2. mglaman/phpstan-drupal: 1.2.7
    3. palantirnet/drupal-rector: 0.20.1
  • Pipeline finished with Failed
    11 months ago
    Total: 899s
    #121487
  • This comment was forced and has ignored the check if a change was already posted. This is only done when we want to update the issue without waiting for changes to happen.

    This is an automated patch generated using Upgrade Status and Drupal Rector. Please see the issue summary for more details. A merge request (MR) is also openend and updated.

    It is important that any automated tests available are run and that you manually test the changes.

    Drupal 11 Compatibility

    According to the Upgrade Status module , even with these changes, this module is not yet compatible with Drupal 11.

    Currently Drupal Rector, version 0.20.1, cannot fix all Drupal 11 compatibility problems.

    Therefore, these changes did not update the info.yml file for Drupal 11 compatibility.

    The compatibility issues that Upgrade Status found after the Drupal Rector fixes were applied are attached to help you resolve them manually.

    Leaving this issue open, even after committing the current patch or merging the MR, will allow the Project Update Bot to post additional Drupal 11 compatibility fixes as they become available in Drupal Rector.

    Debug information

    Bot run #11-137198

    These packages were used to generate the fixes:

    1. drupal/upgrade_status: 4.1.0
    2. mglaman/phpstan-drupal: 1.2.10
    3. palantirnet/drupal-rector: 0.20.1
  • Pipeline finished with Failed
    11 months ago
    Total: 876s
    #137588
  • 🇭🇺Hungary Balu Ertl Budapest 🇪🇺

    Balu Ertl made their first commit to this issue’s fork.

  • 🇭🇺Hungary Balu Ertl Budapest 🇪🇺

    Balu Ertl changed the visibility of the branch project-update-bot-only to hidden.

  • Pipeline finished with Canceled
    8 months ago
    Total: 67s
    #199015
  • Pipeline finished with Failed
    8 months ago
    Total: 769s
    #199016
  • 🇭🇺Hungary Balu Ertl Budapest 🇪🇺

    Based on the answers on this Slack thread, I have the conclusion that it's not strictly necessary to rely on the DeprecationHelper::backwardsCompatibleCall() utility. I assume the module maintainers probably still plan to continue supporting D9, in which this deprecation handling solution was not present yet and thus would have no effect anyway.

    Albeit the change record about the deprecation of watchdog_exception() suggests using \Drupal\Core\Utility\Error::logException() but for me it still seems to be just another wrapper around the \Drupal\Core\Logger\LoggerChannel::log().

    Therefore I simplified exception logging with a more informative solution I peeked from core's \Drupal\Core\EventSubscriber\DefaultExceptionHtmlSubscriber::makeSubrequest().

  • 🇭🇺Hungary Balu Ertl Budapest 🇪🇺

    Reviewed and tested (module install, configuring, trying out, uninstalling) on a D11-beta1 site, found working as expected:

  • Pipeline finished with Failed
    8 months ago
    Total: 850s
    #199289
  • This is an automated patch generated using Upgrade Status and Drupal Rector. Please see the issue summary for more details. A merge request (MR) is also openend and updated.

    It is important that any automated tests available are run and that you manually test the changes.

    Drupal 11 Compatibility

    According to the Upgrade Status module , even with these changes, this module is not yet compatible with Drupal 11.

    Currently Drupal Rector, version 0.20.3, cannot fix all Drupal 11 compatibility problems.

    Therefore, these changes did not update the info.yml file for Drupal 11 compatibility.

    The compatibility issues that Upgrade Status found after the Drupal Rector fixes were applied are attached to help you resolve them manually.

    Leaving this issue open, even after committing the current patch or merging the MR, will allow the Project Update Bot to post additional Drupal 11 compatibility fixes as they become available in Drupal Rector.

    Debug information

    Bot run #11-199781

    These packages were used to generate the fixes:

    1. drupal/upgrade_status: 4.3.2
    2. mglaman/phpstan-drupal: 1.2.11
    3. palantirnet/drupal-rector: 0.20.3
  • Pipeline finished with Failed
    8 months ago
    Total: 918s
    #201411
  • Status changed to Needs work 8 months ago
  • 🇺🇸United States japerry KVUO

    The tests are failing in head, but its possible thats due to current incompatibilities, which would be made worse with D11 support. Those should get fixed before this gets committed.

  • Status changed to Postponed 8 months ago
  • 🇭🇺Hungary Balu Ertl Budapest 🇪🇺

    I believe the MR of 📌 Fix tests Needs review should be included first before we move forward with this one.

  • Pipeline finished with Failed
    8 months ago
    Total: 810s
    #219883
  • Pipeline finished with Failed
    8 months ago
    Total: 793s
    #219900
  • Status changed to Needs review 8 months ago
  • 🇭🇺Hungary Balu Ertl Budapest 🇪🇺

    Drupal Rector still suggests one point to fix:


    As discussed today with @japerry , we agreed this could be ignored because there is a @todo comment above the line communicating this should be fixed eventually in the future. So setting ticket status back to Needs Review.

  • This is an automated patch generated using Upgrade Status and Drupal Rector. Please see the issue summary for more details. A merge request (MR) is also openend and updated.

    It is important that any automated tests available are run and that you manually test the changes.

    Drupal 11 Compatibility

    According to the Upgrade Status module , even with these changes, this module is not yet compatible with Drupal 11.

    Currently Drupal Rector, version 0.20.3, cannot fix all Drupal 11 compatibility problems.

    Therefore, these changes did not update the info.yml file for Drupal 11 compatibility.

    The compatibility issues that Upgrade Status found after the Drupal Rector fixes were applied are attached to help you resolve them manually.

    Leaving this issue open, even after committing the current patch or merging the MR, will allow the Project Update Bot to post additional Drupal 11 compatibility fixes as they become available in Drupal Rector.

    Debug information

    Bot run #11-223311

    These packages were used to generate the fixes:

    1. drupal/upgrade_status: 4.3.4
    2. mglaman/phpstan-drupal: 1.2.11
    3. palantirnet/drupal-rector: 0.20.3
  • Pipeline finished with Failed
    7 months ago
    Total: 804s
    #225043
  • 🇭🇺Hungary Balu Ertl Budapest 🇪🇺

    Balu Ertl changed the visibility of the branch 8.x-1.x to hidden.

  • Pipeline finished with Failed
    7 months ago
    Total: 890s
    #225628
  • 🇺🇦Ukraine yuriy.korzhov

    Patch including rector's fixes from entity_embed.1.x-dev.rector.patch and info file fix.

  • 🇭🇺Hungary Balu Ertl Budapest 🇪🇺

    @ukor thanks for contributing code. This issue already has an open merge request. Would you mind committing the content of your patch file onto the feature branch of this issue repository, please? This would make this issue solved earlier by easing the module maintainer's job of reviewing changes. Thanks in advance!

  • 🇺🇦Ukraine evgen

    Could not apply patch MR 36.

  • First commit to issue fork.
  • Merge request !47Resolve #3430164 "D11 readiness" → (Merged) created by ankitv18
  • Pipeline finished with Canceled
    4 months ago
    Total: 184s
    #308871
  • Pipeline finished with Failed
    4 months ago
    Total: 478s
    #308872
  • Pipeline finished with Failed
    4 months ago
    Total: 448s
    #309359
  • Pipeline finished with Canceled
    4 months ago
    Total: 110s
    #309373
  • Pipeline finished with Failed
    4 months ago
    Total: 318s
    #309374
  • Pipeline finished with Failed
    4 months ago
    Total: 80s
    #309390
  • Pipeline finished with Failed
    4 months ago
    Total: 75s
    #309417
  • Pipeline finished with Failed
    4 months ago
    Total: 224s
    #309422
  • Pipeline finished with Failed
    4 months ago
    Total: 221s
    #309439
  • Pipeline finished with Failed
    4 months ago
    Total: 239s
    #309442
  • Pipeline finished with Failed
    4 months ago
    Total: 290s
    #309575
  • Pipeline finished with Failed
    4 months ago
    Total: 292s
    #309592
  • Pipeline finished with Running
    4 months ago
    #310530
  • Pipeline finished with Failed
    4 months ago
    Total: 673s
    #311104
  • Merge request !50Automated D11 compatibility → (Closed) created by abhinavk
  • Pipeline finished with Failed
    4 months ago
    Total: 310s
    #315931
  • First commit to issue fork.
  • Merge request !51Automated D11 compatibility → (Open) created by abhinavk
  • Pipeline finished with Failed
    4 months ago
    Total: 755s
    #315973
  • Pipeline finished with Failed
    4 months ago
    Total: 415s
    #316010
  • Pipeline finished with Failed
    4 months ago
    Total: 485s
    #316023
  • 🇮🇳India ankitv18

    ankitv18 changed the visibility of the branch 3430164-d11_ready to hidden.

  • Pipeline finished with Failed
    4 months ago
    Total: 504s
    #316047
  • Pipeline finished with Canceled
    4 months ago
    Total: 77s
    #317456
  • Pipeline finished with Failed
    4 months ago
    Total: 954s
    #317457
  • Pipeline finished with Failed
    4 months ago
    Total: 347s
    #318132
  • Pipeline finished with Success
    4 months ago
    Total: 208s
    #318139
  • 🇬🇧United Kingdom Ok4p1 Glasgow

    I get the following error after trying to use the latest MR. Drupal 10.3.8.

    Error: Call to undefined method Drupal\embed\EmbedType\EmbedTypeBase::create() in Drupal\entity_embed\Plugin\EmbedType\Entity::create() (line 56 of modules/contrib/entity_embed/src/Plugin/EmbedType/Entity.php).

  • 🇮🇳India rahul1707

    Tested MR !47 changes in Drupal 10.3 and Drupal 11, functionality is working fine for me.
    Changing status to RTBC.

  • 🇮🇳India ankitv18

    ankitv18 changed the visibility of the branch 3430164-automated-drupal-11 to hidden.

  • 🇺🇸United States phenaproxima Massachusetts

    The comment from #27 is concerning and suggests that there may have been a backwards compatibility break here - can we look into that, please?

  • Status changed to Postponed 3 months ago
  • heddn Nicaragua

    embed.module support for D11 got rolled back. We'll need to wait on https://www.drupal.org/project/embed/issues/3430097 📌 Automated Drupal 11 compatibility fixes for embed Needs review to land first. I'm way down the line in https://www.drupal.org/project/media_migration/issues/3431903 📌 Automated Drupal 11 compatibility fixes for media_migration Needs review waiting for this to land. So hopefully the upstream issues land soonish.

  • 🇬🇧United Kingdom Ok4p1 Glasgow

    Hello, you can disregard my previous message. I realized that I wasn’t using the latest D11 patch from the embed module. Once I updated it, the error disappeared, and I have been using the patch from this ticket in production since then, with no issues.

  • 🇩🇪Germany Anybody Porta Westfalica

    See #31

  • First commit to issue fork.
  • Pipeline finished with Failed
    about 2 months ago
    Total: 162s
    #387864
  • 🇦🇺Australia acbramley

    This is testing against 8.x-1.8 which is the D11 compatible release that was rolled back.

    📌 Automated Drupal 11 compatibility fixes for embed Needs review now has a minimal MR that does not include the addition of EmbedTypeBase::create meaning we can't call parent::create. This looks like the MR that will eventually be committed.

    We need to figure out how to run tests against a patched version of embed 8.x-1.9 using that MR.

  • Pipeline finished with Failed
    about 2 months ago
    Total: 201s
    #387889
  • Pipeline finished with Failed
    about 2 months ago
    Total: 212s
    #387895
  • Pipeline finished with Success
    about 2 months ago
    Total: 239s
    #387897
  • 🇨🇦Canada joseph.olstad

    the MR for embed was merged however we're still waiting for a tagged release.

  • 🇺🇸United States phenaproxima Massachusetts

    Done.

  • 🇺🇸United States phenaproxima Massachusetts

    This needs significant work; I'm seeing many changes that appear to be unrelated to Drupal 11 compatibility. For reference:

    • Let's deprecate CKEditor 4 support, but not remove it.
    • Let's not add any new code or do any refactoring beyond what's needed for Drupal 11 compatibility.

    Godspeed!

  • 🇨🇦Canada joseph.olstad

    ck4 tests won't pass in D11

  • 🇺🇸United States phenaproxima Massachusetts

    Then add something like this to them in setUp():

    if (version_compare(\Drupal::VERSION, 10, '>')) {
      $this->markTestSkipped('This test will not run on Drupal 11 because CKEditor 4 is no longer supported.');
    }
    
  • 🇨🇦Canada joseph.olstad

    New branch and minimum release ^11 would prevent D10 installs from having ck4 issues.

  • Pipeline finished with Success
    about 1 month ago
    Total: 195s
    #404180
  • Pipeline finished with Success
    about 1 month ago
    Total: 193s
    #404193
  • 🇦🇺Australia acbramley

    I believe everything is actioned, and the pipeline's green.

  • 🇨🇭Switzerland znerol

    It looks like changes in JavaScript source files have been reverted. I think that js/build/drupalentity.js should be reverted as well.

  • 🇨🇭Switzerland znerol

    On the general approach: I think it is quite risky to attempt to convert all tests from cke4 to cke5 in this issue. It looks like some people are thinking that it is impossible to run cke4 tests in D11. Luckily this is not true, i.e., it is in fact possible to run tests against cke4 in D11.

    In order to do that, the following is needed:

    • Specify _LENIENT_ALLOW_LIST: "ckeditor" in .gitlab-ci.yml
    • Add a before_script which unconditionally patches all contrib modules so as to make them installable in the current core version.

    An example of this approach can be found in .gitlab-ci.yml of Entity Browser which has had D11 releases for weeks even though embed and entity embed were still lacking D11 support.

    I propose to try this here as well.

  • 🇨🇦Canada joseph.olstad

    @znerol , changes were made also to core in D11 relating to the editor module and ck4. I wanted to run ck4 in D11 but I saw the core changes and decided to switch to ck5 (for better or for worse) due to the core and contrib complexity involved and the fact that ck4 might be dropped from contrib also. So even if I was to fork ckeditor and upgrade it to D11, I asked myself what the likelihood that ck4 was still intact in contrib and decided that it was a pretty risky adventure to embark on. So far we've got ck5 working ok although we did have to sacrifice some functionality like html filtering and one contrib modules widget.

  • 🇯🇴Jordan Rajab Natshah Jordan

    Hoping for a tag release soon to ease and speed up testing and updates in projects.
    Maybe a new 2.0.x branch can help with CKE5 only supported version, keeping the 8.x-1.x branch with minimal support for CKE4

  • 🇨🇦Canada joseph.olstad

    @rajab natshah , I 100% agree with your comment in #48

    Enough with the dipsy doodling, for those ACTUALLY using Drupal 11, only ckeditor 5 makes sense. Forget ck4 in Drupal 11, it's a non-starter.

  • Pipeline finished with Success
    27 days ago
    Total: 205s
    #407718
  • Pipeline finished with Success
    27 days ago
    Total: 193s
    #407723
  • Assigned to znerol
  • Status changed to Needs review 24 days ago
  • 🇨🇭Switzerland znerol

    Working on the tests in order to minimize the amount of coverage loss.

  • Pipeline finished with Failed
    24 days ago
    Total: 302s
    #410367
  • Pipeline finished with Success
    24 days ago
    Total: 323s
    #410419
  • Pipeline finished with Failed
    24 days ago
    Total: 317s
    #410492
  • Pipeline finished with Failed
    24 days ago
    Total: 312s
    #410500
  • Pipeline finished with Failed
    24 days ago
    Total: 517s
    #410508
  • Pipeline finished with Failed
    24 days ago
    Total: 417s
    #410563
  • Pipeline finished with Failed
    24 days ago
    Total: 297s
    #410585
  • Pipeline finished with Success
    24 days ago
    Total: 342s
    #410605
  • Pipeline finished with Running
    24 days ago
    #410614
  • 🇨🇭Switzerland znerol

    This is good to go. There is one weird test fail in phpunit (previous minor). I'd probably just ignore it for the moment.

    This module needs a big effort to increase functional JavaScript test coverage for CKEditor5. I wouldn't attempt to convert the existing tests. Just write new ones for the new editor and leave the old ones there for reference until CKE4 support is removed completely. That work needs to happen in another issue though.

  • 🇨🇦Canada joseph.olstad

    Great job, thank you very much!

    To resolve the test issue, just adjust the core requirements:

    ^10.4 || ^11.1

    There's no need to support 10.3 for much longer anyway.

    Tests are currently passing on 10.4 and 11.1.1

  • 🇨🇭Switzerland znerol

    Removed OPT_IN_TEST_PREVIOUS_MINOR from .gitlab-ci.yml.

  • Pipeline finished with Success
    24 days ago
    Total: 590s
    #410670
  • 🇦🇺Australia acbramley

    There's no need to support 10.3 for much longer anyway.

    Security support is for another 4 months, there's no harm in keeping it here.

  • Pipeline finished with Success
    23 days ago
    Total: 486s
    #410987
  • 🇺🇸United States phenaproxima Massachusetts

    A few questions on the MR, which I've left comments for.

    My main concern here is that most of the CI jobs are actually failing: https://git.drupalcode.org/issue/entity_embed-3430164/-/pipelines/410987. Too many for comfort.

    The ones I'm most concerned about are:

    The other stuff would be fine to fix in follow-ups.

  • 🇨🇦Canada joseph.olstad

    @phenaproxima , next minor and next major have not been released yet. It is completely normal that they could be failing at this point in time. We should focus on 10.4 and 11.1 and if ambitious 10.3 and 11.0.

  • 🇨🇭Switzerland berdir Switzerland

    I was considering to suggest to disable those jobs earlier, especially php max (which is PHP 8.4 now), but yeah, they are definitely not in scope of this issue.

    About phpstan, anything that isn't clearly a D11 thing should IMHO also be ignored here. For one I opened an issue because that's IMHO not correct: https://github.com/mglaman/phpstan-drupal/issues/824.

  • 🇨🇭Switzerland znerol

    So, the test fail in phpunit (next minor) is in fact really interesting. MediaImageDecorator::build() attempts to pass the alt and title attribute values into the referenced entity image / thumbnail.

    This worked well until 🐛 Referring the same entity multiple times breaks _referringItem Active fixed a corner case by introducing a clone $entity which is triggered during parent::build(). As a result, $build['#media'] and $this->decorated->getEntityFromContext(); are not referring to the same object anymore. Modifications to the latter do not have any effect anymore.

    When I revert core commit 40c1ab52 tests are passing.

  • Pipeline finished with Success
    22 days ago
    Total: 644s
    #412244
  • 🇨🇭Switzerland znerol

    Found a way to refresh the entity context value.

  • 🇨🇦Canada joseph.olstad

    Great sleuthing on the next minor fix @znerol ! that core commit happened only about 9 days ago

  • 🇨🇭Switzerland znerol

    Looking at failing phpunit (max PHP version) now.

    A lot of noise is due to one line in EntityEmbedDialog.php, lets get rid of that:

        Deprecated: Drupal\entity_embed\Form\EntityEmbedDialog::buildForm(): Implicitly marking parameter $editor as nullable is deprecated, the explicit nullable type must be used instead in /builds/issue/entity_embed-3430164/src/Form/EntityEmbedDialog.php on line 183
        
        Deprecated: Drupal\entity_embed\Form\EntityEmbedDialog::buildForm(): Implicitly marking parameter $embed_button as nullable is deprecated, the explicit nullable type must be used instead in /builds/issue/entity_embed-3430164/src/Form/EntityEmbedDialog.php on line 183
  • Pipeline finished with Success
    21 days ago
    Total: 502s
    #412473
  • Pipeline finished with Success
    21 days ago
    Total: 462s
    #412481
  • 🇨🇭Switzerland znerol

    Looks like phpunit (max PHP version) was failing because of PHP8.4 deprecations around implicit nullable type hints. All phpunit jobs are green now.

  • Pipeline finished with Success
    21 days ago
    #412483
  • 🇨🇭Switzerland znerol

    Fixed the phpstan jobs as well. The phpstan.neon config is based on the official drupal ci template.

    Additionally it ignores CKEditor 4 plugin paths. I also added a phpstan baseline in order to suppress the following non-D11 related isues:

    1. \Drupal calls should be avoided in classes, use dependency injection instead
    2. config:entity_view_mode_list cache tag might be unclear and does not contain the cache key in it. (see #58.
  • Pipeline finished with Success
    21 days ago
    Total: 923s
    #412498
  • 🇨🇭Switzerland znerol

    Note that EntityEmbedHooksTest randomly fails in any of the phpstan jobs. This is most probably due to its reliance on state to activate the hook in the test module (see 🐛 Race conditions/bad lock logic in CacheCollector/State Active ).

  • 🇺🇸United States phenaproxima Massachusetts

    Thanks for this effort @znerol! And thanks for explaining some of the test changes.

    I think I'm mostly okay with this, but we probably shouldn't change parameter types in base classes (I'm okay with it in forms -- those shouldn't be subclassed anyway) since that would violate PHP's contravariance rules, IIRC. I know that restoring them would cause some deprecation notices but if it's just those, I think that's worthwhile in order to not break this module for people who might have subclassed it.

  • 🇨🇭Switzerland berdir Switzerland

    Adding ? is not a type change, it's fine to add this.

  • 🇺🇸United States phenaproxima Massachusetts

    OK, I took a look at the original PHP 7.1 RFC for nullable types: https://wiki.php.net/rfc/nullable_types, and I think you're probably right. Quoting:

    Because a parameter with = null is a superset of ?, you can use a parameter with a default value of null where a nullable type existed in the parent.

    interface Contract {
        function method(?Foo $foo): bool;
    }
     
    class Implementation implements Contract {
        function method(?Foo $foo = null): bool {
            return is_null($foo);
        }
    }

    The reverse is not true, however: you cannot use only a nullable type where a default value existed in the parent, because the parameter is no longer optional.

    If I understand this correctly, ?Type = NULL (which is what will be in the parent) and Type = NULL (which is what will be in any subclasses) are considered compatible by PHP.

    So okay...I think that addresses my concerns. Let's ship it.

  • Pipeline finished with Skipped
    21 days ago
    #412626
  • 🇺🇸United States phenaproxima Massachusetts

    Merged into 8.x-1.x and will tag shortly. Thanks, everyone.

  • 🇦🇺Australia acbramley

    Great work everyone 💪

  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024