diff --git a/components/property_access.rst b/components/property_access.rst index 7b9053b835f..5cd5095908a 100644 --- a/components/property_access.rst +++ b/components/property_access.rst @@ -237,9 +237,7 @@ enable this feature by using :class:`Symfony\\Component\\PropertyAccess\\Propert { $property = lcfirst(substr($name, 3)); if ('get' === substr($name, 0, 3)) { - return isset($this->children[$property]) - ? $this->children[$property] - : null; + return $this->children[$property] ?? null; } elseif ('set' === substr($name, 0, 3)) { $value = 1 == count($args) ? $args[0] : null; $this->children[$property] = $value; @@ -334,9 +332,7 @@ see `Enable other Features`_:: { $property = lcfirst(substr($name, 3)); if ('get' === substr($name, 0, 3)) { - return isset($this->children[$property]) - ? $this->children[$property] - : null; + return $this->children[$property] ?? null; } elseif ('set' === substr($name, 0, 3)) { $value = 1 == count($args) ? $args[0] : null; $this->children[$property] = $value; diff --git a/create_framework/http_foundation.rst b/create_framework/http_foundation.rst index 99dff5c1faf..3c84dd25e57 100644 --- a/create_framework/http_foundation.rst +++ b/create_framework/http_foundation.rst @@ -25,7 +25,7 @@ First, if the ``name`` query parameter is not defined in the URL query string, you will get a PHP warning; so let's fix it:: // framework/index.php - $name = isset($_GET['name']) ? $_GET['name'] : 'World'; + $name = $_GET['name'] ?? 'World'; printf('Hello %s', $name); @@ -33,7 +33,7 @@ Then, this *application is not secure*. Can you believe it? Even this simple snippet of PHP code is vulnerable to one of the most widespread Internet security issue, XSS (Cross-Site Scripting). Here is a more secure version:: - $name = isset($_GET['name']) ? $_GET['name'] : 'World'; + $name = $_GET['name'] ?? 'World'; header('Content-Type: text/html; charset=utf-8'); diff --git a/frontend/custom_version_strategy.rst b/frontend/custom_version_strategy.rst index 6361ba632c0..d6280637b7f 100644 --- a/frontend/custom_version_strategy.rst +++ b/frontend/custom_version_strategy.rst @@ -83,7 +83,7 @@ version string:: $this->hashes = $this->loadManifest(); } - return isset($this->hashes[$path]) ? $this->hashes[$path] : ''; + return $this->hashes[$path] ?? ''; } public function applyVersion($path)