Skip to content

Commit

Permalink
Merge branch '3.4' into 4.3
Browse files Browse the repository at this point in the history
* 3.4:
  Fix return statements
  [TwigBridge] add missing dep
  Add false type to ChoiceListFactoryInterface::createView $label argument
  • Loading branch information
nicolas-grekas committed Aug 13, 2019
2 parents cca22c4 + e6b52cc commit 7d0795d
Show file tree
Hide file tree
Showing 58 changed files with 102 additions and 104 deletions.
2 changes: 1 addition & 1 deletion src/Symfony/Bridge/Doctrine/Form/ChoiceList/IdReader.php
Expand Up @@ -91,7 +91,7 @@ public function isIntId(): bool
public function getIdValue($object)
{
if (!$object) {
return;
return null;
}

if (!$this->om->contains($object)) {
Expand Down
Expand Up @@ -99,7 +99,7 @@ public function guessRequired($class, $property)
$classMetadatas = $this->getMetadata($class);

if (!$classMetadatas) {
return;
return null;
}

/** @var ClassMetadataInfo $classMetadata */
Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Bridge/Twig/AppVariable.php
Expand Up @@ -68,7 +68,7 @@ public function getToken()
/**
* Returns the current user.
*
* @return mixed
* @return object|null
*
* @see TokenInterface::getUser()
*/
Expand All @@ -79,7 +79,7 @@ public function getUser()
}

if (!$token = $tokenStorage->getToken()) {
return;
return null;
}

$user = $token->getUser();
Expand Down
1 change: 1 addition & 0 deletions src/Symfony/Bridge/Twig/composer.json
Expand Up @@ -22,6 +22,7 @@
},
"require-dev": {
"egulias/email-validator": "^2.0",
"fig/link-util": "^1.0",
"symfony/asset": "~3.4|~4.0",
"symfony/dependency-injection": "~3.4|~4.0",
"symfony/finder": "~3.4|~4.0",
Expand Down
Expand Up @@ -351,7 +351,7 @@ protected function getDoctrine(): ManagerRegistry
/**
* Get a user from the Security Token Storage.
*
* @return mixed
* @return object|null
*
* @throws \LogicException If SecurityBundle is not available
*
Expand All @@ -366,12 +366,12 @@ protected function getUser()
}

if (null === $token = $this->container->get('security.token_storage')->getToken()) {
return;
return null;
}

if (!\is_object($user = $token->getUser())) {
// e.g. anonymous authentication
return;
return null;
}

return $user;
Expand Down
Expand Up @@ -40,7 +40,7 @@ public function __construct(ContainerInterface $container)
public function getToken()
{
if (!$this->container->has('security.token_storage')) {
return;
return null;
}

return $this->container->get('security.token_storage')->getToken();
Expand Down
Expand Up @@ -126,7 +126,7 @@ public function fileExcerpt($file, $line)

// Check if the file is an application/octet-stream (eg. Phar file) because highlight_file cannot parse these files
if ('application/octet-stream' === $finfo->file($file, FILEINFO_MIME_TYPE)) {
return;
return '';
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/BrowserKit/Client.php
Expand Up @@ -533,7 +533,7 @@ protected function filterResponse($response)
protected function createCrawlerFromContent($uri, $content, $type)
{
if (!class_exists('Symfony\Component\DomCrawler\Crawler')) {
return;
return null;
}

$crawler = new Crawler(null, $uri);
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Config/Util/XmlUtils.php
Expand Up @@ -219,7 +219,7 @@ public static function phpize($value)

switch (true) {
case 'null' === $lowercaseValue:
return;
return null;
case ctype_digit($value):
$raw = $value;
$cast = (int) $value;
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Console/Application.php
Expand Up @@ -472,7 +472,7 @@ public function add(Command $command)
if (!$command->isEnabled()) {
$command->setApplication(null);

return;
return null;
}

if (null === $command->getDefinition()) {
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/CssSelector/Parser/TokenStream.php
Expand Up @@ -155,7 +155,7 @@ public function getNextIdentifierOrStar()
}

if ($next->isDelimiter(['*'])) {
return;
return null;
}

throw SyntaxErrorException::unexpectedToken('identifier or "*"', $next);
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Debug/ErrorHandler.php
Expand Up @@ -443,7 +443,7 @@ public function handleError($type, $message, $file, $line)
self::$silencedErrorCache[$id][$message] = $errorAsException;
}
if (null === $lightTrace) {
return;
return true;
}
} else {
$errorAsException = new \ErrorException($logMessage, 0, $type, $file, $line);
Expand Down
Expand Up @@ -33,11 +33,11 @@ public function handleError(array $error, FatalErrorException $exception)
$notFoundSuffix = '\' not found';
$notFoundSuffixLen = \strlen($notFoundSuffix);
if ($notFoundSuffixLen > $messageLen) {
return;
return null;
}

if (0 !== substr_compare($error['message'], $notFoundSuffix, -$notFoundSuffixLen)) {
return;
return null;
}

foreach (['class', 'interface', 'trait'] as $typeName) {
Expand Down
Expand Up @@ -30,17 +30,17 @@ public function handleError(array $error, FatalErrorException $exception)
$notFoundSuffix = '()';
$notFoundSuffixLen = \strlen($notFoundSuffix);
if ($notFoundSuffixLen > $messageLen) {
return;
return null;
}

if (0 !== substr_compare($error['message'], $notFoundSuffix, -$notFoundSuffixLen)) {
return;
return null;
}

$prefix = 'Call to undefined function ';
$prefixLen = \strlen($prefix);
if (0 !== strpos($error['message'], $prefix)) {
return;
return null;
}

$fullyQualifiedFunctionName = substr($error['message'], $prefixLen, -$notFoundSuffixLen);
Expand Down
Expand Up @@ -28,7 +28,7 @@ public function handleError(array $error, FatalErrorException $exception)
{
preg_match('/^Call to undefined method (.*)::(.*)\(\)$/', $error['message'], $matches);
if (!$matches) {
return;
return null;
}

$className = $matches[1];
Expand Down
Expand Up @@ -29,7 +29,7 @@ public static function getTypeHint(\ReflectionFunctionAbstract $r, \ReflectionPa
$type = $r->getReturnType();
}
if (!$type) {
return;
return null;
}
if (!\is_string($type)) {
$name = $type->getName();
Expand All @@ -45,7 +45,7 @@ public static function getTypeHint(\ReflectionFunctionAbstract $r, \ReflectionPa
return $prefix.$name;
}
if (!$r instanceof \ReflectionMethod) {
return;
return null;
}
if ('self' === $lcName) {
return $prefix.$r->getDeclaringClass()->name;
Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Component/Filesystem/Filesystem.php
Expand Up @@ -414,12 +414,12 @@ private function linkException($origin, $target, $linkType)
public function readlink($path, $canonicalize = false)
{
if (!$canonicalize && !is_link($path)) {
return;
return null;
}

if ($canonicalize) {
if (!$this->exists($path)) {
return;
return null;
}

if ('\\' === \DIRECTORY_SEPARATOR) {
Expand Down
Expand Up @@ -78,14 +78,11 @@ public function createListFromLoader(ChoiceLoaderInterface $loader, $value = nul
* attributes that should be added to the respective choice.
*
* @param array|callable|null $preferredChoices The preferred choices
* @param callable|null $label The callable generating the
* choice labels
* @param callable|null $index The callable generating the
* view indices
* @param callable|null $groupBy The callable generating the
* group names
* @param array|callable|null $attr The callable generating the
* HTML attributes
* @param callable|false|null $label The callable generating the choice labels;
* pass false to discard the label
* @param callable|null $index The callable generating the view indices
* @param callable|null $groupBy The callable generating the group names
* @param array|callable|null $attr The callable generating the HTML attributes
*
* @return ChoiceListView The choice list view
*/
Expand Down
Expand Up @@ -45,14 +45,14 @@ public function __construct(string $trueValue, array $falseValues = [null])
*
* @param bool $value Boolean value
*
* @return string String value
* @return string|null String value
*
* @throws TransformationFailedException if the given value is not a Boolean
*/
public function transform($value)
{
if (null === $value) {
return;
return null;
}

if (!\is_bool($value)) {
Expand Down
Expand Up @@ -106,21 +106,21 @@ public function transform($dateInterval)
*
* @param array $value Interval array
*
* @return \DateInterval Normalized date interval
* @return \DateInterval|null Normalized date interval
*
* @throws UnexpectedTypeException if the given value is not an array
* @throws TransformationFailedException if the value could not be transformed
*/
public function reverseTransform($value)
{
if (null === $value) {
return;
return null;
}
if (!\is_array($value)) {
throw new UnexpectedTypeException($value, 'array');
}
if ('' === implode('', $value)) {
return;
return null;
}
$emptyFields = [];
foreach ($this->fields as $field) {
Expand Down
Expand Up @@ -62,21 +62,21 @@ public function transform($value)
*
* @param string $value An ISO 8601 or date string like date interval presentation
*
* @return \DateInterval An instance of \DateInterval
* @return \DateInterval|null An instance of \DateInterval
*
* @throws UnexpectedTypeException if the given value is not a string
* @throws TransformationFailedException if the date interval could not be parsed
*/
public function reverseTransform($value)
{
if (null === $value) {
return;
return null;
}
if (!\is_string($value)) {
throw new UnexpectedTypeException($value, 'string');
}
if ('' === $value) {
return;
return null;
}
if (!$this->isISO8601($value)) {
throw new TransformationFailedException('Non ISO 8601 date strings are not supported yet');
Expand Down
Expand Up @@ -103,23 +103,23 @@ public function transform($dateTime)
*
* @param array $value Localized date
*
* @return \DateTime Normalized date
* @return \DateTime|null Normalized date
*
* @throws TransformationFailedException If the given value is not an array,
* if the value could not be transformed
*/
public function reverseTransform($value)
{
if (null === $value) {
return;
return null;
}

if (!\is_array($value)) {
throw new TransformationFailedException('Expected an array.');
}

if ('' === implode('', $value)) {
return;
return null;
}

$emptyFields = [];
Expand Down
Expand Up @@ -66,7 +66,7 @@ public function transform($dateTime)
*
* @param string $dateTimeLocal Formatted string
*
* @return \DateTime Normalized date
* @return \DateTime|null Normalized date
*
* @throws TransformationFailedException If the given value is not a string,
* if the value could not be transformed
Expand All @@ -78,7 +78,7 @@ public function reverseTransform($dateTimeLocal)
}

if ('' === $dateTimeLocal) {
return;
return null;
}

// to maintain backwards compatibility we do not strictly validate the submitted date
Expand Down
Expand Up @@ -99,7 +99,7 @@ public function transform($dateTime)
*
* @param string|array $value Localized date string/array
*
* @return \DateTime Normalized date
* @return \DateTime|null Normalized date
*
* @throws TransformationFailedException if the given value is not a string,
* if the date could not be parsed
Expand All @@ -111,7 +111,7 @@ public function reverseTransform($value)
}

if ('' === $value) {
return;
return null;
}

// date-only patterns require parsing to be done in UTC, as midnight might not exist in the local timezone due
Expand Down
Expand Up @@ -53,7 +53,7 @@ public function transform($dateTime)
*
* @param string $rfc3339 Formatted string
*
* @return \DateTime Normalized date
* @return \DateTime|null Normalized date
*
* @throws TransformationFailedException If the given value is not a string,
* if the value could not be transformed
Expand All @@ -65,7 +65,7 @@ public function reverseTransform($rfc3339)
}

if ('' === $rfc3339) {
return;
return null;
}

if (!preg_match('/^(\d{4})-(\d{2})-(\d{2})T\d{2}:\d{2}(?::\d{2})?(?:\.\d+)?(?:Z|(?:(?:\+|-)\d{2}:\d{2}))$/', $rfc3339, $matches)) {
Expand Down
Expand Up @@ -101,15 +101,15 @@ public function transform($dateTime)
*
* @param string $value A value as produced by PHP's date() function
*
* @return \DateTime An instance of \DateTime
* @return \DateTime|null An instance of \DateTime
*
* @throws TransformationFailedException If the given value is not a string,
* or could not be transformed
*/
public function reverseTransform($value)
{
if (empty($value)) {
return;
return null;
}

if (!\is_string($value)) {
Expand Down

0 comments on commit 7d0795d

Please sign in to comment.