Closed (fixed)
Project:
Drupal core
Version:
10.0.x-dev
Component:
base system
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
26 Oct 2022 at 19:41 UTC
Updated:
22 Nov 2022 at 15:59 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
mondrakeComment #3
mondrakeComment #4
longwaveCan we just change getString() now, given this is not actually implemented in core?
Comment #5
mondrakeAn external class calling getString() right now in HEAD would lead to fatal, no? So what should getString() return, really? It is public API but quite evidently not called by anything at the moment. Maybe we can just deprecate it?
Comment #6
longwaveWe could just delete the
getString()method from DataReferenceBase, and fall back to the parent implementation?Comment #7
mondrakeGood idea!
Comment #8
longwaveWorks for me, given that the existing method would cause a fatal error.
Comment #9
alexpottSomething could extend DataReferenceBase in contrib and then implement getType(). This is not that farfetched because DataReferenceBase is abstract.
I think we should do something like:
We can add a test for this in \Drupal\KernelTests\Core\TypedData\TypedDataDefinitionTest::testDataReferences as we have \Drupal\Core\TypedData\Plugin\DataType\LanguageReference in core that extends but does not implement this method.
Comment #10
mondrakeI am 97% that #9 won’t work for PHPStan because it will still report the missing method. IMHO the best option is to go back to #2 here, then.
Comment #11
longwave@mondrake I am not so sure: https://github.com/phpstan/phpstan/issues/323 implies that
method_exists()checks inside the same method will work.Comment #12
mondrakeLet’s try then! Thx
Comment #13
mondrakeComment #14
mondrakeAdding a test as suggested in #9.
Comment #15
longwaveLooks great!
Comment #16
alexpottCommitted 4695b21 and pushed to 10.1.x. Thanks!
Committed 5615ede and pushed to 10.0.x. Thanks!