Skip to content

Commit

Permalink
minor #33300 Add missing return annotations on magic methods (nicolas…
Browse files Browse the repository at this point in the history
…-grekas)

This PR was merged into the 4.4 branch.

Discussion
----------

Add missing return annotations on magic methods

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | -

My script had a bug, spotted by reviewing #33267
These annotations express our intention to add real return types in a future major release (likely v6)

Commits
-------

10983fc Add missing return annotations on magic methods
  • Loading branch information
nicolas-grekas committed Aug 23, 2019
2 parents ba784bf + 10983fc commit 5255ab8
Show file tree
Hide file tree
Showing 11 changed files with 35 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/Symfony/Component/BrowserKit/Cookie.php
Expand Up @@ -83,6 +83,8 @@ public function __construct(string $name, ?string $value, string $expires = null

/**
* Returns the HTTP representation of the Cookie.
*
* @return string
*/
public function __toString()
{
Expand Down
Expand Up @@ -59,6 +59,9 @@ final public function ignoreOnUninitialized(): self
return $this;
}

/**
* @return string
*/
public function __toString()
{
return $this->id;
Expand Down
3 changes: 3 additions & 0 deletions src/Symfony/Component/DependencyInjection/Variable.php
Expand Up @@ -33,6 +33,9 @@ public function __construct(string $name)
$this->name = $name;
}

/**
* @return string
*/
public function __toString()
{
return $this->name;
Expand Down
3 changes: 3 additions & 0 deletions src/Symfony/Component/ExpressionLanguage/Node/Node.php
Expand Up @@ -33,6 +33,9 @@ public function __construct(array $nodes = [], array $attributes = [])
$this->attributes = $attributes;
}

/**
* @return string
*/
public function __toString()
{
$attributes = [];
Expand Down
Expand Up @@ -114,6 +114,9 @@ protected function getCasters()
return $casters;
}

/**
* @return array
*/
public function __sleep()
{
if (__CLASS__ !== $c = (new \ReflectionMethod($this, 'serialize'))->getDeclaringClass()->name) {
Expand Down
3 changes: 3 additions & 0 deletions src/Symfony/Component/HttpKernel/Kernel.php
Expand Up @@ -870,6 +870,9 @@ public function unserialize($data)
$this->__construct($environment, $debug);
}

/**
* @return array
*/
public function __sleep()
{
if (__CLASS__ !== $c = (new \ReflectionMethod($this, 'serialize'))->getDeclaringClass()->name) {
Expand Down
3 changes: 3 additions & 0 deletions src/Symfony/Component/HttpKernel/Profiler/Profile.php
Expand Up @@ -288,6 +288,9 @@ public function hasCollector($name)
return isset($this->collectors[$name]);
}

/**
* @return array
*/
public function __sleep()
{
return ['token', 'parent', 'children', 'collectors', 'ip', 'method', 'url', 'time', 'statusCode'];
Expand Down
3 changes: 3 additions & 0 deletions src/Symfony/Component/Mime/Part/DataPart.php
Expand Up @@ -125,6 +125,9 @@ public function __destruct()
}
}

/**
* @return array
*/
public function __sleep()
{
// converts the body to a string
Expand Down
3 changes: 3 additions & 0 deletions src/Symfony/Component/Mime/Part/TextPart.php
Expand Up @@ -179,6 +179,9 @@ private function chooseEncoding(): string
return 'quoted-printable';
}

/**
* @return array
*/
public function __sleep()
{
// convert resources to strings for serialization
Expand Down
3 changes: 3 additions & 0 deletions src/Symfony/Component/VarDumper/Caster/ConstStub.php
Expand Up @@ -26,6 +26,9 @@ public function __construct(string $name, $value = null)
$this->value = 1 < \func_num_args() ? $value : $name;
}

/**
* @return string
*/
public function __toString()
{
return (string) $this->value;
Expand Down
6 changes: 6 additions & 0 deletions src/Symfony/Component/VarDumper/Cloner/Data.php
Expand Up @@ -137,6 +137,9 @@ public function __get($key)
return null;
}

/**
* @return bool
*/
public function __isset($key)
{
return null !== $this->seek($key);
Expand Down Expand Up @@ -165,6 +168,9 @@ public function offsetUnset($key)
throw new \BadMethodCallException(self::class.' objects are immutable.');
}

/**
* @return string
*/
public function __toString()
{
$value = $this->getValue();
Expand Down

0 comments on commit 5255ab8

Please sign in to comment.