Skip to content

Commit

Permalink
minor #33267 Add parameter type declarations to magic methods (derrabus)
Browse files Browse the repository at this point in the history
This PR was merged into the 5.0-dev branch.

Discussion
----------

Add parameter type declarations to magic methods

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #32179
| License       | MIT
| Doc PR        | N/A

Commits
-------

ec8215c Add parameter type declarations to magic methods.
  • Loading branch information
fabpot committed Aug 30, 2019
2 parents 77dd116 + ec8215c commit b273561
Show file tree
Hide file tree
Showing 12 changed files with 21 additions and 22 deletions.
2 changes: 1 addition & 1 deletion src/Symfony/Component/Cache/Traits/RedisClusterProxy.php
Expand Up @@ -26,7 +26,7 @@ public function __construct(\Closure $initializer)
$this->initializer = $initializer;
}

public function __call($method, array $args)
public function __call(string $method, array $args)
{
$this->redis ?: $this->redis = $this->initializer->__invoke();

Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Cache/Traits/RedisProxy.php
Expand Up @@ -28,7 +28,7 @@ public function __construct(\Redis $redis, \Closure $initializer)
$this->initializer = $initializer;
}

public function __call($method, array $args)
public function __call(string $method, array $args)
{
$this->ready ?: $this->ready = $this->initializer->__invoke($this->redis);

Expand Down
Expand Up @@ -25,7 +25,7 @@ abstract class AbstractConfigurator
/** @internal */
protected $definition;

public function __call($method, $args)
public function __call(string $method, array $args)
{
if (method_exists($this, 'set'.$method)) {
return $this->{'set'.$method}(...$args);
Expand Down
Expand Up @@ -8,11 +8,11 @@
*/
class VirtualClassMagicCall
{
public static function __callStatic($name, $arguments)
public static function __callStatic(string $name, array $arguments)
{
}

public function __call($name, $arguments)
public function __call(string $name, array $arguments)
{
}
}
Expand Up @@ -305,15 +305,15 @@ public static function staticControllerMethod()
/**
* Magic method to allow non existing methods to be called and delegated.
*/
public function __call($method, $args)
public function __call(string $method, array $args)
{
throw new \LogicException('Unexpected method call');
}

/**
* Magic method to allow non existing methods to be called and delegated.
*/
public static function __callStatic($method, $args)
public static function __callStatic(string $method, array $args)
{
throw new \LogicException('Unexpected method call');
}
Expand Down
Expand Up @@ -20,7 +20,7 @@ public function __construct($value)
$this->magicCallProperty = $value;
}

public function __call($method, array $args)
public function __call(string $method, array $args)
{
if ('getMagicCallProperty' === $method) {
return $this->magicCallProperty;
Expand Down
Expand Up @@ -22,14 +22,14 @@ public function __construct($value)
$this->magicProperty = $value;
}

public function __set($property, $value)
public function __set(string $property, $value)
{
if ('magicProperty' === $property) {
$this->magicProperty = $value;
}
}

public function __get($property)
public function __get(string $property)
{
if ('magicProperty' === $property) {
return $this->magicProperty;
Expand Down
Expand Up @@ -24,7 +24,7 @@ private function setProperty()
{
}

public function __set($property, $value)
public function __set(string $property, $value)
{
$this->$property = $value;
}
Expand Down
9 changes: 4 additions & 5 deletions src/Symfony/Component/Validator/Constraint.php
Expand Up @@ -163,12 +163,11 @@ public function __construct($options = null)
* this method will be called at most once per constraint instance and
* option name.
*
* @param string $option The option name
* @param mixed $value The value to set
* @param mixed $value The value to set
*
* @throws InvalidOptionsException If an invalid option name is given
*/
public function __set($option, $value)
public function __set(string $option, $value)
{
if ('groups' === $option) {
$this->groups = (array) $value;
Expand All @@ -194,7 +193,7 @@ public function __set($option, $value)
*
* @internal this method should not be used or overwritten in userland code
*/
public function __get($option)
public function __get(string $option)
{
if ('groups' === $option) {
$this->groups = [self::DEFAULT_GROUP];
Expand All @@ -210,7 +209,7 @@ public function __get($option)
*
* @return bool
*/
public function __isset($option)
public function __isset(string $option)
{
return 'groups' === $option;
}
Expand Down
6 changes: 3 additions & 3 deletions src/Symfony/Component/Validator/Constraints/File.php
Expand Up @@ -71,7 +71,7 @@ public function __construct($options = null)
}
}

public function __set($option, $value)
public function __set(string $option, $value)
{
if ('maxSize' === $option) {
$this->normalizeBinaryFormat($value);
Expand All @@ -82,7 +82,7 @@ public function __set($option, $value)
parent::__set($option, $value);
}

public function __get($option)
public function __get(string $option)
{
if ('maxSize' === $option) {
return $this->maxSize;
Expand All @@ -91,7 +91,7 @@ public function __get($option)
return parent::__get($option);
}

public function __isset($option)
public function __isset(string $option)
{
if ('maxSize' === $option) {
return true;
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Validator/Constraints/Valid.php
Expand Up @@ -23,7 +23,7 @@ class Valid extends Constraint
{
public $traverse = true;

public function __get($option)
public function __get(string $option)
{
if ('groups' === $option) {
// when this is reached, no groups have been configured
Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Component/VarDumper/Cloner/Data.php
Expand Up @@ -126,7 +126,7 @@ public function getIterator()
yield from $value;
}

public function __get($key)
public function __get(string $key)
{
if (null !== $data = $this->seek($key)) {
$item = $this->getStub($data->data[$data->position][$data->key]);
Expand All @@ -140,7 +140,7 @@ public function __get($key)
/**
* @return bool
*/
public function __isset($key)
public function __isset(string $key)
{
return null !== $this->seek($key);
}
Expand Down

0 comments on commit b273561

Please sign in to comment.