mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-02 21:46:48 +00:00
Convert Ternary to Elvis or Null Coalescing
This commit is contained in:
committed by
Fabien Potencier
parent
cb8a824784
commit
6ca0d773c5
@@ -655,7 +655,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 [];
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -189,7 +189,7 @@ final class EscaperNodeVisitor implements NodeVisitorInterface
|
||||
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
|
||||
|
||||
@@ -37,7 +37,7 @@ final class HtmlDumper extends BaseDumper
|
||||
|
||||
protected function formatNonTemplate(Profile $profile, $prefix): string
|
||||
{
|
||||
return sprintf('%s└ %s::%s(<span style="background-color: %s">%s</span>)', $prefix, $profile->getTemplate(), $profile->getType(), isset(self::$colors[$profile->getType()]) ? self::$colors[$profile->getType()] : 'auto', $profile->getName());
|
||||
return sprintf('%s└ %s::%s(<span style="background-color: %s">%s</span>)', $prefix, $profile->getTemplate(), $profile->getType(), self::$colors[$profile->getType()] ?? 'auto', $profile->getName());
|
||||
}
|
||||
|
||||
protected function formatTime(Profile $profile, $percent): string
|
||||
|
||||
@@ -43,7 +43,7 @@ abstract class NodeTestCase extends TestCase
|
||||
|
||||
protected function getCompiler(Environment $environment = null)
|
||||
{
|
||||
return new Compiler(null === $environment ? $this->getEnvironment() : $environment);
|
||||
return new Compiler($environment ?? $this->getEnvironment());
|
||||
}
|
||||
|
||||
protected function getEnvironment()
|
||||
|
||||
Reference in New Issue
Block a user