Skip to content

Commit 29df695

Browse files
committed
Fixed deprecation warnings about passing null as parameter
1 parent dffdc71 commit 29df695

File tree

20 files changed

+32
-28
lines changed

20 files changed

+32
-28
lines changed

src/Symfony/Bridge/PhpUnit/bin/simple-phpunit.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,9 @@
151151
}
152152

153153
$COMPOSER = file_exists($COMPOSER = $oldPwd.'/composer.phar')
154-
|| ($COMPOSER = rtrim('\\' === \DIRECTORY_SEPARATOR ? preg_replace('/[\r\n].*/', '', `where.exe composer.phar 2> NUL`) : `which composer.phar 2> /dev/null`))
155-
|| ($COMPOSER = rtrim('\\' === \DIRECTORY_SEPARATOR ? preg_replace('/[\r\n].*/', '', `where.exe composer 2> NUL`) : `which composer 2> /dev/null`))
156-
|| file_exists($COMPOSER = rtrim('\\' === \DIRECTORY_SEPARATOR ? `git rev-parse --show-toplevel 2> NUL` : `git rev-parse --show-toplevel 2> /dev/null`).\DIRECTORY_SEPARATOR.'composer.phar')
154+
|| ($COMPOSER = rtrim((string) ('\\' === \DIRECTORY_SEPARATOR ? preg_replace('/[\r\n].*/', '', `where.exe composer.phar 2> NUL`) : `which composer.phar 2> /dev/null`)))
155+
|| ($COMPOSER = rtrim((string) ('\\' === \DIRECTORY_SEPARATOR ? preg_replace('/[\r\n].*/', '', `where.exe composer 2> NUL`) : `which composer 2> /dev/null`)))
156+
|| file_exists($COMPOSER = rtrim((string) ('\\' === \DIRECTORY_SEPARATOR ? `git rev-parse --show-toplevel 2> NUL` : `git rev-parse --show-toplevel 2> /dev/null`)).\DIRECTORY_SEPARATOR.'composer.phar')
157157
? ('#!/usr/bin/env php' === file_get_contents($COMPOSER, false, null, 0, 18) ? $PHP : '').' '.escapeshellarg($COMPOSER) // detect shell wrappers by looking at the shebang
158158
: 'composer';
159159

src/Symfony/Component/BrowserKit/Cookie.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class Cookie
4646
* Sets a cookie.
4747
*
4848
* @param string $name The cookie name
49-
* @param string $value The value of the cookie
49+
* @param string|null $value The value of the cookie
5050
* @param string|null $expires The time the cookie expires
5151
* @param string|null $path The path on the server in which the cookie will be available on
5252
* @param string $domain The domain that the cookie is available
@@ -62,7 +62,7 @@ public function __construct(string $name, ?string $value, string $expires = null
6262
$this->rawValue = $value;
6363
} else {
6464
$this->value = $value;
65-
$this->rawValue = rawurlencode($value);
65+
$this->rawValue = rawurlencode($value ?? '');
6666
}
6767
$this->name = $name;
6868
$this->path = empty($path) ? '/' : $path;

src/Symfony/Component/CssSelector/XPath/Extension/NodeExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ public function translateElement(Node\ElementNode $node): XPathExpr
157157
{
158158
$element = $node->getElement();
159159

160-
if ($this->hasFlag(self::ELEMENT_NAME_IN_LOWER_CASE)) {
160+
if (null !== $element && $this->hasFlag(self::ELEMENT_NAME_IN_LOWER_CASE)) {
161161
$element = strtolower($element);
162162
}
163163

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ private function checkType(Definition $checkedDefinition, $value, \ReflectionPar
205205
if ($value instanceof Definition) {
206206
$class = $value->getClass();
207207

208-
if (isset(self::BUILTIN_TYPES[strtolower($class)])) {
208+
if (null !== $class && isset(self::BUILTIN_TYPES[strtolower($class)])) {
209209
$class = strtolower($class);
210210
} elseif (!$class || (!$this->autoload && !class_exists($class, false) && !interface_exists($class, false))) {
211211
return;

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,12 @@ protected function processValue($value, $isRoot = false)
8888
$serviceMap[$key] = new Reference($type);
8989
}
9090

91-
if (false !== $i = strpos($name, '::get')) {
92-
$name = lcfirst(substr($name, 5 + $i));
93-
} elseif (false !== strpos($name, '::')) {
94-
$name = null;
91+
if (null !== $name) {
92+
if (false !== $i = strpos($name, '::get')) {
93+
$name = lcfirst(substr($name, 5 + $i));
94+
} elseif (false !== strpos($name, '::')) {
95+
$name = null;
96+
}
9597
}
9698

9799
if (null !== $name && !$this->container->has($name) && !$this->container->has($type.' $'.$name)) {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ protected function processValue($value, $isRoot = false)
178178

179179
$typeHint = ProxyHelper::getTypeHint($reflectionMethod, $parameter);
180180

181-
if (\array_key_exists($k = ltrim($typeHint, '\\').' $'.$parameter->name, $bindings)) {
181+
if (\array_key_exists($k = ltrim($typeHint ?? '', '\\').' $'.$parameter->name, $bindings)) {
182182
$arguments[$key] = $this->getBindingValue($bindings[$k]);
183183

184184
continue;

src/Symfony/Component/DomCrawler/AbstractUriElement.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public function __construct(\DOMElement $node, string $currentUri = null, ?strin
4747
$this->currentUri = $currentUri;
4848

4949
$elementUriIsRelative = null === parse_url(trim($this->getRawUri()), \PHP_URL_SCHEME);
50-
$baseUriIsAbsolute = \in_array(strtolower(substr($this->currentUri, 0, 4)), ['http', 'file']);
50+
$baseUriIsAbsolute = null !== $this->currentUri && \in_array(strtolower(substr($this->currentUri, 0, 4)), ['http', 'file']);
5151
if ($elementUriIsRelative && !$baseUriIsAbsolute) {
5252
throw new \InvalidArgumentException(sprintf('The URL of the element is relative, so you must define its base URI passing an absolute URL to the constructor of the "%s" class ("%s" was passed).', __CLASS__, $this->currentUri));
5353
}

src/Symfony/Component/Finder/Comparator/NumberComparator.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ class NumberComparator extends Comparator
4141
*/
4242
public function __construct(?string $test)
4343
{
44-
if (!preg_match('#^\s*(==|!=|[<>]=?)?\s*([0-9\.]+)\s*([kmg]i?)?\s*$#i', $test, $matches)) {
45-
throw new \InvalidArgumentException(sprintf('Don\'t understand "%s" as a number test.', $test));
44+
if (null === $test || !preg_match('#^\s*(==|!=|[<>]=?)?\s*([0-9\.]+)\s*([kmg]i?)?\s*$#i', $test, $matches)) {
45+
throw new \InvalidArgumentException(sprintf('Don\'t understand "%s" as a number test.', $test ?? 'NULL'));
4646
}
4747

4848
$target = $matches[2];

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ public function process(ContainerBuilder $container)
124124
$args = [];
125125
foreach ($parameters as $p) {
126126
/** @var \ReflectionParameter $p */
127-
$type = ltrim($target = ProxyHelper::getTypeHint($r, $p), '\\');
127+
$type = ltrim($target = (string) ProxyHelper::getTypeHint($r, $p), '\\');
128128
$invalidBehavior = ContainerInterface::IGNORE_ON_INVALID_REFERENCE;
129129

130130
if (isset($arguments[$r->name][$p->name])) {

src/Symfony/Component/HttpKernel/EventListener/RouterListener.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ public static function getSubscribedEvents()
164164
private function createWelcomeResponse(): Response
165165
{
166166
$version = Kernel::VERSION;
167-
$projectDir = realpath($this->projectDir).\DIRECTORY_SEPARATOR;
167+
$projectDir = realpath((string) $this->projectDir).\DIRECTORY_SEPARATOR;
168168
$docVersion = substr(Kernel::VERSION, 0, 3);
169169

170170
ob_start();

0 commit comments

Comments
 (0)