Skip to content

Commit

Permalink
minor #33332 [3.4] Fix return types declarations (nicolas-grekas, der…
Browse files Browse the repository at this point in the history
…rabus)

This PR was merged into the 3.4 branch.

Discussion
----------

[3.4] Fix return types declarations

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

This is the subset of #33236 that applies to branch 3.4.
This PR ensures return types are correctly declared, and adjust some implementations that return incorrect types.

Commits
-------

2ceb453 [SecurityBundle] fix return type declarations
c1d7a88 [BrowserKit] fix return type declarations
07405e2 [PropertyInfo] fix return type declarations
5f3b4b6 [Bridge/Doctrine] fix return type declarations
8706f18 [Form] fix return type declarations
a32a713 [Console] fix return type declarations
523e9b9 [Intl] fix return type declarations
73f504c [Templating] fix return type declarations
2b8ef1d [DomCrawler] fix return type declarations
2ea98bb [Validator] fix return type declarations
6af0c80 [Process] fix return type declarations
28646c7 [Workflow] fix return type declarations
5f9aaa7 [Cache] fix return type declarations
5072cfc [Serializer] fix return type declarations
70feaa4 [Translation] fix return type declarations
ca1fad4 [DI] fix return type declarations
9c63be4 [Config] fix return type declarations
05fe553 [HttpKernel] Fix return type declarations
e0d79f7 [Security] Fix return type declarations
c1b7118 [Routing] Fix return type declarations
ef5ead0 [HttpFoundation] fix return type declarations
  • Loading branch information
nicolas-grekas committed Aug 26, 2019
2 parents 1f72501 + 2ceb453 commit e9886e4
Show file tree
Hide file tree
Showing 102 changed files with 382 additions and 357 deletions.
Expand Up @@ -89,6 +89,6 @@ public function getEntitiesByIds($identifier, array $values)
return $qb->andWhere($where)
->getQuery()
->setParameter($parameter, $values, $parameterType)
->getResult();
->getResult() ?: [];
}
}
Expand Up @@ -107,6 +107,8 @@ protected function doLeaveNode(Node $node, Environment $env)

/**
* {@inheritdoc}
*
* @return int
*/
public function getPriority()
{
Expand Down
Expand Up @@ -97,6 +97,8 @@ protected function doLeaveNode(Node $node, Environment $env)

/**
* {@inheritdoc}
*
* @return int
*/
public function getPriority()
{
Expand Down
4 changes: 1 addition & 3 deletions src/Symfony/Bridge/Twig/Translation/TwigExtractor.php
Expand Up @@ -106,9 +106,7 @@ protected function canBeExtracted($file)
}

/**
* @param string|array $directory
*
* @return array
* {@inheritdoc}
*/
protected function extractFromDirectory($directory)
{
Expand Down
Expand Up @@ -1743,9 +1743,7 @@ private function getKernelRootHash(ContainerBuilder $container)
}

/**
* Returns the base path for the XSD files.
*
* @return string The XSD base path
* {@inheritdoc}
*/
public function getXsdValidationBasePath()
{
Expand Down
Expand Up @@ -24,16 +24,16 @@ public function testProfilerIsDisabled($insulate)
}

$client->request('GET', '/profiler');
$this->assertFalse($client->getProfile());
$this->assertNull($client->getProfile());

// enable the profiler for the next request
$client->enableProfiler();
$this->assertFalse($client->getProfile());
$this->assertNull($client->getProfile());
$client->request('GET', '/profiler');
$this->assertIsObject($client->getProfile());

$client->request('GET', '/profiler');
$this->assertFalse($client->getProfile());
$this->assertNull($client->getProfile());
}

public function getConfigs()
Expand Down
Expand Up @@ -231,7 +231,7 @@ public function getUser()
/**
* Gets the roles of the user.
*
* @return array The roles
* @return array|Data
*/
public function getRoles()
{
Expand All @@ -241,7 +241,7 @@ public function getRoles()
/**
* Gets the inherited roles of the user.
*
* @return array The inherited roles
* @return array|Data
*/
public function getInheritedRoles()
{
Expand Down Expand Up @@ -269,16 +269,25 @@ public function isAuthenticated()
return $this->data['authenticated'];
}

/**
* @return bool
*/
public function isImpersonated()
{
return $this->data['impersonated'];
}

/**
* @return string|null
*/
public function getImpersonatorUser()
{
return $this->data['impersonator_user'];
}

/**
* @return string|null
*/
public function getImpersonationExitPath()
{
return $this->data['impersonation_exit_path'];
Expand All @@ -287,7 +296,7 @@ public function getImpersonationExitPath()
/**
* Get the class name of the security token.
*
* @return string The token
* @return string|Data|null The token
*/
public function getTokenClass()
{
Expand All @@ -297,7 +306,7 @@ public function getTokenClass()
/**
* Get the full security token class as Data object.
*
* @return Data
* @return Data|null
*/
public function getToken()
{
Expand All @@ -307,7 +316,7 @@ public function getToken()
/**
* Get the logout URL.
*
* @return string The logout URL
* @return string|null The logout URL
*/
public function getLogoutUrl()
{
Expand All @@ -317,7 +326,7 @@ public function getLogoutUrl()
/**
* Returns the FQCN of the security voters enabled in the application.
*
* @return string[]
* @return string[]|Data
*/
public function getVoters()
{
Expand All @@ -337,7 +346,7 @@ public function getVoterStrategy()
/**
* Returns the log of the security decisions made by the access decision manager.
*
* @return array
* @return array|Data
*/
public function getAccessDecisionLog()
{
Expand All @@ -347,13 +356,16 @@ public function getAccessDecisionLog()
/**
* Returns the configuration of the current firewall context.
*
* @return array
* @return array|Data
*/
public function getFirewall()
{
return $this->data['firewall'];
}

/**
* @return array|Data
*/
public function getListeners()
{
return $this->data['listeners'];
Expand Down
Expand Up @@ -130,9 +130,9 @@ abstract protected function getListenerId();
* @param ContainerBuilder $container
* @param string $id
* @param array $config
* @param string $defaultEntryPointId
* @param string|null $defaultEntryPointId
*
* @return string the entry point id
* @return string|null the entry point id
*/
protected function createEntryPoint($container, $id, $config, $defaultEntryPointId)
{
Expand Down
Expand Up @@ -24,10 +24,10 @@ interface SecurityFactoryInterface
/**
* Configures the container services required to use the authentication listener.
*
* @param string $id The unique id of the firewall
* @param array $config The options array for the listener
* @param string $userProvider The service id of the user provider
* @param string $defaultEntryPoint
* @param string $id The unique id of the firewall
* @param array $config The options array for the listener
* @param string $userProvider The service id of the user provider
* @param string|null $defaultEntryPoint
*
* @return array containing three values:
* - the provider id
Expand Down
Expand Up @@ -798,9 +798,7 @@ public function addUserProviderFactory(UserProviderFactoryInterface $factory)
}

/**
* Returns the base path for the XSD files.
*
* @return string The XSD base path
* {@inheritdoc}
*/
public function getXsdValidationBasePath()
{
Expand Down
Expand Up @@ -255,9 +255,7 @@ private function normalizeBundleName($name)
}

/**
* Returns the base path for the XSD files.
*
* @return string The XSD base path
* {@inheritdoc}
*/
public function getXsdValidationBasePath()
{
Expand Down
Expand Up @@ -64,9 +64,7 @@ public function load(array $configs, ContainerBuilder $container)
}

/**
* Returns the base path for the XSD files.
*
* @return string The XSD base path
* {@inheritdoc}
*/
public function getXsdValidationBasePath()
{
Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Component/BrowserKit/Client.php
Expand Up @@ -141,9 +141,9 @@ public function setServerParameter($key, $value)
* Gets single server parameter for specified key.
*
* @param string $key A key of the parameter to get
* @param string $default A default value when key is undefined
* @param mixed $default A default value when key is undefined
*
* @return string A value of the parameter
* @return mixed A value of the parameter
*/
public function getServerParameter($key, $default = '')
{
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/BrowserKit/Request.php
Expand Up @@ -107,7 +107,7 @@ public function getServer()
/**
* Gets the request raw body data.
*
* @return string The request raw body data
* @return string|null The request raw body data
*/
public function getContent()
{
Expand Down
3 changes: 2 additions & 1 deletion src/Symfony/Component/Cache/DoctrineProvider.php
Expand Up @@ -90,13 +90,14 @@ protected function doDelete($id)
*/
protected function doFlush()
{
$this->pool->clear();
return $this->pool->clear();
}

/**
* {@inheritdoc}
*/
protected function doGetStats()
{
return null;
}
}
Expand Up @@ -40,6 +40,10 @@ public function testLongKeyVersioning()
->setConstructorArgs([str_repeat('-', 26)])
->getMock();

$cache
->method('doFetch')
->willReturn(['2:']);

$reflectionClass = new \ReflectionClass(AbstractAdapter::class);

$reflectionMethod = $reflectionClass->getMethod('getId');
Expand All @@ -56,7 +60,7 @@ public function testLongKeyVersioning()
$reflectionProperty->setValue($cache, true);

// Versioning enabled
$this->assertEquals('--------------------------:1:------------', $reflectionMethod->invokeArgs($cache, [str_repeat('-', 12)]));
$this->assertEquals('--------------------------:2:------------', $reflectionMethod->invokeArgs($cache, [str_repeat('-', 12)]));
$this->assertLessThanOrEqual(50, \strlen($reflectionMethod->invokeArgs($cache, [str_repeat('-', 12)])));
$this->assertLessThanOrEqual(50, \strlen($reflectionMethod->invokeArgs($cache, [str_repeat('-', 23)])));
$this->assertLessThanOrEqual(50, \strlen($reflectionMethod->invokeArgs($cache, [str_repeat('-', 40)])));
Expand Down
6 changes: 1 addition & 5 deletions src/Symfony/Component/Config/Definition/ArrayNode.php
Expand Up @@ -38,17 +38,13 @@ public function setNormalizeKeys($normalizeKeys)
}

/**
* Normalizes keys between the different configuration formats.
* {@inheritdoc}
*
* Namely, you mostly have foo_bar in YAML while you have foo-bar in XML.
* After running this method, all keys are normalized to foo_bar.
*
* If you have a mixed key like foo-bar_moo, it will not be altered.
* The key will also not be altered if the target key already exists.
*
* @param mixed $value
*
* @return array The value with normalized keys
*/
protected function preNormalize($value)
{
Expand Down
23 changes: 21 additions & 2 deletions src/Symfony/Component/Config/Definition/BaseNode.php
Expand Up @@ -49,21 +49,37 @@ public function __construct($name, NodeInterface $parent = null)
$this->parent = $parent;
}

/**
* @param string $key
*/
public function setAttribute($key, $value)
{
$this->attributes[$key] = $value;
}

/**
* @param string $key
*
* @return mixed
*/
public function getAttribute($key, $default = null)
{
return isset($this->attributes[$key]) ? $this->attributes[$key] : $default;
}

/**
* @param string $key
*
* @return bool
*/
public function hasAttribute($key)
{
return isset($this->attributes[$key]);
}

/**
* @return array
*/
public function getAttributes()
{
return $this->attributes;
Expand All @@ -74,6 +90,9 @@ public function setAttributes(array $attributes)
$this->attributes = $attributes;
}

/**
* @param string $key
*/
public function removeAttribute($key)
{
unset($this->attributes[$key]);
Expand All @@ -92,7 +111,7 @@ public function setInfo($info)
/**
* Returns info message.
*
* @return string The info text
* @return string|null The info text
*/
public function getInfo()
{
Expand All @@ -112,7 +131,7 @@ public function setExample($example)
/**
* Retrieves the example configuration for this node.
*
* @return string|array The example
* @return string|array|null The example
*/
public function getExample()
{
Expand Down
Expand Up @@ -78,7 +78,7 @@ public function setKeyAttribute($attribute, $remove = true)
/**
* Retrieves the name of the attribute which value should be used as key.
*
* @return string The name of the attribute
* @return string|null The name of the attribute
*/
public function getKeyAttribute()
{
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Config/Util/XmlUtils.php
Expand Up @@ -152,7 +152,7 @@ public static function loadFile($file, $schemaOrCallable = null)
* @param \DOMElement $element A \DOMElement instance
* @param bool $checkPrefix Check prefix in an element or an attribute name
*
* @return array A PHP array
* @return mixed
*/
public static function convertDomElementToArray(\DOMElement $element, $checkPrefix = true)
{
Expand Down

0 comments on commit e9886e4

Please sign in to comment.