Do not override PHP constants, only use when available
This commit is contained in:
parent
1439da4c30
commit
d5cc056cd3
@ -11,10 +11,6 @@
|
|||||||
|
|
||||||
namespace Symfony\Bridge\Twig\Command;
|
namespace Symfony\Bridge\Twig\Command;
|
||||||
|
|
||||||
if (!defined('JSON_PRETTY_PRINT')) {
|
|
||||||
define('JSON_PRETTY_PRINT', 128);
|
|
||||||
}
|
|
||||||
|
|
||||||
use Symfony\Component\Console\Command\Command;
|
use Symfony\Component\Console\Command\Command;
|
||||||
use Symfony\Component\Console\Input\InputInterface;
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
use Symfony\Component\Console\Input\InputOption;
|
use Symfony\Component\Console\Input\InputOption;
|
||||||
@ -40,7 +36,7 @@ class LintCommand extends Command
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the twig environment
|
* Sets the twig environment.
|
||||||
*
|
*
|
||||||
* @param \Twig_Environment $twig
|
* @param \Twig_Environment $twig
|
||||||
*/
|
*/
|
||||||
@ -98,7 +94,7 @@ EOF
|
|||||||
|
|
||||||
if (!$filename) {
|
if (!$filename) {
|
||||||
if (0 !== ftell(STDIN)) {
|
if (0 !== ftell(STDIN)) {
|
||||||
throw new \RuntimeException("Please provide a filename or pipe template content to STDIN.");
|
throw new \RuntimeException('Please provide a filename or pipe template content to STDIN.');
|
||||||
}
|
}
|
||||||
|
|
||||||
$template = '';
|
$template = '';
|
||||||
@ -190,7 +186,7 @@ EOF
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$output->writeln(json_encode($filesInfo, JSON_PRETTY_PRINT));
|
$output->writeln(json_encode($filesInfo, defined('JSON_PRETTY_PRINT') ? JSON_PRETTY_PRINT : 0));
|
||||||
|
|
||||||
return min($errors, 1);
|
return min($errors, 1);
|
||||||
}
|
}
|
||||||
@ -200,14 +196,14 @@ EOF
|
|||||||
$line = $exception->getTemplateLine();
|
$line = $exception->getTemplateLine();
|
||||||
|
|
||||||
if ($file) {
|
if ($file) {
|
||||||
$output->writeln(sprintf("<error>KO</error> in %s (line %s)", $file, $line));
|
$output->writeln(sprintf('<error>KO</error> in %s (line %s)', $file, $line));
|
||||||
} else {
|
} else {
|
||||||
$output->writeln(sprintf("<error>KO</error> (line %s)", $line));
|
$output->writeln(sprintf('<error>KO</error> (line %s)', $line));
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($this->getContext($template, $line) as $no => $code) {
|
foreach ($this->getContext($template, $line) as $no => $code) {
|
||||||
$output->writeln(sprintf(
|
$output->writeln(sprintf(
|
||||||
"%s %-6s %s",
|
'%s %-6s %s',
|
||||||
$no == $line ? '<error>>></error>' : ' ',
|
$no == $line ? '<error>>></error>' : ' ',
|
||||||
$no,
|
$no,
|
||||||
$code
|
$code
|
||||||
|
@ -11,10 +11,6 @@
|
|||||||
|
|
||||||
namespace Symfony\Bundle\FrameworkBundle\Command;
|
namespace Symfony\Bundle\FrameworkBundle\Command;
|
||||||
|
|
||||||
if (!defined('JSON_PRETTY_PRINT')) {
|
|
||||||
define('JSON_PRETTY_PRINT', 128);
|
|
||||||
}
|
|
||||||
|
|
||||||
use Symfony\Component\Console\Command\Command;
|
use Symfony\Component\Console\Command\Command;
|
||||||
use Symfony\Component\Console\Input\InputInterface;
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
use Symfony\Component\Console\Input\InputOption;
|
use Symfony\Component\Console\Input\InputOption;
|
||||||
@ -156,7 +152,7 @@ EOF
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$output->writeln(json_encode($filesInfo, JSON_PRETTY_PRINT));
|
$output->writeln(json_encode($filesInfo, defined('JSON_PRETTY_PRINT') ? JSON_PRETTY_PRINT : 0));
|
||||||
|
|
||||||
return min($errors, 1);
|
return min($errors, 1);
|
||||||
}
|
}
|
||||||
|
@ -11,10 +11,6 @@
|
|||||||
|
|
||||||
namespace Symfony\Bundle\FrameworkBundle\Console\Descriptor;
|
namespace Symfony\Bundle\FrameworkBundle\Console\Descriptor;
|
||||||
|
|
||||||
if (!defined('JSON_PRETTY_PRINT')) {
|
|
||||||
define('JSON_PRETTY_PRINT', 128);
|
|
||||||
}
|
|
||||||
|
|
||||||
use Symfony\Component\DependencyInjection\Alias;
|
use Symfony\Component\DependencyInjection\Alias;
|
||||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||||
use Symfony\Component\DependencyInjection\Definition;
|
use Symfony\Component\DependencyInjection\Definition;
|
||||||
@ -174,7 +170,13 @@ class JsonDescriptor extends Descriptor
|
|||||||
*/
|
*/
|
||||||
private function writeData(array $data, array $options)
|
private function writeData(array $data, array $options)
|
||||||
{
|
{
|
||||||
$this->write(json_encode($data, (isset($options['json_encoding']) ? $options['json_encoding'] : 0) | JSON_PRETTY_PRINT)."\n");
|
$flags = isset($options['json_encoding']) ? $options['json_encoding'] : 0;
|
||||||
|
|
||||||
|
if (defined('JSON_PRETTY_PRINT')) {
|
||||||
|
$flags |= JSON_PRETTY_PRINT;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->write(json_encode($data, $flags)."\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -13,10 +13,6 @@ namespace Symfony\Component\Translation\Dumper;
|
|||||||
|
|
||||||
use Symfony\Component\Translation\MessageCatalogue;
|
use Symfony\Component\Translation\MessageCatalogue;
|
||||||
|
|
||||||
if (!defined('JSON_PRETTY_PRINT')) {
|
|
||||||
define('JSON_PRETTY_PRINT', 128);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* JsonFileDumper generates an json formatted string representation of a message catalogue.
|
* JsonFileDumper generates an json formatted string representation of a message catalogue.
|
||||||
*
|
*
|
||||||
@ -29,7 +25,7 @@ class JsonFileDumper extends FileDumper
|
|||||||
*/
|
*/
|
||||||
public function format(MessageCatalogue $messages, $domain = 'messages')
|
public function format(MessageCatalogue $messages, $domain = 'messages')
|
||||||
{
|
{
|
||||||
return json_encode($messages->all($domain), JSON_PRETTY_PRINT);
|
return json_encode($messages->all($domain), defined('JSON_PRETTY_PRINT') ? JSON_PRETTY_PRINT : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user