-
-
Notifications
You must be signed in to change notification settings - Fork 9.8k
Add and improve docblock typing for static analysis #40783
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
Closed
Closed
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
aa75810
Add return type for getBadge in PassportInterface
1525a2e
Add annotations for Forms
ed7bfd8
Possible fix psalm error on view variables.
150a3f0
Annotate IteratorAggregate types
a5517de
Annotate serializer types
c69de7e
Annotate Cookie sameSite parameters
0a4543a
Fix annotations for CacheInterface
b9c5eb8
Style fixes
9d6bb60
Generics annotation for DataTransformerInterface
283a071
Revert "Annotate serializer types"
3feb479
Form related annotation fixes
cfb5dd6
Fix DOMNode annotation
d40a5cb
Remove unneeded InvalidArgumentException annotation from Cookie
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 |
|---|---|---|
|
|
@@ -18,13 +18,15 @@ | |
|
|
||
| /** | ||
| * @author Bernhard Schussek <[email protected]> | ||
| * | ||
| * @implements DataTransformerInterface<Collection, array> | ||
| */ | ||
| class CollectionToArrayTransformer implements DataTransformerInterface | ||
| { | ||
| /** | ||
| * Transforms a collection into an array. | ||
| * | ||
| * @return mixed An array of entities | ||
| * @return mixed[] An array of entities | ||
| * | ||
| * @throws TransformationFailedException | ||
| */ | ||
|
|
||
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 |
|---|---|---|
|
|
@@ -21,6 +21,8 @@ | |
| * | ||
| * @author Nicolas Grekas <[email protected]> | ||
| * | ||
| * @implements \IteratorAggregate<mixed, \SplFileInfo> | ||
| * | ||
| * @final | ||
| */ | ||
| class GlobResource implements \IteratorAggregate, SelfCheckingResourceInterface | ||
|
|
||
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 |
|---|---|---|
|
|
@@ -18,6 +18,8 @@ | |
| * HelperSet represents a set of helpers to be used with a command. | ||
| * | ||
| * @author Fabien Potencier <[email protected]> | ||
| * | ||
| * @implements \IteratorAggregate<Helper> | ||
| */ | ||
| class HelperSet implements \IteratorAggregate | ||
| { | ||
|
|
@@ -89,7 +91,7 @@ public function getCommand() | |
| } | ||
|
|
||
| /** | ||
| * @return Helper[] | ||
| * @return \Traversable<Helper> | ||
| */ | ||
| public function getIterator() | ||
| { | ||
|
|
||
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 |
|---|---|---|
|
|
@@ -18,6 +18,8 @@ | |
| * Crawler eases navigation of a list of \DOMNode objects. | ||
| * | ||
| * @author Fabien Potencier <[email protected]> | ||
| * | ||
| * @implements \IteratorAggregate<\DOMNode> | ||
| */ | ||
| class Crawler implements \Countable, \IteratorAggregate | ||
| { | ||
|
|
@@ -1109,7 +1111,7 @@ public function count() | |
| } | ||
|
|
||
| /** | ||
| * @return \ArrayIterator|\DOMNode[] | ||
| * @return \Traversable<\DOMNode> | ||
| */ | ||
| public function getIterator() | ||
| { | ||
|
|
||
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 |
|---|---|---|
|
|
@@ -19,6 +19,8 @@ | |
| * Encapsulates events thus decoupling the observer from the subject they encapsulate. | ||
| * | ||
| * @author Drak <[email protected]> | ||
| * | ||
| * @implements \IteratorAggregate<string, mixed> | ||
| */ | ||
| class GenericEvent extends Event implements \ArrayAccess, \IteratorAggregate | ||
| { | ||
|
|
@@ -161,7 +163,7 @@ public function offsetExists($key) | |
| /** | ||
| * IteratorAggregate for iterating over the object like an array. | ||
| * | ||
| * @return \ArrayIterator | ||
| * @return \Traversable<string, mixed> | ||
| */ | ||
| public function getIterator() | ||
| { | ||
|
|
||
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 |
|---|---|---|
|
|
@@ -36,6 +36,8 @@ | |
| * $finder = Finder::create()->files()->name('*.php')->in(__DIR__); | ||
| * | ||
| * @author Fabien Potencier <[email protected]> | ||
| * | ||
| * @implements \IteratorAggregate<SplFileInfo> | ||
| */ | ||
| class Finder implements \IteratorAggregate, \Countable | ||
| { | ||
|
|
@@ -601,7 +603,7 @@ public function in($dirs) | |
| * | ||
| * This method implements the IteratorAggregate interface. | ||
| * | ||
| * @return \Iterator|SplFileInfo[] An iterator | ||
| * @return \Traversable<SplFileInfo> An iterator | ||
| * | ||
| * @throws \LogicException if the in() method has not been called | ||
| */ | ||
|
|
||
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 |
|---|---|---|
|
|
@@ -17,6 +17,9 @@ | |
|
|
||
| /** | ||
| * @author Bernhard Schussek <[email protected]> | ||
| * | ||
| * @template T | ||
| * @implements FormTypeInterface<T> | ||
| */ | ||
| abstract class AbstractType implements FormTypeInterface | ||
| { | ||
|
|
||
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 |
|---|---|---|
|
|
@@ -15,6 +15,9 @@ | |
|
|
||
| /** | ||
| * @author Bernhard Schussek <[email protected]> | ||
| * | ||
| * @template T | ||
| * @implements FormTypeExtensionInterface<T> | ||
| */ | ||
| abstract class AbstractTypeExtension implements FormTypeExtensionInterface | ||
| { | ||
|
|
||
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 |
|---|---|---|
|
|
@@ -18,6 +18,10 @@ | |
| * A form button. | ||
| * | ||
| * @author Bernhard Schussek <[email protected]> | ||
| * | ||
| * @template T | ||
| * | ||
| * @implements FormInterface<T> | ||
| */ | ||
| class Button implements \IteratorAggregate, FormInterface | ||
| { | ||
|
|
||
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 |
|---|---|---|
|
|
@@ -19,6 +19,10 @@ | |
| * A builder for {@link Button} instances. | ||
| * | ||
| * @author Bernhard Schussek <[email protected]> | ||
| * | ||
| * @template T | ||
| * | ||
| * @implements FormBuilderInterface<T> | ||
| */ | ||
| class ButtonBuilder implements \IteratorAggregate, FormBuilderInterface | ||
| { | ||
|
|
@@ -135,7 +139,7 @@ public function all() | |
| /** | ||
| * Creates the button. | ||
| * | ||
| * @return Button The button | ||
| * @return FormInterface<T> The button | ||
| */ | ||
| public function getForm() | ||
| { | ||
|
|
||
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 |
|---|---|---|
|
|
@@ -15,6 +15,8 @@ | |
| * Represents a group of choices in templates. | ||
| * | ||
| * @author Bernhard Schussek <[email protected]> | ||
| * | ||
| * @implements \IteratorAggregate<self|ChoiceView> | ||
| */ | ||
| class ChoiceGroupView implements \IteratorAggregate | ||
| { | ||
|
|
@@ -35,7 +37,7 @@ public function __construct(string $label, array $choices = []) | |
| /** | ||
| * {@inheritdoc} | ||
| * | ||
| * @return self[]|ChoiceView[] | ||
| * @return \Traversable<self|ChoiceView> | ||
| */ | ||
| public function getIterator() | ||
| { | ||
|
|
||
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 |
|---|---|---|
|
|
@@ -17,6 +17,9 @@ | |
| * Transforms a value between different representations. | ||
| * | ||
| * @author Bernhard Schussek <[email protected]> | ||
| * | ||
| * @template T | ||
| * @template R | ||
| */ | ||
| interface DataTransformerInterface | ||
| { | ||
|
|
@@ -53,9 +56,9 @@ interface DataTransformerInterface | |
| * of the first data transformer outputs NULL, the second must be able to | ||
| * process that value. | ||
| * | ||
| * @param mixed $value The value in the original representation | ||
| * @param T $value The value in the original representation | ||
| * | ||
| * @return mixed The value in the transformed representation | ||
| * @return R The value in the transformed representation | ||
| * | ||
| * @throws TransformationFailedException when the transformation fails | ||
| */ | ||
|
|
@@ -82,9 +85,9 @@ public function transform($value); | |
| * By convention, reverseTransform() should return NULL if an empty string | ||
| * is passed. | ||
| * | ||
| * @param mixed $value The value in the transformed representation | ||
| * @param R $value The value in the transformed representation | ||
| * | ||
| * @return mixed The value in the original representation | ||
| * @return T The value in the original representation | ||
| * | ||
| * @throws TransformationFailedException when the transformation fails | ||
| */ | ||
|
|
||
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
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
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 |
|---|---|---|
|
|
@@ -16,6 +16,8 @@ | |
|
|
||
| /** | ||
| * @author Bernhard Schussek <[email protected]> | ||
| * | ||
| * @implements DataTransformerInterface<array|null, array|null> | ||
| */ | ||
| class ArrayToPartsTransformer implements DataTransformerInterface | ||
| { | ||
|
|
||
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 |
|---|---|---|
|
|
@@ -20,6 +20,8 @@ | |
| * | ||
| * @author Bernhard Schussek <[email protected]> | ||
| * @author Florian Eckerstorfer <[email protected]> | ||
| * | ||
| * @implements DataTransformerInterface<bool, string> | ||
| */ | ||
| class BooleanToStringTransformer implements DataTransformerInterface | ||
| { | ||
|
|
||
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 |
|---|---|---|
|
|
@@ -17,6 +17,8 @@ | |
|
|
||
| /** | ||
| * @author Bernhard Schussek <[email protected]> | ||
| * | ||
| * @implements DataTransformerInterface<mixed, string> | ||
| */ | ||
| class ChoiceToValueTransformer implements DataTransformerInterface | ||
| { | ||
|
|
||
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 |
|---|---|---|
|
|
@@ -17,6 +17,8 @@ | |
|
|
||
| /** | ||
| * @author Bernhard Schussek <[email protected]> | ||
| * | ||
| * @implements DataTransformerInterface<array, string[]> | ||
| */ | ||
| class ChoicesToValuesTransformer implements DataTransformerInterface | ||
| { | ||
|
|
@@ -28,7 +30,7 @@ public function __construct(ChoiceListInterface $choiceList) | |
| } | ||
|
|
||
| /** | ||
| * @return array | ||
| * @return string[] | ||
| * | ||
| * @throws TransformationFailedException if the given value is not an array | ||
| */ | ||
|
|
||
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 |
|---|---|---|
|
|
@@ -18,6 +18,8 @@ | |
| * Passes a value through multiple value transformers. | ||
| * | ||
| * @author Bernhard Schussek <[email protected]> | ||
| * | ||
| * @implements DataTransformerInterface<mixed, mixed> | ||
| */ | ||
| class DataTransformerChain implements DataTransformerInterface | ||
| { | ||
|
|
||
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 |
|---|---|---|
|
|
@@ -19,6 +19,8 @@ | |
| * Transforms between a normalized date interval and an interval string/array. | ||
| * | ||
| * @author Steffen Roßkamp <[email protected]> | ||
| * | ||
| * @implements DataTransformerInterface<\DateInterval, array> | ||
| */ | ||
| class DateIntervalToArrayTransformer implements DataTransformerInterface | ||
| { | ||
|
|
||
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 |
|---|---|---|
|
|
@@ -19,6 +19,8 @@ | |
| * Transforms between a date string and a DateInterval object. | ||
| * | ||
| * @author Steffen Roßkamp <[email protected]> | ||
| * | ||
| * @implements DataTransformerInterface<\DateInterval, string> | ||
| */ | ||
| class DateIntervalToStringTransformer implements DataTransformerInterface | ||
| { | ||
|
|
||
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 |
|---|---|---|
|
|
@@ -18,6 +18,8 @@ | |
| * Transforms between a DateTimeImmutable object and a DateTime object. | ||
| * | ||
| * @author Valentin Udaltsov <[email protected]> | ||
| * | ||
| * @implements DataTransformerInterface<\DateTimeImmutable|null, \DateTime|null> | ||
|
mdeboer marked this conversation as resolved.
|
||
| */ | ||
| final class DateTimeImmutableToDateTimeTransformer implements DataTransformerInterface | ||
| { | ||
|
|
||
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.
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 am not sure whether we should use
\Traversable<Helper>or\Traversable<Helper>|Helper[]. Technically the first is correct but I believe that the latter is a common workaround for IDEs not being able to make sense of the generic\Traversable. Though I'm not sure this applies to thegetIteratormethod in case the method is not called but the object is iterated over in aforeach.