Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 00da371

Browse filesBrowse files
minor #42714 Add back `@return $this` annotations (nicolas-grekas)
This PR was merged into the 6.0 branch. Discussion ---------- Add back ``@return` $this` annotations | Q | A | ------------- | --- | Branch? | 6.0 | Bug fix? | no | New feature? | no | Deprecations? | no | Tickets | - | License | MIT | Doc PR | - In #42213 I removed those annotations and tried to convinced myself and others that we could do so without loosing too much. I was about to send a PR to remove all remaining similar annotations. When I reviewed the patch I created for that, I stopped on `ItemInterface::tag()` (which is just an example): https://github.com/symfony/symfony/blob/444d43fa11990092c53ba54849bb1df36225adcf/src/Symfony/Contracts/Cache/ItemInterface.php#L52-L57 If we remove that annotation on the interface, all implementations will have to deal with the return value of the call to `tag()`. Whereas with ``@return` $this`, the contracts are clear: no need to, implementations are expected to mutate and return the current object. I don't think this would be appropriate in this example. /cc `@nikic` as this might be some nice food for thoughts to consider adding `$this` as a possible native return type. Commits ------- 7fafe83 Add back ``@return` $this` annotations
2 parents c8bba75 + 7fafe83 commit 00da371
Copy full SHA for 00da371

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Dismiss banner

44 files changed

+306
-0
lines changed

‎src/Symfony/Bridge/Twig/Mime/WrappedTemplatedEmail.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Twig/Mime/WrappedTemplatedEmail.php
+24Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ public function attach(string $file, string $name = null, string $contentType =
5757
}
5858
}
5959

60+
/**
61+
* @return $this
62+
*/
6063
public function setSubject(string $subject): static
6164
{
6265
$this->message->subject($subject);
@@ -69,6 +72,9 @@ public function getSubject(): ?string
6972
return $this->message->getSubject();
7073
}
7174

75+
/**
76+
* @return $this
77+
*/
7278
public function setReturnPath(string $address): static
7379
{
7480
$this->message->returnPath($address);
@@ -81,6 +87,9 @@ public function getReturnPath(): string
8187
return $this->message->getReturnPath();
8288
}
8389

90+
/**
91+
* @return $this
92+
*/
8493
public function addFrom(string $address, string $name = ''): static
8594
{
8695
$this->message->addFrom(new Address($address, $name));
@@ -96,6 +105,9 @@ public function getFrom(): array
96105
return $this->message->getFrom();
97106
}
98107

108+
/**
109+
* @return $this
110+
*/
99111
public function addReplyTo(string $address): static
100112
{
101113
$this->message->addReplyTo($address);
@@ -111,6 +123,9 @@ public function getReplyTo(): array
111123
return $this->message->getReplyTo();
112124
}
113125

126+
/**
127+
* @return $this
128+
*/
114129
public function addTo(string $address, string $name = ''): static
115130
{
116131
$this->message->addTo(new Address($address, $name));
@@ -126,6 +141,9 @@ public function getTo(): array
126141
return $this->message->getTo();
127142
}
128143

144+
/**
145+
* @return $this
146+
*/
129147
public function addCc(string $address, string $name = ''): static
130148
{
131149
$this->message->addCc(new Address($address, $name));
@@ -141,6 +159,9 @@ public function getCc(): array
141159
return $this->message->getCc();
142160
}
143161

162+
/**
163+
* @return $this
164+
*/
144165
public function addBcc(string $address, string $name = ''): static
145166
{
146167
$this->message->addBcc(new Address($address, $name));
@@ -156,6 +177,9 @@ public function getBcc(): array
156177
return $this->message->getBcc();
157178
}
158179

180+
/**
181+
* @return $this
182+
*/
159183
public function setPriority(int $priority): static
160184
{
161185
$this->message->priority($priority);

‎src/Symfony/Component/DependencyInjection/Loader/Configurator/DefaultsConfigurator.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Loader/Configurator/DefaultsConfigurator.php
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ public function __construct(ServicesConfigurator $parent, Definition $definition
3838
/**
3939
* Adds a tag for this definition.
4040
*
41+
* @return $this
42+
*
4143
* @throws InvalidArgumentException when an invalid tag name or attribute is provided
4244
*/
4345
final public function tag(string $name, array $attributes = []): static

‎src/Symfony/Component/DependencyInjection/Loader/Configurator/ParametersConfigurator.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Loader/Configurator/ParametersConfigurator.php
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,19 @@ public function __construct(ContainerBuilder $container)
2727
$this->container = $container;
2828
}
2929

30+
/**
31+
* @return $this
32+
*/
3033
final public function set(string $name, mixed $value): static
3134
{
3235
$this->container->setParameter($name, static::processValue($value, true));
3336

3437
return $this;
3538
}
3639

40+
/**
41+
* @return $this
42+
*/
3743
final public function __invoke(string $name, mixed $value): static
3844
{
3945
return $this->set($name, $value);

‎src/Symfony/Component/DependencyInjection/Loader/Configurator/PrototypeConfigurator.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Loader/Configurator/PrototypeConfigurator.php
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ public function __destruct()
7575
* Excludes files from registration using glob patterns.
7676
*
7777
* @param string[]|string $excludes
78+
*
79+
* @return $this
7880
*/
7981
final public function exclude(array|string $excludes): static
8082
{

‎src/Symfony/Component/DependencyInjection/Loader/Configurator/ReferenceConfigurator.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Loader/Configurator/ReferenceConfigurator.php
+9Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,20 +29,29 @@ public function __construct(string $id)
2929
$this->id = $id;
3030
}
3131

32+
/**
33+
* @return $this
34+
*/
3235
final public function ignoreOnInvalid(): static
3336
{
3437
$this->invalidBehavior = ContainerInterface::IGNORE_ON_INVALID_REFERENCE;
3538

3639
return $this;
3740
}
3841

42+
/**
43+
* @return $this
44+
*/
3945
final public function nullOnInvalid(): static
4046
{
4147
$this->invalidBehavior = ContainerInterface::NULL_ON_INVALID_REFERENCE;
4248

4349
return $this;
4450
}
4551

52+
/**
53+
* @return $this
54+
*/
4655
final public function ignoreOnUninitialized(): static
4756
{
4857
$this->invalidBehavior = ContainerInterface::IGNORE_ON_UNINITIALIZED_REFERENCE;

‎src/Symfony/Component/DependencyInjection/Loader/Configurator/Traits/AbstractTrait.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Loader/Configurator/Traits/AbstractTrait.php
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ trait AbstractTrait
1616
/**
1717
* Whether this definition is abstract, that means it merely serves as a
1818
* template for other definitions.
19+
*
20+
* @return $this
1921
*/
2022
final public function abstract(bool $abstract = true): static
2123
{

‎src/Symfony/Component/DependencyInjection/Loader/Configurator/Traits/ArgumentTrait.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Loader/Configurator/Traits/ArgumentTrait.php
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ trait ArgumentTrait
1515
{
1616
/**
1717
* Sets the arguments to pass to the service constructor/factory method.
18+
*
19+
* @return $this
1820
*/
1921
final public function args(array $arguments): static
2022
{
@@ -25,6 +27,8 @@ final public function args(array $arguments): static
2527

2628
/**
2729
* Sets one argument to pass to the service constructor/factory method.
30+
*
31+
* @return $this
2832
*/
2933
final public function arg(string|int $key, mixed $value): static
3034
{

‎src/Symfony/Component/DependencyInjection/Loader/Configurator/Traits/AutoconfigureTrait.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Loader/Configurator/Traits/AutoconfigureTrait.php
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ trait AutoconfigureTrait
1818
/**
1919
* Sets whether or not instanceof conditionals should be prepended with a global set.
2020
*
21+
* @return $this
22+
*
2123
* @throws InvalidArgumentException when a parent is already set
2224
*/
2325
final public function autoconfigure(bool $autoconfigured = true): static

‎src/Symfony/Component/DependencyInjection/Loader/Configurator/Traits/AutowireTrait.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Loader/Configurator/Traits/AutowireTrait.php
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ trait AutowireTrait
1515
{
1616
/**
1717
* Enables/disables autowiring.
18+
*
19+
* @return $this
1820
*/
1921
final public function autowire(bool $autowired = true): static
2022
{

‎src/Symfony/Component/DependencyInjection/Loader/Configurator/Traits/BindTrait.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Loader/Configurator/Traits/BindTrait.php
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ trait BindTrait
2828
*
2929
* @param string $nameOrFqcn A parameter name with its "$" prefix, or an FQCN
3030
* @param mixed $valueOrRef The value or reference to bind
31+
*
32+
* @return $this
3133
*/
3234
final public function bind(string $nameOrFqcn, mixed $valueOrRef): static
3335
{

‎src/Symfony/Component/DependencyInjection/Loader/Configurator/Traits/CallTrait.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Loader/Configurator/Traits/CallTrait.php
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ trait CallTrait
2222
* @param array $arguments An array of arguments to pass to the method call
2323
* @param bool $returnsClone Whether the call returns the service instance or not
2424
*
25+
* @return $this
26+
*
2527
* @throws InvalidArgumentException on empty $method param
2628
*/
2729
final public function call(string $method, array $arguments = [], bool $returnsClone = false): static

‎src/Symfony/Component/DependencyInjection/Loader/Configurator/Traits/ClassTrait.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Loader/Configurator/Traits/ClassTrait.php
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ trait ClassTrait
1515
{
1616
/**
1717
* Sets the service class.
18+
*
19+
* @return $this
1820
*/
1921
final public function class(?string $class): static
2022
{

‎src/Symfony/Component/DependencyInjection/Loader/Configurator/Traits/ConfiguratorTrait.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Loader/Configurator/Traits/ConfiguratorTrait.php
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ trait ConfiguratorTrait
1717
{
1818
/**
1919
* Sets a configurator to call after the service is fully initialized.
20+
*
21+
* @return $this
2022
*/
2123
final public function configurator(string|array|ReferenceConfigurator $configurator): static
2224
{

‎src/Symfony/Component/DependencyInjection/Loader/Configurator/Traits/DecorateTrait.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Loader/Configurator/Traits/DecorateTrait.php
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ trait DecorateTrait
2121
*
2222
* @param string|null $id The decorated service id, use null to remove decoration
2323
*
24+
* @return $this
25+
*
2426
* @throws InvalidArgumentException in case the decorated service id and the new decorated service id are equals
2527
*/
2628
final public function decorate(?string $id, string $renamedId = null, int $priority = 0, int $invalidBehavior = ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE): static

‎src/Symfony/Component/DependencyInjection/Loader/Configurator/Traits/DeprecateTrait.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Loader/Configurator/Traits/DeprecateTrait.php
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ trait DeprecateTrait
2222
* @param string $version The version of the package that introduced the deprecation
2323
* @param string $message The deprecation message to use
2424
*
25+
* @return $this
26+
*
2527
* @throws InvalidArgumentException when the message template is invalid
2628
*/
2729
final public function deprecate(string $package, string $version, string $message): static

‎src/Symfony/Component/DependencyInjection/Loader/Configurator/Traits/FactoryTrait.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Loader/Configurator/Traits/FactoryTrait.php
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ trait FactoryTrait
1818
{
1919
/**
2020
* Sets a factory.
21+
*
22+
* @return $this
2123
*/
2224
final public function factory(string|array|ReferenceConfigurator $factory): static
2325
{

‎src/Symfony/Component/DependencyInjection/Loader/Configurator/Traits/FileTrait.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Loader/Configurator/Traits/FileTrait.php
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ trait FileTrait
1515
{
1616
/**
1717
* Sets a file to require before creating the service.
18+
*
19+
* @return $this
1820
*/
1921
final public function file(string $file): static
2022
{

‎src/Symfony/Component/DependencyInjection/Loader/Configurator/Traits/LazyTrait.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Loader/Configurator/Traits/LazyTrait.php
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ trait LazyTrait
1717
* Sets the lazy flag of this service.
1818
*
1919
* @param bool|string $lazy A FQCN to derivate the lazy proxy from or `true` to make it extend from the definition's class
20+
*
21+
* @return $this
2022
*/
2123
final public function lazy(bool|string $lazy = true): static
2224
{

‎src/Symfony/Component/DependencyInjection/Loader/Configurator/Traits/ParentTrait.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Loader/Configurator/Traits/ParentTrait.php
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ trait ParentTrait
1919
/**
2020
* Sets the Definition to inherit from.
2121
*
22+
* @return $this
23+
*
2224
* @throws InvalidArgumentException when parent cannot be set
2325
*/
2426
final public function parent(string $parent): static

‎src/Symfony/Component/DependencyInjection/Loader/Configurator/Traits/PropertyTrait.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Loader/Configurator/Traits/PropertyTrait.php
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ trait PropertyTrait
1515
{
1616
/**
1717
* Sets a specific property.
18+
*
19+
* @return $this
1820
*/
1921
final public function property(string $name, mixed $value): static
2022
{

‎src/Symfony/Component/DependencyInjection/Loader/Configurator/Traits/PublicTrait.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Loader/Configurator/Traits/PublicTrait.php
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,19 @@
1313

1414
trait PublicTrait
1515
{
16+
/**
17+
* @return $this
18+
*/
1619
final public function public(): static
1720
{
1821
$this->definition->setPublic(true);
1922

2023
return $this;
2124
}
2225

26+
/**
27+
* @return $this
28+
*/
2329
final public function private(): static
2430
{
2531
$this->definition->setPublic(false);

‎src/Symfony/Component/DependencyInjection/Loader/Configurator/Traits/ShareTrait.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Loader/Configurator/Traits/ShareTrait.php
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ trait ShareTrait
1515
{
1616
/**
1717
* Sets if the service must be shared or not.
18+
*
19+
* @return $this
1820
*/
1921
final public function share(bool $shared = true): static
2022
{

‎src/Symfony/Component/DependencyInjection/Loader/Configurator/Traits/SyntheticTrait.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Loader/Configurator/Traits/SyntheticTrait.php
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ trait SyntheticTrait
1616
/**
1717
* Sets whether this definition is synthetic, that is not constructed by the
1818
* container, but dynamically injected.
19+
*
20+
* @return $this
1921
*/
2022
final public function synthetic(bool $synthetic = true): static
2123
{

‎src/Symfony/Component/DependencyInjection/Loader/Configurator/Traits/TagTrait.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Loader/Configurator/Traits/TagTrait.php
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ trait TagTrait
1717
{
1818
/**
1919
* Adds a tag for this definition.
20+
*
21+
* @return $this
2022
*/
2123
final public function tag(string $name, array $attributes = []): static
2224
{

‎src/Symfony/Component/Dotenv/Dotenv.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Dotenv/Dotenv.php
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ public function __construct(string $envKey = 'APP_ENV', string $debugKey = 'APP_
4646
$this->debugKey = $debugKey;
4747
}
4848

49+
/**
50+
* @return $this
51+
*/
4952
public function setProdEnvs(array $prodEnvs): static
5053
{
5154
$this->prodEnvs = $prodEnvs;
@@ -56,6 +59,8 @@ public function setProdEnvs(array $prodEnvs): static
5659
/**
5760
* @param bool $usePutenv If `putenv()` should be used to define environment variables or not.
5861
* Beware that `putenv()` is not thread safe, that's why this setting defaults to false
62+
*
63+
* @return $this
5964
*/
6065
public function usePutenv(bool $usePutenv = true): static
6166
{

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.