Skip to content

unified return null usages #10717

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

Merged
merged 1 commit into from
Apr 18, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -291,8 +291,6 @@ protected function detectMetadataDriver($dir, ContainerBuilder $container)
if (is_dir($dir.'/'.$this->getMappingObjectDefaultName())) {
return 'annotation';
}

return null;
}

/**
Expand Down
4 changes: 1 addition & 3 deletions src/Symfony/Bridge/Doctrine/Form/DoctrineOrmTypeGuesser.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public function guessRequired($class, $property)
$classMetadatas = $this->getMetadata($class);

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

/* @var ClassMetadataInfo $classMetadata */
Expand Down Expand Up @@ -116,8 +116,6 @@ public function guessRequired($class, $property)

return new ValueGuess(!$mapping['joinColumns'][0]['nullable'], Guess::HIGH_CONFIDENCE);
}

return null;
}

/**
Expand Down
2 changes: 0 additions & 2 deletions src/Symfony/Bridge/Doctrine/Form/Type/DoctrineType.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,6 @@ public function setDefaultOptions(OptionsResolverInterface $resolver)
if (null !== $options['query_builder']) {
return $type->getLoader($options['em'], $options['query_builder'], $options['class']);
}

return null;
};

$choiceList = function (Options $options) use (&$choiceListCache, $propertyAccessor) {
Expand Down
2 changes: 0 additions & 2 deletions src/Symfony/Bridge/Propel1/Tests/Fixtures/ItemQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,6 @@ public function getColumn($column)
if ($this->hasColumn($column)) {
return new Column($column, $this->map[$column]);
}

return null;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ private function getReadDomainFromArguments(\Twig_Node $arguments, $index)
} elseif ($arguments->hasNode($index)) {
$argument = $arguments->getNode($index);
} else {
return null;
return;
}

return $this->getReadDomainFromNode($argument);
Expand All @@ -125,7 +125,7 @@ private function getReadDomainFromArguments(\Twig_Node $arguments, $index)
private function getReadDomainFromNode(\Twig_Node $node = null)
{
if (null === $node) {
return null;
return;
}

if ($node instanceof \Twig_Node_Expression_Constant) {
Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Bundle/FrameworkBundle/Controller/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -218,11 +218,11 @@ public function getUser()
}

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

if (!is_object($user = $token->getUser())) {
return null;
return;
}

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

$crawler = new Crawler(null, $uri);
Expand Down
4 changes: 1 addition & 3 deletions src/Symfony/Component/BrowserKit/CookieJar.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public function get($name, $path = '/', $domain = null)
}
}

return null;
return;
}

// avoid relying on this behavior that is mainly here for BC reasons
Expand All @@ -82,8 +82,6 @@ public function get($name, $path = '/', $domain = null)
return $cookies[$path][$name];
}
}

return null;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Config/Util/XmlUtils.php
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ public static function phpize($value)

switch (true) {
case 'null' === $lowercaseValue:
return null;
return;
case ctype_digit($value):
$raw = $value;
$cast = intval($value);
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/CssSelector/Parser/TokenStream.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ public function getNextIdentifierOrStar()
}

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

throw SyntaxErrorException::unexpectedToken('identifier or "*"', $next);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ private function getDefinitionId($id)
}

if (!$this->container->hasDefinition($id)) {
return null;
return;
}

return $id;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ private function validateScope(Reference $reference, Definition $definition = nu
private function getDefinition($id)
{
if (!$this->container->hasDefinition($id)) {
return null;
return;
}

return $this->container->getDefinition($id);
Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Component/DependencyInjection/Container.php
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ public function get($id, $invalidBehavior = self::EXCEPTION_ON_INVALID_REFERENCE
throw new ServiceNotFoundException($id, null, null, $alternatives);
}

return null;
return;
}

$this->loading[$id] = true;
Expand All @@ -325,7 +325,7 @@ public function get($id, $invalidBehavior = self::EXCEPTION_ON_INVALID_REFERENCE
}

if ($e instanceof InactiveScopeException && self::EXCEPTION_ON_INVALID_REFERENCE !== $invalidBehavior) {
return null;
return;
}

throw $e;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ public function get($id, $invalidBehavior = ContainerInterface::EXCEPTION_ON_INV
$definition = $this->getDefinition($id);
} catch (InvalidArgumentException $e) {
if (ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE !== $invalidBehavior) {
return null;
return;
}

throw $e;
Expand All @@ -492,7 +492,7 @@ public function get($id, $invalidBehavior = ContainerInterface::EXCEPTION_ON_INV
unset($this->loading[$id]);

if ($e instanceof InactiveScopeException && self::EXCEPTION_ON_INVALID_REFERENCE !== $invalidBehavior) {
return null;
return;
}

throw $e;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,6 @@ public function getConfiguration(array $config, ContainerBuilder $container)
return $configuration;
}
}

return null;
}

final protected function processConfiguration(ConfigurationInterface $configuration, array $configs)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,5 @@ public function getAlias()

public function getConfiguration(array $config, ContainerBuilder $container)
{
return null;
}
}
4 changes: 1 addition & 3 deletions src/Symfony/Component/DomCrawler/Crawler.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public function addContent($content, $type = null)

// DOM only for HTML/XML content
if (!preg_match('/(x|ht)ml/i', $type, $xmlMatches)) {
return null;
return;
}

$charset = null;
Expand Down Expand Up @@ -784,8 +784,6 @@ protected function getNode($position)
}
// @codeCoverageIgnoreStart
}

return null;
// @codeCoverageIgnoreEnd
}

Expand Down
1 change: 0 additions & 1 deletion src/Symfony/Component/Form/AbstractExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@ protected function loadTypeExtensions()
*/
protected function loadTypeGuesser()
{
return null;
}

/**
Expand Down
4 changes: 0 additions & 4 deletions src/Symfony/Component/Form/Button.php
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,6 @@ public function setData($modelData)
*/
public function getData()
{
return null;
}

/**
Expand All @@ -221,7 +220,6 @@ public function getData()
*/
public function getNormData()
{
return null;
}

/**
Expand All @@ -231,7 +229,6 @@ public function getNormData()
*/
public function getViewData()
{
return null;
}

/**
Expand Down Expand Up @@ -281,7 +278,6 @@ public function getName()
*/
public function getPropertyPath()
{
return null;
}

/**
Expand Down
10 changes: 0 additions & 10 deletions src/Symfony/Component/Form/ButtonBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,6 @@ public function getFormConfig()
*/
public function getEventDispatcher()
{
return null;
}

/**
Expand All @@ -567,7 +566,6 @@ public function getName()
*/
public function getPropertyPath()
{
return null;
}

/**
Expand Down Expand Up @@ -647,7 +645,6 @@ public function getModelTransformers()
*/
public function getDataMapper()
{
return null;
}

/**
Expand Down Expand Up @@ -687,7 +684,6 @@ public function getErrorBubbling()
*/
public function getEmptyData()
{
return null;
}

/**
Expand Down Expand Up @@ -732,7 +728,6 @@ public function getAttribute($name, $default = null)
*/
public function getData()
{
return null;
}

/**
Expand All @@ -742,7 +737,6 @@ public function getData()
*/
public function getDataClass()
{
return null;
}

/**
Expand All @@ -762,7 +756,6 @@ public function getDataLocked()
*/
public function getFormFactory()
{
return null;
}

/**
Expand All @@ -772,7 +765,6 @@ public function getFormFactory()
*/
public function getAction()
{
return null;
}

/**
Expand All @@ -782,7 +774,6 @@ public function getAction()
*/
public function getMethod()
{
return null;
}

/**
Expand All @@ -792,7 +783,6 @@ public function getMethod()
*/
public function getRequestHandler()
{
return null;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public function reverseTransform($array)
if (count($emptyKeys) > 0) {
if (count($emptyKeys) === count($this->partMapping)) {
// All parts empty
return null;
return;
}

throw new TransformationFailedException(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function __construct($trueValue)
public function transform($value)
{
if (null === $value) {
return null;
return;
}

if (!is_bool($value)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,11 @@ public function reverseTransform($values)
if (isset($choices[$i])) {
return $choices[$i] === '' ? null : $choices[$i];
} elseif ($this->placeholderPresent && 'placeholder' === $i) {
return null;
return;
} else {
throw new TransformationFailedException(sprintf('The choice "%s" does not exist', $i));
}
}
}

return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function reverseTransform($value)
// These are now valid ChoiceList values, so we can return null
// right away
if ('' === $value || null === $value) {
return null;
return;
}

$choices = $this->choiceList->getChoicesForValues(array($value));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,15 +119,15 @@ public function transform($dateTime)
public function reverseTransform($value)
{
if (null === $value) {
return null;
return;
}

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

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

$emptyFields = array();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public function reverseTransform($value)
}

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

$timestamp = $this->getIntlDateFormatter()->parse($value);
Expand Down
Loading