8000 minor #19830 Code enhancement and cleanup (yceruto) · symfony/symfony@39905fd · GitHub
[go: up one dir, main page]

Skip to content

Commit 39905fd

Browse files
minor #19830 Code enhancement and cleanup (yceruto)
This PR was squashed before being merged into the 2.7 branch (closes #19830). Discussion ---------- Code enhancement and cleanup | Q | A | ------------- | --- | Branch? | 2.7 | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - Commits ------- 325da3c Code enhancement and cleanup
2 parents 053d67b + 325da3c commit 39905fd

File tree

41 files changed

+70
-59
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+70
-59
lines changed

src/Symfony/Bridge/Doctrine/DependencyInjection/AbstractDoctrineExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ protected function loadCacheDriver($cacheName, $objectManagerName, array $cacheD
336336
$memcacheClass = !empty($cacheDriver['class']) ? $cacheDriver['class'] : '%'.$this->getObjectManagerElementName('cache.memcache.class').'%';
337337
$memcacheInstanceClass = !empty($cacheDriver['instance_class']) ? $cacheDriver['instance_class'] : '%'.$this->getObjectManagerElementName('cache.memcache_instance.class').'%';
338338
$memcacheHost = !empty($cacheDriver['host']) ? $cacheDriver['host'] : '%'.$this->getObjectManagerElementName('cache.memcache_host').'%';
339-
$memcachePort = !empty($cacheDriver['port']) || (isset($cacheDriver['port']) && $cacheDriver['port'] === 0) ? $cacheDriver['port'] : '%'.$this->getObjectManagerElementName('cache.memcache_port').'%';
339+
$memcachePort = !empty($cacheDriver['port']) || (isset($cacheDriver['port']) && $cacheDriver['port'] === 0) ? $cacheDriver['port'] : '%'.$this->getObjectManagerElementName('cache.memcache_port').'%';
340340
$cacheDef = new Definition($memcacheClass);
341341
$memcacheInstance = new Definition($memcacheInstanceClass);
342342
$memcacheInstance->addMethodCall('connect', array(

src/Symfony/Bridge/Twig/Command/DebugCommand.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,6 @@ private function getMetadata($type, $entity)
140140
return;
141141
}
142142
if ($type === 'functions' || $type === 'filters') {
143-
$args = array();
144143
$cb = $entity->getCallable();
145144
if (is_null($cb)) {
146145
return;

src/Symfony/Bundle/FrameworkBundle/Command/YamlLintCommand.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ protected function execute(InputInterface $input, OutputInterface $output)
8585
throw new \RuntimeException(sprintf('File or directory "%s" is not readable', $filename));
8686
}
8787

88-
$files = array();
8988
if (is_file($filename)) {
9089
$files = array($filename);
9190
} elseif (is_dir($filename)) {

src/Symfony/Bundle/TwigBundle/Extension/ActionsExtension.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ public function __construct($handler)
5252
* @param string $uri A URI
5353
* @param array $options An array of options
5454
*
55+
* @return string|null The Response content or null when the Response is streamed
56+
*
5557
* @see FragmentHandler::render()
5658
*/
5759
public function renderUri($uri, array $options = array())

src/Symfony/Bundle/WebProfilerBundle/EventListener/WebDebugToolbarListener.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,6 @@ public function onKernelResponse(FilterResponseEvent $event)
108108

109109
/**
110110
* Injects the web debug toolbar into the given Response.
111-
*
112-
* @param Response $response A Response instance
113111
*/
114112
protected function injectToolbar(Response $response, Request $request)
115113
{

src/Symfony/Component/BrowserKit/Tests/CookieTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ public function testIsExpired()
178178
}
179179

180180
/**
181-
* @expectedException UnexpectedValueException
181+
* @expectedException \UnexpectedValueException
182182
* @expectedExceptionMessage The cookie expiration time "string" is not valid.
183183
*/
184184
public function testConstructException()

src/Symfony/Component/Console/Command/Command.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -569,6 +569,8 @@ public function getSynopsis($short = false)
569569
* Add a command usage example.
570570
*
571571
* @param string $usage The usage, it'll be prefixed with the command name
572+
*
573+
* @return Command The current instance
572574
*/
573575
public function addUsage($usage)
574576
{

src/Symfony/Component/Console/Descriptor/MarkdownDescriptor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ protected function describeCommand(Command $command, array $options = array())
9898
.'* Description: '.($command->getDescription() ?: '<none>')."\n"
9999
.'* Usage:'."\n\n"
100100
.array_reduce(array_merge(array($command->getSynopsis()), $command->getAliases(), $command->getUsages()), function ($carry, $usage) {
101-
return $carry .= ' * `'.$usage.'`'."\n";
101+
return $carry.' * `'.$usage.'`'."\n";
102102
})
103103
);
104104

src/Symfony/Component/Console/Helper/ProgressHelper.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -371,8 +371,6 @@ private function generate($finish = false)
371371
}
372372

373373
if (isset($this->formatVars['bar'])) {
374-
$completeBars = 0;
375-
376374
if ($this->max > 0) {
377375
$completeBars = floor($percent * $this->barWidth);
378376
} else {

src/Symfony/Component/Console/Helper/QuestionHelper.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ protected function writeError(OutputInterface $output, \Exception $error)
200200
*
201201
* @param OutputInterface $output
202202
* @param Question $question
203+
* @param resource $inputStream
203204
*
204205
* @return string
205206
*/
@@ -316,7 +317,8 @@ private function autocomplete(OutputInterface $output, Question $question, $inpu
316317
/**
317318
* Gets a hidden response from user.
318319
*
319-
* @param OutputInterface $output An Output instance
320+
* @param OutputInterface $output An Output instance
321+
* @param resource $inputStream The handler resource
320322
*
321323
* @return string The answer
322324
*

src/Symfony/Component/Console/Tests/Helper/HelperSetTest.php

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -107,13 +107,6 @@ public function testIteration()
107107
}
108108
}
109109

110-
/**
111-
* Create a generic mock for the helper interface. Optionally check for a call to setHelperSet with a specific
112-
* helperset instance.
113-
*
114-
* @param string $name
115-
* @param HelperSet $helperset allows a mock to verify a particular helperset set is being added to the Helper
116-
*/
117110
private function getGenericMockHelper($name, HelperSet $helperset = null)
118111
{
119112
$mock_helper = $this->getMock('\Symfony\Component\Console\Helper\HelperInterface');

src/Symfony/Component/CssSelector/XPath/Translator.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,6 @@ class Translator implements TranslatorInterface
6868
*/
6969
private $attributeMatchingTranslators = array();
7070

71-
/**
72-
* Constructor.
73-
*/
7471
public function __construct(ParserInterface $parser = null)
7572
{
7673
$this->mainParser = $parser ?: new Parser();

src/Symfony/Component/Debug/ErrorHandler.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,10 +349,12 @@ private function reRegister($prev)
349349
/**
350350
* Handles errors by filtering then logging them according to the configured bit fields.
351351
*
352-
* @param int $type One of the E_* constants
352+
* @param int $type One of the E_* constants
353+
* @param string $message
353354
* @param string $file
354355
* @param int $line
355356
* @param array $context
357+
* @param array $backtrace
356358
*
357359
* @return bool Returns false when no handling happens so that the PHP engine can handle the error itself
358360
*

src/Symfony/Component/DependencyInjection/Compiler/ServiceReferenceGraphEdge.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public function __construct(ServiceReferenceGraphNode $sourceNode, ServiceRefere
3939
/**
4040
* Returns the value of the edge.
4141
*
42-
* @return ServiceReferenceGraphNode
42+
* @return string
4343
*/
4444
public function getValue()
4545
{

src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ public function testAddServiceInvalidServiceId()
169169

170170
/**
171171
* @dataProvider provideInvalidFactories
172-
* @expectedException Symfony\Component\DependencyInjection\Exception\RuntimeException
172+
* @expectedException \Symfony\Component\DependencyInjection\Exception\RuntimeException
173173
* @expectedExceptionMessage Cannot dump definition
174174
*/
175175
public function testInvalidFactories($factory)

src/Symfony/Component/ExpressionLanguage/TokenStream.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@ public function next()
6060

6161
/**
6262
* Tests a token.
63+
*
64+
* @param array|int $type The type to test
65+
* @param string|null $value The token value
66+
* @param string|null $message The syntax error message
6367
*/
6468
public function expect($type, $value = null, $message = null)
6569
{

src/Symfony/Component/Filesystem/Filesystem.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,8 @@ public function rename($origin, $target, $overwrite = false)
285285
*
286286
* @param string $filename Path to the file
287287
*
288+
* @return bool
289+
*
288290
* @throws IOException When windows path is longer than 258 characters
289291
*/
290292
private function isReadable($filename)

src/Symfony/Component/Form/ChoiceList/ArrayChoiceList.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -183,12 +183,13 @@ public function getValuesForChoices(array $choices)
183183
/**
184184
* Flattens an array into the given output variables.
185185
*
186-
* @param array $choices The array to flatten
187-
* @param callable $value The callable for generating choice values
188-
* @param array $choicesByValues The flattened choices indexed by the
189-
* corresponding values
190-
* @param array $keysByValues The original keys indexed by the
191-
* corresponding values
186+
* @param array $choices The array to flatten
187+
* @param callable $value The callable for generating choice values
188+
* @param array $choicesByValues The flattened choices indexed by the
189+
* corresponding values
190+
* @param array $keysByValues The original keys indexed by the
191+
* corresponding values
192+
* @param array $structuredValues The values indexed by the original keys
192193
*
193194
* @internal Must not be used by user-land code
194195
*/

src/Symfony/Component/Form/ChoiceList/ArrayKeyChoiceList.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -153,12 +153,13 @@ public function getValuesForChoices(array $choices)
153153
/**
154154
* Flattens and flips an array into the given output variable.
155155
*
156-
* @param array $choices The array to flatten
157-
* @param callable $value The callable for generating choice values
158-
* @param array $choicesByValues The flattened choices indexed by the
159-
* corresponding values
160-
* @param array $keysByValues The original keys indexed by the
161-
* corresponding values
156+
* @param array $choices The array to flatten
157+
* @param callable $value The callable for generating choice values
158+
* @param array $choicesByValues The flattened choices indexed by the
159+
* corresponding values
160+
* @param array $keysByValues The original keys indexed by the
161+
* corresponding values
162+
* @param array $structuredValues The values indexed by the original keys
162163
*
163164
* @internal Must not be used by user-land code
164165
*/

src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformer.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,6 @@ protected function getIntlDateFormatter($ignoreTimezone = false)
178178
/**
179179
* Checks if the pattern contains only a date.
180180
*
181-
* @param string $pattern The input pattern
182-
*
183181
* @return bool
184182
*/
185183
protected function isPatternDateOnly()

src/Symfony/Component/Form/Extension/DataCollector/FormDataExtractor.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,8 @@
2323
*/
2424
class FormDataExtractor implements FormDataExtractorInterface
2525
{
26-
/**
27-
* @var ValueExporter
28-
*/
2926
private $valueExporter;
3027

31-
/**
32-
* Constructs a new data extractor.
33-
*/
3428
public function __construct(ValueExporter $valueExporter = null)
3529
{
3630
$this->valueExporter = $valueExporter ?: new ValueExporter();

src/Symfony/Component/Form/Tests/Extension/Core/Type/ChoiceTypeTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2040,7 +2040,7 @@ public function getOptionsWithPlaceholderAndEmptyValue()
20402040
'An empty string empty_value is used if placeholder is also an empty string when required [maintains BC]' => array(false, false, true, '', '', ''),
20412041
'A non-empty string empty_value is used if placeholder is an empty string when required [maintains BC]' => array(false, false, true, '', 'bar', 'bar'),
20422042
'A non-empty string placeholder takes precedence over an empty_value set to false when required' => array(false, false, true, 'foo', false, 'foo'),
2043-
'A non-empty string placeholder takes precedence over a not set empty_value' => array(false, false, true, 'foo', null, 'foo'),
2043+
'A non-empty string placeholder takes precedence over a not set empty_value when required' => array(false, false, true, 'foo', null, 'foo'),
20442044
'A non-empty string placeholder takes precedence over an empty string empty_value when required' => array(false, false, true, 'foo', '', 'foo'),
20452045
'A non-empty string placeholder takes precedence over a non-empty string empty_value when required' => array(false, false, true, 'foo', 'bar', 'foo'),
20462046
// single expanded, not required

src/Symfony/Component/HttpFoundation/JsonResponse.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,18 @@ public function __construct($data = null, $status = 200, $headers = array())
5050
}
5151

5252
/**
53-
* {@inheritdoc}
53+
* Factory method for chainability.
54+
*
55+
* Example:
56+
*
57+
* return JsonResponse::create($data, 200)
58+
* ->setSharedMaxAge(300);
59+
*
60+
* @param mixed $data The json response data
61+
* @param int $status The response status code
62+
* @param array $headers An array of response headers
63+
*
64+
* @return JsonResponse
5465
*/
5566
public static function create($data = null, $status = 200, $headers = array())
5667
{

src/Symfony/Component/HttpFoundation/Session/Flash/FlashBagInterface.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ public function all();
7272

7373
/**
7474
* Sets all flash messages.
75+
*
76+
* @param array $messages
7577
*/
7678
public function setAll(array $messages);
7779

src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MongoDbSessionHandler.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,8 @@ protected function getMongo()
214214
* Return an instance of a MongoDate or \MongoDB\BSON\UTCDateTime
215215
*
216216
* @param int $seconds An integer representing UTC seconds since Jan 1 1970. Defaults to now.
217+
*
218+
* @return \MongoDate|\MongoDB\BSON\UTCDateTime
217219
*/
218220
private function createDateTime($seconds = null)
219221
{

src/Symfony/Component/HttpKernel/DependencyInjection/LazyLoadingFragmentHandler.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ public function __construct(ContainerInterface $container, $debug = false, Reque
3535
/**
3636
* Adds a service as a fragment renderer.
3737
*
38+
* @param string $name The service name
3839
* @param string $renderer The render service id
3940
*/
4041
public function addRendererService($name, $renderer)

src/Symfony/Component/HttpKernel/Profiler/Profiler.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public function enable()
7878
*
7979
* @param Response $response A Response instance
8080
*
81-
* @return Profile A Profile instance
81+
* @return Profile|false A Profile instance
8282
*/
8383
public function loadProfileFromResponse(Response $response)
8484
{
@@ -149,7 +149,7 @@ public function export(Profile $profile)
149149
*
150150
* @param string $data A data string as exported by the export() method
151151
*
152-
* @return Profile A Profile instance
152+
* @return Profile|false A Profile instance
153153
*/
154154
public function import($data)
155155
{

src/Symfony/Component/HttpKernel/Tests/EventListener/ValidateRequestListenerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
class ValidateRequestListenerTest extends \PHPUnit_Framework_TestCase
2222
{
2323
/**
24-
* @expectedException Symfony\Component\HttpFoundation\Exception\ConflictingHeadersException
24+
* @expectedException \Symfony\Component\HttpFoundation\Exception\ConflictingHeadersException
2525
*/
2626
public function testListenerThrowsWhenMasterRequestHasInconsistentClientIps()
2727
{

src/Symfony/Component/HttpKernel/Tests/HttpKernelTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ public function testVerifyRequestStackPushPopDuringHandle()
272272
}
273273

274274
/**
275-
* @expectedException Symfony\Component\HttpKernel\Exception\BadRequestHttpException
275+
* @expectedException \Symfony\Component\HttpKernel\Exception\BadRequestHttpException
276276
*/
277277
public function testInconsistentClientIpsOnMasterRequests()
278278
{

src/Symfony/Component/HttpKernel/UriSigner.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ private function buildUrl(array $url, array $params = array())
9898
$host = isset($url['host']) ? $url['host'] : '';
9999
$port = isset($url['port']) ? ':'.$url['port'] : '';
100100
$user = isset($url['user']) ? $url['user'] : '';
101-
$pass = isset($url['pass']) ? ':'.$url['pass'] : '';
101+
$pass = isset($url['pass']) ? ':'.$url['pass'] : '';
102102
$pass = ($user || $pass) ? "$pass@" : '';
103103
$path = isset($url['path']) ? $url['path'] : '';
104104
$query = isset($url['query']) && $url['query'] ? '?'.$url['query'] : '';

src/Symfony/Component/Intl/DateFormatter/IntlDateFormatter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,7 @@ public function setTimeZoneId($timeZoneId)
564564
try {
565565
$this->dateTimeZone = new \DateTimeZone($timeZoneId);
566566
if ('GMT' !== $timeZoneId && $this->dateTimeZone->getName() !== $timeZoneId) {
567-
$timeZoneId = $timeZone = $this->getTimeZoneId();
567+
$timeZone = $this->getTimeZoneId();
568568
}
569569
} catch (\Exception $e) {
570570
if (PHP_VERSION_ID >= 50500 || (extension_loaded('intl') && method_exists('IntlDateFormatter', 'setTimeZone'))) {

src/Symfony/Component/Intl/ResourceBundle/LanguageBundle.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ class LanguageBundle extends LanguageDataProvider implements LanguageBundleInter
4242
* @param string $path
4343
* @param BundleEntryReaderInterface $reader
4444
* @param LocaleDataProvider $localeProvider
45+
* @param ScriptDataProvider $scriptProvider
4546
*/
4647
public function __construct($path, BundleEntryReaderInterface $reader, LocaleDataProvider $localeProvider, ScriptDataProvider $scriptProvider)
4748
{

src/Symfony/Component/Process/Tests/ProcessTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -943,7 +943,7 @@ public function provideMethodsThatNeedARunningProcess()
943943

944944
/**
945945
* @dataProvider provideMethodsThatNeedATerminatedProcess
946-
* @expectedException Symfony\Component\Process\Exception\LogicException
946+
* @expectedException \Symfony\Component\Process\Exception\LogicException
947947
* @expectedExceptionMessage Process must be terminated before calling
948948
*/
949949
public function testMethodsThatNeedATerminatedProcess($method)

src/Symfony/Component/Security/Http/Tests/Firewall/RememberMeListenerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ public function testOnCoreSecurityIgnoresAuthenticationExceptionThrownByAuthenti
101101
}
102102

103103
/**
104-
* @expectedException Symfony\Component\Security\Core\Exception\AuthenticationException
104+
* @expectedException \Symfony\Component\Security\Core\Exception\AuthenticationException
105105
* @expectedExceptionMessage Authentication failed.
106106
*/
107107
public function testOnCoreSecurityIgnoresAuthenticationOptionallyRethrowsExceptionThrownAuthenticationManagerImplementation()

src/Symfony/Component/Templating/PhpEngine.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ protected function evaluate(Storage $template, array $parameters = array())
142142
throw new \InvalidArgumentException('Invalid parameter (view)');
143143
}
144144

145+
// the view variable is exposed to the require file below
145146
$view = $this;
146147
if ($this->evalTemplate instanceof FileStorage) {
147148
extract($this->evalParameters, EXTR_SKIP);

src/Symfony/Component/Translation/DataCollectorTranslator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ public function getCollectedMessages()
108108
* @param string|null $locale
109109
* @param string|null $domain
110110
* @param string $id
111-
* @param string $trans
111+
* @param string $translation
112112
*/
113113
private function collectMessage($locale, $domain, $id, $translation)
114114
{

src/Symfony/Component/Translation/Dumper/MoFileDumper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class MoFileDumper extends FileDumper
2626
*/
2727
public function format(MessageCatalogue $messages, $domain = 'messages')
2828
{
29-
$output = $sources = $targets = $sourceOffsets = $targetOffsets = '';
29+
$sources = $targets = $sourceOffsets = $targetOffsets = '';
3030
$offsets = array();
3131
$size = 0;
3232

0 commit comments

Comments
 (0)
0