Skip to content
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

[3.4] Fix return types declarations #33332

Merged
merged 21 commits into from Aug 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
ef5ead0
[HttpFoundation] fix return type declarations
nicolas-grekas Aug 21, 2019
c1b7118
[Routing] Fix return type declarations
derrabus Aug 23, 2019
e0d79f7
[Security] Fix return type declarations
derrabus Aug 23, 2019
05fe553
[HttpKernel] Fix return type declarations
nicolas-grekas Aug 23, 2019
9c63be4
[Config] fix return type declarations
derrabus Aug 23, 2019
ca1fad4
[DI] fix return type declarations
derrabus Aug 23, 2019
70feaa4
[Translation] fix return type declarations
derrabus Aug 23, 2019
5072cfc
[Serializer] fix return type declarations
derrabus Aug 23, 2019
5f9aaa7
[Cache] fix return type declarations
nicolas-grekas Aug 24, 2019
28646c7
[Workflow] fix return type declarations
nicolas-grekas Aug 24, 2019
6af0c80
[Process] fix return type declarations
nicolas-grekas Aug 24, 2019
2ea98bb
[Validator] fix return type declarations
nicolas-grekas Aug 24, 2019
2b8ef1d
[DomCrawler] fix return type declarations
nicolas-grekas Aug 24, 2019
73f504c
[Templating] fix return type declarations
nicolas-grekas Aug 24, 2019
523e9b9
[Intl] fix return type declarations
nicolas-grekas Aug 24, 2019
a32a713
[Console] fix return type declarations
nicolas-grekas Aug 24, 2019
8706f18
[Form] fix return type declarations
nicolas-grekas Aug 24, 2019
5f3b4b6
[Bridge/Doctrine] fix return type declarations
nicolas-grekas Aug 24, 2019
07405e2
[PropertyInfo] fix return type declarations
nicolas-grekas Aug 25, 2019
c1d7a88
[BrowserKit] fix return type declarations
nicolas-grekas Aug 25, 2019
2ceb453
[SecurityBundle] fix return type declarations
nicolas-grekas Aug 25, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -89,6 +89,6 @@ public function getEntitiesByIds($identifier, array $values)
return $qb->andWhere($where)
->getQuery()
->setParameter($parameter, $values, $parameterType)
->getResult();
->getResult() ?: [];
nicolas-grekas marked this conversation as resolved.
Show resolved Hide resolved
}
}
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
Copy link
Contributor

Choose a reason for hiding this comment

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

do we want this? At first sight i dont see any test relying on it...

Copy link
Member Author

Choose a reason for hiding this comment

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

on branch 4.4 at least:

  1. Symfony\Component\BrowserKit\Tests\AbstractBrowserTest::testXmlHttpRequest
    Failed asserting that '' is false.

Copy link
Contributor

Choose a reason for hiding this comment

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

hm, i would patch 4.4 instead. It's a type violation IMHO.

Copy link
Member Author

Choose a reason for hiding this comment

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

or a BC break :)
REQUEST_TIME_FLOAT isn't a string either so that forcing a string here wouldn't be good (for the return type I mean)

Copy link
Contributor

Choose a reason for hiding this comment

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

float values can be represented as string :) for now i'd rely on the fact we dont use strict types: https://3v4l.org/3lAC8

getting server parameters as strings seems really valueable IMHO.

Copy link
Member Author

Choose a reason for hiding this comment

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

float to string to float isn't always accurate, we shouldn't take the risk

Copy link
Contributor

Choose a reason for hiding this comment

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

fair enough.. maybe server params arent strings per se 😅

*
* @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