Merge branch '5.1'
* 5.1: Enable "native_constant_invocation" CS rule Make AbstractPhpFileCacheWarmer public Fix CS Add a warning comment on ldap empty password Bump Symfony version to 4.4.14 Update VERSION for 4.4.13 Update CHANGELOG for 4.4.13 [PhpunitBridge] Fix deprecation type detection
This commit is contained in:
commit
4ee85e8e3b
@ -13,6 +13,7 @@ return PhpCsFixer\Config::create()
|
|||||||
'array_syntax' => ['syntax' => 'short'],
|
'array_syntax' => ['syntax' => 'short'],
|
||||||
'fopen_flags' => false,
|
'fopen_flags' => false,
|
||||||
'protected_to_private' => false,
|
'protected_to_private' => false,
|
||||||
|
'native_constant_invocation' => true,
|
||||||
'combine_nested_dirname' => true,
|
'combine_nested_dirname' => true,
|
||||||
])
|
])
|
||||||
->setRiskyAllowed(true)
|
->setRiskyAllowed(true)
|
||||||
|
@ -7,6 +7,15 @@ in 4.4 minor versions.
|
|||||||
To get the diff for a specific change, go to https://github.com/symfony/symfony/commit/XXX where XXX is the change hash
|
To get the diff for a specific change, go to https://github.com/symfony/symfony/commit/XXX where XXX is the change hash
|
||||||
To get the diff between two versions, go to https://github.com/symfony/symfony/compare/v4.4.0...v4.4.1
|
To get the diff between two versions, go to https://github.com/symfony/symfony/compare/v4.4.0...v4.4.1
|
||||||
|
|
||||||
|
* 4.4.13 (2020-09-02)
|
||||||
|
|
||||||
|
* security #cve-2020-15094 Remove headers with internal meaning from HttpClient responses (mpdude)
|
||||||
|
* bug #38024 [Console] Fix undefined index for inconsistent command name definition (chalasr)
|
||||||
|
* bug #38023 [DI] fix inlining of non-shared services (nicolas-grekas)
|
||||||
|
* bug #38020 [PhpUnitBridge] swallow deprecations (xabbuh)
|
||||||
|
* bug #38010 [Cache] Psr16Cache does not handle Proxy cache items (alex-dev)
|
||||||
|
* bug #37937 [Serializer] fixed fix encoding of cache keys with anonymous classes (michaelzangerle)
|
||||||
|
|
||||||
* 4.4.12 (2020-08-31)
|
* 4.4.12 (2020-08-31)
|
||||||
|
|
||||||
* bug #37966 [HttpClient][MockHttpClient][DX] Throw when the response factory callable does not return a valid response (fancyweb)
|
* bug #37966 [HttpClient][MockHttpClient][DX] Throw when the response factory callable does not return a valid response (fancyweb)
|
||||||
|
@ -242,11 +242,11 @@ abstract class AbstractDoctrineExtension extends Extension
|
|||||||
$configPath = $this->getMappingResourceConfigDirectory();
|
$configPath = $this->getMappingResourceConfigDirectory();
|
||||||
$extension = $this->getMappingResourceExtension();
|
$extension = $this->getMappingResourceExtension();
|
||||||
|
|
||||||
if (glob($dir.'/'.$configPath.'/*.'.$extension.'.xml', GLOB_NOSORT)) {
|
if (glob($dir.'/'.$configPath.'/*.'.$extension.'.xml', \GLOB_NOSORT)) {
|
||||||
$driver = 'xml';
|
$driver = 'xml';
|
||||||
} elseif (glob($dir.'/'.$configPath.'/*.'.$extension.'.yml', GLOB_NOSORT)) {
|
} elseif (glob($dir.'/'.$configPath.'/*.'.$extension.'.yml', \GLOB_NOSORT)) {
|
||||||
$driver = 'yml';
|
$driver = 'yml';
|
||||||
} elseif (glob($dir.'/'.$configPath.'/*.'.$extension.'.php', GLOB_NOSORT)) {
|
} elseif (glob($dir.'/'.$configPath.'/*.'.$extension.'.php', \GLOB_NOSORT)) {
|
||||||
$driver = 'php';
|
$driver = 'php';
|
||||||
} else {
|
} else {
|
||||||
// add the closest existing directory as a resource
|
// add the closest existing directory as a resource
|
||||||
|
@ -99,7 +99,7 @@ trait ServerLogHandlerTrait
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
if (-1 === stream_socket_sendto($this->socket, $recordFormatted)) {
|
if (-1 === stream_socket_sendto($this->socket, $recordFormatted)) {
|
||||||
stream_socket_shutdown($this->socket, STREAM_SHUT_RDWR);
|
stream_socket_shutdown($this->socket, \STREAM_SHUT_RDWR);
|
||||||
|
|
||||||
// Let's retry: the persistent connection might just be stale
|
// Let's retry: the persistent connection might just be stale
|
||||||
if ($this->socket = $this->createSocket()) {
|
if ($this->socket = $this->createSocket()) {
|
||||||
@ -125,7 +125,7 @@ trait ServerLogHandlerTrait
|
|||||||
|
|
||||||
private function createSocket()
|
private function createSocket()
|
||||||
{
|
{
|
||||||
$socket = stream_socket_client($this->host, $errno, $errstr, 0, STREAM_CLIENT_CONNECT | STREAM_CLIENT_ASYNC_CONNECT | STREAM_CLIENT_PERSISTENT, $this->context);
|
$socket = stream_socket_client($this->host, $errno, $errstr, 0, \STREAM_CLIENT_CONNECT | \STREAM_CLIENT_ASYNC_CONNECT | \STREAM_CLIENT_PERSISTENT, $this->context);
|
||||||
|
|
||||||
if ($socket) {
|
if ($socket) {
|
||||||
stream_set_blocking($socket, false);
|
stream_set_blocking($socket, false);
|
||||||
|
@ -89,7 +89,7 @@ class DeprecationErrorHandler
|
|||||||
{
|
{
|
||||||
$deprecations = [];
|
$deprecations = [];
|
||||||
$previousErrorHandler = set_error_handler(function ($type, $msg, $file, $line, $context = []) use (&$deprecations, &$previousErrorHandler) {
|
$previousErrorHandler = set_error_handler(function ($type, $msg, $file, $line, $context = []) use (&$deprecations, &$previousErrorHandler) {
|
||||||
if (E_USER_DEPRECATED !== $type && E_DEPRECATED !== $type && (E_WARNING !== $type || false === strpos($msg, '" targeting switch is equivalent to "break'))) {
|
if (\E_USER_DEPRECATED !== $type && \E_DEPRECATED !== $type && (\E_WARNING !== $type || false === strpos($msg, '" targeting switch is equivalent to "break'))) {
|
||||||
if ($previousErrorHandler) {
|
if ($previousErrorHandler) {
|
||||||
return $previousErrorHandler($type, $msg, $file, $line, $context);
|
return $previousErrorHandler($type, $msg, $file, $line, $context);
|
||||||
}
|
}
|
||||||
@ -121,7 +121,7 @@ class DeprecationErrorHandler
|
|||||||
*/
|
*/
|
||||||
public function handleError($type, $msg, $file, $line, $context = [])
|
public function handleError($type, $msg, $file, $line, $context = [])
|
||||||
{
|
{
|
||||||
if ((E_USER_DEPRECATED !== $type && E_DEPRECATED !== $type && (E_WARNING !== $type || false === strpos($msg, '" targeting switch is equivalent to "break'))) || !$this->getConfiguration()->isEnabled()) {
|
if ((\E_USER_DEPRECATED !== $type && \E_DEPRECATED !== $type && (\E_WARNING !== $type || false === strpos($msg, '" targeting switch is equivalent to "break'))) || !$this->getConfiguration()->isEnabled()) {
|
||||||
return \call_user_func(self::getPhpUnitErrorHandler(), $type, $msg, $file, $line, $context);
|
return \call_user_func(self::getPhpUnitErrorHandler(), $type, $msg, $file, $line, $context);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -337,7 +337,7 @@ class DeprecationErrorHandler
|
|||||||
return 'PHPUnit\Util\ErrorHandler::handleError';
|
return 'PHPUnit\Util\ErrorHandler::handleError';
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (debug_backtrace(DEBUG_BACKTRACE_PROVIDE_OBJECT | DEBUG_BACKTRACE_IGNORE_ARGS) as $frame) {
|
foreach (debug_backtrace(\DEBUG_BACKTRACE_PROVIDE_OBJECT | \DEBUG_BACKTRACE_IGNORE_ARGS) as $frame) {
|
||||||
if (isset($frame['object']) && $frame['object'] instanceof TestResult) {
|
if (isset($frame['object']) && $frame['object'] instanceof TestResult) {
|
||||||
return new ErrorHandler(
|
return new ErrorHandler(
|
||||||
$frame['object']->getConvertDeprecationsToExceptions(),
|
$frame['object']->getConvertDeprecationsToExceptions(),
|
||||||
@ -376,21 +376,21 @@ class DeprecationErrorHandler
|
|||||||
|
|
||||||
if (\DIRECTORY_SEPARATOR === '\\') {
|
if (\DIRECTORY_SEPARATOR === '\\') {
|
||||||
return (\function_exists('sapi_windows_vt100_support')
|
return (\function_exists('sapi_windows_vt100_support')
|
||||||
&& sapi_windows_vt100_support(STDOUT))
|
&& sapi_windows_vt100_support(\STDOUT))
|
||||||
|| false !== getenv('ANSICON')
|
|| false !== getenv('ANSICON')
|
||||||
|| 'ON' === getenv('ConEmuANSI')
|
|| 'ON' === getenv('ConEmuANSI')
|
||||||
|| 'xterm' === getenv('TERM');
|
|| 'xterm' === getenv('TERM');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (\function_exists('stream_isatty')) {
|
if (\function_exists('stream_isatty')) {
|
||||||
return stream_isatty(STDOUT);
|
return stream_isatty(\STDOUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (\function_exists('posix_isatty')) {
|
if (\function_exists('posix_isatty')) {
|
||||||
return posix_isatty(STDOUT);
|
return posix_isatty(\STDOUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
$stat = fstat(STDOUT);
|
$stat = fstat(\STDOUT);
|
||||||
|
|
||||||
// Check if formatted mode is S_IFCHR
|
// Check if formatted mode is S_IFCHR
|
||||||
return $stat ? 0020000 === ($stat['mode'] & 0170000) : false;
|
return $stat ? 0020000 === ($stat['mode'] & 0170000) : false;
|
||||||
|
@ -173,13 +173,13 @@ class Configuration
|
|||||||
'quiet' => [],
|
'quiet' => [],
|
||||||
];
|
];
|
||||||
|
|
||||||
if ('' === $normalizedConfiguration['disabled'] || filter_var($normalizedConfiguration['disabled'], FILTER_VALIDATE_BOOLEAN)) {
|
if ('' === $normalizedConfiguration['disabled'] || filter_var($normalizedConfiguration['disabled'], \FILTER_VALIDATE_BOOLEAN)) {
|
||||||
return self::inDisabledMode();
|
return self::inDisabledMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
$verboseOutput = [];
|
$verboseOutput = [];
|
||||||
foreach (['unsilenced', 'direct', 'indirect', 'self', 'other'] as $group) {
|
foreach (['unsilenced', 'direct', 'indirect', 'self', 'other'] as $group) {
|
||||||
$verboseOutput[$group] = filter_var($normalizedConfiguration['verbose'], FILTER_VALIDATE_BOOLEAN);
|
$verboseOutput[$group] = filter_var($normalizedConfiguration['verbose'], \FILTER_VALIDATE_BOOLEAN);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (\is_array($normalizedConfiguration['quiet'])) {
|
if (\is_array($normalizedConfiguration['quiet'])) {
|
||||||
|
@ -270,7 +270,10 @@ class Deprecation
|
|||||||
if (file_exists($v.'/composer/installed.json')) {
|
if (file_exists($v.'/composer/installed.json')) {
|
||||||
self::$vendors[] = $v;
|
self::$vendors[] = $v;
|
||||||
$loader = require $v.'/autoload.php';
|
$loader = require $v.'/autoload.php';
|
||||||
$paths = self::getSourcePathsFromPrefixes(array_merge($loader->getPrefixes(), $loader->getPrefixesPsr4()));
|
$paths = self::addSourcePathsFromPrefixes(
|
||||||
|
array_merge($loader->getPrefixes(), $loader->getPrefixesPsr4()),
|
||||||
|
$paths
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -286,15 +289,17 @@ class Deprecation
|
|||||||
return self::$vendors;
|
return self::$vendors;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function getSourcePathsFromPrefixes(array $prefixesByNamespace)
|
private static function addSourcePathsFromPrefixes(array $prefixesByNamespace, array $paths)
|
||||||
{
|
{
|
||||||
foreach ($prefixesByNamespace as $prefixes) {
|
foreach ($prefixesByNamespace as $prefixes) {
|
||||||
foreach ($prefixes as $prefix) {
|
foreach ($prefixes as $prefix) {
|
||||||
if (false !== realpath($prefix)) {
|
if (false !== realpath($prefix)) {
|
||||||
yield realpath($prefix);
|
$paths[] = realpath($prefix);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return $paths;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -0,0 +1,5 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
require_once __DIR__.'/composer/autoload_real.php';
|
||||||
|
|
||||||
|
return ComposerAutoloaderInitFakeBis::getLoader();
|
@ -0,0 +1,47 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
class ComposerLoaderFakeBis
|
||||||
|
{
|
||||||
|
public function getPrefixes()
|
||||||
|
{
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getPrefixesPsr4()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'foo\\lib\\' => [__DIR__.'/../foo/lib/'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function loadClass($className)
|
||||||
|
{
|
||||||
|
foreach ($this->getPrefixesPsr4() as $prefix => $baseDirs) {
|
||||||
|
if (strpos($className, $prefix) !== 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($baseDirs as $baseDir) {
|
||||||
|
$file = str_replace([$prefix, '\\'], [$baseDir, '/'], $className.'.php');
|
||||||
|
if (file_exists($file)) {
|
||||||
|
require $file;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class ComposerAutoloaderInitFakeBis
|
||||||
|
{
|
||||||
|
private static $loader;
|
||||||
|
|
||||||
|
public static function getLoader()
|
||||||
|
{
|
||||||
|
if (null === self::$loader) {
|
||||||
|
self::$loader = new ComposerLoaderFakeBis();
|
||||||
|
spl_autoload_register([self::$loader, 'loadClass']);
|
||||||
|
}
|
||||||
|
|
||||||
|
return self::$loader;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1 @@
|
|||||||
|
{"just here": "for the detection"}
|
@ -0,0 +1,14 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace foo\lib;
|
||||||
|
|
||||||
|
class SomeOtherService
|
||||||
|
{
|
||||||
|
public function deprecatedApi()
|
||||||
|
{
|
||||||
|
@trigger_error(
|
||||||
|
__FUNCTION__.' from foo is deprecated! You should stop relying on it!',
|
||||||
|
E_USER_DEPRECATED
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,45 @@
|
|||||||
|
--TEST--
|
||||||
|
Test DeprecationErrorHandler with multiple autoload files
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
|
||||||
|
$k = 'SYMFONY_DEPRECATIONS_HELPER';
|
||||||
|
putenv($k.'='.$_SERVER[$k] = $_ENV[$k] = 'max[self]=0');
|
||||||
|
putenv('ANSICON');
|
||||||
|
putenv('ConEmuANSI');
|
||||||
|
putenv('TERM');
|
||||||
|
|
||||||
|
$vendor = __DIR__;
|
||||||
|
while (!file_exists($vendor.'/vendor')) {
|
||||||
|
$vendor = dirname($vendor);
|
||||||
|
}
|
||||||
|
define('PHPUNIT_COMPOSER_INSTALL', $vendor.'/vendor/autoload.php');
|
||||||
|
require PHPUNIT_COMPOSER_INSTALL;
|
||||||
|
require_once __DIR__.'/../../bootstrap.php';
|
||||||
|
|
||||||
|
eval(<<<'EOPHP'
|
||||||
|
namespace PHPUnit\Util;
|
||||||
|
|
||||||
|
class Test
|
||||||
|
{
|
||||||
|
public static function getGroups()
|
||||||
|
{
|
||||||
|
return array();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
EOPHP
|
||||||
|
);
|
||||||
|
|
||||||
|
require __DIR__.'/fake_vendor/autoload.php';
|
||||||
|
require __DIR__.'/fake_vendor_bis/autoload.php';
|
||||||
|
|
||||||
|
(new \App\Services\AppService())->directDeprecations();
|
||||||
|
?>
|
||||||
|
--EXPECTF--
|
||||||
|
Remaining direct deprecation notices (2)
|
||||||
|
|
||||||
|
1x: deprecatedApi is deprecated! You should stop relying on it!
|
||||||
|
1x in AppService::directDeprecations from App\Services
|
||||||
|
|
||||||
|
1x: deprecatedApi from foo is deprecated! You should stop relying on it!
|
||||||
|
1x in AppService::directDeprecations from App\Services
|
@ -141,8 +141,8 @@ class DnsMockTest extends TestCase
|
|||||||
|
|
||||||
$this->assertFalse(DnsMock::dns_get_record('foobar.com'));
|
$this->assertFalse(DnsMock::dns_get_record('foobar.com'));
|
||||||
$this->assertSame($records, DnsMock::dns_get_record('example.com'));
|
$this->assertSame($records, DnsMock::dns_get_record('example.com'));
|
||||||
$this->assertSame($records, DnsMock::dns_get_record('example.com', DNS_ALL));
|
$this->assertSame($records, DnsMock::dns_get_record('example.com', \DNS_ALL));
|
||||||
$this->assertSame($records, DnsMock::dns_get_record('example.com', DNS_A | DNS_PTR));
|
$this->assertSame($records, DnsMock::dns_get_record('example.com', \DNS_A | \DNS_PTR));
|
||||||
$this->assertSame([$ptr], DnsMock::dns_get_record('example.com', DNS_PTR));
|
$this->assertSame([$ptr], DnsMock::dns_get_record('example.com', \DNS_PTR));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@ final class ExpectDeprecationTraitTest extends TestCase
|
|||||||
public function testOne()
|
public function testOne()
|
||||||
{
|
{
|
||||||
$this->expectDeprecation('foo');
|
$this->expectDeprecation('foo');
|
||||||
@trigger_error('foo', E_USER_DEPRECATED);
|
@trigger_error('foo', \E_USER_DEPRECATED);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -38,7 +38,7 @@ final class ExpectDeprecationTraitTest extends TestCase
|
|||||||
public function testOneInIsolation()
|
public function testOneInIsolation()
|
||||||
{
|
{
|
||||||
$this->expectDeprecation('foo');
|
$this->expectDeprecation('foo');
|
||||||
@trigger_error('foo', E_USER_DEPRECATED);
|
@trigger_error('foo', \E_USER_DEPRECATED);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -50,8 +50,8 @@ final class ExpectDeprecationTraitTest extends TestCase
|
|||||||
{
|
{
|
||||||
$this->expectDeprecation('foo');
|
$this->expectDeprecation('foo');
|
||||||
$this->expectDeprecation('bar');
|
$this->expectDeprecation('bar');
|
||||||
@trigger_error('foo', E_USER_DEPRECATED);
|
@trigger_error('foo', \E_USER_DEPRECATED);
|
||||||
@trigger_error('bar', E_USER_DEPRECATED);
|
@trigger_error('bar', \E_USER_DEPRECATED);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -64,8 +64,8 @@ final class ExpectDeprecationTraitTest extends TestCase
|
|||||||
public function testOneWithAnnotation()
|
public function testOneWithAnnotation()
|
||||||
{
|
{
|
||||||
$this->expectDeprecation('bar');
|
$this->expectDeprecation('bar');
|
||||||
@trigger_error('foo', E_USER_DEPRECATED);
|
@trigger_error('foo', \E_USER_DEPRECATED);
|
||||||
@trigger_error('bar', E_USER_DEPRECATED);
|
@trigger_error('bar', \E_USER_DEPRECATED);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -80,9 +80,9 @@ final class ExpectDeprecationTraitTest extends TestCase
|
|||||||
{
|
{
|
||||||
$this->expectDeprecation('ccc');
|
$this->expectDeprecation('ccc');
|
||||||
$this->expectDeprecation('fcy');
|
$this->expectDeprecation('fcy');
|
||||||
@trigger_error('foo', E_USER_DEPRECATED);
|
@trigger_error('foo', \E_USER_DEPRECATED);
|
||||||
@trigger_error('bar', E_USER_DEPRECATED);
|
@trigger_error('bar', \E_USER_DEPRECATED);
|
||||||
@trigger_error('ccc', E_USER_DEPRECATED);
|
@trigger_error('ccc', \E_USER_DEPRECATED);
|
||||||
@trigger_error('fcy', E_USER_DEPRECATED);
|
@trigger_error('fcy', \E_USER_DEPRECATED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@ final class ExpectedDeprecationAnnotationTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testOne()
|
public function testOne()
|
||||||
{
|
{
|
||||||
@trigger_error('foo', E_USER_DEPRECATED);
|
@trigger_error('foo', \E_USER_DEPRECATED);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -37,7 +37,7 @@ final class ExpectedDeprecationAnnotationTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testMany()
|
public function testMany()
|
||||||
{
|
{
|
||||||
@trigger_error('foo', E_USER_DEPRECATED);
|
@trigger_error('foo', \E_USER_DEPRECATED);
|
||||||
@trigger_error('bar', E_USER_DEPRECATED);
|
@trigger_error('bar', \E_USER_DEPRECATED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@ final class ExpectDeprecationTraitTestFail extends TestCase
|
|||||||
public function testOne()
|
public function testOne()
|
||||||
{
|
{
|
||||||
$this->expectDeprecation('foo');
|
$this->expectDeprecation('foo');
|
||||||
@trigger_error('bar', E_USER_DEPRECATED);
|
@trigger_error('bar', \E_USER_DEPRECATED);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -44,6 +44,6 @@ final class ExpectDeprecationTraitTestFail extends TestCase
|
|||||||
public function testOneInIsolation()
|
public function testOneInIsolation()
|
||||||
{
|
{
|
||||||
$this->expectDeprecation('foo');
|
$this->expectDeprecation('foo');
|
||||||
@trigger_error('bar', E_USER_DEPRECATED);
|
@trigger_error('bar', \E_USER_DEPRECATED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@ class ProcessIsolationTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testIsolation()
|
public function testIsolation()
|
||||||
{
|
{
|
||||||
@trigger_error('Test abc', E_USER_DEPRECATED);
|
@trigger_error('Test abc', \E_USER_DEPRECATED);
|
||||||
$this->addToAssertionCount(1);
|
$this->addToAssertionCount(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -27,6 +27,6 @@ class ProcessIsolationTest extends TestCase
|
|||||||
$this->expectException('PHPUnit\Framework\Exception');
|
$this->expectException('PHPUnit\Framework\Exception');
|
||||||
$this->expectExceptionMessage('Test that PHPUnit\'s error handler fires.');
|
$this->expectExceptionMessage('Test that PHPUnit\'s error handler fires.');
|
||||||
|
|
||||||
trigger_error('Test that PHPUnit\'s error handler fires.', E_USER_WARNING);
|
trigger_error('Test that PHPUnit\'s error handler fires.', \E_USER_WARNING);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ $getEnvVar = function ($name, $default = false) use ($argv) {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (is_dir($probableConfig)) {
|
if (is_dir($probableConfig)) {
|
||||||
return $getPhpUnitConfig($probableConfig.DIRECTORY_SEPARATOR.'phpunit.xml');
|
return $getPhpUnitConfig($probableConfig.\DIRECTORY_SEPARATOR.'phpunit.xml');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (file_exists($probableConfig)) {
|
if (file_exists($probableConfig)) {
|
||||||
@ -93,19 +93,19 @@ $passthruOrFail = function ($command) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if (PHP_VERSION_ID >= 80000) {
|
if (\PHP_VERSION_ID >= 80000) {
|
||||||
// PHP 8 requires PHPUnit 9.3+
|
// PHP 8 requires PHPUnit 9.3+
|
||||||
$PHPUNIT_VERSION = $getEnvVar('SYMFONY_PHPUNIT_VERSION', '9.3');
|
$PHPUNIT_VERSION = $getEnvVar('SYMFONY_PHPUNIT_VERSION', '9.3');
|
||||||
} elseif (PHP_VERSION_ID >= 70200) {
|
} elseif (\PHP_VERSION_ID >= 70200) {
|
||||||
// PHPUnit 8 requires PHP 7.2+
|
// PHPUnit 8 requires PHP 7.2+
|
||||||
$PHPUNIT_VERSION = $getEnvVar('SYMFONY_PHPUNIT_VERSION', '8.3');
|
$PHPUNIT_VERSION = $getEnvVar('SYMFONY_PHPUNIT_VERSION', '8.3');
|
||||||
} elseif (PHP_VERSION_ID >= 70100) {
|
} elseif (\PHP_VERSION_ID >= 70100) {
|
||||||
// PHPUnit 7 requires PHP 7.1+
|
// PHPUnit 7 requires PHP 7.1+
|
||||||
$PHPUNIT_VERSION = $getEnvVar('SYMFONY_PHPUNIT_VERSION', '7.5');
|
$PHPUNIT_VERSION = $getEnvVar('SYMFONY_PHPUNIT_VERSION', '7.5');
|
||||||
} elseif (PHP_VERSION_ID >= 70000) {
|
} elseif (\PHP_VERSION_ID >= 70000) {
|
||||||
// PHPUnit 6 requires PHP 7.0+
|
// PHPUnit 6 requires PHP 7.0+
|
||||||
$PHPUNIT_VERSION = $getEnvVar('SYMFONY_PHPUNIT_VERSION', '6.5');
|
$PHPUNIT_VERSION = $getEnvVar('SYMFONY_PHPUNIT_VERSION', '6.5');
|
||||||
} elseif (PHP_VERSION_ID >= 50600) {
|
} elseif (\PHP_VERSION_ID >= 50600) {
|
||||||
// PHPUnit 4 does not support PHP 7
|
// PHPUnit 4 does not support PHP 7
|
||||||
$PHPUNIT_VERSION = $getEnvVar('SYMFONY_PHPUNIT_VERSION', '5.7');
|
$PHPUNIT_VERSION = $getEnvVar('SYMFONY_PHPUNIT_VERSION', '5.7');
|
||||||
} else {
|
} else {
|
||||||
@ -113,7 +113,7 @@ if (PHP_VERSION_ID >= 80000) {
|
|||||||
$PHPUNIT_VERSION = '4.8';
|
$PHPUNIT_VERSION = '4.8';
|
||||||
}
|
}
|
||||||
|
|
||||||
$PHPUNIT_REMOVE_RETURN_TYPEHINT = filter_var($getEnvVar('SYMFONY_PHPUNIT_REMOVE_RETURN_TYPEHINT', '0'), FILTER_VALIDATE_BOOLEAN);
|
$PHPUNIT_REMOVE_RETURN_TYPEHINT = filter_var($getEnvVar('SYMFONY_PHPUNIT_REMOVE_RETURN_TYPEHINT', '0'), \FILTER_VALIDATE_BOOLEAN);
|
||||||
|
|
||||||
$COMPOSER_JSON = getenv('COMPOSER') ?: 'composer.json';
|
$COMPOSER_JSON = getenv('COMPOSER') ?: 'composer.json';
|
||||||
|
|
||||||
@ -127,9 +127,9 @@ while (!file_exists($root.'/'.$COMPOSER_JSON) || file_exists($root.'/Deprecation
|
|||||||
|
|
||||||
$oldPwd = getcwd();
|
$oldPwd = getcwd();
|
||||||
$PHPUNIT_DIR = $getEnvVar('SYMFONY_PHPUNIT_DIR', $root.'/vendor/bin/.phpunit');
|
$PHPUNIT_DIR = $getEnvVar('SYMFONY_PHPUNIT_DIR', $root.'/vendor/bin/.phpunit');
|
||||||
$PHP = defined('PHP_BINARY') ? PHP_BINARY : 'php';
|
$PHP = defined('PHP_BINARY') ? \PHP_BINARY : 'php';
|
||||||
$PHP = escapeshellarg($PHP);
|
$PHP = escapeshellarg($PHP);
|
||||||
if ('phpdbg' === PHP_SAPI) {
|
if ('phpdbg' === \PHP_SAPI) {
|
||||||
$PHP .= ' -qrr';
|
$PHP .= ' -qrr';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -148,14 +148,14 @@ foreach ($defaultEnvs as $envName => $envValue) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$COMPOSER = file_exists($COMPOSER = $oldPwd.'/composer.phar')
|
$COMPOSER = file_exists($COMPOSER = $oldPwd.'/composer.phar')
|
||||||
|| ($COMPOSER = rtrim('\\' === DIRECTORY_SEPARATOR ? preg_replace('/[\r\n].*/', '', `where.exe composer.phar`) : `which composer.phar 2> /dev/null`))
|
|| ($COMPOSER = rtrim('\\' === \DIRECTORY_SEPARATOR ? preg_replace('/[\r\n].*/', '', `where.exe composer.phar`) : `which composer.phar 2> /dev/null`))
|
||||||
|| ($COMPOSER = rtrim('\\' === DIRECTORY_SEPARATOR ? preg_replace('/[\r\n].*/', '', `where.exe composer`) : `which composer 2> /dev/null`))
|
|| ($COMPOSER = rtrim('\\' === \DIRECTORY_SEPARATOR ? preg_replace('/[\r\n].*/', '', `where.exe composer`) : `which composer 2> /dev/null`))
|
||||||
|| file_exists($COMPOSER = rtrim('\\' === DIRECTORY_SEPARATOR ? `git rev-parse --show-toplevel 2> NUL` : `git rev-parse --show-toplevel 2> /dev/null`).DIRECTORY_SEPARATOR.'composer.phar')
|
|| file_exists($COMPOSER = rtrim('\\' === \DIRECTORY_SEPARATOR ? `git rev-parse --show-toplevel 2> NUL` : `git rev-parse --show-toplevel 2> /dev/null`).\DIRECTORY_SEPARATOR.'composer.phar')
|
||||||
? ('#!/usr/bin/env php' === file_get_contents($COMPOSER, false, null, 0, 18) ? $PHP : '').' '.escapeshellarg($COMPOSER) // detect shell wrappers by looking at the shebang
|
? ('#!/usr/bin/env php' === file_get_contents($COMPOSER, false, null, 0, 18) ? $PHP : '').' '.escapeshellarg($COMPOSER) // detect shell wrappers by looking at the shebang
|
||||||
: 'composer';
|
: 'composer';
|
||||||
|
|
||||||
$SYMFONY_PHPUNIT_REMOVE = $getEnvVar('SYMFONY_PHPUNIT_REMOVE', 'phpspec/prophecy'.($PHPUNIT_VERSION < 6.0 ? ' symfony/yaml' : ''));
|
$SYMFONY_PHPUNIT_REMOVE = $getEnvVar('SYMFONY_PHPUNIT_REMOVE', 'phpspec/prophecy'.($PHPUNIT_VERSION < 6.0 ? ' symfony/yaml' : ''));
|
||||||
$configurationHash = md5(implode(PHP_EOL, [md5_file(__FILE__), $SYMFONY_PHPUNIT_REMOVE, (int) $PHPUNIT_REMOVE_RETURN_TYPEHINT]));
|
$configurationHash = md5(implode(\PHP_EOL, [md5_file(__FILE__), $SYMFONY_PHPUNIT_REMOVE, (int) $PHPUNIT_REMOVE_RETURN_TYPEHINT]));
|
||||||
$PHPUNIT_VERSION_DIR = sprintf('phpunit-%s-%d', $PHPUNIT_VERSION, $PHPUNIT_REMOVE_RETURN_TYPEHINT);
|
$PHPUNIT_VERSION_DIR = sprintf('phpunit-%s-%d', $PHPUNIT_VERSION, $PHPUNIT_REMOVE_RETURN_TYPEHINT);
|
||||||
if (!file_exists("$PHPUNIT_DIR/$PHPUNIT_VERSION_DIR/phpunit") || $configurationHash !== @file_get_contents("$PHPUNIT_DIR/.$PHPUNIT_VERSION_DIR.md5")) {
|
if (!file_exists("$PHPUNIT_DIR/$PHPUNIT_VERSION_DIR/phpunit") || $configurationHash !== @file_get_contents("$PHPUNIT_DIR/.$PHPUNIT_VERSION_DIR.md5")) {
|
||||||
// Build a standalone phpunit without symfony/yaml nor prophecy by default
|
// Build a standalone phpunit without symfony/yaml nor prophecy by default
|
||||||
@ -163,9 +163,9 @@ if (!file_exists("$PHPUNIT_DIR/$PHPUNIT_VERSION_DIR/phpunit") || $configurationH
|
|||||||
@mkdir($PHPUNIT_DIR, 0777, true);
|
@mkdir($PHPUNIT_DIR, 0777, true);
|
||||||
chdir($PHPUNIT_DIR);
|
chdir($PHPUNIT_DIR);
|
||||||
if (file_exists("$PHPUNIT_VERSION_DIR")) {
|
if (file_exists("$PHPUNIT_VERSION_DIR")) {
|
||||||
passthru(sprintf('\\' === DIRECTORY_SEPARATOR ? 'rmdir /S /Q %s > NUL' : 'rm -rf %s', "$PHPUNIT_VERSION_DIR.old"));
|
passthru(sprintf('\\' === \DIRECTORY_SEPARATOR ? 'rmdir /S /Q %s > NUL' : 'rm -rf %s', "$PHPUNIT_VERSION_DIR.old"));
|
||||||
rename("$PHPUNIT_VERSION_DIR", "$PHPUNIT_VERSION_DIR.old");
|
rename("$PHPUNIT_VERSION_DIR", "$PHPUNIT_VERSION_DIR.old");
|
||||||
passthru(sprintf('\\' === DIRECTORY_SEPARATOR ? 'rmdir /S /Q %s' : 'rm -rf %s', "$PHPUNIT_VERSION_DIR.old"));
|
passthru(sprintf('\\' === \DIRECTORY_SEPARATOR ? 'rmdir /S /Q %s' : 'rm -rf %s', "$PHPUNIT_VERSION_DIR.old"));
|
||||||
}
|
}
|
||||||
|
|
||||||
$info = [];
|
$info = [];
|
||||||
@ -216,15 +216,15 @@ if (!file_exists("$PHPUNIT_DIR/$PHPUNIT_VERSION_DIR/phpunit") || $configurationH
|
|||||||
$passthruOrFail("$COMPOSER require --no-update phpunit/phpunit-mock-objects \"~3.1.0\"");
|
$passthruOrFail("$COMPOSER require --no-update phpunit/phpunit-mock-objects \"~3.1.0\"");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (preg_match('{\^((\d++\.)\d++)[\d\.]*$}', $info['requires']['php'], $phpVersion) && version_compare($phpVersion[2].'99', PHP_VERSION, '<')) {
|
if (preg_match('{\^((\d++\.)\d++)[\d\.]*$}', $info['requires']['php'], $phpVersion) && version_compare($phpVersion[2].'99', \PHP_VERSION, '<')) {
|
||||||
$passthruOrFail("$COMPOSER config platform.php \"$phpVersion[1].99\"");
|
$passthruOrFail("$COMPOSER config platform.php \"$phpVersion[1].99\"");
|
||||||
} else {
|
} else {
|
||||||
$passthruOrFail("$COMPOSER config --unset platform.php");
|
$passthruOrFail("$COMPOSER config --unset platform.php");
|
||||||
}
|
}
|
||||||
if (file_exists($path = $root.'/vendor/symfony/phpunit-bridge')) {
|
if (file_exists($path = $root.'/vendor/symfony/phpunit-bridge')) {
|
||||||
$passthruOrFail("$COMPOSER require --no-update symfony/phpunit-bridge \"*@dev\"");
|
$passthruOrFail("$COMPOSER require --no-update symfony/phpunit-bridge \"*@dev\"");
|
||||||
$passthruOrFail("$COMPOSER config repositories.phpunit-bridge path ".escapeshellarg(str_replace('/', DIRECTORY_SEPARATOR, $path)));
|
$passthruOrFail("$COMPOSER config repositories.phpunit-bridge path ".escapeshellarg(str_replace('/', \DIRECTORY_SEPARATOR, $path)));
|
||||||
if ('\\' === DIRECTORY_SEPARATOR) {
|
if ('\\' === \DIRECTORY_SEPARATOR) {
|
||||||
file_put_contents('composer.json', preg_replace('/^( {8})"phpunit-bridge": \{$/m', "$0\n$1 ".'"options": {"symlink": false},', file_get_contents('composer.json')));
|
file_put_contents('composer.json', preg_replace('/^( {8})"phpunit-bridge": \{$/m', "$0\n$1 ".'"options": {"symlink": false},', file_get_contents('composer.json')));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -232,7 +232,7 @@ if (!file_exists("$PHPUNIT_DIR/$PHPUNIT_VERSION_DIR/phpunit") || $configurationH
|
|||||||
}
|
}
|
||||||
$prevRoot = getenv('COMPOSER_ROOT_VERSION');
|
$prevRoot = getenv('COMPOSER_ROOT_VERSION');
|
||||||
putenv("COMPOSER_ROOT_VERSION=$PHPUNIT_VERSION.99");
|
putenv("COMPOSER_ROOT_VERSION=$PHPUNIT_VERSION.99");
|
||||||
$q = '\\' === DIRECTORY_SEPARATOR ? '"' : '';
|
$q = '\\' === \DIRECTORY_SEPARATOR ? '"' : '';
|
||||||
// --no-suggest is not in the list to keep compat with composer 1.0, which is shipped with Ubuntu 16.04LTS
|
// --no-suggest is not in the list to keep compat with composer 1.0, which is shipped with Ubuntu 16.04LTS
|
||||||
$exit = proc_close(proc_open("$q$COMPOSER install --no-dev --prefer-dist --no-progress $q", [], $p, getcwd()));
|
$exit = proc_close(proc_open("$q$COMPOSER install --no-dev --prefer-dist --no-progress $q", [], $p, getcwd()));
|
||||||
putenv('COMPOSER_ROOT_VERSION'.(false !== $prevRoot ? '='.$prevRoot : ''));
|
putenv('COMPOSER_ROOT_VERSION'.(false !== $prevRoot ? '='.$prevRoot : ''));
|
||||||
@ -245,12 +245,12 @@ if (!file_exists("$PHPUNIT_DIR/$PHPUNIT_VERSION_DIR/phpunit") || $configurationH
|
|||||||
if ($PHPUNIT_REMOVE_RETURN_TYPEHINT) {
|
if ($PHPUNIT_REMOVE_RETURN_TYPEHINT) {
|
||||||
$alteredCode = preg_replace('/^ ((?:protected|public)(?: static)? function \w+\(\)): void/m', ' $1', $alteredCode);
|
$alteredCode = preg_replace('/^ ((?:protected|public)(?: static)? function \w+\(\)): void/m', ' $1', $alteredCode);
|
||||||
}
|
}
|
||||||
$alteredCode = preg_replace('/abstract class (?:TestCase|PHPUnit_Framework_TestCase)[^\{]+\{/', '$0 '.PHP_EOL." use \Symfony\Bridge\PhpUnit\Legacy\PolyfillTestCaseTrait;", $alteredCode, 1);
|
$alteredCode = preg_replace('/abstract class (?:TestCase|PHPUnit_Framework_TestCase)[^\{]+\{/', '$0 '.\PHP_EOL." use \Symfony\Bridge\PhpUnit\Legacy\PolyfillTestCaseTrait;", $alteredCode, 1);
|
||||||
file_put_contents($alteredFile, $alteredCode);
|
file_put_contents($alteredFile, $alteredCode);
|
||||||
|
|
||||||
// Mutate Assert code
|
// Mutate Assert code
|
||||||
$alteredCode = file_get_contents($alteredFile = './src/Framework/Assert.php');
|
$alteredCode = file_get_contents($alteredFile = './src/Framework/Assert.php');
|
||||||
$alteredCode = preg_replace('/abstract class (?:Assert|PHPUnit_Framework_Assert)[^\{]+\{/', '$0 '.PHP_EOL." use \Symfony\Bridge\PhpUnit\Legacy\PolyfillAssertTrait;", $alteredCode, 1);
|
$alteredCode = preg_replace('/abstract class (?:Assert|PHPUnit_Framework_Assert)[^\{]+\{/', '$0 '.\PHP_EOL." use \Symfony\Bridge\PhpUnit\Legacy\PolyfillAssertTrait;", $alteredCode, 1);
|
||||||
file_put_contents($alteredFile, $alteredCode);
|
file_put_contents($alteredFile, $alteredCode);
|
||||||
|
|
||||||
file_put_contents('phpunit', <<<'EOPHP'
|
file_put_contents('phpunit', <<<'EOPHP'
|
||||||
@ -303,7 +303,7 @@ if ($PHPUNIT_VERSION < 8.0) {
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
} elseif (filter_var(getenv('SYMFONY_PHPUNIT_DISABLE_RESULT_CACHE'), FILTER_VALIDATE_BOOLEAN)) {
|
} elseif (filter_var(getenv('SYMFONY_PHPUNIT_DISABLE_RESULT_CACHE'), \FILTER_VALIDATE_BOOLEAN)) {
|
||||||
$argv[] = '--do-not-cache-result';
|
$argv[] = '--do-not-cache-result';
|
||||||
++$argc;
|
++$argc;
|
||||||
}
|
}
|
||||||
@ -335,7 +335,7 @@ if (isset($argv[1]) && is_dir($argv[1]) && !file_exists($argv[1].'/phpunit.xml.d
|
|||||||
$cmd[0] = sprintf('%s %s --colors=always', $PHP, escapeshellarg("$PHPUNIT_DIR/$PHPUNIT_VERSION_DIR/phpunit"));
|
$cmd[0] = sprintf('%s %s --colors=always', $PHP, escapeshellarg("$PHPUNIT_DIR/$PHPUNIT_VERSION_DIR/phpunit"));
|
||||||
$cmd = str_replace('%', '%%', implode(' ', $cmd)).' %1$s';
|
$cmd = str_replace('%', '%%', implode(' ', $cmd)).' %1$s';
|
||||||
|
|
||||||
if ('\\' === DIRECTORY_SEPARATOR) {
|
if ('\\' === \DIRECTORY_SEPARATOR) {
|
||||||
$cmd = 'cmd /v:on /d /c "('.$cmd.')%2$s"';
|
$cmd = 'cmd /v:on /d /c "('.$cmd.')%2$s"';
|
||||||
} else {
|
} else {
|
||||||
$cmd .= '%2$s';
|
$cmd .= '%2$s';
|
||||||
@ -385,7 +385,7 @@ if ($components) {
|
|||||||
// STATUS_STACK_BUFFER_OVERRUN (-1073740791/0xC0000409)
|
// STATUS_STACK_BUFFER_OVERRUN (-1073740791/0xC0000409)
|
||||||
// STATUS_ACCESS_VIOLATION (-1073741819/0xC0000005)
|
// STATUS_ACCESS_VIOLATION (-1073741819/0xC0000005)
|
||||||
// STATUS_HEAP_CORRUPTION (-1073740940/0xC0000374)
|
// STATUS_HEAP_CORRUPTION (-1073740940/0xC0000374)
|
||||||
if ($procStatus && ('\\' !== DIRECTORY_SEPARATOR || !extension_loaded('apcu') || !filter_var(ini_get('apc.enable_cli'), FILTER_VALIDATE_BOOLEAN) || !in_array($procStatus, [-1073740791, -1073741819, -1073740940]))) {
|
if ($procStatus && ('\\' !== \DIRECTORY_SEPARATOR || !extension_loaded('apcu') || !filter_var(ini_get('apc.enable_cli'), \FILTER_VALIDATE_BOOLEAN) || !in_array($procStatus, [-1073740791, -1073741819, -1073740940]))) {
|
||||||
$exit = $procStatus;
|
$exit = $procStatus;
|
||||||
echo "\033[41mKO\033[0m $component\n\n";
|
echo "\033[41mKO\033[0m $component\n\n";
|
||||||
} else {
|
} else {
|
||||||
|
@ -115,7 +115,7 @@ if (!defined('PHPUNIT_COMPOSER_INSTALL') && !class_exists('PHPUnit_TextUI_Comman
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Enforce a consistent locale
|
// Enforce a consistent locale
|
||||||
setlocale(LC_ALL, 'C');
|
setlocale(\LC_ALL, 'C');
|
||||||
|
|
||||||
if (!class_exists('Doctrine\Common\Annotations\AnnotationRegistry', false) && class_exists('Doctrine\Common\Annotations\AnnotationRegistry')) {
|
if (!class_exists('Doctrine\Common\Annotations\AnnotationRegistry', false) && class_exists('Doctrine\Common\Annotations\AnnotationRegistry')) {
|
||||||
if (method_exists('Doctrine\Common\Annotations\AnnotationRegistry', 'registerUniqueLoader')) {
|
if (method_exists('Doctrine\Common\Annotations\AnnotationRegistry', 'registerUniqueLoader')) {
|
||||||
|
@ -66,7 +66,7 @@ class LazyLoadingValueHolderGenerator extends BaseGenerator
|
|||||||
if (null !== $docBlock = $method->getDocBlock()) {
|
if (null !== $docBlock = $method->getDocBlock()) {
|
||||||
$code = substr($code, \strlen($docBlock->generate()));
|
$code = substr($code, \strlen($docBlock->generate()));
|
||||||
}
|
}
|
||||||
$refAmp = (strpos($code, '&') ?: PHP_INT_MAX) <= strpos($code, '(') ? '&' : '';
|
$refAmp = (strpos($code, '&') ?: \PHP_INT_MAX) <= strpos($code, '(') ? '&' : '';
|
||||||
$body = preg_replace(
|
$body = preg_replace(
|
||||||
'/\nreturn (\$this->valueHolder[0-9a-f]++)(->[^;]++);$/',
|
'/\nreturn (\$this->valueHolder[0-9a-f]++)(->[^;]++);$/',
|
||||||
"\nif ($1 === \$returnValue = {$refAmp}$1$2) {\n \$returnValue = \$this;\n}\n\nreturn \$returnValue;",
|
"\nif ($1 === \$returnValue = {$refAmp}$1$2) {\n \$returnValue = \$this;\n}\n\nreturn \$returnValue;",
|
||||||
|
@ -262,7 +262,7 @@ EOF
|
|||||||
$data['warnings'] = $this->buildWarningMessages($wrongBundles);
|
$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);
|
$io->writeln($decorated ? OutputFormatter::escape($data) : $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -392,7 +392,7 @@ EOF
|
|||||||
$bundleNames = [];
|
$bundleNames = [];
|
||||||
|
|
||||||
if ($this->twigDefaultPath && $this->projectDir) {
|
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);
|
$relativePath = ltrim(substr($this->twigDefaultPath.'/bundles/', \strlen($this->projectDir)), \DIRECTORY_SEPARATOR);
|
||||||
$bundleNames = array_reduce($folders, function ($carry, $absolutePath) use ($relativePath) {
|
$bundleNames = array_reduce($folders, function ($carry, $absolutePath) use ($relativePath) {
|
||||||
if (0 === strpos($absolutePath, $this->projectDir)) {
|
if (0 === strpos($absolutePath, $this->projectDir)) {
|
||||||
@ -532,7 +532,7 @@ EOF
|
|||||||
|
|
||||||
$threshold = 1e3;
|
$threshold = 1e3;
|
||||||
$alternatives = array_filter($alternatives, function ($lev) use ($threshold) { return $lev < 2 * $threshold; });
|
$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);
|
return array_keys($alternatives);
|
||||||
}
|
}
|
||||||
@ -548,7 +548,7 @@ EOF
|
|||||||
|
|
||||||
private function isAbsolutePath(string $file): bool
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -101,7 +101,7 @@ EOF
|
|||||||
|
|
||||||
if ($showDeprecations) {
|
if ($showDeprecations) {
|
||||||
$prevErrorHandler = set_error_handler(static function ($level, $message, $file, $line) use (&$prevErrorHandler) {
|
$prevErrorHandler = set_error_handler(static function ($level, $message, $file, $line) use (&$prevErrorHandler) {
|
||||||
if (E_USER_DEPRECATED === $level) {
|
if (\E_USER_DEPRECATED === $level) {
|
||||||
$templateLine = 0;
|
$templateLine = 0;
|
||||||
if (preg_match('/ at line (\d+)[ .]/', $message, $matches)) {
|
if (preg_match('/ at line (\d+)[ .]/', $message, $matches)) {
|
||||||
$templateLine = $matches[1];
|
$templateLine = $matches[1];
|
||||||
@ -214,7 +214,7 @@ EOF
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$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);
|
return min($errors, 1);
|
||||||
}
|
}
|
||||||
|
@ -97,7 +97,7 @@ final class CodeExtension extends AbstractExtension
|
|||||||
} elseif ('resource' === $item[0]) {
|
} elseif ('resource' === $item[0]) {
|
||||||
$formattedValue = '<em>resource</em>';
|
$formattedValue = '<em>resource</em>';
|
||||||
} else {
|
} 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);
|
$result[] = \is_int($key) ? $formattedValue : sprintf("'%s' => %s", $key, $formattedValue);
|
||||||
@ -166,7 +166,7 @@ final class CodeExtension extends AbstractExtension
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (false !== $link = $this->getFileLink($file, $line)) {
|
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;
|
return $text;
|
||||||
@ -222,7 +222,7 @@ final class CodeExtension extends AbstractExtension
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return htmlspecialchars($message, ENT_COMPAT | ENT_SUBSTITUTE, $this->charset);
|
return htmlspecialchars($message, \ENT_COMPAT | \ENT_SUBSTITUTE, $this->charset);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static function fixCodeMarkup(string $line): string
|
protected static function fixCodeMarkup(string $line): string
|
||||||
|
@ -102,11 +102,11 @@ EOF;
|
|||||||
], [new JsonEncoder()]);
|
], [new JsonEncoder()]);
|
||||||
|
|
||||||
$serialized = $serializer->serialize($e, 'json');
|
$serialized = $serializer->serialize($e, 'json');
|
||||||
$this->assertSame($expectedJson, json_encode(json_decode($serialized), JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
|
$this->assertSame($expectedJson, json_encode(json_decode($serialized), \JSON_PRETTY_PRINT | \JSON_UNESCAPED_SLASHES));
|
||||||
|
|
||||||
$n = $serializer->deserialize($serialized, TemplatedEmail::class, 'json');
|
$n = $serializer->deserialize($serialized, TemplatedEmail::class, 'json');
|
||||||
$serialized = $serializer->serialize($e, 'json');
|
$serialized = $serializer->serialize($e, 'json');
|
||||||
$this->assertSame($expectedJson, json_encode(json_decode($serialized), JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
|
$this->assertSame($expectedJson, json_encode(json_decode($serialized), \JSON_PRETTY_PRINT | \JSON_UNESCAPED_SLASHES));
|
||||||
|
|
||||||
$n->from('fabien@symfony.com');
|
$n->from('fabien@symfony.com');
|
||||||
$expected->from('fabien@symfony.com');
|
$expected->from('fabien@symfony.com');
|
||||||
|
@ -89,7 +89,7 @@ class TwigExtractor extends AbstractFileExtractor implements ExtractorInterface
|
|||||||
*/
|
*/
|
||||||
protected function canBeExtracted(string $file)
|
protected function canBeExtracted(string $file)
|
||||||
{
|
{
|
||||||
return $this->isFile($file) && 'twig' === pathinfo($file, PATHINFO_EXTENSION);
|
return $this->isFile($file) && 'twig' === pathinfo($file, \PATHINFO_EXTENSION);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -87,12 +87,12 @@ EOT
|
|||||||
new TableSeparator(),
|
new TableSeparator(),
|
||||||
['<info>PHP</>'],
|
['<info>PHP</>'],
|
||||||
new TableSeparator(),
|
new TableSeparator(),
|
||||||
['Version', PHP_VERSION],
|
['Version', \PHP_VERSION],
|
||||||
['Architecture', (\PHP_INT_SIZE * 8).' bits'],
|
['Architecture', (\PHP_INT_SIZE * 8).' bits'],
|
||||||
['Intl locale', class_exists('Locale', false) && \Locale::getDefault() ? \Locale::getDefault() : 'n/a'],
|
['Intl locale', class_exists('Locale', false) && \Locale::getDefault() ? \Locale::getDefault() : 'n/a'],
|
||||||
['Timezone', date_default_timezone_get().' (<comment>'.(new \DateTime())->format(\DateTime::W3C).'</>)'],
|
['Timezone', date_default_timezone_get().' (<comment>'.(new \DateTime())->format(\DateTime::W3C).'</>)'],
|
||||||
['OPcache', \extension_loaded('Zend OPcache') && filter_var(ini_get('opcache.enable'), FILTER_VALIDATE_BOOLEAN) ? 'true' : 'false'],
|
['OPcache', \extension_loaded('Zend OPcache') && filter_var(ini_get('opcache.enable'), \FILTER_VALIDATE_BOOLEAN) ? 'true' : 'false'],
|
||||||
['APCu', \extension_loaded('apcu') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? 'true' : 'false'],
|
['APCu', \extension_loaded('apcu') && filter_var(ini_get('apc.enabled'), \FILTER_VALIDATE_BOOLEAN) ? 'true' : 'false'],
|
||||||
['Xdebug', \extension_loaded('xdebug') ? 'true' : 'false'],
|
['Xdebug', \extension_loaded('xdebug') ? 'true' : 'false'],
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -63,7 +63,7 @@ abstract class AbstractConfigCommand extends ContainerDebugCommand
|
|||||||
protected function findExtension(string $name)
|
protected function findExtension(string $name)
|
||||||
{
|
{
|
||||||
$bundles = $this->initializeBundles();
|
$bundles = $this->initializeBundles();
|
||||||
$minScore = INF;
|
$minScore = \INF;
|
||||||
|
|
||||||
$kernel = $this->getApplication()->getKernel();
|
$kernel = $this->getApplication()->getKernel();
|
||||||
if ($kernel instanceof ExtensionInterface && ($kernel instanceof ConfigurationInterface || $kernel instanceof ConfigurationExtensionInterface)) {
|
if ($kernel instanceof ExtensionInterface && ($kernel instanceof ConfigurationInterface || $kernel instanceof ConfigurationExtensionInterface)) {
|
||||||
|
@ -183,7 +183,7 @@ class JsonDescriptor extends Descriptor
|
|||||||
{
|
{
|
||||||
$flags = isset($options['json_encoding']) ? $options['json_encoding'] : 0;
|
$flags = isset($options['json_encoding']) ? $options['json_encoding'] : 0;
|
||||||
|
|
||||||
$this->write(json_encode($data, $flags | JSON_PRETTY_PRINT)."\n");
|
$this->write(json_encode($data, $flags | \JSON_PRETTY_PRINT)."\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getRouteData(Route $route): array
|
protected function getRouteData(Route $route): array
|
||||||
|
@ -120,7 +120,7 @@ class RedirectController
|
|||||||
}
|
}
|
||||||
|
|
||||||
// redirect if the path is a full URL
|
// redirect if the path is a full URL
|
||||||
if (parse_url($path, PHP_URL_SCHEME)) {
|
if (parse_url($path, \PHP_URL_SCHEME)) {
|
||||||
return new RedirectResponse($path, $statusCode);
|
return new RedirectResponse($path, $statusCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ class ProfilerPass implements CompilerPassInterface
|
|||||||
$definition = $container->getDefinition('profiler');
|
$definition = $container->getDefinition('profiler');
|
||||||
|
|
||||||
$collectors = new \SplPriorityQueue();
|
$collectors = new \SplPriorityQueue();
|
||||||
$order = PHP_INT_MAX;
|
$order = \PHP_INT_MAX;
|
||||||
foreach ($container->findTaggedServiceIds('data_collector', true) as $id => $attributes) {
|
foreach ($container->findTaggedServiceIds('data_collector', true) as $id => $attributes) {
|
||||||
$priority = isset($attributes[0]['priority']) ? $attributes[0]['priority'] : 0;
|
$priority = isset($attributes[0]['priority']) ? $attributes[0]['priority'] : 0;
|
||||||
$template = null;
|
$template = null;
|
||||||
|
@ -196,7 +196,7 @@ class Configuration implements ConfigurationInterface
|
|||||||
->validate()
|
->validate()
|
||||||
->ifTrue()
|
->ifTrue()
|
||||||
->then(function ($v) {
|
->then(function ($v) {
|
||||||
@trigger_error('Since symfony/framework-bundle 5.2: Setting the "framework.form.legacy_error_messages" option to "true" is deprecated. It will have no effect as of Symfony 6.0.', E_USER_DEPRECATED);
|
@trigger_error('Since symfony/framework-bundle 5.2: Setting the "framework.form.legacy_error_messages" option to "true" is deprecated. It will have no effect as of Symfony 6.0.', \E_USER_DEPRECATED);
|
||||||
|
|
||||||
return $v;
|
return $v;
|
||||||
})
|
})
|
||||||
|
@ -1093,7 +1093,7 @@ class FrameworkExtension extends Extension
|
|||||||
|
|
||||||
if (null !== $jsonManifestPath) {
|
if (null !== $jsonManifestPath) {
|
||||||
$definitionName = 'assets.json_manifest_version_strategy';
|
$definitionName = 'assets.json_manifest_version_strategy';
|
||||||
if (0 === strpos(parse_url($jsonManifestPath, PHP_URL_SCHEME), 'http')) {
|
if (0 === strpos(parse_url($jsonManifestPath, \PHP_URL_SCHEME), 'http')) {
|
||||||
$definitionName = 'assets.remote_json_manifest_version_strategy';
|
$definitionName = 'assets.remote_json_manifest_version_strategy';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,7 +89,7 @@ class SodiumVault extends AbstractVault implements EnvVarLoaderInterface
|
|||||||
$list = $this->list();
|
$list = $this->list();
|
||||||
$list[$name] = null;
|
$list[$name] = null;
|
||||||
uksort($list, 'strnatcmp');
|
uksort($list, 'strnatcmp');
|
||||||
file_put_contents($this->pathPrefix.'list.php', sprintf("<?php\n\nreturn %s;\n", var_export($list, true), LOCK_EX));
|
file_put_contents($this->pathPrefix.'list.php', sprintf("<?php\n\nreturn %s;\n", var_export($list, true), \LOCK_EX));
|
||||||
|
|
||||||
$this->lastMessage = sprintf('Secret "%s" encrypted in "%s"; you can commit it.', $name, $this->getPrettyPath(\dirname($this->pathPrefix).\DIRECTORY_SEPARATOR));
|
$this->lastMessage = sprintf('Secret "%s" encrypted in "%s"; you can commit it.', $name, $this->getPrettyPath(\dirname($this->pathPrefix).\DIRECTORY_SEPARATOR));
|
||||||
}
|
}
|
||||||
@ -141,7 +141,7 @@ class SodiumVault extends AbstractVault implements EnvVarLoaderInterface
|
|||||||
|
|
||||||
$list = $this->list();
|
$list = $this->list();
|
||||||
unset($list[$name]);
|
unset($list[$name]);
|
||||||
file_put_contents($this->pathPrefix.'list.php', sprintf("<?php\n\nreturn %s;\n", var_export($list, true), LOCK_EX));
|
file_put_contents($this->pathPrefix.'list.php', sprintf("<?php\n\nreturn %s;\n", var_export($list, true), \LOCK_EX));
|
||||||
|
|
||||||
$this->lastMessage = sprintf('Secret "%s" removed from "%s".', $name, $this->getPrettyPath(\dirname($this->pathPrefix).\DIRECTORY_SEPARATOR));
|
$this->lastMessage = sprintf('Secret "%s" removed from "%s".', $name, $this->getPrettyPath(\dirname($this->pathPrefix).\DIRECTORY_SEPARATOR));
|
||||||
|
|
||||||
@ -205,9 +205,9 @@ class SodiumVault extends AbstractVault implements EnvVarLoaderInterface
|
|||||||
|
|
||||||
$this->createSecretsDir();
|
$this->createSecretsDir();
|
||||||
|
|
||||||
if (false === file_put_contents($this->pathPrefix.$file.'.php', $data, LOCK_EX)) {
|
if (false === file_put_contents($this->pathPrefix.$file.'.php', $data, \LOCK_EX)) {
|
||||||
$e = error_get_last();
|
$e = error_get_last();
|
||||||
throw new \ErrorException($e['message'] ?? 'Failed to write secrets data.', 0, $e['type'] ?? E_USER_WARNING);
|
throw new \ErrorException($e['message'] ?? 'Failed to write secrets data.', 0, $e['type'] ?? \E_USER_WARNING);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -242,9 +242,9 @@ abstract class AbstractDescriptorTest extends TestCase
|
|||||||
$this->getDescriptor()->describe($output, $describedObject, $options);
|
$this->getDescriptor()->describe($output, $describedObject, $options);
|
||||||
|
|
||||||
if ('json' === $this->getFormat()) {
|
if ('json' === $this->getFormat()) {
|
||||||
$this->assertEquals(json_encode(json_decode($expectedDescription), JSON_PRETTY_PRINT), json_encode(json_decode($output->fetch()), JSON_PRETTY_PRINT));
|
$this->assertEquals(json_encode(json_decode($expectedDescription), \JSON_PRETTY_PRINT), json_encode(json_decode($output->fetch()), \JSON_PRETTY_PRINT));
|
||||||
} else {
|
} else {
|
||||||
$this->assertEquals(trim($expectedDescription), trim(str_replace(PHP_EOL, "\n", $output->fetch())));
|
$this->assertEquals(trim($expectedDescription), trim(str_replace(\PHP_EOL, "\n", $output->fetch())));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -224,7 +224,7 @@ class AbstractControllerTest extends TestCase
|
|||||||
$response = $controller->json([], 200, [], ['json_encode_options' => 0, 'other' => 'context']);
|
$response = $controller->json([], 200, [], ['json_encode_options' => 0, 'other' => 'context']);
|
||||||
$this->assertInstanceOf(JsonResponse::class, $response);
|
$this->assertInstanceOf(JsonResponse::class, $response);
|
||||||
$this->assertEquals('[]', $response->getContent());
|
$this->assertEquals('[]', $response->getContent());
|
||||||
$response->setEncodingOptions(JSON_FORCE_OBJECT);
|
$response->setEncodingOptions(\JSON_FORCE_OBJECT);
|
||||||
$this->assertEquals('{}', $response->getContent());
|
$this->assertEquals('{}', $response->getContent());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -134,7 +134,7 @@ EOF
|
|||||||
if ($input->isInteractive() && !$emptySalt) {
|
if ($input->isInteractive() && !$emptySalt) {
|
||||||
$emptySalt = true;
|
$emptySalt = true;
|
||||||
|
|
||||||
$errorIo->note('The command will take care of generating a salt for you. Be aware that some encoders advise to let them generate their own salt. If you\'re using one of those encoders, please answer \'no\' to the question below. '.PHP_EOL.'Provide the \'empty-salt\' option in order to let the encoder handle the generation itself.');
|
$errorIo->note('The command will take care of generating a salt for you. Be aware that some encoders advise to let them generate their own salt. If you\'re using one of those encoders, please answer \'no\' to the question below. '.\PHP_EOL.'Provide the \'empty-salt\' option in order to let the encoder handle the generation itself.');
|
||||||
|
|
||||||
if ($errorIo->confirm('Confirm salt generation ?')) {
|
if ($errorIo->confirm('Confirm salt generation ?')) {
|
||||||
$salt = $this->generateSalt();
|
$salt = $this->generateSalt();
|
||||||
|
@ -696,7 +696,7 @@ class SecurityExtension extends Extension implements PrependExtensionInterface
|
|||||||
// bcrypt encoder
|
// bcrypt encoder
|
||||||
if ('bcrypt' === $config['algorithm']) {
|
if ('bcrypt' === $config['algorithm']) {
|
||||||
$config['algorithm'] = 'native';
|
$config['algorithm'] = 'native';
|
||||||
$config['native_algorithm'] = PASSWORD_BCRYPT;
|
$config['native_algorithm'] = \PASSWORD_BCRYPT;
|
||||||
|
|
||||||
return $this->createEncoder($config);
|
return $this->createEncoder($config);
|
||||||
}
|
}
|
||||||
@ -707,7 +707,7 @@ class SecurityExtension extends Extension implements PrependExtensionInterface
|
|||||||
$config['algorithm'] = 'sodium';
|
$config['algorithm'] = 'sodium';
|
||||||
} elseif (\defined('PASSWORD_ARGON2I')) {
|
} elseif (\defined('PASSWORD_ARGON2I')) {
|
||||||
$config['algorithm'] = 'native';
|
$config['algorithm'] = 'native';
|
||||||
$config['native_algorithm'] = PASSWORD_ARGON2I;
|
$config['native_algorithm'] = \PASSWORD_ARGON2I;
|
||||||
} else {
|
} else {
|
||||||
throw new InvalidConfigurationException(sprintf('Algorithm "argon2i" is not available. Either use "%s" or upgrade to PHP 7.2+ instead.', \defined('SODIUM_CRYPTO_PWHASH_ALG_ARGON2ID13') ? 'argon2id", "auto' : 'auto'));
|
throw new InvalidConfigurationException(sprintf('Algorithm "argon2i" is not available. Either use "%s" or upgrade to PHP 7.2+ instead.', \defined('SODIUM_CRYPTO_PWHASH_ALG_ARGON2ID13') ? 'argon2id", "auto' : 'auto'));
|
||||||
}
|
}
|
||||||
@ -720,7 +720,7 @@ class SecurityExtension extends Extension implements PrependExtensionInterface
|
|||||||
$config['algorithm'] = 'sodium';
|
$config['algorithm'] = 'sodium';
|
||||||
} elseif (\defined('PASSWORD_ARGON2ID')) {
|
} elseif (\defined('PASSWORD_ARGON2ID')) {
|
||||||
$config['algorithm'] = 'native';
|
$config['algorithm'] = 'native';
|
||||||
$config['native_algorithm'] = PASSWORD_ARGON2ID;
|
$config['native_algorithm'] = \PASSWORD_ARGON2ID;
|
||||||
} else {
|
} else {
|
||||||
throw new InvalidConfigurationException(sprintf('Algorithm "argon2id" is not available. Either use "%s", upgrade to PHP 7.3+ or use libsodium 1.0.15+ instead.', \defined('PASSWORD_ARGON2I') || $hasSodium ? 'argon2i", "auto' : 'auto'));
|
throw new InvalidConfigurationException(sprintf('Algorithm "argon2id" is not available. Either use "%s", upgrade to PHP 7.3+ or use libsodium 1.0.15+ instead.', \defined('PASSWORD_ARGON2I') || $hasSodium ? 'argon2i", "auto' : 'auto'));
|
||||||
}
|
}
|
||||||
@ -944,7 +944,7 @@ class SecurityExtension extends Extension implements PrependExtensionInterface
|
|||||||
$cidrParts = explode('/', $cidr);
|
$cidrParts = explode('/', $cidr);
|
||||||
|
|
||||||
if (1 === \count($cidrParts)) {
|
if (1 === \count($cidrParts)) {
|
||||||
return false !== filter_var($cidrParts[0], FILTER_VALIDATE_IP);
|
return false !== filter_var($cidrParts[0], \FILTER_VALIDATE_IP);
|
||||||
}
|
}
|
||||||
|
|
||||||
$ip = $cidrParts[0];
|
$ip = $cidrParts[0];
|
||||||
@ -954,11 +954,11 @@ class SecurityExtension extends Extension implements PrependExtensionInterface
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) {
|
if (filter_var($ip, \FILTER_VALIDATE_IP, \FILTER_FLAG_IPV4)) {
|
||||||
return $netmask <= 32;
|
return $netmask <= 32;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) {
|
if (filter_var($ip, \FILTER_VALIDATE_IP, \FILTER_FLAG_IPV6)) {
|
||||||
return $netmask <= 128;
|
return $netmask <= 128;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -432,7 +432,7 @@ abstract class CompleteConfigurationTest extends TestCase
|
|||||||
],
|
],
|
||||||
'JMS\FooBundle\Entity\User7' => [
|
'JMS\FooBundle\Entity\User7' => [
|
||||||
'class' => $sodium ? SodiumPasswordEncoder::class : NativePasswordEncoder::class,
|
'class' => $sodium ? SodiumPasswordEncoder::class : NativePasswordEncoder::class,
|
||||||
'arguments' => $sodium ? [256, 1] : [1, 262144, null, PASSWORD_ARGON2I],
|
'arguments' => $sodium ? [256, 1] : [1, 262144, null, \PASSWORD_ARGON2I],
|
||||||
],
|
],
|
||||||
]], $container->getDefinition('security.encoder_factory.generic')->getArguments());
|
]], $container->getDefinition('security.encoder_factory.generic')->getArguments());
|
||||||
}
|
}
|
||||||
@ -542,7 +542,7 @@ abstract class CompleteConfigurationTest extends TestCase
|
|||||||
],
|
],
|
||||||
'JMS\FooBundle\Entity\User7' => [
|
'JMS\FooBundle\Entity\User7' => [
|
||||||
'class' => NativePasswordEncoder::class,
|
'class' => NativePasswordEncoder::class,
|
||||||
'arguments' => [null, null, 15, PASSWORD_BCRYPT],
|
'arguments' => [null, null, 15, \PASSWORD_BCRYPT],
|
||||||
],
|
],
|
||||||
]], $container->getDefinition('security.encoder_factory.generic')->getArguments());
|
]], $container->getDefinition('security.encoder_factory.generic')->getArguments());
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,7 @@ class UserPasswordEncoderCommandTest extends AbstractWebTestCase
|
|||||||
'user-class' => 'Symfony\Component\Security\Core\User\User',
|
'user-class' => 'Symfony\Component\Security\Core\User\User',
|
||||||
'--empty-salt' => true,
|
'--empty-salt' => true,
|
||||||
], ['decorated' => false]);
|
], ['decorated' => false]);
|
||||||
$expected = str_replace("\n", PHP_EOL, file_get_contents(__DIR__.'/app/PasswordEncode/emptysalt.txt'));
|
$expected = str_replace("\n", \PHP_EOL, file_get_contents(__DIR__.'/app/PasswordEncode/emptysalt.txt'));
|
||||||
|
|
||||||
$this->assertEquals($expected, $this->passwordEncoderCommandTester->getDisplay());
|
$this->assertEquals($expected, $this->passwordEncoderCommandTester->getDisplay());
|
||||||
}
|
}
|
||||||
@ -65,7 +65,7 @@ class UserPasswordEncoderCommandTest extends AbstractWebTestCase
|
|||||||
$output = $this->passwordEncoderCommandTester->getDisplay();
|
$output = $this->passwordEncoderCommandTester->getDisplay();
|
||||||
$this->assertStringContainsString('Password encoding succeeded', $output);
|
$this->assertStringContainsString('Password encoding succeeded', $output);
|
||||||
|
|
||||||
$encoder = new NativePasswordEncoder(null, null, 17, PASSWORD_BCRYPT);
|
$encoder = new NativePasswordEncoder(null, null, 17, \PASSWORD_BCRYPT);
|
||||||
preg_match('# Encoded password\s{1,}([\w+\/$.]+={0,2})\s+#', $output, $matches);
|
preg_match('# Encoded password\s{1,}([\w+\/$.]+={0,2})\s+#', $output, $matches);
|
||||||
$hash = $matches[1];
|
$hash = $matches[1];
|
||||||
$this->assertTrue($encoder->isPasswordValid($hash, 'password', null));
|
$this->assertTrue($encoder->isPasswordValid($hash, 'password', null));
|
||||||
@ -86,7 +86,7 @@ class UserPasswordEncoderCommandTest extends AbstractWebTestCase
|
|||||||
$output = $this->passwordEncoderCommandTester->getDisplay();
|
$output = $this->passwordEncoderCommandTester->getDisplay();
|
||||||
$this->assertStringContainsString('Password encoding succeeded', $output);
|
$this->assertStringContainsString('Password encoding succeeded', $output);
|
||||||
|
|
||||||
$encoder = $sodium ? new SodiumPasswordEncoder() : new NativePasswordEncoder(null, null, null, PASSWORD_ARGON2I);
|
$encoder = $sodium ? new SodiumPasswordEncoder() : new NativePasswordEncoder(null, null, null, \PASSWORD_ARGON2I);
|
||||||
preg_match('# Encoded password\s+(\$argon2i?\$[\w,=\$+\/]+={0,2})\s+#', $output, $matches);
|
preg_match('# Encoded password\s+(\$argon2i?\$[\w,=\$+\/]+={0,2})\s+#', $output, $matches);
|
||||||
$hash = $matches[1];
|
$hash = $matches[1];
|
||||||
$this->assertTrue($encoder->isPasswordValid($hash, 'password', null));
|
$this->assertTrue($encoder->isPasswordValid($hash, 'password', null));
|
||||||
@ -107,7 +107,7 @@ class UserPasswordEncoderCommandTest extends AbstractWebTestCase
|
|||||||
$output = $this->passwordEncoderCommandTester->getDisplay();
|
$output = $this->passwordEncoderCommandTester->getDisplay();
|
||||||
$this->assertStringContainsString('Password encoding succeeded', $output);
|
$this->assertStringContainsString('Password encoding succeeded', $output);
|
||||||
|
|
||||||
$encoder = $sodium ? new SodiumPasswordEncoder() : new NativePasswordEncoder(null, null, null, PASSWORD_ARGON2ID);
|
$encoder = $sodium ? new SodiumPasswordEncoder() : new NativePasswordEncoder(null, null, null, \PASSWORD_ARGON2ID);
|
||||||
preg_match('# Encoded password\s+(\$argon2id?\$[\w,=\$+\/]+={0,2})\s+#', $output, $matches);
|
preg_match('# Encoded password\s+(\$argon2id?\$[\w,=\$+\/]+={0,2})\s+#', $output, $matches);
|
||||||
$hash = $matches[1];
|
$hash = $matches[1];
|
||||||
$this->assertTrue($encoder->isPasswordValid($hash, 'password', null));
|
$this->assertTrue($encoder->isPasswordValid($hash, 'password', null));
|
||||||
@ -314,7 +314,7 @@ EOTXT
|
|||||||
|
|
||||||
protected function setUp(): void
|
protected function setUp(): void
|
||||||
{
|
{
|
||||||
putenv('COLUMNS='.(119 + \strlen(PHP_EOL)));
|
putenv('COLUMNS='.(119 + \strlen(\PHP_EOL)));
|
||||||
$kernel = $this->createKernel(['test_case' => 'PasswordEncode']);
|
$kernel = $this->createKernel(['test_case' => 'PasswordEncode']);
|
||||||
$kernel->boot();
|
$kernel->boot();
|
||||||
|
|
||||||
@ -332,7 +332,7 @@ EOTXT
|
|||||||
|
|
||||||
private function setupArgon2i()
|
private function setupArgon2i()
|
||||||
{
|
{
|
||||||
putenv('COLUMNS='.(119 + \strlen(PHP_EOL)));
|
putenv('COLUMNS='.(119 + \strlen(\PHP_EOL)));
|
||||||
$kernel = $this->createKernel(['test_case' => 'PasswordEncode', 'root_config' => 'argon2i.yml']);
|
$kernel = $this->createKernel(['test_case' => 'PasswordEncode', 'root_config' => 'argon2i.yml']);
|
||||||
$kernel->boot();
|
$kernel->boot();
|
||||||
|
|
||||||
@ -345,7 +345,7 @@ EOTXT
|
|||||||
|
|
||||||
private function setupArgon2id()
|
private function setupArgon2id()
|
||||||
{
|
{
|
||||||
putenv('COLUMNS='.(119 + \strlen(PHP_EOL)));
|
putenv('COLUMNS='.(119 + \strlen(\PHP_EOL)));
|
||||||
$kernel = $this->createKernel(['test_case' => 'PasswordEncode', 'root_config' => 'argon2id.yml']);
|
$kernel = $this->createKernel(['test_case' => 'PasswordEncode', 'root_config' => 'argon2id.yml']);
|
||||||
$kernel->boot();
|
$kernel->boot();
|
||||||
|
|
||||||
@ -358,7 +358,7 @@ EOTXT
|
|||||||
|
|
||||||
private function setupBcrypt()
|
private function setupBcrypt()
|
||||||
{
|
{
|
||||||
putenv('COLUMNS='.(119 + \strlen(PHP_EOL)));
|
putenv('COLUMNS='.(119 + \strlen(\PHP_EOL)));
|
||||||
$kernel = $this->createKernel(['test_case' => 'PasswordEncode', 'root_config' => 'bcrypt.yml']);
|
$kernel = $this->createKernel(['test_case' => 'PasswordEncode', 'root_config' => 'bcrypt.yml']);
|
||||||
$kernel->boot();
|
$kernel->boot();
|
||||||
|
|
||||||
@ -371,7 +371,7 @@ EOTXT
|
|||||||
|
|
||||||
private function setupSodium()
|
private function setupSodium()
|
||||||
{
|
{
|
||||||
putenv('COLUMNS='.(119 + \strlen(PHP_EOL)));
|
putenv('COLUMNS='.(119 + \strlen(\PHP_EOL)));
|
||||||
$kernel = $this->createKernel(['test_case' => 'PasswordEncode', 'root_config' => 'sodium.yml']);
|
$kernel = $this->createKernel(['test_case' => 'PasswordEncode', 'root_config' => 'sodium.yml']);
|
||||||
$kernel->boot();
|
$kernel->boot();
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ class WebProfilerBundle extends Bundle
|
|||||||
public function boot()
|
public function boot()
|
||||||
{
|
{
|
||||||
if ('prod' === $this->container->getParameter('kernel.environment')) {
|
if ('prod' === $this->container->getParameter('kernel.environment')) {
|
||||||
@trigger_error('Using WebProfilerBundle in production is not supported and puts your project at risk, disable it.', E_USER_WARNING);
|
@trigger_error('Using WebProfilerBundle in production is not supported and puts your project at risk, disable it.', \E_USER_WARNING);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -123,7 +123,7 @@ class UrlPackage extends Package
|
|||||||
foreach ($urls as $url) {
|
foreach ($urls as $url) {
|
||||||
if ('https://' === substr($url, 0, 8) || '//' === substr($url, 0, 2)) {
|
if ('https://' === substr($url, 0, 8) || '//' === substr($url, 0, 2)) {
|
||||||
$sslUrls[] = $url;
|
$sslUrls[] = $url;
|
||||||
} elseif (null === parse_url($url, PHP_URL_SCHEME)) {
|
} elseif (null === parse_url($url, \PHP_URL_SCHEME)) {
|
||||||
throw new InvalidArgumentException(sprintf('"%s" is not a valid URL.', $url));
|
throw new InvalidArgumentException(sprintf('"%s" is not a valid URL.', $url));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -352,12 +352,12 @@ abstract class AbstractBrowser
|
|||||||
|
|
||||||
$server = array_merge($this->server, $server);
|
$server = array_merge($this->server, $server);
|
||||||
|
|
||||||
if (!empty($server['HTTP_HOST']) && null === parse_url($originalUri, PHP_URL_HOST)) {
|
if (!empty($server['HTTP_HOST']) && null === parse_url($originalUri, \PHP_URL_HOST)) {
|
||||||
$uri = preg_replace('{^(https?\://)'.preg_quote($this->extractHost($uri)).'}', '${1}'.$server['HTTP_HOST'], $uri);
|
$uri = preg_replace('{^(https?\://)'.preg_quote($this->extractHost($uri)).'}', '${1}'.$server['HTTP_HOST'], $uri);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($server['HTTPS']) && null === parse_url($originalUri, PHP_URL_SCHEME)) {
|
if (isset($server['HTTPS']) && null === parse_url($originalUri, \PHP_URL_SCHEME)) {
|
||||||
$uri = preg_replace('{^'.parse_url($uri, PHP_URL_SCHEME).'}', $server['HTTPS'] ? 'https' : 'http', $uri);
|
$uri = preg_replace('{^'.parse_url($uri, \PHP_URL_SCHEME).'}', $server['HTTPS'] ? 'https' : 'http', $uri);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isset($server['HTTP_REFERER']) && !$this->history->isEmpty()) {
|
if (!isset($server['HTTP_REFERER']) && !$this->history->isEmpty()) {
|
||||||
@ -368,7 +368,7 @@ abstract class AbstractBrowser
|
|||||||
$server['HTTP_HOST'] = $this->extractHost($uri);
|
$server['HTTP_HOST'] = $this->extractHost($uri);
|
||||||
}
|
}
|
||||||
|
|
||||||
$server['HTTPS'] = 'https' == parse_url($uri, PHP_URL_SCHEME);
|
$server['HTTPS'] = 'https' == parse_url($uri, \PHP_URL_SCHEME);
|
||||||
|
|
||||||
$this->internalRequest = new Request($uri, $method, $parameters, $files, $this->cookieJar->allValues($uri), $server, $content);
|
$this->internalRequest = new Request($uri, $method, $parameters, $files, $this->cookieJar->allValues($uri), $server, $content);
|
||||||
|
|
||||||
@ -437,9 +437,9 @@ abstract class AbstractBrowser
|
|||||||
foreach ($deprecations ? unserialize($deprecations) : [] as $deprecation) {
|
foreach ($deprecations ? unserialize($deprecations) : [] as $deprecation) {
|
||||||
if ($deprecation[0]) {
|
if ($deprecation[0]) {
|
||||||
// unsilenced on purpose
|
// unsilenced on purpose
|
||||||
trigger_error($deprecation[1], E_USER_DEPRECATED);
|
trigger_error($deprecation[1], \E_USER_DEPRECATED);
|
||||||
} else {
|
} else {
|
||||||
@trigger_error($deprecation[1], E_USER_DEPRECATED);
|
@trigger_error($deprecation[1], \E_USER_DEPRECATED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -653,7 +653,7 @@ abstract class AbstractBrowser
|
|||||||
|
|
||||||
// protocol relative URL
|
// protocol relative URL
|
||||||
if (0 === strpos($uri, '//')) {
|
if (0 === strpos($uri, '//')) {
|
||||||
return parse_url($currentUri, PHP_URL_SCHEME).':'.$uri;
|
return parse_url($currentUri, \PHP_URL_SCHEME).':'.$uri;
|
||||||
}
|
}
|
||||||
|
|
||||||
// anchor or query string parameters?
|
// anchor or query string parameters?
|
||||||
@ -662,7 +662,7 @@ abstract class AbstractBrowser
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ('/' !== $uri[0]) {
|
if ('/' !== $uri[0]) {
|
||||||
$path = parse_url($currentUri, PHP_URL_PATH);
|
$path = parse_url($currentUri, \PHP_URL_PATH);
|
||||||
|
|
||||||
if ('/' !== substr($path, -1)) {
|
if ('/' !== substr($path, -1)) {
|
||||||
$path = substr($path, 0, strrpos($path, '/') + 1);
|
$path = substr($path, 0, strrpos($path, '/') + 1);
|
||||||
@ -689,7 +689,7 @@ abstract class AbstractBrowser
|
|||||||
private function updateServerFromUri(array $server, string $uri): array
|
private function updateServerFromUri(array $server, string $uri): array
|
||||||
{
|
{
|
||||||
$server['HTTP_HOST'] = $this->extractHost($uri);
|
$server['HTTP_HOST'] = $this->extractHost($uri);
|
||||||
$scheme = parse_url($uri, PHP_URL_SCHEME);
|
$scheme = parse_url($uri, \PHP_URL_SCHEME);
|
||||||
$server['HTTPS'] = null === $scheme ? $server['HTTPS'] : 'https' == $scheme;
|
$server['HTTPS'] = null === $scheme ? $server['HTTPS'] : 'https' == $scheme;
|
||||||
unset($server['HTTP_IF_NONE_MATCH'], $server['HTTP_IF_MODIFIED_SINCE']);
|
unset($server['HTTP_IF_NONE_MATCH'], $server['HTTP_IF_MODIFIED_SINCE']);
|
||||||
|
|
||||||
@ -698,9 +698,9 @@ abstract class AbstractBrowser
|
|||||||
|
|
||||||
private function extractHost(string $uri): ?string
|
private function extractHost(string $uri): ?string
|
||||||
{
|
{
|
||||||
$host = parse_url($uri, PHP_URL_HOST);
|
$host = parse_url($uri, \PHP_URL_HOST);
|
||||||
|
|
||||||
if ($port = parse_url($uri, PHP_URL_PORT)) {
|
if ($port = parse_url($uri, \PHP_URL_PORT)) {
|
||||||
return $host.':'.$port;
|
return $host.':'.$port;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -91,7 +91,7 @@ class HttpBrowser extends AbstractBrowser
|
|||||||
return ['', []];
|
return ['', []];
|
||||||
}
|
}
|
||||||
|
|
||||||
return [http_build_query($fields, '', '&', PHP_QUERY_RFC1738), ['Content-Type' => 'application/x-www-form-urlencoded']];
|
return [http_build_query($fields, '', '&', \PHP_QUERY_RFC1738), ['Content-Type' => 'application/x-www-form-urlencoded']];
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getHeaders(Request $request): array
|
private function getHeaders(Request $request): array
|
||||||
|
@ -112,7 +112,7 @@ abstract class AbstractAdapter implements AdapterInterface, CacheInterface, Logg
|
|||||||
return $opcache;
|
return $opcache;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (\in_array(\PHP_SAPI, ['cli', 'phpdbg'], true) && !filter_var(ini_get('apc.enable_cli'), FILTER_VALIDATE_BOOLEAN)) {
|
if (\in_array(\PHP_SAPI, ['cli', 'phpdbg'], true) && !filter_var(ini_get('apc.enable_cli'), \FILTER_VALIDATE_BOOLEAN)) {
|
||||||
return $opcache;
|
return $opcache;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ class ApcuAdapter extends AbstractAdapter
|
|||||||
|
|
||||||
public static function isSupported()
|
public static function isSupported()
|
||||||
{
|
{
|
||||||
return \function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN);
|
return \function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), \FILTER_VALIDATE_BOOLEAN);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -63,7 +63,7 @@ class ApcuAdapter extends AbstractAdapter
|
|||||||
|
|
||||||
return $values;
|
return $values;
|
||||||
} catch (\Error $e) {
|
} catch (\Error $e) {
|
||||||
throw new \ErrorException($e->getMessage(), $e->getCode(), E_ERROR, $e->getFile(), $e->getLine());
|
throw new \ErrorException($e->getMessage(), $e->getCode(), \E_ERROR, $e->getFile(), $e->getLine());
|
||||||
} finally {
|
} finally {
|
||||||
ini_set('unserialize_callback_func', $unserializeCallbackHandler);
|
ini_set('unserialize_callback_func', $unserializeCallbackHandler);
|
||||||
}
|
}
|
||||||
@ -82,8 +82,8 @@ class ApcuAdapter extends AbstractAdapter
|
|||||||
*/
|
*/
|
||||||
protected function doClear(string $namespace)
|
protected function doClear(string $namespace)
|
||||||
{
|
{
|
||||||
return isset($namespace[0]) && class_exists('APCuIterator', false) && ('cli' !== \PHP_SAPI || filter_var(ini_get('apc.enable_cli'), FILTER_VALIDATE_BOOLEAN))
|
return isset($namespace[0]) && class_exists('APCuIterator', false) && ('cli' !== \PHP_SAPI || filter_var(ini_get('apc.enable_cli'), \FILTER_VALIDATE_BOOLEAN))
|
||||||
? apcu_delete(new \APCuIterator(sprintf('/^%s/', preg_quote($namespace, '/')), APC_ITER_KEY))
|
? apcu_delete(new \APCuIterator(sprintf('/^%s/', preg_quote($namespace, '/')), \APC_ITER_KEY))
|
||||||
: apcu_clear_cache();
|
: apcu_clear_cache();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,7 +78,7 @@ class ArrayAdapter implements AdapterInterface, CacheInterface, LoggerAwareInter
|
|||||||
$metadata = $item->getMetadata();
|
$metadata = $item->getMetadata();
|
||||||
|
|
||||||
// ArrayAdapter works in memory, we don't care about stampede protection
|
// ArrayAdapter works in memory, we don't care about stampede protection
|
||||||
if (INF === $beta || !$item->isHit()) {
|
if (\INF === $beta || !$item->isHit()) {
|
||||||
$save = true;
|
$save = true;
|
||||||
$this->save($item->set($callback($item, $save)));
|
$this->save($item->set($callback($item, $save)));
|
||||||
}
|
}
|
||||||
@ -197,7 +197,7 @@ class ArrayAdapter implements AdapterInterface, CacheInterface, LoggerAwareInter
|
|||||||
$now = microtime(true);
|
$now = microtime(true);
|
||||||
|
|
||||||
if (0 === $expiry) {
|
if (0 === $expiry) {
|
||||||
$expiry = PHP_INT_MAX;
|
$expiry = \PHP_INT_MAX;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (null !== $expiry && $expiry <= $now) {
|
if (null !== $expiry && $expiry <= $now) {
|
||||||
@ -229,7 +229,7 @@ class ArrayAdapter implements AdapterInterface, CacheInterface, LoggerAwareInter
|
|||||||
}
|
}
|
||||||
|
|
||||||
$this->values[$key] = $value;
|
$this->values[$key] = $value;
|
||||||
$this->expiries[$key] = null !== $expiry ? $expiry : PHP_INT_MAX;
|
$this->expiries[$key] = null !== $expiry ? $expiry : \PHP_INT_MAX;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -51,7 +51,7 @@ class ChainAdapter implements AdapterInterface, CacheInterface, PruneableInterfa
|
|||||||
if (!$adapter instanceof CacheItemPoolInterface) {
|
if (!$adapter instanceof CacheItemPoolInterface) {
|
||||||
throw new InvalidArgumentException(sprintf('The class "%s" does not implement the "%s" interface.', get_debug_type($adapter), CacheItemPoolInterface::class));
|
throw new InvalidArgumentException(sprintf('The class "%s" does not implement the "%s" interface.', get_debug_type($adapter), CacheItemPoolInterface::class));
|
||||||
}
|
}
|
||||||
if (\in_array(\PHP_SAPI, ['cli', 'phpdbg'], true) && $adapter instanceof ApcuAdapter && !filter_var(ini_get('apc.enable_cli'), FILTER_VALIDATE_BOOLEAN)) {
|
if (\in_array(\PHP_SAPI, ['cli', 'phpdbg'], true) && $adapter instanceof ApcuAdapter && !filter_var(ini_get('apc.enable_cli'), \FILTER_VALIDATE_BOOLEAN)) {
|
||||||
continue; // skip putting APCu in the chain when the backend is disabled
|
continue; // skip putting APCu in the chain when the backend is disabled
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -95,7 +95,7 @@ class ChainAdapter implements AdapterInterface, CacheInterface, PruneableInterfa
|
|||||||
$adapter = $this->adapters[$i];
|
$adapter = $this->adapters[$i];
|
||||||
if (isset($this->adapters[++$i])) {
|
if (isset($this->adapters[++$i])) {
|
||||||
$callback = $wrap;
|
$callback = $wrap;
|
||||||
$beta = INF === $beta ? INF : 0;
|
$beta = \INF === $beta ? \INF : 0;
|
||||||
}
|
}
|
||||||
if ($adapter instanceof CacheInterface) {
|
if ($adapter instanceof CacheInterface) {
|
||||||
$value = $adapter->get($key, $callback, $beta, $metadata);
|
$value = $adapter->get($key, $callback, $beta, $metadata);
|
||||||
|
@ -52,7 +52,7 @@ class DoctrineAdapter extends AbstractAdapter
|
|||||||
case 'unserialize':
|
case 'unserialize':
|
||||||
case 'apcu_fetch':
|
case 'apcu_fetch':
|
||||||
case 'apc_fetch':
|
case 'apc_fetch':
|
||||||
throw new \ErrorException($e->getMessage(), $e->getCode(), E_ERROR, $e->getFile(), $e->getLine());
|
throw new \ErrorException($e->getMessage(), $e->getCode(), \E_ERROR, $e->getFile(), $e->getLine());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,7 +72,7 @@ class FilesystemTagAwareAdapter extends AbstractTagAwareAdapter implements Prune
|
|||||||
if (!is_dir($d = $dir.$chars[$i].\DIRECTORY_SEPARATOR.$chars[$j])) {
|
if (!is_dir($d = $dir.$chars[$i].\DIRECTORY_SEPARATOR.$chars[$j])) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
foreach (scandir($d, SCANDIR_SORT_NONE) ?: [] as $link) {
|
foreach (scandir($d, \SCANDIR_SORT_NONE) ?: [] as $link) {
|
||||||
if ('.' !== $link && '..' !== $link && (null !== $renamed || !realpath($d.\DIRECTORY_SEPARATOR.$link))) {
|
if ('.' !== $link && '..' !== $link && (null !== $renamed || !realpath($d.\DIRECTORY_SEPARATOR.$link))) {
|
||||||
unlink($d.\DIRECTORY_SEPARATOR.$link);
|
unlink($d.\DIRECTORY_SEPARATOR.$link);
|
||||||
}
|
}
|
||||||
|
@ -172,7 +172,7 @@ class MemcachedAdapter extends AbstractAdapter
|
|||||||
|
|
||||||
// set client's options
|
// set client's options
|
||||||
unset($options['persistent_id'], $options['username'], $options['password'], $options['weight'], $options['lazy']);
|
unset($options['persistent_id'], $options['username'], $options['password'], $options['weight'], $options['lazy']);
|
||||||
$options = array_change_key_case($options, CASE_UPPER);
|
$options = array_change_key_case($options, \CASE_UPPER);
|
||||||
$client->setOption(\Memcached::OPT_BINARY_PROTOCOL, true);
|
$client->setOption(\Memcached::OPT_BINARY_PROTOCOL, true);
|
||||||
$client->setOption(\Memcached::OPT_NO_BLOCK, true);
|
$client->setOption(\Memcached::OPT_NO_BLOCK, true);
|
||||||
$client->setOption(\Memcached::OPT_TCP_NODELAY, true);
|
$client->setOption(\Memcached::OPT_TCP_NODELAY, true);
|
||||||
@ -269,7 +269,7 @@ class MemcachedAdapter extends AbstractAdapter
|
|||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
} catch (\Error $e) {
|
} catch (\Error $e) {
|
||||||
throw new \ErrorException($e->getMessage(), $e->getCode(), E_ERROR, $e->getFile(), $e->getLine());
|
throw new \ErrorException($e->getMessage(), $e->getCode(), \E_ERROR, $e->getFile(), $e->getLine());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ class PhpFilesAdapter extends AbstractAdapter implements PruneableInterface
|
|||||||
{
|
{
|
||||||
self::$startTime = self::$startTime ?? $_SERVER['REQUEST_TIME'] ?? time();
|
self::$startTime = self::$startTime ?? $_SERVER['REQUEST_TIME'] ?? time();
|
||||||
|
|
||||||
return \function_exists('opcache_invalidate') && filter_var(ini_get('opcache.enable'), FILTER_VALIDATE_BOOLEAN) && (!\in_array(\PHP_SAPI, ['cli', 'phpdbg'], true) || filter_var(ini_get('opcache.enable_cli'), FILTER_VALIDATE_BOOLEAN));
|
return \function_exists('opcache_invalidate') && filter_var(ini_get('opcache.enable'), \FILTER_VALIDATE_BOOLEAN) && (!\in_array(\PHP_SAPI, ['cli', 'phpdbg'], true) || filter_var(ini_get('opcache.enable_cli'), \FILTER_VALIDATE_BOOLEAN));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -183,7 +183,7 @@ final class CacheItem implements ItemInterface
|
|||||||
$replace['{'.$k.'}'] = $v;
|
$replace['{'.$k.'}'] = $v;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@trigger_error(strtr($message, $replace), E_USER_WARNING);
|
@trigger_error(strtr($message, $replace), \E_USER_WARNING);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -70,7 +70,7 @@ final class LockRegistry
|
|||||||
|
|
||||||
foreach (self::$openedFiles as $file) {
|
foreach (self::$openedFiles as $file) {
|
||||||
if ($file) {
|
if ($file) {
|
||||||
flock($file, LOCK_UN);
|
flock($file, \LOCK_UN);
|
||||||
fclose($file);
|
fclose($file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -90,7 +90,7 @@ final class LockRegistry
|
|||||||
while (true) {
|
while (true) {
|
||||||
try {
|
try {
|
||||||
// race to get the lock in non-blocking mode
|
// race to get the lock in non-blocking mode
|
||||||
$locked = flock($lock, LOCK_EX | LOCK_NB, $wouldBlock);
|
$locked = flock($lock, \LOCK_EX | \LOCK_NB, $wouldBlock);
|
||||||
|
|
||||||
if ($locked || !$wouldBlock) {
|
if ($locked || !$wouldBlock) {
|
||||||
$logger && $logger->info(sprintf('Lock %s, now computing item "{key}"', $locked ? 'acquired' : 'not supported'), ['key' => $item->getKey()]);
|
$logger && $logger->info(sprintf('Lock %s, now computing item "{key}"', $locked ? 'acquired' : 'not supported'), ['key' => $item->getKey()]);
|
||||||
@ -111,9 +111,9 @@ final class LockRegistry
|
|||||||
}
|
}
|
||||||
// if we failed the race, retry locking in blocking mode to wait for the winner
|
// if we failed the race, retry locking in blocking mode to wait for the winner
|
||||||
$logger && $logger->info('Item "{key}" is locked, waiting for it to be released', ['key' => $item->getKey()]);
|
$logger && $logger->info('Item "{key}" is locked, waiting for it to be released', ['key' => $item->getKey()]);
|
||||||
flock($lock, LOCK_SH);
|
flock($lock, \LOCK_SH);
|
||||||
} finally {
|
} finally {
|
||||||
flock($lock, LOCK_UN);
|
flock($lock, \LOCK_UN);
|
||||||
unset(self::$lockedFiles[$key]);
|
unset(self::$lockedFiles[$key]);
|
||||||
}
|
}
|
||||||
static $signalingException, $signalingCallback;
|
static $signalingException, $signalingCallback;
|
||||||
|
@ -83,7 +83,7 @@ class DefaultMarshaller implements MarshallerInterface
|
|||||||
|
|
||||||
throw new \DomainException(error_get_last() ? error_get_last()['message'] : 'Failed to unserialize values.');
|
throw new \DomainException(error_get_last() ? error_get_last()['message'] : 'Failed to unserialize values.');
|
||||||
} catch (\Error $e) {
|
} catch (\Error $e) {
|
||||||
throw new \ErrorException($e->getMessage(), $e->getCode(), E_ERROR, $e->getFile(), $e->getLine());
|
throw new \ErrorException($e->getMessage(), $e->getCode(), \E_ERROR, $e->getFile(), $e->getLine());
|
||||||
} finally {
|
} finally {
|
||||||
ini_set('unserialize_callback_func', $unserializeCallbackHandler);
|
ini_set('unserialize_callback_func', $unserializeCallbackHandler);
|
||||||
}
|
}
|
||||||
|
@ -58,7 +58,7 @@ abstract class AdapterTestCase extends CachePoolTest
|
|||||||
$isHit = false;
|
$isHit = false;
|
||||||
$this->assertTrue($item->isHit());
|
$this->assertTrue($item->isHit());
|
||||||
$this->assertSame($value, $item->get());
|
$this->assertSame($value, $item->get());
|
||||||
}, INF));
|
}, \INF));
|
||||||
$this->assertFalse($isHit);
|
$this->assertFalse($isHit);
|
||||||
|
|
||||||
$this->assertSame($value, $cache->get('bar', new class($value) implements CallbackInterface {
|
$this->assertSame($value, $cache->get('bar', new class($value) implements CallbackInterface {
|
||||||
|
@ -25,10 +25,10 @@ class ApcuAdapterTest extends AdapterTestCase
|
|||||||
|
|
||||||
public function createCachePool(int $defaultLifetime = 0): CacheItemPoolInterface
|
public function createCachePool(int $defaultLifetime = 0): CacheItemPoolInterface
|
||||||
{
|
{
|
||||||
if (!\function_exists('apcu_fetch') || !filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN)) {
|
if (!\function_exists('apcu_fetch') || !filter_var(ini_get('apc.enabled'), \FILTER_VALIDATE_BOOLEAN)) {
|
||||||
$this->markTestSkipped('APCu extension is required.');
|
$this->markTestSkipped('APCu extension is required.');
|
||||||
}
|
}
|
||||||
if ('cli' === \PHP_SAPI && !filter_var(ini_get('apc.enable_cli'), FILTER_VALIDATE_BOOLEAN)) {
|
if ('cli' === \PHP_SAPI && !filter_var(ini_get('apc.enable_cli'), \FILTER_VALIDATE_BOOLEAN)) {
|
||||||
if ('testWithCliSapi' !== $this->getName()) {
|
if ('testWithCliSapi' !== $this->getName()) {
|
||||||
$this->markTestSkipped('apc.enable_cli=1 is required.');
|
$this->markTestSkipped('apc.enable_cli=1 is required.');
|
||||||
}
|
}
|
||||||
|
@ -146,7 +146,7 @@ class MemcachedAdapterTest extends AdapterTestCase
|
|||||||
'localhost',
|
'localhost',
|
||||||
11222,
|
11222,
|
||||||
];
|
];
|
||||||
if (filter_var(ini_get('memcached.use_sasl'), FILTER_VALIDATE_BOOLEAN)) {
|
if (filter_var(ini_get('memcached.use_sasl'), \FILTER_VALIDATE_BOOLEAN)) {
|
||||||
yield [
|
yield [
|
||||||
'memcached://user:password@127.0.0.1?weight=50',
|
'memcached://user:password@127.0.0.1?weight=50',
|
||||||
'127.0.0.1',
|
'127.0.0.1',
|
||||||
@ -163,7 +163,7 @@ class MemcachedAdapterTest extends AdapterTestCase
|
|||||||
'/var/local/run/memcached.socket',
|
'/var/local/run/memcached.socket',
|
||||||
0,
|
0,
|
||||||
];
|
];
|
||||||
if (filter_var(ini_get('memcached.use_sasl'), FILTER_VALIDATE_BOOLEAN)) {
|
if (filter_var(ini_get('memcached.use_sasl'), \FILTER_VALIDATE_BOOLEAN)) {
|
||||||
yield [
|
yield [
|
||||||
'memcached://user:password@/var/local/run/memcached.socket?weight=25',
|
'memcached://user:password@/var/local/run/memcached.socket?weight=25',
|
||||||
'/var/local/run/memcached.socket',
|
'/var/local/run/memcached.socket',
|
||||||
|
@ -143,7 +143,7 @@ trait FilesystemCommonTrait
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (@scandir($dir, SCANDIR_SORT_NONE) ?: [] as $file) {
|
foreach (@scandir($dir, \SCANDIR_SORT_NONE) ?: [] as $file) {
|
||||||
if ('.' !== $file && '..' !== $file) {
|
if ('.' !== $file && '..' !== $file) {
|
||||||
yield $dir.\DIRECTORY_SEPARATOR.$file;
|
yield $dir.\DIRECTORY_SEPARATOR.$file;
|
||||||
}
|
}
|
||||||
|
@ -298,7 +298,7 @@ class ArrayNode extends BaseNode implements PrototypeNodeInterface
|
|||||||
$guesses = [];
|
$guesses = [];
|
||||||
|
|
||||||
foreach (array_keys($value) as $subject) {
|
foreach (array_keys($value) as $subject) {
|
||||||
$minScore = INF;
|
$minScore = \INF;
|
||||||
foreach ($proposals as $proposal) {
|
foreach ($proposals as $proposal) {
|
||||||
$distance = levenshtein($subject, $proposal);
|
$distance = levenshtein($subject, $proposal);
|
||||||
if ($distance <= $minScore && $distance < 3) {
|
if ($distance <= $minScore && $distance < 3) {
|
||||||
|
@ -189,7 +189,7 @@ class XmlReferenceDumper
|
|||||||
$commentDepth = $depth + 4 + \strlen($attrName) + 2;
|
$commentDepth = $depth + 4 + \strlen($attrName) + 2;
|
||||||
$commentLines = explode("\n", $comment);
|
$commentLines = explode("\n", $comment);
|
||||||
$multiline = (\count($commentLines) > 1);
|
$multiline = (\count($commentLines) > 1);
|
||||||
$comment = implode(PHP_EOL.str_repeat(' ', $commentDepth), $commentLines);
|
$comment = implode(\PHP_EOL.str_repeat(' ', $commentDepth), $commentLines);
|
||||||
|
|
||||||
if ($multiline) {
|
if ($multiline) {
|
||||||
$this->writeLine('<!--', $depth);
|
$this->writeLine('<!--', $depth);
|
||||||
@ -260,7 +260,7 @@ class XmlReferenceDumper
|
|||||||
$indent = \strlen($text) + $indent;
|
$indent = \strlen($text) + $indent;
|
||||||
$format = '%'.$indent.'s';
|
$format = '%'.$indent.'s';
|
||||||
|
|
||||||
$this->reference .= sprintf($format, $text).PHP_EOL;
|
$this->reference .= sprintf($format, $text).\PHP_EOL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -84,7 +84,7 @@ class FileLocator implements FileLocatorInterface
|
|||||||
&& ':' === $file[1]
|
&& ':' === $file[1]
|
||||||
&& ('\\' === $file[2] || '/' === $file[2])
|
&& ('\\' === $file[2] || '/' === $file[2])
|
||||||
)
|
)
|
||||||
|| null !== parse_url($file, PHP_URL_SCHEME)
|
|| null !== parse_url($file, \PHP_URL_SCHEME)
|
||||||
) {
|
) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -48,7 +48,7 @@ class GlobResource implements \IteratorAggregate, SelfCheckingResourceInterface
|
|||||||
$this->recursive = $recursive;
|
$this->recursive = $recursive;
|
||||||
$this->forExclusion = $forExclusion;
|
$this->forExclusion = $forExclusion;
|
||||||
$this->excludedPrefixes = $excludedPrefixes;
|
$this->excludedPrefixes = $excludedPrefixes;
|
||||||
$this->globBrace = \defined('GLOB_BRACE') ? GLOB_BRACE : 0;
|
$this->globBrace = \defined('GLOB_BRACE') ? \GLOB_BRACE : 0;
|
||||||
|
|
||||||
if (false === $this->prefix) {
|
if (false === $this->prefix) {
|
||||||
throw new \InvalidArgumentException(sprintf('The path "%s" does not exist.', $prefix));
|
throw new \InvalidArgumentException(sprintf('The path "%s" does not exist.', $prefix));
|
||||||
@ -104,10 +104,10 @@ class GlobResource implements \IteratorAggregate, SelfCheckingResourceInterface
|
|||||||
|
|
||||||
if (0 !== strpos($this->prefix, 'phar://') && false === strpos($this->pattern, '/**/')) {
|
if (0 !== strpos($this->prefix, 'phar://') && false === strpos($this->pattern, '/**/')) {
|
||||||
if ($this->globBrace || false === strpos($this->pattern, '{')) {
|
if ($this->globBrace || false === strpos($this->pattern, '{')) {
|
||||||
$paths = glob($this->prefix.$this->pattern, GLOB_NOSORT | $this->globBrace);
|
$paths = glob($this->prefix.$this->pattern, \GLOB_NOSORT | $this->globBrace);
|
||||||
} elseif (false === strpos($this->pattern, '\\') || !preg_match('/\\\\[,{}]/', $this->pattern)) {
|
} elseif (false === strpos($this->pattern, '\\') || !preg_match('/\\\\[,{}]/', $this->pattern)) {
|
||||||
foreach ($this->expandGlob($this->pattern) as $p) {
|
foreach ($this->expandGlob($this->pattern) as $p) {
|
||||||
$paths[] = glob($this->prefix.$p, GLOB_NOSORT);
|
$paths[] = glob($this->prefix.$p, \GLOB_NOSORT);
|
||||||
}
|
}
|
||||||
$paths = array_merge(...$paths);
|
$paths = array_merge(...$paths);
|
||||||
}
|
}
|
||||||
@ -200,7 +200,7 @@ class GlobResource implements \IteratorAggregate, SelfCheckingResourceInterface
|
|||||||
|
|
||||||
private function expandGlob(string $pattern): array
|
private function expandGlob(string $pattern): array
|
||||||
{
|
{
|
||||||
$segments = preg_split('/\{([^{}]*+)\}/', $pattern, -1, PREG_SPLIT_DELIM_CAPTURE);
|
$segments = preg_split('/\{([^{}]*+)\}/', $pattern, -1, \PREG_SPLIT_DELIM_CAPTURE);
|
||||||
$paths = [$segments[0]];
|
$paths = [$segments[0]];
|
||||||
$patterns = [];
|
$patterns = [];
|
||||||
|
|
||||||
|
@ -137,7 +137,7 @@ class ResourceCheckerConfigCache implements ConfigCacheInterface
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (\function_exists('opcache_invalidate') && filter_var(ini_get('opcache.enable'), FILTER_VALIDATE_BOOLEAN)) {
|
if (\function_exists('opcache_invalidate') && filter_var(ini_get('opcache.enable'), \FILTER_VALIDATE_BOOLEAN)) {
|
||||||
@opcache_invalidate($this->file, true);
|
@opcache_invalidate($this->file, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -243,7 +243,7 @@ class ArrayNodeTest extends TestCase
|
|||||||
|
|
||||||
$deprecationTriggered = false;
|
$deprecationTriggered = false;
|
||||||
$deprecationHandler = function ($level, $message, $file, $line) use (&$prevErrorHandler, &$deprecationTriggered) {
|
$deprecationHandler = function ($level, $message, $file, $line) use (&$prevErrorHandler, &$deprecationTriggered) {
|
||||||
if (E_USER_DEPRECATED === $level) {
|
if (\E_USER_DEPRECATED === $level) {
|
||||||
return $deprecationTriggered = true;
|
return $deprecationTriggered = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ class XmlReferenceDumperTest extends TestCase
|
|||||||
|
|
||||||
private function getConfigurationAsString()
|
private function getConfigurationAsString()
|
||||||
{
|
{
|
||||||
return str_replace("\n", PHP_EOL, <<<'EOL'
|
return str_replace("\n", \PHP_EOL, <<<'EOL'
|
||||||
<!-- Namespace: http://example.org/schema/dic/acme_root -->
|
<!-- Namespace: http://example.org/schema/dic/acme_root -->
|
||||||
<!-- scalar-required: Required -->
|
<!-- scalar-required: Required -->
|
||||||
<!-- scalar-deprecated: Deprecated (Since vendor/package 1.1: The child node "scalar_deprecated" at path "acme_root" is deprecated.) -->
|
<!-- scalar-deprecated: Deprecated (Since vendor/package 1.1: The child node "scalar_deprecated" at path "acme_root" is deprecated.) -->
|
||||||
|
@ -57,7 +57,7 @@ class ScalarNodeTest extends TestCase
|
|||||||
|
|
||||||
$deprecationTriggered = 0;
|
$deprecationTriggered = 0;
|
||||||
$deprecationHandler = function ($level, $message, $file, $line) use (&$prevErrorHandler, &$deprecationTriggered) {
|
$deprecationHandler = function ($level, $message, $file, $line) use (&$prevErrorHandler, &$deprecationTriggered) {
|
||||||
if (E_USER_DEPRECATED === $level) {
|
if (\E_USER_DEPRECATED === $level) {
|
||||||
return ++$deprecationTriggered;
|
return ++$deprecationTriggered;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -107,7 +107,7 @@ class ProjectLoader1 extends Loader
|
|||||||
|
|
||||||
public function supports($resource, string $type = null): bool
|
public function supports($resource, string $type = null): bool
|
||||||
{
|
{
|
||||||
return \is_string($resource) && 'foo' === pathinfo($resource, PATHINFO_EXTENSION);
|
return \is_string($resource) && 'foo' === pathinfo($resource, \PATHINFO_EXTENSION);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getType()
|
public function getType()
|
||||||
|
@ -199,7 +199,7 @@ class XmlUtilsTest extends TestCase
|
|||||||
// test for issue https://github.com/symfony/symfony/issues/9731
|
// test for issue https://github.com/symfony/symfony/issues/9731
|
||||||
public function testLoadWrongEmptyXMLWithErrorHandler()
|
public function testLoadWrongEmptyXMLWithErrorHandler()
|
||||||
{
|
{
|
||||||
if (LIBXML_VERSION < 20900) {
|
if (\LIBXML_VERSION < 20900) {
|
||||||
$originalDisableEntities = libxml_disable_entity_loader(false);
|
$originalDisableEntities = libxml_disable_entity_loader(false);
|
||||||
}
|
}
|
||||||
$errorReporting = error_reporting(-1);
|
$errorReporting = error_reporting(-1);
|
||||||
@ -221,7 +221,7 @@ class XmlUtilsTest extends TestCase
|
|||||||
error_reporting($errorReporting);
|
error_reporting($errorReporting);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (LIBXML_VERSION < 20900) {
|
if (\LIBXML_VERSION < 20900) {
|
||||||
$disableEntities = libxml_disable_entity_loader(true);
|
$disableEntities = libxml_disable_entity_loader(true);
|
||||||
libxml_disable_entity_loader($disableEntities);
|
libxml_disable_entity_loader($disableEntities);
|
||||||
|
|
||||||
|
@ -51,15 +51,15 @@ class XmlUtils
|
|||||||
}
|
}
|
||||||
|
|
||||||
$internalErrors = libxml_use_internal_errors(true);
|
$internalErrors = libxml_use_internal_errors(true);
|
||||||
if (LIBXML_VERSION < 20900) {
|
if (\LIBXML_VERSION < 20900) {
|
||||||
$disableEntities = libxml_disable_entity_loader(true);
|
$disableEntities = libxml_disable_entity_loader(true);
|
||||||
}
|
}
|
||||||
libxml_clear_errors();
|
libxml_clear_errors();
|
||||||
|
|
||||||
$dom = new \DOMDocument();
|
$dom = new \DOMDocument();
|
||||||
$dom->validateOnParse = true;
|
$dom->validateOnParse = true;
|
||||||
if (!$dom->loadXML($content, LIBXML_NONET | (\defined('LIBXML_COMPACT') ? LIBXML_COMPACT : 0))) {
|
if (!$dom->loadXML($content, \LIBXML_NONET | (\defined('LIBXML_COMPACT') ? \LIBXML_COMPACT : 0))) {
|
||||||
if (LIBXML_VERSION < 20900) {
|
if (\LIBXML_VERSION < 20900) {
|
||||||
libxml_disable_entity_loader($disableEntities);
|
libxml_disable_entity_loader($disableEntities);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -69,12 +69,12 @@ class XmlUtils
|
|||||||
$dom->normalizeDocument();
|
$dom->normalizeDocument();
|
||||||
|
|
||||||
libxml_use_internal_errors($internalErrors);
|
libxml_use_internal_errors($internalErrors);
|
||||||
if (LIBXML_VERSION < 20900) {
|
if (\LIBXML_VERSION < 20900) {
|
||||||
libxml_disable_entity_loader($disableEntities);
|
libxml_disable_entity_loader($disableEntities);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($dom->childNodes as $child) {
|
foreach ($dom->childNodes as $child) {
|
||||||
if (XML_DOCUMENT_TYPE_NODE === $child->nodeType) {
|
if (\XML_DOCUMENT_TYPE_NODE === $child->nodeType) {
|
||||||
throw new XmlParsingException('Document types are not allowed.');
|
throw new XmlParsingException('Document types are not allowed.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -267,7 +267,7 @@ class XmlUtils
|
|||||||
$errors = [];
|
$errors = [];
|
||||||
foreach (libxml_get_errors() as $error) {
|
foreach (libxml_get_errors() as $error) {
|
||||||
$errors[] = sprintf('[%s %s] %s (in %s - line %d, column %d)',
|
$errors[] = sprintf('[%s %s] %s (in %s - line %d, column %d)',
|
||||||
LIBXML_ERR_WARNING == $error->level ? 'WARNING' : 'ERROR',
|
\LIBXML_ERR_WARNING == $error->level ? 'WARNING' : 'ERROR',
|
||||||
$error->code,
|
$error->code,
|
||||||
trim($error->message),
|
trim($error->message),
|
||||||
$error->file ?: 'n/a',
|
$error->file ?: 'n/a',
|
||||||
|
@ -90,7 +90,7 @@ class Application implements ResetInterface
|
|||||||
$this->defaultCommand = 'list';
|
$this->defaultCommand = 'list';
|
||||||
$this->signalRegistry = new SignalRegistry();
|
$this->signalRegistry = new SignalRegistry();
|
||||||
if (\defined('SIGINT')) {
|
if (\defined('SIGINT')) {
|
||||||
$this->signalsToDispatchEvent = [SIGINT, SIGTERM, SIGUSR1, SIGUSR2];
|
$this->signalsToDispatchEvent = [\SIGINT, \SIGTERM, \SIGUSR1, \SIGUSR2];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -288,7 +288,7 @@ class Application implements ResetInterface
|
|||||||
|
|
||||||
// No more handlers, we try to simulate PHP default behavior
|
// No more handlers, we try to simulate PHP default behavior
|
||||||
if (!$hasNext) {
|
if (!$hasNext) {
|
||||||
if (!\in_array($signal, [SIGUSR1, SIGUSR2], true)) {
|
if (!\in_array($signal, [\SIGUSR1, \SIGUSR2], true)) {
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -828,7 +828,7 @@ class Application implements ResetInterface
|
|||||||
}, $message);
|
}, $message);
|
||||||
}
|
}
|
||||||
|
|
||||||
$width = $this->terminal->getWidth() ? $this->terminal->getWidth() - 1 : PHP_INT_MAX;
|
$width = $this->terminal->getWidth() ? $this->terminal->getWidth() - 1 : \PHP_INT_MAX;
|
||||||
$lines = [];
|
$lines = [];
|
||||||
foreach ('' !== $message ? preg_split('/\r?\n/', $message) : [] as $line) {
|
foreach ('' !== $message ? preg_split('/\r?\n/', $message) : [] as $line) {
|
||||||
foreach ($this->splitStringByWidth($line, $width - 4) as $line) {
|
foreach ($this->splitStringByWidth($line, $width - 4) as $line) {
|
||||||
@ -1117,7 +1117,7 @@ class Application implements ResetInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
$alternatives = array_filter($alternatives, function ($lev) use ($threshold) { return $lev < 2 * $threshold; });
|
$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);
|
return array_keys($alternatives);
|
||||||
}
|
}
|
||||||
|
@ -223,7 +223,7 @@ class Command
|
|||||||
if (null !== $this->processTitle) {
|
if (null !== $this->processTitle) {
|
||||||
if (\function_exists('cli_set_process_title')) {
|
if (\function_exists('cli_set_process_title')) {
|
||||||
if (!@cli_set_process_title($this->processTitle)) {
|
if (!@cli_set_process_title($this->processTitle)) {
|
||||||
if ('Darwin' === PHP_OS) {
|
if ('Darwin' === \PHP_OS) {
|
||||||
$output->writeln('<comment>Running "cli_set_process_title" as an unprivileged user is not supported on MacOS.</comment>', OutputInterface::VERBOSITY_VERY_VERBOSE);
|
$output->writeln('<comment>Running "cli_set_process_title" as an unprivileged user is not supported on MacOS.</comment>', OutputInterface::VERBOSITY_VERY_VERBOSE);
|
||||||
} else {
|
} else {
|
||||||
cli_set_process_title($this->processTitle);
|
cli_set_process_title($this->processTitle);
|
||||||
|
@ -24,7 +24,7 @@ final class Cursor
|
|||||||
public function __construct(OutputInterface $output, $input = null)
|
public function __construct(OutputInterface $output, $input = null)
|
||||||
{
|
{
|
||||||
$this->output = $output;
|
$this->output = $output;
|
||||||
$this->input = $input ?? (\defined('STDIN') ? STDIN : fopen('php://input', 'r+'));
|
$this->input = $input ?? (\defined('STDIN') ? \STDIN : fopen('php://input', 'r+'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function moveUp(int $lines = 1): self
|
public function moveUp(int $lines = 1): self
|
||||||
|
@ -107,7 +107,7 @@ class JsonDescriptor extends Descriptor
|
|||||||
'is_required' => $argument->isRequired(),
|
'is_required' => $argument->isRequired(),
|
||||||
'is_array' => $argument->isArray(),
|
'is_array' => $argument->isArray(),
|
||||||
'description' => preg_replace('/\s*[\r\n]\s*/', ' ', $argument->getDescription()),
|
'description' => preg_replace('/\s*[\r\n]\s*/', ' ', $argument->getDescription()),
|
||||||
'default' => INF === $argument->getDefault() ? 'INF' : $argument->getDefault(),
|
'default' => \INF === $argument->getDefault() ? 'INF' : $argument->getDefault(),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -120,7 +120,7 @@ class JsonDescriptor extends Descriptor
|
|||||||
'is_value_required' => $option->isValueRequired(),
|
'is_value_required' => $option->isValueRequired(),
|
||||||
'is_multiple' => $option->isArray(),
|
'is_multiple' => $option->isArray(),
|
||||||
'description' => preg_replace('/\s*[\r\n]\s*/', ' ', $option->getDescription()),
|
'description' => preg_replace('/\s*[\r\n]\s*/', ' ', $option->getDescription()),
|
||||||
'default' => INF === $option->getDefault() ? 'INF' : $option->getDefault(),
|
'default' => \INF === $option->getDefault() ? 'INF' : $option->getDefault(),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -278,7 +278,7 @@ class TextDescriptor extends Descriptor
|
|||||||
*/
|
*/
|
||||||
private function formatDefaultValue($default): string
|
private function formatDefaultValue($default): string
|
||||||
{
|
{
|
||||||
if (INF === $default) {
|
if (\INF === $default) {
|
||||||
return 'INF';
|
return 'INF';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -292,7 +292,7 @@ class TextDescriptor extends Descriptor
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return str_replace('\\\\', '\\', json_encode($default, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE));
|
return str_replace('\\\\', '\\', json_encode($default, \JSON_UNESCAPED_SLASHES | \JSON_UNESCAPED_UNICODE));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -136,7 +136,7 @@ class OutputFormatter implements WrappableOutputFormatterInterface
|
|||||||
$output = '';
|
$output = '';
|
||||||
$tagRegex = '[a-z][^<>]*+';
|
$tagRegex = '[a-z][^<>]*+';
|
||||||
$currentLineLength = 0;
|
$currentLineLength = 0;
|
||||||
preg_match_all("#<(($tagRegex) | /($tagRegex)?)>#ix", $message, $matches, PREG_OFFSET_CAPTURE);
|
preg_match_all("#<(($tagRegex) | /($tagRegex)?)>#ix", $message, $matches, \PREG_OFFSET_CAPTURE);
|
||||||
foreach ($matches[0] as $i => $match) {
|
foreach ($matches[0] as $i => $match) {
|
||||||
$pos = $match[1];
|
$pos = $match[1];
|
||||||
$text = $match[0];
|
$text = $match[0];
|
||||||
@ -194,7 +194,7 @@ class OutputFormatter implements WrappableOutputFormatterInterface
|
|||||||
return $this->styles[$string];
|
return $this->styles[$string];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!preg_match_all('/([^=]+)=([^;]+)(;|$)/', $string, $matches, PREG_SET_ORDER)) {
|
if (!preg_match_all('/([^=]+)=([^;]+)(;|$)/', $string, $matches, \PREG_SET_ORDER)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -474,7 +474,7 @@ final class ProgressBar
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} elseif ($this->step > 0) {
|
} elseif ($this->step > 0) {
|
||||||
$message = PHP_EOL.$message;
|
$message = \PHP_EOL.$message;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->previousMessage = $originalMessage;
|
$this->previousMessage = $originalMessage;
|
||||||
@ -533,7 +533,7 @@ final class ProgressBar
|
|||||||
return Helper::formatMemory(memory_get_usage(true));
|
return Helper::formatMemory(memory_get_usage(true));
|
||||||
},
|
},
|
||||||
'current' => function (self $bar) {
|
'current' => function (self $bar) {
|
||||||
return str_pad($bar->getProgress(), $bar->getStepWidth(), ' ', STR_PAD_LEFT);
|
return str_pad($bar->getProgress(), $bar->getStepWidth(), ' ', \STR_PAD_LEFT);
|
||||||
},
|
},
|
||||||
'max' => function (self $bar) {
|
'max' => function (self $bar) {
|
||||||
return $bar->getMaxSteps();
|
return $bar->getMaxSteps();
|
||||||
|
@ -107,7 +107,7 @@ class QuestionHelper extends Helper
|
|||||||
{
|
{
|
||||||
$this->writePrompt($output, $question);
|
$this->writePrompt($output, $question);
|
||||||
|
|
||||||
$inputStream = $this->inputStream ?: STDIN;
|
$inputStream = $this->inputStream ?: \STDIN;
|
||||||
$autocomplete = $question->getAutocompleterCallback();
|
$autocomplete = $question->getAutocompleterCallback();
|
||||||
|
|
||||||
if (\function_exists('sapi_windows_cp_set')) {
|
if (\function_exists('sapi_windows_cp_set')) {
|
||||||
|
@ -100,7 +100,7 @@ class SymfonyQuestionHelper extends QuestionHelper
|
|||||||
|
|
||||||
private function getEofShortcut(): string
|
private function getEofShortcut(): string
|
||||||
{
|
{
|
||||||
if (false !== strpos(PHP_OS, 'WIN')) {
|
if (false !== strpos(\PHP_OS, 'WIN')) {
|
||||||
return '<comment>Ctrl+Z</comment> then <comment>Enter</comment>';
|
return '<comment>Ctrl+Z</comment> then <comment>Enter</comment>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,9 +35,9 @@ class TableCellStyle
|
|||||||
];
|
];
|
||||||
|
|
||||||
private $alignMap = [
|
private $alignMap = [
|
||||||
'left' => STR_PAD_RIGHT,
|
'left' => \STR_PAD_RIGHT,
|
||||||
'center' => STR_PAD_BOTH,
|
'center' => \STR_PAD_BOTH,
|
||||||
'right' => STR_PAD_LEFT,
|
'right' => \STR_PAD_LEFT,
|
||||||
];
|
];
|
||||||
|
|
||||||
public function __construct(array $options = [])
|
public function __construct(array $options = [])
|
||||||
@ -70,7 +70,7 @@ class TableCellStyle
|
|||||||
function ($key) {
|
function ($key) {
|
||||||
return \in_array($key, $this->tagOptions) && isset($this->options[$key]);
|
return \in_array($key, $this->tagOptions) && isset($this->options[$key]);
|
||||||
},
|
},
|
||||||
ARRAY_FILTER_USE_KEY
|
\ARRAY_FILTER_USE_KEY
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ class TableStyle
|
|||||||
private $cellRowFormat = '%s';
|
private $cellRowFormat = '%s';
|
||||||
private $cellRowContentFormat = ' %s ';
|
private $cellRowContentFormat = ' %s ';
|
||||||
private $borderFormat = '%s';
|
private $borderFormat = '%s';
|
||||||
private $padType = STR_PAD_RIGHT;
|
private $padType = \STR_PAD_RIGHT;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets padding character, used for cell padding.
|
* Sets padding character, used for cell padding.
|
||||||
@ -319,7 +319,7 @@ class TableStyle
|
|||||||
*/
|
*/
|
||||||
public function setPadType(int $padType)
|
public function setPadType(int $padType)
|
||||||
{
|
{
|
||||||
if (!\in_array($padType, [STR_PAD_LEFT, STR_PAD_RIGHT, STR_PAD_BOTH], true)) {
|
if (!\in_array($padType, [\STR_PAD_LEFT, \STR_PAD_RIGHT, \STR_PAD_BOTH], true)) {
|
||||||
throw new InvalidArgumentException('Invalid padding type. Expected one of (STR_PAD_LEFT, STR_PAD_RIGHT, STR_PAD_BOTH).');
|
throw new InvalidArgumentException('Invalid padding type. Expected one of (STR_PAD_LEFT, STR_PAD_RIGHT, STR_PAD_BOTH).');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -171,7 +171,7 @@ class InputDefinition
|
|||||||
*/
|
*/
|
||||||
public function getArgumentCount()
|
public function getArgumentCount()
|
||||||
{
|
{
|
||||||
return $this->hasAnArrayArgument ? PHP_INT_MAX : \count($this->arguments);
|
return $this->hasAnArrayArgument ? \PHP_INT_MAX : \count($this->arguments);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -39,7 +39,7 @@ class BufferedOutput extends Output
|
|||||||
$this->buffer .= $message;
|
$this->buffer .= $message;
|
||||||
|
|
||||||
if ($newline) {
|
if ($newline) {
|
||||||
$this->buffer .= PHP_EOL;
|
$this->buffer .= \PHP_EOL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -131,7 +131,7 @@ class ConsoleOutput extends StreamOutput implements ConsoleOutputInterface
|
|||||||
$checks = [
|
$checks = [
|
||||||
\function_exists('php_uname') ? php_uname('s') : '',
|
\function_exists('php_uname') ? php_uname('s') : '',
|
||||||
getenv('OSTYPE'),
|
getenv('OSTYPE'),
|
||||||
PHP_OS,
|
\PHP_OS,
|
||||||
];
|
];
|
||||||
|
|
||||||
return false !== stripos(implode(';', $checks), 'OS400');
|
return false !== stripos(implode(';', $checks), 'OS400');
|
||||||
|
@ -82,10 +82,10 @@ class ConsoleSectionOutput extends StreamOutput
|
|||||||
*/
|
*/
|
||||||
public function addContent(string $input)
|
public function addContent(string $input)
|
||||||
{
|
{
|
||||||
foreach (explode(PHP_EOL, $input) as $lineContent) {
|
foreach (explode(\PHP_EOL, $input) as $lineContent) {
|
||||||
$this->lines += ceil($this->getDisplayLength($lineContent) / $this->terminal->getWidth()) ?: 1;
|
$this->lines += ceil($this->getDisplayLength($lineContent) / $this->terminal->getWidth()) ?: 1;
|
||||||
$this->content[] = $lineContent;
|
$this->content[] = $lineContent;
|
||||||
$this->content[] = PHP_EOL;
|
$this->content[] = \PHP_EOL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,7 +70,7 @@ class StreamOutput extends Output
|
|||||||
protected function doWrite(string $message, bool $newline)
|
protected function doWrite(string $message, bool $newline)
|
||||||
{
|
{
|
||||||
if ($newline) {
|
if ($newline) {
|
||||||
$message .= PHP_EOL;
|
$message .= \PHP_EOL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@fwrite($this->stream, $message);
|
@fwrite($this->stream, $message);
|
||||||
|
@ -35,7 +35,7 @@ abstract class OutputStyle implements OutputInterface, StyleInterface
|
|||||||
*/
|
*/
|
||||||
public function newLine(int $count = 1)
|
public function newLine(int $count = 1)
|
||||||
{
|
{
|
||||||
$this->output->write(str_repeat(PHP_EOL, $count));
|
$this->output->write(str_repeat(\PHP_EOL, $count));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -432,7 +432,7 @@ class SymfonyStyle extends OutputStyle
|
|||||||
|
|
||||||
private function autoPrependBlock(): void
|
private function autoPrependBlock(): void
|
||||||
{
|
{
|
||||||
$chars = substr(str_replace(PHP_EOL, "\n", $this->bufferedOutput->fetch()), -2);
|
$chars = substr(str_replace(\PHP_EOL, "\n", $this->bufferedOutput->fetch()), -2);
|
||||||
|
|
||||||
if (!isset($chars[0])) {
|
if (!isset($chars[0])) {
|
||||||
$this->newLine(); //empty history, so we should start with a new line.
|
$this->newLine(); //empty history, so we should start with a new line.
|
||||||
@ -477,7 +477,7 @@ class SymfonyStyle extends OutputStyle
|
|||||||
$message = OutputFormatter::escape($message);
|
$message = OutputFormatter::escape($message);
|
||||||
}
|
}
|
||||||
|
|
||||||
$lines = array_merge($lines, explode(PHP_EOL, wordwrap($message, $this->lineLength - $prefixLength - $indentLength, PHP_EOL, true)));
|
$lines = array_merge($lines, explode(\PHP_EOL, wordwrap($message, $this->lineLength - $prefixLength - $indentLength, \PHP_EOL, true)));
|
||||||
|
|
||||||
if (\count($messages) > 1 && $key < \count($messages) - 1) {
|
if (\count($messages) > 1 && $key < \count($messages) - 1) {
|
||||||
$lines[] = '';
|
$lines[] = '';
|
||||||
|
@ -44,7 +44,7 @@ trait TesterTrait
|
|||||||
$display = stream_get_contents($this->output->getStream());
|
$display = stream_get_contents($this->output->getStream());
|
||||||
|
|
||||||
if ($normalize) {
|
if ($normalize) {
|
||||||
$display = str_replace(PHP_EOL, "\n", $display);
|
$display = str_replace(\PHP_EOL, "\n", $display);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $display;
|
return $display;
|
||||||
@ -68,7 +68,7 @@ trait TesterTrait
|
|||||||
$display = stream_get_contents($this->output->getErrorOutput()->getStream());
|
$display = stream_get_contents($this->output->getErrorOutput()->getStream());
|
||||||
|
|
||||||
if ($normalize) {
|
if ($normalize) {
|
||||||
$display = str_replace(PHP_EOL, "\n", $display);
|
$display = str_replace(\PHP_EOL, "\n", $display);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $display;
|
return $display;
|
||||||
@ -176,7 +176,7 @@ trait TesterTrait
|
|||||||
$stream = fopen('php://memory', 'r+', false);
|
$stream = fopen('php://memory', 'r+', false);
|
||||||
|
|
||||||
foreach ($inputs as $input) {
|
foreach ($inputs as $input) {
|
||||||
fwrite($stream, $input.PHP_EOL);
|
fwrite($stream, $input.\PHP_EOL);
|
||||||
}
|
}
|
||||||
|
|
||||||
rewind($stream);
|
rewind($stream);
|
||||||
|
@ -81,7 +81,7 @@ class ApplicationTest extends TestCase
|
|||||||
|
|
||||||
protected function normalizeLineBreaks($text)
|
protected function normalizeLineBreaks($text)
|
||||||
{
|
{
|
||||||
return str_replace(PHP_EOL, "\n", $text);
|
return str_replace(\PHP_EOL, "\n", $text);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1018,10 +1018,10 @@ class ApplicationTest extends TestCase
|
|||||||
$tester = new ApplicationTester($application);
|
$tester = new ApplicationTester($application);
|
||||||
|
|
||||||
$tester->run(['command' => 'foo:bar', '--no-interaction' => true], ['decorated' => false]);
|
$tester->run(['command' => 'foo:bar', '--no-interaction' => true], ['decorated' => false]);
|
||||||
$this->assertSame('called'.PHP_EOL, $tester->getDisplay(), '->run() does not call interact() if --no-interaction is passed');
|
$this->assertSame('called'.\PHP_EOL, $tester->getDisplay(), '->run() does not call interact() if --no-interaction is passed');
|
||||||
|
|
||||||
$tester->run(['command' => 'foo:bar', '-n' => true], ['decorated' => false]);
|
$tester->run(['command' => 'foo:bar', '-n' => true], ['decorated' => false]);
|
||||||
$this->assertSame('called'.PHP_EOL, $tester->getDisplay(), '->run() does not call interact() if -n is passed');
|
$this->assertSame('called'.\PHP_EOL, $tester->getDisplay(), '->run() does not call interact() if -n is passed');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testRunWithGlobalOptionAndNoCommand()
|
public function testRunWithGlobalOptionAndNoCommand()
|
||||||
@ -1318,7 +1318,7 @@ class ApplicationTest extends TestCase
|
|||||||
|
|
||||||
$tester = new ApplicationTester($application);
|
$tester = new ApplicationTester($application);
|
||||||
$tester->run(['command' => 'foo']);
|
$tester->run(['command' => 'foo']);
|
||||||
$this->assertEquals('before.foo.after.'.PHP_EOL, $tester->getDisplay());
|
$this->assertEquals('before.foo.after.'.\PHP_EOL, $tester->getDisplay());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testRunWithExceptionAndDispatcher()
|
public function testRunWithExceptionAndDispatcher()
|
||||||
@ -1602,7 +1602,7 @@ class ApplicationTest extends TestCase
|
|||||||
|
|
||||||
$tester = new ApplicationTester($application);
|
$tester = new ApplicationTester($application);
|
||||||
$tester->run([], ['interactive' => false]);
|
$tester->run([], ['interactive' => false]);
|
||||||
$this->assertEquals('called'.PHP_EOL, $tester->getDisplay(), 'Application runs the default set command if different from \'list\' command');
|
$this->assertEquals('called'.\PHP_EOL, $tester->getDisplay(), 'Application runs the default set command if different from \'list\' command');
|
||||||
|
|
||||||
$application = new CustomDefaultCommandApplication();
|
$application = new CustomDefaultCommandApplication();
|
||||||
$application->setAutoExit(false);
|
$application->setAutoExit(false);
|
||||||
@ -1610,7 +1610,7 @@ class ApplicationTest extends TestCase
|
|||||||
$tester = new ApplicationTester($application);
|
$tester = new ApplicationTester($application);
|
||||||
$tester->run([], ['interactive' => false]);
|
$tester->run([], ['interactive' => false]);
|
||||||
|
|
||||||
$this->assertEquals('called'.PHP_EOL, $tester->getDisplay(), 'Application runs the default set command if different from \'list\' command');
|
$this->assertEquals('called'.\PHP_EOL, $tester->getDisplay(), 'Application runs the default set command if different from \'list\' command');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSetRunCustomDefaultCommandWithOption()
|
public function testSetRunCustomDefaultCommandWithOption()
|
||||||
@ -1625,7 +1625,7 @@ class ApplicationTest extends TestCase
|
|||||||
$tester = new ApplicationTester($application);
|
$tester = new ApplicationTester($application);
|
||||||
$tester->run(['--fooopt' => 'opt'], ['interactive' => false]);
|
$tester->run(['--fooopt' => 'opt'], ['interactive' => false]);
|
||||||
|
|
||||||
$this->assertEquals('called'.PHP_EOL.'opt'.PHP_EOL, $tester->getDisplay(), 'Application runs the default set command if different from \'list\' command');
|
$this->assertEquals('called'.\PHP_EOL.'opt'.\PHP_EOL, $tester->getDisplay(), 'Application runs the default set command if different from \'list\' command');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSetRunCustomSingleCommand()
|
public function testSetRunCustomSingleCommand()
|
||||||
|
@ -264,7 +264,7 @@ class CommandTest extends TestCase
|
|||||||
|
|
||||||
$tester->execute([], ['interactive' => true]);
|
$tester->execute([], ['interactive' => true]);
|
||||||
|
|
||||||
$this->assertEquals('interact called'.PHP_EOL.'execute called'.PHP_EOL, $tester->getDisplay(), '->run() calls the interact() method if the input is interactive');
|
$this->assertEquals('interact called'.\PHP_EOL.'execute called'.\PHP_EOL, $tester->getDisplay(), '->run() calls the interact() method if the input is interactive');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testRunNonInteractive()
|
public function testRunNonInteractive()
|
||||||
@ -273,7 +273,7 @@ class CommandTest extends TestCase
|
|||||||
|
|
||||||
$tester->execute([], ['interactive' => false]);
|
$tester->execute([], ['interactive' => false]);
|
||||||
|
|
||||||
$this->assertEquals('execute called'.PHP_EOL, $tester->getDisplay(), '->run() does not call the interact() method if the input is not interactive');
|
$this->assertEquals('execute called'.\PHP_EOL, $tester->getDisplay(), '->run() does not call the interact() method if the input is not interactive');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testExecuteMethodNeedsToBeOverridden()
|
public function testExecuteMethodNeedsToBeOverridden()
|
||||||
@ -316,7 +316,7 @@ class CommandTest extends TestCase
|
|||||||
$command->setProcessTitle('foo');
|
$command->setProcessTitle('foo');
|
||||||
$this->assertSame(0, $command->run(new StringInput(''), new NullOutput()));
|
$this->assertSame(0, $command->run(new StringInput(''), new NullOutput()));
|
||||||
if (\function_exists('cli_set_process_title')) {
|
if (\function_exists('cli_set_process_title')) {
|
||||||
if (null === @cli_get_process_title() && 'Darwin' === PHP_OS) {
|
if (null === @cli_get_process_title() && 'Darwin' === \PHP_OS) {
|
||||||
$this->markTestSkipped('Running "cli_get_process_title" as an unprivileged user is not supported on MacOS.');
|
$this->markTestSkipped('Running "cli_get_process_title" as an unprivileged user is not supported on MacOS.');
|
||||||
}
|
}
|
||||||
$this->assertEquals('foo', cli_get_process_title());
|
$this->assertEquals('foo', cli_get_process_title());
|
||||||
@ -332,7 +332,7 @@ class CommandTest extends TestCase
|
|||||||
$this->assertEquals($command, $ret, '->setCode() implements a fluent interface');
|
$this->assertEquals($command, $ret, '->setCode() implements a fluent interface');
|
||||||
$tester = new CommandTester($command);
|
$tester = new CommandTester($command);
|
||||||
$tester->execute([]);
|
$tester->execute([]);
|
||||||
$this->assertEquals('interact called'.PHP_EOL.'from the code...'.PHP_EOL, $tester->getDisplay());
|
$this->assertEquals('interact called'.\PHP_EOL.'from the code...'.\PHP_EOL, $tester->getDisplay());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getSetCodeBindToClosureTests()
|
public function getSetCodeBindToClosureTests()
|
||||||
@ -357,7 +357,7 @@ class CommandTest extends TestCase
|
|||||||
$command->setCode($code);
|
$command->setCode($code);
|
||||||
$tester = new CommandTester($command);
|
$tester = new CommandTester($command);
|
||||||
$tester->execute([]);
|
$tester->execute([]);
|
||||||
$this->assertEquals('interact called'.PHP_EOL.$expected.PHP_EOL, $tester->getDisplay());
|
$this->assertEquals('interact called'.\PHP_EOL.$expected.\PHP_EOL, $tester->getDisplay());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSetCodeWithStaticClosure()
|
public function testSetCodeWithStaticClosure()
|
||||||
@ -367,7 +367,7 @@ class CommandTest extends TestCase
|
|||||||
$tester = new CommandTester($command);
|
$tester = new CommandTester($command);
|
||||||
$tester->execute([]);
|
$tester->execute([]);
|
||||||
|
|
||||||
$this->assertEquals('interact called'.PHP_EOL.'bound'.PHP_EOL, $tester->getDisplay());
|
$this->assertEquals('interact called'.\PHP_EOL.'bound'.\PHP_EOL, $tester->getDisplay());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function createClosure()
|
private static function createClosure()
|
||||||
@ -384,7 +384,7 @@ class CommandTest extends TestCase
|
|||||||
$this->assertEquals($command, $ret, '->setCode() implements a fluent interface');
|
$this->assertEquals($command, $ret, '->setCode() implements a fluent interface');
|
||||||
$tester = new CommandTester($command);
|
$tester = new CommandTester($command);
|
||||||
$tester->execute([]);
|
$tester->execute([]);
|
||||||
$this->assertEquals('interact called'.PHP_EOL.'from the code...'.PHP_EOL, $tester->getDisplay());
|
$this->assertEquals('interact called'.\PHP_EOL.'from the code...'.\PHP_EOL, $tester->getDisplay());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function callableMethodCommand(InputInterface $input, OutputInterface $output)
|
public function callableMethodCommand(InputInterface $input, OutputInterface $output)
|
||||||
|
@ -198,7 +198,7 @@ class CursorTest extends TestCase
|
|||||||
{
|
{
|
||||||
rewind($output->getStream());
|
rewind($output->getStream());
|
||||||
|
|
||||||
return str_replace(PHP_EOL, "\n", stream_get_contents($output->getStream()));
|
return str_replace(\PHP_EOL, "\n", stream_get_contents($output->getStream()));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getOutputStream(): StreamOutput
|
protected function getOutputStream(): StreamOutput
|
||||||
|
@ -102,6 +102,6 @@ abstract class AbstractDescriptorTest extends TestCase
|
|||||||
{
|
{
|
||||||
$output = new BufferedOutput(BufferedOutput::VERBOSITY_NORMAL, true);
|
$output = new BufferedOutput(BufferedOutput::VERBOSITY_NORMAL, true);
|
||||||
$this->getDescriptor()->describe($output, $describedObject, $options + ['raw_output' => true]);
|
$this->getDescriptor()->describe($output, $describedObject, $options + ['raw_output' => true]);
|
||||||
$this->assertEquals(trim($expectedDescription), trim(str_replace(PHP_EOL, "\n", $output->fetch())));
|
$this->assertEquals(trim($expectedDescription), trim(str_replace(\PHP_EOL, "\n", $output->fetch())));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,6 +30,6 @@ class JsonDescriptorTest extends AbstractDescriptorTest
|
|||||||
{
|
{
|
||||||
$output = new BufferedOutput(BufferedOutput::VERBOSITY_NORMAL, true);
|
$output = new BufferedOutput(BufferedOutput::VERBOSITY_NORMAL, true);
|
||||||
$this->getDescriptor()->describe($output, $describedObject, $options + ['raw_output' => true]);
|
$this->getDescriptor()->describe($output, $describedObject, $options + ['raw_output' => true]);
|
||||||
$this->assertEquals(json_decode(trim($expectedDescription), true), json_decode(trim(str_replace(PHP_EOL, "\n", $output->fetch())), true));
|
$this->assertEquals(json_decode(trim($expectedDescription), true), json_decode(trim(str_replace(\PHP_EOL, "\n", $output->fetch())), true));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@ class ObjectsProvider
|
|||||||
'input_argument_3' => new InputArgument('argument_name', InputArgument::OPTIONAL, 'argument description', 'default_value'),
|
'input_argument_3' => new InputArgument('argument_name', InputArgument::OPTIONAL, 'argument description', 'default_value'),
|
||||||
'input_argument_4' => new InputArgument('argument_name', InputArgument::REQUIRED, "multiline\nargument description"),
|
'input_argument_4' => new InputArgument('argument_name', InputArgument::REQUIRED, "multiline\nargument description"),
|
||||||
'input_argument_with_style' => new InputArgument('argument_name', InputArgument::OPTIONAL, 'argument description', '<comment>style</>'),
|
'input_argument_with_style' => new InputArgument('argument_name', InputArgument::OPTIONAL, 'argument description', '<comment>style</>'),
|
||||||
'input_argument_with_default_inf_value' => new InputArgument('argument_name', InputArgument::OPTIONAL, 'argument description', INF),
|
'input_argument_with_default_inf_value' => new InputArgument('argument_name', InputArgument::OPTIONAL, 'argument description', \INF),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -47,7 +47,7 @@ class ObjectsProvider
|
|||||||
'input_option_6' => new InputOption('option_name', ['o', 'O'], InputOption::VALUE_REQUIRED, 'option with multiple shortcuts'),
|
'input_option_6' => new InputOption('option_name', ['o', 'O'], InputOption::VALUE_REQUIRED, 'option with multiple shortcuts'),
|
||||||
'input_option_with_style' => new InputOption('option_name', 'o', InputOption::VALUE_REQUIRED, 'option description', '<comment>style</>'),
|
'input_option_with_style' => new InputOption('option_name', 'o', InputOption::VALUE_REQUIRED, 'option description', '<comment>style</>'),
|
||||||
'input_option_with_style_array' => new InputOption('option_name', 'o', InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED, 'option description', ['<comment>Hello</comment>', '<info>world</info>']),
|
'input_option_with_style_array' => new InputOption('option_name', 'o', InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED, 'option description', ['<comment>Hello</comment>', '<info>world</info>']),
|
||||||
'input_option_with_default_inf_value' => new InputOption('option_name', 'o', InputOption::VALUE_OPTIONAL, 'option description', INF),
|
'input_option_with_default_inf_value' => new InputOption('option_name', 'o', InputOption::VALUE_OPTIONAL, 'option description', \INF),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -109,9 +109,9 @@ EOT;
|
|||||||
['', 'php -r "syntax error"', StreamOutput::VERBOSITY_VERBOSE, null],
|
['', 'php -r "syntax error"', StreamOutput::VERBOSITY_VERBOSE, null],
|
||||||
[$syntaxErrorOutputVerbose, 'php -r "fwrite(STDERR, \'error message\');usleep(50000);fwrite(STDOUT, \'out message\');exit(252);"', StreamOutput::VERBOSITY_VERY_VERBOSE, null],
|
[$syntaxErrorOutputVerbose, 'php -r "fwrite(STDERR, \'error message\');usleep(50000);fwrite(STDOUT, \'out message\');exit(252);"', StreamOutput::VERBOSITY_VERY_VERBOSE, null],
|
||||||
[$syntaxErrorOutputDebug, 'php -r "fwrite(STDERR, \'error message\');usleep(500000);fwrite(STDOUT, \'out message\');exit(252);"', StreamOutput::VERBOSITY_DEBUG, null],
|
[$syntaxErrorOutputDebug, 'php -r "fwrite(STDERR, \'error message\');usleep(500000);fwrite(STDOUT, \'out message\');exit(252);"', StreamOutput::VERBOSITY_DEBUG, null],
|
||||||
[$errorMessage.PHP_EOL, 'php -r "fwrite(STDERR, \'error message\');usleep(50000);fwrite(STDOUT, \'out message\');exit(252);"', StreamOutput::VERBOSITY_VERBOSE, $errorMessage],
|
[$errorMessage.\PHP_EOL, 'php -r "fwrite(STDERR, \'error message\');usleep(50000);fwrite(STDOUT, \'out message\');exit(252);"', StreamOutput::VERBOSITY_VERBOSE, $errorMessage],
|
||||||
[$syntaxErrorOutputVerbose.$errorMessage.PHP_EOL, 'php -r "fwrite(STDERR, \'error message\');usleep(50000);fwrite(STDOUT, \'out message\');exit(252);"', StreamOutput::VERBOSITY_VERY_VERBOSE, $errorMessage],
|
[$syntaxErrorOutputVerbose.$errorMessage.\PHP_EOL, 'php -r "fwrite(STDERR, \'error message\');usleep(50000);fwrite(STDOUT, \'out message\');exit(252);"', StreamOutput::VERBOSITY_VERY_VERBOSE, $errorMessage],
|
||||||
[$syntaxErrorOutputDebug.$errorMessage.PHP_EOL, 'php -r "fwrite(STDERR, \'error message\');usleep(500000);fwrite(STDOUT, \'out message\');exit(252);"', StreamOutput::VERBOSITY_DEBUG, $errorMessage],
|
[$syntaxErrorOutputDebug.$errorMessage.\PHP_EOL, 'php -r "fwrite(STDERR, \'error message\');usleep(500000);fwrite(STDOUT, \'out message\');exit(252);"', StreamOutput::VERBOSITY_DEBUG, $errorMessage],
|
||||||
[$successOutputProcessDebug, ['php', '-r', 'echo 42;'], StreamOutput::VERBOSITY_DEBUG, null],
|
[$successOutputProcessDebug, ['php', '-r', 'echo 42;'], StreamOutput::VERBOSITY_DEBUG, null],
|
||||||
[$successOutputDebug, $fromShellCommandline('php -r "echo 42;"'), StreamOutput::VERBOSITY_DEBUG, null],
|
[$successOutputDebug, $fromShellCommandline('php -r "echo 42;"'), StreamOutput::VERBOSITY_DEBUG, null],
|
||||||
[$successOutputProcessDebug, [new Process(['php', '-r', 'echo 42;'])], StreamOutput::VERBOSITY_DEBUG, null],
|
[$successOutputProcessDebug, [new Process(['php', '-r', 'echo 42;'])], StreamOutput::VERBOSITY_DEBUG, null],
|
||||||
|
@ -336,9 +336,9 @@ class ProgressBarTest extends TestCase
|
|||||||
|
|
||||||
rewind($output->getStream());
|
rewind($output->getStream());
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
' 0/50 [>---------------------------] 0%'.PHP_EOL.
|
' 0/50 [>---------------------------] 0%'.\PHP_EOL.
|
||||||
"\x1b[1A\x1b[0J".' 1/50 [>---------------------------] 2%'.PHP_EOL.
|
"\x1b[1A\x1b[0J".' 1/50 [>---------------------------] 2%'.\PHP_EOL.
|
||||||
"\x1b[1A\x1b[0J".' 2/50 [=>--------------------------] 4%'.PHP_EOL,
|
"\x1b[1A\x1b[0J".' 2/50 [=>--------------------------] 4%'.\PHP_EOL,
|
||||||
stream_get_contents($output->getStream())
|
stream_get_contents($output->getStream())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -362,12 +362,12 @@ class ProgressBarTest extends TestCase
|
|||||||
rewind($stream->getStream());
|
rewind($stream->getStream());
|
||||||
|
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
' 0/50 [>---------------------------] 0%'.PHP_EOL.
|
' 0/50 [>---------------------------] 0%'.\PHP_EOL.
|
||||||
' 0/50 [>---------------------------] 0%'.PHP_EOL.
|
' 0/50 [>---------------------------] 0%'.\PHP_EOL.
|
||||||
"\x1b[1A\x1b[0J".' 1/50 [>---------------------------] 2%'.PHP_EOL.
|
"\x1b[1A\x1b[0J".' 1/50 [>---------------------------] 2%'.\PHP_EOL.
|
||||||
"\x1b[2A\x1b[0J".' 1/50 [>---------------------------] 2%'.PHP_EOL.
|
"\x1b[2A\x1b[0J".' 1/50 [>---------------------------] 2%'.\PHP_EOL.
|
||||||
"\x1b[1A\x1b[0J".' 1/50 [>---------------------------] 2%'.PHP_EOL.
|
"\x1b[1A\x1b[0J".' 1/50 [>---------------------------] 2%'.\PHP_EOL.
|
||||||
' 1/50 [>---------------------------] 2%'.PHP_EOL,
|
' 1/50 [>---------------------------] 2%'.\PHP_EOL,
|
||||||
stream_get_contents($stream->getStream())
|
stream_get_contents($stream->getStream())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -393,12 +393,12 @@ class ProgressBarTest extends TestCase
|
|||||||
|
|
||||||
rewind($stream->getStream());
|
rewind($stream->getStream());
|
||||||
|
|
||||||
$this->assertEquals(' 0/50 [>---------------------------] 0%'.PHP_EOL.
|
$this->assertEquals(' 0/50 [>---------------------------] 0%'.\PHP_EOL.
|
||||||
' 0/50 [>] 0% Fruitcake marzipan toffee. Cupcake gummi bears tart dessert ice cream chupa chups cupcake chocolate bar sesame snaps. Croissant halvah cookie jujubes powder macaroon. Fruitcake bear claw bonbon jelly beans oat cake pie muffin Fruitcake marzipan toffee.'.PHP_EOL.
|
' 0/50 [>] 0% Fruitcake marzipan toffee. Cupcake gummi bears tart dessert ice cream chupa chups cupcake chocolate bar sesame snaps. Croissant halvah cookie jujubes powder macaroon. Fruitcake bear claw bonbon jelly beans oat cake pie muffin Fruitcake marzipan toffee.'.\PHP_EOL.
|
||||||
"\x1b[4A\x1b[0J".' 0/50 [>] 0% Fruitcake marzipan toffee. Cupcake gummi bears tart dessert ice cream chupa chups cupcake chocolate bar sesame snaps. Croissant halvah cookie jujubes powder macaroon. Fruitcake bear claw bonbon jelly beans oat cake pie muffin Fruitcake marzipan toffee.'.PHP_EOL.
|
"\x1b[4A\x1b[0J".' 0/50 [>] 0% Fruitcake marzipan toffee. Cupcake gummi bears tart dessert ice cream chupa chups cupcake chocolate bar sesame snaps. Croissant halvah cookie jujubes powder macaroon. Fruitcake bear claw bonbon jelly beans oat cake pie muffin Fruitcake marzipan toffee.'.\PHP_EOL.
|
||||||
"\x1b[3A\x1b[0J".' 1/50 [>---------------------------] 2%'.PHP_EOL.
|
"\x1b[3A\x1b[0J".' 1/50 [>---------------------------] 2%'.\PHP_EOL.
|
||||||
' 0/50 [>] 0% Fruitcake marzipan toffee. Cupcake gummi bears tart dessert ice cream chupa chups cupcake chocolate bar sesame snaps. Croissant halvah cookie jujubes powder macaroon. Fruitcake bear claw bonbon jelly beans oat cake pie muffin Fruitcake marzipan toffee.'.PHP_EOL.
|
' 0/50 [>] 0% Fruitcake marzipan toffee. Cupcake gummi bears tart dessert ice cream chupa chups cupcake chocolate bar sesame snaps. Croissant halvah cookie jujubes powder macaroon. Fruitcake bear claw bonbon jelly beans oat cake pie muffin Fruitcake marzipan toffee.'.\PHP_EOL.
|
||||||
"\x1b[3A\x1b[0J".' 1/50 [>] 2% Fruitcake marzipan toffee. Cupcake gummi bears tart dessert ice cream chupa chups cupcake chocolate bar sesame snaps. Croissant halvah cookie jujubes powder macaroon. Fruitcake bear claw bonbon jelly beans oat cake pie muffin Fruitcake marzipan toffee.'.PHP_EOL,
|
"\x1b[3A\x1b[0J".' 1/50 [>] 2% Fruitcake marzipan toffee. Cupcake gummi bears tart dessert ice cream chupa chups cupcake chocolate bar sesame snaps. Croissant halvah cookie jujubes powder macaroon. Fruitcake bear claw bonbon jelly beans oat cake pie muffin Fruitcake marzipan toffee.'.\PHP_EOL,
|
||||||
stream_get_contents($stream->getStream())
|
stream_get_contents($stream->getStream())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -555,16 +555,16 @@ class ProgressBarTest extends TestCase
|
|||||||
|
|
||||||
rewind($output->getStream());
|
rewind($output->getStream());
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
' 0/200 [>---------------------------] 0%'.PHP_EOL.
|
' 0/200 [>---------------------------] 0%'.\PHP_EOL.
|
||||||
' 20/200 [==>-------------------------] 10%'.PHP_EOL.
|
' 20/200 [==>-------------------------] 10%'.\PHP_EOL.
|
||||||
' 40/200 [=====>----------------------] 20%'.PHP_EOL.
|
' 40/200 [=====>----------------------] 20%'.\PHP_EOL.
|
||||||
' 60/200 [========>-------------------] 30%'.PHP_EOL.
|
' 60/200 [========>-------------------] 30%'.\PHP_EOL.
|
||||||
' 80/200 [===========>----------------] 40%'.PHP_EOL.
|
' 80/200 [===========>----------------] 40%'.\PHP_EOL.
|
||||||
' 100/200 [==============>-------------] 50%'.PHP_EOL.
|
' 100/200 [==============>-------------] 50%'.\PHP_EOL.
|
||||||
' 120/200 [================>-----------] 60%'.PHP_EOL.
|
' 120/200 [================>-----------] 60%'.\PHP_EOL.
|
||||||
' 140/200 [===================>--------] 70%'.PHP_EOL.
|
' 140/200 [===================>--------] 70%'.\PHP_EOL.
|
||||||
' 160/200 [======================>-----] 80%'.PHP_EOL.
|
' 160/200 [======================>-----] 80%'.\PHP_EOL.
|
||||||
' 180/200 [=========================>--] 90%'.PHP_EOL.
|
' 180/200 [=========================>--] 90%'.\PHP_EOL.
|
||||||
' 200/200 [============================] 100%',
|
' 200/200 [============================] 100%',
|
||||||
stream_get_contents($output->getStream())
|
stream_get_contents($output->getStream())
|
||||||
);
|
);
|
||||||
@ -581,8 +581,8 @@ class ProgressBarTest extends TestCase
|
|||||||
|
|
||||||
rewind($output->getStream());
|
rewind($output->getStream());
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
' 0/50 [>---------------------------] 0%'.PHP_EOL.
|
' 0/50 [>---------------------------] 0%'.\PHP_EOL.
|
||||||
' 25/50 [==============>-------------] 50%'.PHP_EOL.
|
' 25/50 [==============>-------------] 50%'.\PHP_EOL.
|
||||||
' 50/50 [============================] 100%',
|
' 50/50 [============================] 100%',
|
||||||
stream_get_contents($output->getStream())
|
stream_get_contents($output->getStream())
|
||||||
);
|
);
|
||||||
@ -596,7 +596,7 @@ class ProgressBarTest extends TestCase
|
|||||||
|
|
||||||
rewind($output->getStream());
|
rewind($output->getStream());
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
' 0 [>---------------------------]'.PHP_EOL.
|
' 0 [>---------------------------]'.\PHP_EOL.
|
||||||
' 1 [->--------------------------]',
|
' 1 [->--------------------------]',
|
||||||
stream_get_contents($output->getStream())
|
stream_get_contents($output->getStream())
|
||||||
);
|
);
|
||||||
|
@ -46,11 +46,11 @@ class ProgressIndicatorTest extends TestCase
|
|||||||
$this->generateOutput(' \\ Advancing...').
|
$this->generateOutput(' \\ Advancing...').
|
||||||
$this->generateOutput(' | Advancing...').
|
$this->generateOutput(' | Advancing...').
|
||||||
$this->generateOutput(' | Done...').
|
$this->generateOutput(' | Done...').
|
||||||
PHP_EOL.
|
\PHP_EOL.
|
||||||
$this->generateOutput(' - Starting Again...').
|
$this->generateOutput(' - Starting Again...').
|
||||||
$this->generateOutput(' \\ Starting Again...').
|
$this->generateOutput(' \\ Starting Again...').
|
||||||
$this->generateOutput(' \\ Done Again...').
|
$this->generateOutput(' \\ Done Again...').
|
||||||
PHP_EOL,
|
\PHP_EOL,
|
||||||
stream_get_contents($output->getStream())
|
stream_get_contents($output->getStream())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -70,9 +70,9 @@ class ProgressIndicatorTest extends TestCase
|
|||||||
rewind($output->getStream());
|
rewind($output->getStream());
|
||||||
|
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
' Starting...'.PHP_EOL.
|
' Starting...'.\PHP_EOL.
|
||||||
' Midway...'.PHP_EOL.
|
' Midway...'.\PHP_EOL.
|
||||||
' Done...'.PHP_EOL.PHP_EOL,
|
' Done...'.\PHP_EOL.\PHP_EOL,
|
||||||
stream_get_contents($output->getStream())
|
stream_get_contents($output->getStream())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -206,7 +206,7 @@ EOT
|
|||||||
$stream = stream_get_contents($output->getStream());
|
$stream = stream_get_contents($output->getStream());
|
||||||
|
|
||||||
if ($normalize) {
|
if ($normalize) {
|
||||||
$stream = str_replace(PHP_EOL, "\n", $stream);
|
$stream = str_replace(\PHP_EOL, "\n", $stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->assertStringContainsString($expected, $stream);
|
$this->assertStringContainsString($expected, $stream);
|
||||||
@ -216,7 +216,7 @@ EOT
|
|||||||
{
|
{
|
||||||
$expected = 'Write an essay (press Ctrl+D to continue)';
|
$expected = 'Write an essay (press Ctrl+D to continue)';
|
||||||
|
|
||||||
if (false !== strpos(PHP_OS, 'WIN')) {
|
if (false !== strpos(\PHP_OS, 'WIN')) {
|
||||||
$expected = 'Write an essay (press Ctrl+Z then Enter to continue)';
|
$expected = 'Write an essay (press Ctrl+Z then Enter to continue)';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -994,7 +994,7 @@ TABLE;
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
$style = new TableStyle();
|
$style = new TableStyle();
|
||||||
$style->setPadType(STR_PAD_LEFT);
|
$style->setPadType(\STR_PAD_LEFT);
|
||||||
$table->setColumnStyle(3, $style);
|
$table->setColumnStyle(3, $style);
|
||||||
|
|
||||||
$table->render();
|
$table->render();
|
||||||
@ -1040,7 +1040,7 @@ TABLE;
|
|||||||
->setColumnWidth(3, 10);
|
->setColumnWidth(3, 10);
|
||||||
|
|
||||||
$style = new TableStyle();
|
$style = new TableStyle();
|
||||||
$style->setPadType(STR_PAD_LEFT);
|
$style->setPadType(\STR_PAD_LEFT);
|
||||||
$table->setColumnStyle(3, $style);
|
$table->setColumnStyle(3, $style);
|
||||||
|
|
||||||
$table->render();
|
$table->render();
|
||||||
@ -1071,7 +1071,7 @@ TABLE;
|
|||||||
->setColumnWidths([15, 0, -1, 10]);
|
->setColumnWidths([15, 0, -1, 10]);
|
||||||
|
|
||||||
$style = new TableStyle();
|
$style = new TableStyle();
|
||||||
$style->setPadType(STR_PAD_LEFT);
|
$style->setPadType(\STR_PAD_LEFT);
|
||||||
$table->setColumnStyle(3, $style);
|
$table->setColumnStyle(3, $style);
|
||||||
|
|
||||||
$table->render();
|
$table->render();
|
||||||
@ -1467,7 +1467,7 @@ EOTXT;
|
|||||||
{
|
{
|
||||||
rewind($output->getStream());
|
rewind($output->getStream());
|
||||||
|
|
||||||
return str_replace(PHP_EOL, "\n", stream_get_contents($output->getStream()));
|
return str_replace(\PHP_EOL, "\n", stream_get_contents($output->getStream()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testWithColspanAndMaxWith(): void
|
public function testWithColspanAndMaxWith(): void
|
||||||
|
@ -67,7 +67,7 @@ class ConsoleLoggerTest extends TestCase
|
|||||||
$logger = new ConsoleLogger($out, $addVerbosityLevelMap);
|
$logger = new ConsoleLogger($out, $addVerbosityLevelMap);
|
||||||
$logger->log($logLevel, 'foo bar');
|
$logger->log($logLevel, 'foo bar');
|
||||||
$logs = $out->fetch();
|
$logs = $out->fetch();
|
||||||
$this->assertEquals($isOutput ? "[$logLevel] foo bar".PHP_EOL : '', $logs);
|
$this->assertEquals($isOutput ? "[$logLevel] foo bar".\PHP_EOL : '', $logs);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function provideOutputMappingParams()
|
public function provideOutputMappingParams()
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user