Skip to content

Commit

Permalink
Merge branch '3.4' into 4.4
Browse files Browse the repository at this point in the history
* 3.4:
  Enable "native_constant_invocation" CS rule
  Make AbstractPhpFileCacheWarmer public
  • Loading branch information
nicolas-grekas committed Sep 2, 2020
2 parents 448aefe + ae9afde commit ac5de06
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 18 deletions.
14 changes: 7 additions & 7 deletions Command/DebugCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function __construct(Environment $twig, string $projectDir = null, array
$this->twigDefaultPath = $twigDefaultPath;

if (\is_string($fileLinkFormatter) || $rootDir instanceof FileLinkFormatter) {
@trigger_error(sprintf('Passing a string as "$fileLinkFormatter" 5th argument or an instance of FileLinkFormatter as "$rootDir" 6th argument of the "%s()" method is deprecated since Symfony 4.4, swap the variables position.', __METHOD__), E_USER_DEPRECATED);
@trigger_error(sprintf('Passing a string as "$fileLinkFormatter" 5th argument or an instance of FileLinkFormatter as "$rootDir" 6th argument of the "%s()" method is deprecated since Symfony 4.4, swap the variables position.', __METHOD__), \E_USER_DEPRECATED);

$this->rootDir = $fileLinkFormatter;
$this->fileLinkFormatter = $rootDir;
Expand Down Expand Up @@ -276,7 +276,7 @@ private function displayGeneralJson(SymfonyStyle $io, ?string $filter)
$data['warnings'] = $this->buildWarningMessages($wrongBundles);
}

$data = json_encode($data, JSON_PRETTY_PRINT);
$data = json_encode($data, \JSON_PRETTY_PRINT);
$io->writeln($decorated ? OutputFormatter::escape($data) : $data);
}

Expand Down Expand Up @@ -406,23 +406,23 @@ private function findWrongBundleOverrides(): array
$bundleNames = [];

if ($this->rootDir && $this->projectDir) {
$folders = glob($this->rootDir.'/Resources/*/views', GLOB_ONLYDIR);
$folders = glob($this->rootDir.'/Resources/*/views', \GLOB_ONLYDIR);
$relativePath = ltrim(substr($this->rootDir.\DIRECTORY_SEPARATOR.'Resources/', \strlen($this->projectDir)), \DIRECTORY_SEPARATOR);
$bundleNames = array_reduce($folders, function ($carry, $absolutePath) use ($relativePath) {
if (0 === strpos($absolutePath, $this->projectDir)) {
$name = basename(\dirname($absolutePath));
$path = ltrim($relativePath.$name, \DIRECTORY_SEPARATOR);
$carry[$name] = $path;

@trigger_error(sprintf('Loading Twig templates from the "%s" directory is deprecated since Symfony 4.2, use "%s" instead.', $absolutePath, $this->twigDefaultPath.'/bundles/'.$name), E_USER_DEPRECATED);
@trigger_error(sprintf('Loading Twig templates from the "%s" directory is deprecated since Symfony 4.2, use "%s" instead.', $absolutePath, $this->twigDefaultPath.'/bundles/'.$name), \E_USER_DEPRECATED);
}

return $carry;
}, $bundleNames);
}

if ($this->twigDefaultPath && $this->projectDir) {
$folders = glob($this->twigDefaultPath.'/bundles/*', GLOB_ONLYDIR);
$folders = glob($this->twigDefaultPath.'/bundles/*', \GLOB_ONLYDIR);
$relativePath = ltrim(substr($this->twigDefaultPath.'/bundles/', \strlen($this->projectDir)), \DIRECTORY_SEPARATOR);
$bundleNames = array_reduce($folders, function ($carry, $absolutePath) use ($relativePath) {
if (0 === strpos($absolutePath, $this->projectDir)) {
Expand Down Expand Up @@ -562,7 +562,7 @@ private function findAlternatives(string $name, array $collection): array

$threshold = 1e3;
$alternatives = array_filter($alternatives, function ($lev) use ($threshold) { return $lev < 2 * $threshold; });
ksort($alternatives, SORT_NATURAL | SORT_FLAG_CASE);
ksort($alternatives, \SORT_NATURAL | \SORT_FLAG_CASE);

return array_keys($alternatives);
}
Expand All @@ -578,7 +578,7 @@ private function getRelativePath(string $path): string

private function isAbsolutePath(string $file): bool
{
return strspn($file, '/\\', 0, 1) || (\strlen($file) > 3 && ctype_alpha($file[0]) && ':' === $file[1] && strspn($file, '/\\', 2, 1)) || null !== parse_url($file, PHP_URL_SCHEME);
return strspn($file, '/\\', 0, 1) || (\strlen($file) > 3 && ctype_alpha($file[0]) && ':' === $file[1] && strspn($file, '/\\', 2, 1)) || null !== parse_url($file, \PHP_URL_SCHEME);
}

/**
Expand Down
8 changes: 4 additions & 4 deletions Command/LintCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ protected function execute(InputInterface $input, OutputInterface $output)

if (!$filenames) {
// @deprecated to be removed in 5.0
if (0 === ftell(STDIN)) {
@trigger_error('Piping content from STDIN to the "lint:twig" command without passing the dash symbol "-" as argument is deprecated since Symfony 4.4.', E_USER_DEPRECATED);
if (0 === ftell(\STDIN)) {
@trigger_error('Piping content from STDIN to the "lint:twig" command without passing the dash symbol "-" as argument is deprecated since Symfony 4.4.', \E_USER_DEPRECATED);

return $this->display($input, $output, $io, [$this->validate(file_get_contents('php://stdin'), uniqid('sf_', true))]);
}
Expand All @@ -108,7 +108,7 @@ protected function execute(InputInterface $input, OutputInterface $output)

if ($showDeprecations) {
$prevErrorHandler = set_error_handler(static function ($level, $message, $file, $line) use (&$prevErrorHandler) {
if (E_USER_DEPRECATED === $level) {
if (\E_USER_DEPRECATED === $level) {
$templateLine = 0;
if (preg_match('/ at line (\d+)[ .]/', $message, $matches)) {
$templateLine = $matches[1];
Expand Down Expand Up @@ -221,7 +221,7 @@ private function displayJson(OutputInterface $output, array $filesInfo)
}
});

$output->writeln(json_encode($filesInfo, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
$output->writeln(json_encode($filesInfo, \JSON_PRETTY_PRINT | \JSON_UNESCAPED_SLASHES));

return min($errors, 1);
}
Expand Down
6 changes: 3 additions & 3 deletions Extension/CodeExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public function formatArgs($args)
} elseif ('resource' === $item[0]) {
$formattedValue = '<em>resource</em>';
} else {
$formattedValue = str_replace("\n", '', htmlspecialchars(var_export($item[1], true), ENT_COMPAT | ENT_SUBSTITUTE, $this->charset));
$formattedValue = str_replace("\n", '', htmlspecialchars(var_export($item[1], true), \ENT_COMPAT | \ENT_SUBSTITUTE, $this->charset));
}

$result[] = \is_int($key) ? $formattedValue : sprintf("'%s' => %s", $key, $formattedValue);
Expand Down Expand Up @@ -192,7 +192,7 @@ public function formatFile($file, $line, $text = null)
}

if (false !== $link = $this->getFileLink($file, $line)) {
return sprintf('<a href="%s" title="Click to open this file" class="file_link">%s</a>', htmlspecialchars($link, ENT_COMPAT | ENT_SUBSTITUTE, $this->charset), $text);
return sprintf('<a href="%s" title="Click to open this file" class="file_link">%s</a>', htmlspecialchars($link, \ENT_COMPAT | \ENT_SUBSTITUTE, $this->charset), $text);
}

return $text;
Expand Down Expand Up @@ -251,7 +251,7 @@ public function formatLogMessage(string $message, array $context): string
}
}

return htmlspecialchars($message, ENT_COMPAT | ENT_SUBSTITUTE, $this->charset);
return htmlspecialchars($message, \ENT_COMPAT | \ENT_SUBSTITUTE, $this->charset);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion Extension/HttpFoundationExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function __construct($urlHelper)
throw new \TypeError(sprintf('The first argument must be an instance of "%s" or an instance of "%s".', UrlHelper::class, RequestStack::class));
}

@trigger_error(sprintf('Passing a "%s" instance as the first argument to the "%s" constructor is deprecated since Symfony 4.3, pass a "%s" instance instead.', RequestStack::class, __CLASS__, UrlHelper::class), E_USER_DEPRECATED);
@trigger_error(sprintf('Passing a "%s" instance as the first argument to the "%s" constructor is deprecated since Symfony 4.3, pass a "%s" instance instead.', RequestStack::class, __CLASS__, UrlHelper::class), \E_USER_DEPRECATED);

$requestContext = null;
if (2 === \func_num_args()) {
Expand Down
2 changes: 1 addition & 1 deletion TokenParser/TransChoiceTokenParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function parse(Token $token)
$lineno = $token->getLine();
$stream = $this->parser->getStream();

@trigger_error(sprintf('The "transchoice" tag is deprecated since Symfony 4.2, use the "trans" one instead with a "%%count%%" parameter in %s line %d.', $stream->getSourceContext()->getName(), $lineno), E_USER_DEPRECATED);
@trigger_error(sprintf('The "transchoice" tag is deprecated since Symfony 4.2, use the "trans" one instead with a "%%count%%" parameter in %s line %d.', $stream->getSourceContext()->getName(), $lineno), \E_USER_DEPRECATED);

$vars = new ArrayExpression([], $lineno);

Expand Down
2 changes: 1 addition & 1 deletion Translation/TwigExtractor.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ protected function extractTemplate($template, MessageCatalogue $catalogue)
*/
protected function canBeExtracted($file)
{
return $this->isFile($file) && 'twig' === pathinfo($file, PATHINFO_EXTENSION);
return $this->isFile($file) && 'twig' === pathinfo($file, \PATHINFO_EXTENSION);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion TwigEngine.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace Symfony\Bridge\Twig;

@trigger_error('The '.TwigEngine::class.' class is deprecated since version 4.3 and will be removed in 5.0; use \Twig\Environment instead.', E_USER_DEPRECATED);
@trigger_error('The '.TwigEngine::class.' class is deprecated since version 4.3 and will be removed in 5.0; use \Twig\Environment instead.', \E_USER_DEPRECATED);

use Symfony\Component\Templating\EngineInterface;
use Symfony\Component\Templating\StreamingEngineInterface;
Expand Down

0 comments on commit ac5de06

Please sign in to comment.