Skip to content

Commit 1692ffa

Browse files
committed
Merge branch '5.2' into 5.x
* 5.2: Use null coalescing operator instead of ternary operator
2 parents dd06a75 + e10be5a commit 1692ffa

File tree

3 files changed

+5
-9
lines changed

3 files changed

+5
-9
lines changed

components/property_access.rst

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -239,9 +239,7 @@ enable this feature by using :class:`Symfony\\Component\\PropertyAccess\\Propert
239239
{
240240
$property = lcfirst(substr($name, 3));
241241
if ('get' === substr($name, 0, 3)) {
242-
return isset($this->children[$property])
243-
? $this->children[$property]
244-
: null;
242+
return $this->children[$property] ?? null;
245243
} elseif ('set' === substr($name, 0, 3)) {
246244
$value = 1 == count($args) ? $args[0] : null;
247245
$this->children[$property] = $value;
@@ -338,9 +336,7 @@ see `Enable other Features`_::
338336
{
339337
$property = lcfirst(substr($name, 3));
340338
if ('get' === substr($name, 0, 3)) {
341-
return isset($this->children[$property])
342-
? $this->children[$property]
343-
: null;
339+
return $this->children[$property] ?? null;
344340
} elseif ('set' === substr($name, 0, 3)) {
345341
$value = 1 == count($args) ? $args[0] : null;
346342
$this->children[$property] = $value;

create_framework/http_foundation.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,15 @@ First, if the ``name`` query parameter is not defined in the URL query string,
2525
you will get a PHP warning; so let's fix it::
2626

2727
// framework/index.php
28-
$name = isset($_GET['name']) ? $_GET['name'] : 'World';
28+
$name = $_GET['name'] ?? 'World';
2929

3030
printf('Hello %s', $name);
3131

3232
Then, this *application is not secure*. Can you believe it? Even this simple
3333
snippet of PHP code is vulnerable to one of the most widespread Internet
3434
security issue, XSS (Cross-Site Scripting). Here is a more secure version::
3535

36-
$name = isset($_GET['name']) ? $_GET['name'] : 'World';
36+
$name = $_GET['name'] ?? 'World';
3737

3838
header('Content-Type: text/html; charset=utf-8');
3939

frontend/custom_version_strategy.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ version string::
8383
$this->hashes = $this->loadManifest();
8484
}
8585

86-
return isset($this->hashes[$path]) ? $this->hashes[$path] : '';
86+
return $this->hashes[$path] ?? '';
8787
}
8888

8989
public function applyVersion(string $path)

0 commit comments

Comments
 (0)