8000 [master] Fix issues reported by static analyse · symfony/symfony@671694d · GitHub
[go: up one dir, main page]

Skip to content

Commit 671694d

Browse files
committed
[master] Fix issues reported by static analyse
1 parent 9e4f82e commit 671694d

File tree

13 files changed

+29
-29
lines changed

13 files changed

+29
-29
lines changed

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/CachePoolClearerPass.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler;
1313

14+
use Symfony\Component\Cache\Adapter\AbstractAdapter;
1415
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
1516
use Symfony\Component\DependencyInjection\ContainerBuilder;
1617
use Symfony\Component\DependencyInjection\Reference;

src/Symfony/Bundle/TwigBundle/ContainerAwareRuntimeLoader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
namespace Symfony\Bundle\TwigBundle;
1313

14-
@trigger_error(sprintf('The %s class is deprecated since version 3.3 and will be removed in 4.0. Use the Twig_ContainerRuntimeLoader class instead.'), ContainerAwareRuntimeLoader::class);
14+
@trigger_error(sprintf('The %s class is deprecated since version 3.3 and will be removed in 4.0. Use the Twig_ContainerRuntimeLoader class instead.', ContainerAwareRuntimeLoader::class), E_USER_DEPRECATED);
1515

1616
use Psr\Log\LoggerInterface;
1717
use Symfony\Component\DependencyInjection\ContainerInterface;

src/Symfony/Component/Cache/Simple/Psr6Cache.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Psr\Cache\CacheException as Psr6CacheException;
1616
use Psr\SimpleCache\CacheInterface;
1717
use Psr\SimpleCache\CacheException as SimpleCacheException;
18+
use Symfony\Component\Cache\Adapter\AbstractAdapter;
1819
use Symfony\Component\Cache\CacheItem;
1920
use Symfony\Component\Cache\Exception\InvalidArgumentException;
2021

@@ -30,22 +31,20 @@ public function __construct(CacheItemPoolInterface $pool)
3031
{
3132
$this->pool = $pool;
3233

33-
if ($pool instanceof Adapter\AdapterInterface) {
34+
if ($pool instanceof AbstractAdapter) {
3435
$this->createCacheItem = \Closure::bind(
3536
function ($key, $value, $allowInt = false) {
3637
if ($allowInt && is_int($key)) {
3738
$key = (string) $key;
3839
} else {
3940
CacheItem::validateKey($key);
4041
}
41-
$item = new CacheItem();
42-
$item->key = $key;
43-
$item->value = $value;
42+
$f = $this->createCacheItem;
4443

45-
return $item;
44+
return $f($key, $value, false);
4645
},
47-
null,
48-
CacheItem::class
46+
$pool,
47+
AbstractAdapter::class
4948
);
5049
}
5150
}

src/Symfony/Component/Config/Loader/FileLoader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ protected function glob($resource, $recursive, &$prefix = null, $ignoreErrors =
144144
}
145145

146146
if (!class_exists(Finder::class)) {
147-
throw new LogicException(sprintf('Extended glob pattern "%s" cannot be used as the Finder component is not installed.', $resource));
147+
throw new \LogicException(sprintf('Extended glob pattern "%s" cannot be used as the Finder component is not installed.', $resource));
148148
}
149149

150150
$finder = new Finder();

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public static function strlen($string)
7070
public static function substr($string, $from, $length = null)
7171
{
7272
if (false === $encoding = mb_detect_encoding($string, null, true)) {
73-
return substr($string);
73+
return substr($string, $from, $length);
7474
}
7575

7676
return mb_substr($string, $from, $length, $encoding);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ protected function processValue($value, $isRoot = false)
113113
if ($constructor = $reflectionClass->getConstructor()) {
114114
array_unshift($methodCalls, array($constructor->name, $value->getArguments()));
115115
} elseif ($value->getArguments()) {
116-
throw new RuntimeException(sprintf('Cannot autowire service "%s": class %s has no constructor but arguments are defined.', $this->currentId, $reflectionClass->name, $method));
116+
throw new RuntimeException(sprintf('Cannot autowire service "%s": class %s has no constructor but arguments are defined.', $this->currentId, $reflectionClass->name));
117117
}
118118

119119
$methodCalls = $this->autowireCalls($reflectionClass, $methodCalls, $autowiredMethods);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public function connect($sourceId, $sourceValue, $destId, $destValue = null, $re
9494
if (__CLASS__ !== get_class($this)) {
9595
$r = new \ReflectionMethod($this, __FUNCTION__);
9696
if (__CLASS__ !== $r->getDeclaringClass()->getName()) {
97-
@trigger_error(sprintf('Method %s() will have a 6th `$lazy = false` argument in version 4.0. Not defining it is deprecated since 3.3.', get_class($this), __FUNCTION__), E_USER_DEPRECATED);
97+
@trigger_error(sprintf('Method %s() will have a 6th `$lazy = false` argument in version 4.0. Not defining it is deprecated since 3.3.', __METHOD__), E_USER_DEPRECATED);
9898
}
9999
}
100100
$lazy = false;

src/Symfony/Component/DependencyInjection/ContainerBuilder.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,11 @@ class ContainerBuilder extends Container implements TaggedContainerInterface
117117
*/
118118
private $vendors;
119119

120+
/**
121+
* @var \ReflectionClass[] a list of class reflectors
122+
*/
123+
private $classReflectors;
124+
120125
/**
121126
* Sets the track resources flag.
122127
*

src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Component\DependencyInjection\Loader;
1313

1414
use Symfony\Component\DependencyInjection\Alias;
15+
use Symfony\Component\DependencyInjection\Argument\ArgumentInterface;
1516
use Symfony\Component\DependencyInjection\Argument\ClosureProxyArgument;
1617
use Symfony\Component\DependencyInjection\Argument\IteratorArgument;
1718
use Symfony\Component\DependencyInjection\Argument\ServiceLocatorArgument;

src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_private_frozen.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
11
<?php
22

3+
use Symfony\Component\DependencyInjection\Argument\RewindableGenerator;
34
use Symfony\Component\DependencyInjection\ContainerInterface;
45
use Symfony\Component\DependencyInjection\Container;
56
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
67
use Symfony\Component\DependencyInjection\Exception\LogicException;
78
use Symfony\Component\DependencyInjection\Exception\RuntimeException;
89
use Symfony\Component\DependencyInjection\ParameterBag\FrozenParameterBag;
10+
use Symfony\Component\DependencyInjection\ServiceLocator;
911

1012
/**
1113
* ProjectServiceContainer.
1214
*
1315
* This class has been auto-generated
1416
* by the Symfony Dependency Injection Component.
17+
*
18+
* @final since Symfony 3.3
1519
*/
1620
class ProjectServiceContainer extends Container
1721
{

src/Symfony/Component/Process/Process.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ public function __construct($commandline, $cwd = null, array $env = null, $input
151151
throw new RuntimeException('The Process class relies on proc_open, which is not available on your PHP installation.');
152152
}
153153

154-
$this->setCommandline($commandline);
154+
$this->setCommandLine($commandline);
155155
$this->cwd = $cwd;
156156

157157
// on Windows, if the cwd changed via chdir(), proc_open defaults to the dir where PHP was started
@@ -309,7 +309,7 @@ public function start(callable $callback = null/*, array $env = array()*/)
309309
}
310310
$env = null;
311311
} elseif (null !== $env) {
312-
@trigger_error(sprintf('Not inheriting environment variables is deprecated since Symfony 3.3 and will always happen in 4.0. Set "Process::inheritEnvironmentVariables()" to true instead.', __METHOD__), E_USER_DEPRECATED);
312+
@trigger_error('Not inheriting environment variables is deprecated since Symfony 3.3 and will always happen in 4.0. Set "Process::inheritEnvironmentVariables()" to true instead.', E_USER_DEPRECATED);
313313
}
314314
if ('\\' === DIRECTORY_SEPARATOR && $this->enhanceWindowsCompatibility) {
315315
$this->options['bypass_shell'] = true;
@@ -1291,7 +1291,7 @@ public function setEnhanceSigchildCompatibility($enhance)
12911291
public function inheritEnvironmentVariables($inheritEnv = true)
12921292
{
12931293
if (!$inheritEnv) {
1294-
@trigger_error(sprintf('Not inheriting environment variables is deprecated since Symfony 3.3 and will always happen in 4.0. Set "Process::inheritEnvironmentVariables()" to true instead.', __METHOD__), E_USER_DEPRECATED);
1294+
@trigger_error('Not inheriting environment variables is deprecated since Symfony 3.3 and will always happen in 4.0. Set "Process::inheritEnvironmentVariables()" to true instead.', E_USER_DEPRECATED);
12951295
}
12961296

12971297
$this->inheritEnv = (bool) $inheritEnv;

src/Symfony/Component/Serializer/Serializer.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ public function supportsNormalization($data, $format = null/*, array $context =
185185
if (__CLASS__ !== get_class($this)) {
186186
$r = new \ReflectionMethod($this, __FUNCTION__);
187187
if (__CLASS__ !== $r->getDeclaringClass()->getName()) {
188-
@trigger_error(sprintf('Method %s() will have a third `$context = array()` argument in version 4.0. Not defining it is deprecated since 3.3.', get_class($this), __FUNCTION__), E_USER_DEPRECATED);
188+
@trigger_error(sprintf('Method %s() will have a third `$context = array()` argument in version 4.0. Not defining it is deprecated since 3.3.', __METHOD__), E_USER_DEPRECATED);
189189
}
190190
}
191191

@@ -206,7 +206,7 @@ public function supportsDenormalization($data, $type, $format = null/*, array $c
206206
if (__CLASS__ !== get_class($this)) {
207207
$r = new \ReflectionMethod($this, __FUNCTION__);
208208
if (__CLASS__ !== $r->getDeclaringClass()->getName()) {
209-
@trigger_error(sprintf('Method %s() will have a fourth `$context = array()` argument in version 4.0. Not defining it is deprecated since 3.3.', get_class($this), __FUNCTION__), E_USER_DEPRECATED);
209+
@trigger_error(sprintf('Method %s() will have a fourth `$context = array()` argument in version 4.0. Not defining it is deprecated since 3.3.', __METHOD__), E_USER_DEPRECATED);
210210
}
211211
}
212212

@@ -306,7 +306,7 @@ public function supportsEncoding($format/*, array $context = array()*/)
306306
if (__CLASS__ !== get_class($this)) {
307307
$r = new \ReflectionMethod($this, __FUNCTION__);
308308
if (__CLASS__ !== $r->getDeclaringClass()->getName()) {
309-
@trigger_error(sprintf('Method %s() will have a second `$context = array()` argument in version 4.0. Not defining it is deprecated since 3.3.', get_class($this), __FUNCTION__), E_USER_DEPRECATED);
309+
@trigger_error(sprintf('Method %s() will have a second `$context = array()` argument in version 4.0. Not defining it is deprecated since 3.3.', __METHOD__), E_USER_DEPRECATED);
310310
}
311311
}
312312

@@ -327,7 +327,7 @@ public function supportsDecoding($format/*, array $context = array()*/)
327327
if (__CLASS__ !== get_class($this)) {
328328
$r = new \ReflectionMethod($this, __FUNCTION__);
329329
if (__CLASS__ !== $r->getDeclaringClass()->getName()) {
330-
@trigger_error(sprintf('Method %s() will have a second `$context = array()` argument in version 4.0. Not defining it is deprecated since 3.3.', get_class($this), __FUNCTION__), E_USER_DEPRECATED);
330+
@trigger_error(sprintf('Method %s() will have a second `$context = array()` argument in version 4.0. Not defining it is deprecated since 3.3.', __METHOD__), E_USER_DEPRECATED);
331331
}
332332
}
333333

src/Symfony/Component/Translation/Command/XliffLintCommand.php

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
*/
2727
class XliffLintCommand extends Command
2828
{
29-
private $parser;
3029
private $format;
3130
private $displayCorrectFiles;
3231
private $directoryIteratorProvider;
@@ -214,15 +213,6 @@ private function getStdin()
214213
return $inputs;
215214
}
216215

217-
private function getParser()
218-
{
219-
if (!$this->parser) {
220-
$this->parser = new Parser();
221-
}
222-
223-
return $this->parser;
224-
}
225-
226216
private function getDirectoryIterator($directory)
227217
{
228218
$default = function ($directory) {

0 commit comments

Comments
 (0)
0