Problem/Motivation

The trait was used for workaround of PHP bug which is fixed since 7.4 https://3v4l.org/5ZJ2i
It has only 2 usages and DTP already has issue #2828835: Drupal DateTime have no render to json_encode
And since PHP 8.0 there's Stringable

Steps to reproduce

Follow-up from #3465827-5: Stop passing E_USER_ERROR to trigger_error() on PHP 8.4

Proposed resolution

- deprecate the trait or wait for 12.x
- fix usage

Remaining tasks

- patch
- review
- commit

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

Issue fork drupal-3548957

Command icon 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:

Comments

andypost created an issue. See original summary.

andypost’s picture

Issue summary: View changes
Issue tags: +PHP 8.0

andypost’s picture

Status: Active » Needs review
smustgrave’s picture

Status: Needs review » Needs work
Issue tags: +Needs change record updates

Can we add a simple before/after snippet to the CR to show how people should update their code who may be using this trait.

chi’s picture

Status: Needs work » Needs review

Updated the change record.

dcam’s picture

Status: Needs review » Needs work

I looked over the MR. I agree with the other comments that were made and left suggestions, so I'm setting to NW. Mainly, that assertTrue() is dead code.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.

andypost’s picture

Status: Needs work » Needs review

rebased

dcam’s picture

Status: Needs review » Reviewed & tested by the community

I don't have any additional feedback. All uses of ToStringTrait have been removed. The change record looks good to me.

amateescu’s picture

Status: Reviewed & tested by the community » Needs work

Very nice cleanup! Left some comments on the MR.

andypost’s picture

Status: Needs work » Needs review

Thank you fixed both

amateescu’s picture

There's a phpstan failure now :/ Feel free to self-rtbc once that's fixed.

andypost’s picture

Status: Needs review » Reviewed & tested by the community

fixed baseline and rebased, now green

  • amateescu committed f14dbcc2 on main
    task: #3548957 Deprecate ToStringTrait
    
    By: andypost
    By: chi
    By: dcam
    By...
amateescu’s picture

Version: main » 11.x-dev
Status: Reviewed & tested by the community » Patch (to be ported)

Committed f14dbcc and pushed to main. Thanks!

We'll need a 11.x MR with a regenerated baseline.

andypost’s picture

Status: Patch (to be ported) » Needs review

rebased but CI wont start

amateescu’s picture

Status: Needs review » Reviewed & tested by the community

Asked for a retest and it's all green.

  • amateescu committed 671cd636 on 11.x
    task: #3548957 Deprecate ToStringTrait
    
    By: andypost
    By: chi
    By: dcam
    By...
amateescu’s picture

Status: Reviewed & tested by the community » Fixed

Committed 671cd63 and pushed to 11.x. Thanks!

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.