diff --git a/src/Extension/CoreExtension.php b/src/Extension/CoreExtension.php
index 0ff956bd615..d114e6cf2c4 100644
--- a/src/Extension/CoreExtension.php
+++ b/src/Extension/CoreExtension.php
@@ -656,7 +656,7 @@ function twig_slice(Environment $env, $item, $start, $length = null, $preserveKe
if ($start >= 0 && $length >= 0 && $item instanceof \Iterator) {
try {
- return iterator_to_array(new \LimitIterator($item, $start, null === $length ? -1 : $length), $preserveKeys);
+ return iterator_to_array(new \LimitIterator($item, $start, $length ?? -1), $preserveKeys);
} catch (\OutOfBoundsException $e) {
return [];
}
diff --git a/src/Loader/FilesystemLoader.php b/src/Loader/FilesystemLoader.php
index 62267a11c89..e10c8f2b092 100644
--- a/src/Loader/FilesystemLoader.php
+++ b/src/Loader/FilesystemLoader.php
@@ -36,7 +36,7 @@ class FilesystemLoader implements LoaderInterface
*/
public function __construct($paths = [], string $rootPath = null)
{
- $this->rootPath = (null === $rootPath ? getcwd() : $rootPath).\DIRECTORY_SEPARATOR;
+ $this->rootPath = ($rootPath ?? getcwd()).\DIRECTORY_SEPARATOR;
if (null !== $rootPath && false !== ($realPath = realpath($rootPath))) {
$this->rootPath = $realPath.\DIRECTORY_SEPARATOR;
}
diff --git a/src/NodeVisitor/EscaperNodeVisitor.php b/src/NodeVisitor/EscaperNodeVisitor.php
index fe56ea30741..f19c44b4ff5 100644
--- a/src/NodeVisitor/EscaperNodeVisitor.php
+++ b/src/NodeVisitor/EscaperNodeVisitor.php
@@ -57,7 +57,7 @@ public function enterNode(Node $node, Environment $env): Node
} elseif ($node instanceof AutoEscapeNode) {
$this->statusStack[] = $node->getAttribute('value');
} elseif ($node instanceof BlockNode) {
- $this->statusStack[] = isset($this->blocks[$node->getAttribute('name')]) ? $this->blocks[$node->getAttribute('name')] : $this->needEscaping($env);
+ $this->statusStack[] = $this->blocks[$node->getAttribute('name')] ?? $this->needEscaping($env);
} elseif ($node instanceof ImportNode) {
$this->safeVars[] = $node->getNode('var')->getAttribute('name');
}
@@ -189,7 +189,7 @@ private function needEscaping(Environment $env)
return $this->statusStack[\count($this->statusStack) - 1];
}
- return $this->defaultStrategy ? $this->defaultStrategy : false;
+ return $this->defaultStrategy ?: false;
}
private function getEscaperFilter(string $type, Node $node): FilterExpression
diff --git a/src/Profiler/Dumper/HtmlDumper.php b/src/Profiler/Dumper/HtmlDumper.php
index 1f2433b4d36..3c0daf1c8d3 100644
--- a/src/Profiler/Dumper/HtmlDumper.php
+++ b/src/Profiler/Dumper/HtmlDumper.php
@@ -37,7 +37,7 @@ protected function formatTemplate(Profile $profile, $prefix): string
protected function formatNonTemplate(Profile $profile, $prefix): string
{
- return sprintf('%s└ %s::%s(%s)', $prefix, $profile->getTemplate(), $profile->getType(), isset(self::$colors[$profile->getType()]) ? self::$colors[$profile->getType()] : 'auto', $profile->getName());
+ return sprintf('%s└ %s::%s(%s)', $prefix, $profile->getTemplate(), $profile->getType(), self::$colors[$profile->getType()] ?? 'auto', $profile->getName());
}
protected function formatTime(Profile $profile, $percent): string
diff --git a/src/Test/NodeTestCase.php b/src/Test/NodeTestCase.php
index 3b8b2c86c67..8b1bef776d3 100644
--- a/src/Test/NodeTestCase.php
+++ b/src/Test/NodeTestCase.php
@@ -43,7 +43,7 @@ public function assertNodeCompilation($source, Node $node, Environment $environm
protected function getCompiler(Environment $environment = null)
{
- return new Compiler(null === $environment ? $this->getEnvironment() : $environment);
+ return new Compiler($environment ?? $this->getEnvironment());
}
protected function getEnvironment()