8000 Fix @return statements to use $this or static when relevant by fabpot · Pull Request #21054 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

Fix @return statements to use $this or static when relevant #21054

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 1 commit into from
Dec 27, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/Symfony/Bridge/Twig/NodeVisitor/Scope.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function __construct(Scope $parent = null)
/**
* Opens a new child scope.
*
* @return Scope
* @return self
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to be inconsistent with a lot of changes below.. where it goes to static for new self.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If new self is used, it should be self anyway.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree.

*/
public function enter()
{
Expand All @@ -52,7 +52,7 @@ public function enter()
/**
* Closes current scope and returns parent one.
*
* @return Scope|null
* @return self|null
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure we should prefer using self over the class/interface name. IMHO, we should only distinguish $this, static and classname usages, but self does not bring anything more, so it isn't worth it.

Copy link
Contributor
@ro0NL ro0NL Dec 26, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure we should prefer using self over the class/interface name.

Personally, i prefer it... so while we're at it 👍 for doing this as well.

Copy link
Contributor
@ogizanagi ogizanagi Dec 26, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personally, i prefer it...

I don't 😆

I just don't understand the motivations behind, and there are many places where this was not applied (FormFactoryBuilderInterface::getFormFactory() for instance).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid duplicating terms. But you're right, if not done consistently it's not really worth it anyway.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will keep self as in the code, that's also what we are using.

*/
public function leave()
{
Expand All @@ -67,7 +67,7 @@ public function leave()
* @param string $key
* @param mixed $value
*
* @return Scope Current scope
* @return $this
*
* @throws \LogicException
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/BrowserKit/Cookie.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public function __toString()
* @param string $cookie A Set-Cookie header value
* @param string $url The base URL
*
* @return Cookie A Cookie instance
* @return static
*
* @throws \InvalidArgumentException
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public function prototype($type)
* If this function has been called and the node is not set during the finalization
* phase, it's default value will be derived from its children default values.
*
* @return ArrayNodeDefinition
* @return $this
*/
public function addDefaultsIfNotSet()
{
Expand All @@ -101,7 +101,7 @@ public function addDefaultsIfNotSet()
*
* This method is applicable to prototype nodes only.
*
* @return ArrayNodeDefinition
* @return $this
*/
public function addDefaultChildrenIfNoneSet($children = null)
{
Expand All @@ -115,7 +115,7 @@ public function addDefaultChildrenIfNoneSet($children = null)
*
* This method is applicable to prototype nodes only.
*
* @return ArrayNodeDefinition
* @return $this
*/
public function requiresAtLeastOneElement()
{
Expand All @@ -129,7 +129,7 @@ public function requiresAtLeastOneElement()
*
* If used all keys have to be defined in the same configuration file.
*
* @return ArrayNodeDefinition
* @return $this
*/
public function disallowNewKeysInSubsequentConfigs()
{
Expand All @@ -144,7 +144,7 @@ public function disallowNewKeysInSubsequentConfigs()
* @param string $singular The key to remap
* @param string $plural The plural of the key for irregular plurals
*
* @return ArrayNodeDefinition
* @return $this
*/
public function fixXmlConfig($singular, $plural = null)
{
Expand Down Expand Up @@ -179,7 +179,7 @@ public function fixXmlConfig($singular, $plural = null)
* @param string $name The name of the key
* @param bool $removeKeyItem Whether or not the key item should be removed
*
* @return ArrayNodeDefinition
* @return $this
*/
public function useAttributeAsKey($name, $removeKeyItem = true)
{
Expand All @@ -194,7 +194,7 @@ public function useAttributeAsKey($name, $removeKeyItem = true)
*
* @param bool $allow
*
* @return ArrayNodeDefinition
* @return $this
*/
public function canBeUnset($allow = true)
{
Expand All @@ -216,7 +216,7 @@ public function canBeUnset($allow = true)
* enableableArrayNode: {enabled: false, ...} # The config is disabled
* enableableArrayNode: false # The config is disabled
*
* @return ArrayNodeDefinition
* @return $this
*/
public function canBeEnabled()
{
Expand Down Expand Up @@ -246,7 +246,7 @@ public function canBeEnabled()
*
* By default, the section is enabled.
*
* @return ArrayNodeDefinition
* @return $this
*/
public function canBeDisabled()
{
Expand All @@ -266,7 +266,7 @@ public function canBeDisabled()
/**
* Disables the deep merging of the node.
*
* @return ArrayNodeDefinition
* @return $this
*/
public function performNoDeepMerging()
{
Expand All @@ -284,7 +284,7 @@ public function performNoDeepMerging()
* you want to send an entire configuration array through a special
* tree that processes only part of the array.
*
* @return ArrayNodeDefinition
* @return $this
*/
public function ignoreExtraKeys()
{
Expand All @@ -298,7 +298,7 @@ public function ignoreExtraKeys()
*
* @param bool $bool Whether to enable key normalization
*
* @return ArrayNodeDefinition
* @return $this
*/
public function normalizeKeys($bool)
{
Expand All @@ -320,7 +320,7 @@ public function normalizeKeys($bool)
*
* @param NodeDefinition $node A NodeDefinition instance
*
* @return ArrayNodeDefinition This node
* @return $this
*/
public function append(NodeDefinition $node)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class EnumNodeDefinition extends ScalarNodeDefinition
/**
* @param array $values
*
* @return EnumNodeDefinition|$this
* @return $this
*/
public function values(array $values)
{
Expand Down
22 changes: 11 additions & 11 deletions src/Symfony/Component/Config/Definition/Builder/ExprBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function __construct(NodeDefinition $node)
*
* @param \Closure $then
*
* @return ExprBuilder
* @return $this
*/
public function always(\Closure $then = null)
{
Expand All @@ -60,7 +60,7 @@ public function always(\Closure $then = null)
*
* @param \Closure $closure
*
* @return ExprBuilder
* @return $this
*/
public function ifTrue(\Closure $closure = null)
{
Expand All @@ -76,7 +76,7 @@ public function ifTrue(\Closure $closure = null)
/**
* Tests if the value is a string.
*
* @return ExprBuilder
* @return $this
*/
public function ifString()
{
Expand All @@ -88,7 +88,7 @@ public function ifString()
/**
* Tests if the value is null.
*
* @return ExprBuilder
* @return $this
*/
public function ifNull()
{
Expand All @@ -100,7 +100,7 @@ public function ifNull()
/**
* Tests if the value is an array.
*
* @return ExprBuilder
* @return $this
*/
public function ifArray()
{
Expand All @@ -114,7 +114,7 @@ public function ifArray()
*
* @param array $array
*
* @return ExprBuilder
* @return $this
*/
public function ifInArray(array $array)
{
Expand All @@ -128,7 +128,7 @@ public function ifInArray(array $array)
*
* @param array $array
*
* @return ExprBuilder
* @return $this
*/
public function ifNotInArray(array $array)
{
Expand All @@ -142,7 +142,7 @@ public function ifNotInArray(array $array)
*
* @param \Closure $closure
*
* @return ExprBuilder
* @return $this
*/
public function then(\Closure $closure)
{
Expand All @@ -154,7 +154,7 @@ public function then(\Closure $closure)
/**
* Sets a closure returning an empty array.
*
* @return ExprBuilder
* @return $this
*/
public function thenEmptyArray()
{
Expand All @@ -170,7 +170,7 @@ public function thenEmptyArray()
*
* @param string $message
*
* @return ExprBuilder
* @return $this
*
* @throws \InvalidArgumentException
*/
Expand All @@ -184,7 +184,7 @@ public function thenInvalid($message)
/**
* Sets a closure unsetting this key of the array at validation time.
*
* @return ExprBuilder
* @return $this
*
* @throws UnsetKeyException
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function __construct(NodeDefinition $node)
*
* @param bool $allow
*
* @return MergeBuilder
* @return $this
*/
public function allowUnset($allow = true)
{
Expand All @@ -51,7 +51,7 @@ public function allowUnset($allow = true)
*
* @param bool $deny Whether the overwriting is forbidden or not
*
* @return MergeBuilder
* @return $this
*/
public function denyOverwrite($deny = true)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function __construct()
*
* @param ParentNodeDefinitionInterface $parent The parent node
*
* @return NodeBuilder This node builder
* @return $this
*/
public function setParent(ParentNodeDefinitionInterface $parent = null)
{
Expand Down Expand Up @@ -182,7 +182,7 @@ public function node($name, $type)
*
* @param NodeDefinition $node
*
* @return NodeBuilder This node builder
* @return $this
*/
public function append(NodeDefinition $node)
{
Expand All @@ -207,7 +207,7 @@ public function append(NodeDefinition $node)
* @param string $type The name of the type
* @param string $class The fully qualified name the node definition class
*
* @return NodeBuilder This node builder
* @return $this
*/
public function setNodeClass($type, $class)
{
Expand Down
Loading
0