-
-
Notifications
You must be signed in to change notification settings - Fork 82
Make FormatterInterface stub generic #846
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
Merged
Merged
Changes from 4 commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
197fc07
Make FormatterInterface stub generic
Niklan eaf48f4
Add FormatterBase stub/generic
Niklan 4788f20
Add required stubs
Niklan 29ca5db
Remove unused use
Niklan b13060e
Merge branch 'main' into fork/Niklan/2.x-formatter-generic
mglaman 3b11f51
revise and pass T to FieldItemListInterface
mglaman 6b3b75b
Add initial FormatterInterface generic test
Niklan 248dcf7
Add generics test data as excluded dir
Niklan 2b5297e
Revert "Add initial FormatterInterface generic test"
Niklan ee2c395
Revert "Add generics test data as excluded dir"
Niklan ed89e13
Revert generic definition to initial approach
Niklan 7e017cc
Add more tests
Niklan e7f3e9d
WIP on tests
Niklan 27d712a
Merge branch 'main' into 2.x-formatter-generic
Niklan df636fc
Fix tests
Niklan 57d2b14
Fix tests
Niklan 0f50a89
Merge branch 'main' into 2.x-formatter-generic
Niklan 659c793
Merge branch 'main' into 2.x-formatter-generic
mglaman 5791204
WIP
Niklan 0737691
Merge remote-tracking branch 'origin/2.x-formatter-generic' into 2.x-…
Niklan 62a7b8c
EntityReferenceFormatterBase stub
Niklan 67c2331
EntityReferenceFormatterBase stub
Niklan c3ff6f6
EntityReferenceFormatterBase stub
Niklan eecb43b
Merge branch 'main' into 2.x-formatter-generic
mglaman 5382f35
Fix test
Niklan 4f7b2ff
Merge branch 'main' into 2.x-formatter-generic
mglaman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?php | ||
|
||
namespace Drupal\Component\Plugin; | ||
|
||
interface DependentPluginInterface { | ||
|
||
} |
7 changes: 7 additions & 0 deletions
7
stubs/Drupal/Component/Plugin/DerivativeInspectionInterface.stub
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?php | ||
|
||
namespace Drupal\Component\Plugin; | ||
|
||
interface DerivativeInspectionInterface { | ||
|
||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?php | ||
|
||
namespace Drupal\Component\Plugin; | ||
|
||
abstract class PluginBase implements PluginInspectionInterface, DerivativeInspectionInterface { | ||
|
||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
|
||
namespace Drupal\Core\Field; | ||
|
||
use Drupal\Core\Plugin\ContainerFactoryPluginInterface; | ||
|
||
/** | ||
* @template TFieldItemList of \Drupal\Core\Field\FieldItemListInterface | ||
* @implements FormatterInterface<TFieldItemList> | ||
*/ | ||
abstract class FormatterBase extends PluginSettingsBase implements FormatterInterface, ContainerFactoryPluginInterface { | ||
|
||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
|
||
namespace Drupal\Core\Field; | ||
|
||
use Drupal\Component\Plugin\DependentPluginInterface; | ||
use Drupal\Core\Plugin\PluginBase; | ||
|
||
abstract class PluginSettingsBase extends PluginBase implements PluginSettingsInterface, DependentPluginInterface { | ||
|
||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
|
||
namespace Drupal\Core\Field; | ||
|
||
use Drupal\Component\Plugin\PluginInspectionInterface; | ||
use Drupal\Core\Config\Entity\ThirdPartySettingsInterface; | ||
|
||
interface PluginSettingsInterface extends PluginInspectionInterface, ThirdPartySettingsInterface { | ||
|
||
} |
7 changes: 7 additions & 0 deletions
7
stubs/Drupal/Core/Plugin/ContainerFactoryPluginInterface.stub
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?php | ||
|
||
namespace Drupal\Core\Plugin; | ||
|
||
interface ContainerFactoryPluginInterface { | ||
|
||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php | ||
|
||
namespace Drupal\Core\Plugin; | ||
|
||
use Drupal\Component\Plugin\PluginBase as ComponentPluginBase; | ||
|
||
abstract class PluginBase extends ComponentPluginBase { | ||
|
||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
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.
Wouldn't we want
so that way the
T
template of the field type is properly passed down intoFieldItemListInterface
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.
MissingMethodParameterTypehintRule
returns the error, we could make a test which calls it to see if this fixes. But there should be some kind of type test we can write instead.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.
I don't think the template name makes any difference; it's just a preference or an alias, as I understood it. It won't pass it to other inherited generics automatically anyway.
The reason I gave it such an explicit alias is that
FormatterInterface
works not only withFieldItemListInterface
. There is a chance that in the futureFieldDefinitionInterface
orFormStateInterface
(form object can be specified through it) might also require a generic template. In this case,TFieldItemList
will be self-documenting, whileT
might cause some confusion.I don't mind changing it to
T
, as PHPStan allows changing that name freely; the only thing we should care about for BC is the order of templates. So when we need a second one, we can make the name clearer.I fully agree about tests; I will try to create one.