minor #35586 Fix CS (fabpot)

This PR was merged into the 4.4 branch.

Discussion
----------

Fix CS

| Q             | A
| ------------- | ---
| Branch?       | 4.4 <!-- see below -->
| Bug fix?      | no
| New feature?  | no <!-- please update src/**/CHANGELOG.md files -->
| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tickets       | <!-- prefix each issue number with "Fix #", if any -->
| License       | MIT
| Doc PR        |  n/a

Commits
-------

de8348a033 Fix CS
This commit is contained in:
Fabien Potencier 2020-02-04 10:33:59 +01:00
commit 03181ee843
66 changed files with 177 additions and 171 deletions

View File

@ -29,7 +29,7 @@ class Logger extends BaseLogger implements DebugLoggerInterface, ResetInterface
*/
public function getLogs(/* Request $request = null */)
{
if (\func_num_args() < 1 && __CLASS__ !== \get_class($this) && __CLASS__ !== (new \ReflectionMethod($this, __FUNCTION__))->getDeclaringClass()->getName() && !$this instanceof \PHPUnit\Framework\MockObject\MockObject && !$this instanceof \Prophecy\Prophecy\ProphecySubjectInterface) {
if (\func_num_args() < 1 && __CLASS__ !== static::class && __CLASS__ !== (new \ReflectionMethod($this, __FUNCTION__))->getDeclaringClass()->getName() && !$this instanceof \PHPUnit\Framework\MockObject\MockObject && !$this instanceof \Prophecy\Prophecy\ProphecySubjectInterface) {
@trigger_error(sprintf('The "%s()" method will have a new "Request $request = null" argument in version 5.0, not defining it is deprecated since Symfony 4.2.', __METHOD__), E_USER_DEPRECATED);
}
@ -47,7 +47,7 @@ class Logger extends BaseLogger implements DebugLoggerInterface, ResetInterface
*/
public function countErrors(/* Request $request = null */)
{
if (\func_num_args() < 1 && __CLASS__ !== \get_class($this) && __CLASS__ !== (new \ReflectionMethod($this, __FUNCTION__))->getDeclaringClass()->getName() && !$this instanceof \PHPUnit\Framework\MockObject\MockObject && !$this instanceof \Prophecy\Prophecy\ProphecySubjectInterface) {
if (\func_num_args() < 1 && __CLASS__ !== static::class && __CLASS__ !== (new \ReflectionMethod($this, __FUNCTION__))->getDeclaringClass()->getName() && !$this instanceof \PHPUnit\Framework\MockObject\MockObject && !$this instanceof \Prophecy\Prophecy\ProphecySubjectInterface) {
@trigger_error(sprintf('The "%s()" method will have a new "Request $request = null" argument in version 5.0, not defining it is deprecated since Symfony 4.2.', __METHOD__), E_USER_DEPRECATED);
}

View File

@ -63,7 +63,7 @@ class DebugProcessor implements DebugLoggerInterface, ResetInterface
*/
public function getLogs(/* Request $request = null */)
{
if (\func_num_args() < 1 && __CLASS__ !== \get_class($this) && __CLASS__ !== (new \ReflectionMethod($this, __FUNCTION__))->getDeclaringClass()->getName() && !$this instanceof \PHPUnit\Framework\MockObject\MockObject && !$this instanceof \Prophecy\Prophecy\ProphecySubjectInterface) {
if (\func_num_args() < 1 && __CLASS__ !== static::class && __CLASS__ !== (new \ReflectionMethod($this, __FUNCTION__))->getDeclaringClass()->getName() && !$this instanceof \PHPUnit\Framework\MockObject\MockObject && !$this instanceof \Prophecy\Prophecy\ProphecySubjectInterface) {
@trigger_error(sprintf('The "%s()" method will have a new "Request $request = null" argument in version 5.0, not defining it is deprecated since Symfony 4.2.', __METHOD__), E_USER_DEPRECATED);
}
@ -85,7 +85,7 @@ class DebugProcessor implements DebugLoggerInterface, ResetInterface
*/
public function countErrors(/* Request $request = null */)
{
if (\func_num_args() < 1 && __CLASS__ !== \get_class($this) && __CLASS__ !== (new \ReflectionMethod($this, __FUNCTION__))->getDeclaringClass()->getName() && !$this instanceof \PHPUnit\Framework\MockObject\MockObject && !$this instanceof \Prophecy\Prophecy\ProphecySubjectInterface) {
if (\func_num_args() < 1 && __CLASS__ !== static::class && __CLASS__ !== (new \ReflectionMethod($this, __FUNCTION__))->getDeclaringClass()->getName() && !$this instanceof \PHPUnit\Framework\MockObject\MockObject && !$this instanceof \Prophecy\Prophecy\ProphecySubjectInterface) {
@trigger_error(sprintf('The "%s()" method will have a new "Request $request = null" argument in version 5.0, not defining it is deprecated since Symfony 4.2.', __METHOD__), E_USER_DEPRECATED);
}

View File

@ -18,15 +18,15 @@ class DnsMockTest extends TestCase
{
protected function tearDown(): void
{
DnsMock::withMockedHosts(array());
DnsMock::withMockedHosts([]);
}
public function testCheckdnsrr()
{
DnsMock::withMockedHosts(array('example.com' => array(array('type' => 'MX'))));
DnsMock::withMockedHosts(['example.com' => [['type' => 'MX']]]);
$this->assertTrue(DnsMock::checkdnsrr('example.com'));
DnsMock::withMockedHosts(array('example.com' => array(array('type' => 'A'))));
DnsMock::withMockedHosts(['example.com' => [['type' => 'A']]]);
$this->assertFalse(DnsMock::checkdnsrr('example.com'));
$this->assertTrue(DnsMock::checkdnsrr('example.com', 'a'));
$this->assertTrue(DnsMock::checkdnsrr('example.com', 'any'));
@ -35,34 +35,34 @@ class DnsMockTest extends TestCase
public function testGetmxrr()
{
DnsMock::withMockedHosts(array(
'example.com' => array(array(
DnsMock::withMockedHosts([
'example.com' => [[
'type' => 'MX',
'host' => 'mx.example.com',
'pri' => 10,
)),
));
]],
]);
$this->assertFalse(DnsMock::getmxrr('foobar.com', $mxhosts, $weight));
$this->assertTrue(DnsMock::getmxrr('example.com', $mxhosts, $weight));
$this->assertSame(array('mx.example.com'), $mxhosts);
$this->assertSame(array(10), $weight);
$this->assertSame(['mx.example.com'], $mxhosts);
$this->assertSame([10], $weight);
}
public function testGethostbyaddr()
{
DnsMock::withMockedHosts(array(
'example.com' => array(
array(
DnsMock::withMockedHosts([
'example.com' => [
[
'type' => 'A',
'ip' => '1.2.3.4',
),
array(
],
[
'type' => 'AAAA',
'ipv6' => '::12',
),
),
));
],
],
]);
$this->assertSame('::21', DnsMock::gethostbyaddr('::21'));
$this->assertSame('example.com', DnsMock::gethostbyaddr('::12'));
@ -71,18 +71,18 @@ class DnsMockTest extends TestCase
public function testGethostbyname()
{
DnsMock::withMockedHosts(array(
'example.com' => array(
array(
DnsMock::withMockedHosts([
'example.com' => [
[
'type' => 'AAAA',
'ipv6' => '::12',
),
array(
],
[
'type' => 'A',
'ip' => '1.2.3.4',
),
),
));
],
],
]);
$this->assertSame('foobar.com', DnsMock::gethostbyname('foobar.com'));
$this->assertSame('1.2.3.4', DnsMock::gethostbyname('example.com'));
@ -90,59 +90,59 @@ class DnsMockTest extends TestCase
public function testGethostbynamel()
{
DnsMock::withMockedHosts(array(
'example.com' => array(
array(
DnsMock::withMockedHosts([
'example.com' => [
[
'type' => 'A',
'ip' => '1.2.3.4',
),
array(
],
[
'type' => 'A',
'ip' => '2.3.4.5',
),
),
));
],
],
]);
$this->assertFalse(DnsMock::gethostbynamel('foobar.com'));
$this->assertSame(array('1.2.3.4', '2.3.4.5'), DnsMock::gethostbynamel('example.com'));
$this->assertSame(['1.2.3.4', '2.3.4.5'], DnsMock::gethostbynamel('example.com'));
}
public function testDnsGetRecord()
{
DnsMock::withMockedHosts(array(
'example.com' => array(
array(
DnsMock::withMockedHosts([
'example.com' => [
[
'type' => 'A',
'ip' => '1.2.3.4',
),
array(
],
[
'type' => 'PTR',
'ip' => '2.3.4.5',
),
),
));
],
],
]);
$records = array(
array(
$records = [
[
'host' => 'example.com',
'class' => 'IN',
'ttl' => 1,
'type' => 'A',
'ip' => '1.2.3.4',
),
$ptr = array(
],
$ptr = [
'host' => 'example.com',
'class' => 'IN',
'ttl' => 1,
'type' => 'PTR',
'ip' => '2.3.4.5',
),
);
],
];
$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', DNS_ALL));
$this->assertSame($records, DnsMock::dns_get_record('example.com', DNS_A | DNS_PTR));
$this->assertSame(array($ptr), DnsMock::dns_get_record('example.com', DNS_PTR));
$this->assertSame([$ptr], DnsMock::dns_get_record('example.com', DNS_PTR));
}
}

View File

@ -15,7 +15,7 @@
error_reporting(-1);
global $argv, $argc;
$argv = isset($_SERVER['argv']) ? $_SERVER['argv'] : array();
$argv = isset($_SERVER['argv']) ? $_SERVER['argv'] : [];
$argc = isset($_SERVER['argc']) ? $_SERVER['argc'] : 0;
$getEnvVar = function ($name, $default = false) use ($argv) {
if (false !== $value = getenv($name)) {
@ -130,11 +130,11 @@ if ('phpdbg' === PHP_SAPI) {
$PHP .= ' -qrr';
}
$defaultEnvs = array(
$defaultEnvs = [
'COMPOSER' => 'composer.json',
'COMPOSER_VENDOR_DIR' => 'vendor',
'COMPOSER_BIN_DIR' => 'bin',
);
];
foreach ($defaultEnvs as $envName => $envValue) {
if ($envValue !== getenv($envName)) {
@ -147,21 +147,21 @@ $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`) : `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_get_contents($COMPOSER, false, null, 0, 18) === '#!/usr/bin/env php' ? $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';
$SYMFONY_PHPUNIT_REMOVE = $getEnvVar('SYMFONY_PHPUNIT_REMOVE', 'phpspec/prophecy'.($PHPUNIT_VERSION < 6.0 ? ' symfony/yaml': ''));
$configurationHash = md5(implode(PHP_EOL, array(md5_file(__FILE__), $SYMFONY_PHPUNIT_REMOVE, (int) $PHPUNIT_REMOVE_RETURN_TYPEHINT)));
$PHPUNIT_VERSION_DIR=sprintf('phpunit-%s-%d', $PHPUNIT_VERSION, $PHPUNIT_REMOVE_RETURN_TYPEHINT);
$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]));
$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")) {
// Build a standalone phpunit without symfony/yaml nor prophecy by default
@mkdir($PHPUNIT_DIR, 0777, true);
chdir($PHPUNIT_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");
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"));
}
$passthruOrFail("$COMPOSER create-project --no-install --prefer-dist --no-scripts --no-plugins --no-progress --ansi phpunit/phpunit $PHPUNIT_VERSION_DIR \"$PHPUNIT_VERSION.*\"");
@copy("$PHPUNIT_VERSION_DIR/phpunit.xsd", 'phpunit.xsd');
@ -187,7 +187,7 @@ if (!file_exists("$PHPUNIT_DIR/$PHPUNIT_VERSION_DIR/phpunit") || $configurationH
putenv("COMPOSER_ROOT_VERSION=$PHPUNIT_VERSION.99");
$q = '\\' === DIRECTORY_SEPARATOR ? '"' : '';
// --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 --ansi$q", array(), $p, getcwd()));
$exit = proc_close(proc_open("$q$COMPOSER install --no-dev --prefer-dist --no-progress --ansi$q", [], $p, getcwd()));
putenv('COMPOSER_ROOT_VERSION'.(false !== $prevRoot ? '='.$prevRoot : ''));
if ($exit) {
exit($exit);
@ -233,13 +233,20 @@ EOPHP
}
if ($PHPUNIT_VERSION < 8.0) {
$argv = array_filter($argv, function ($v) use (&$argc) { if ('--do-not-cache-result' !== $v) return true; --$argc; return false; });
$argv = array_filter($argv, function ($v) use (&$argc) {
if ('--do-not-cache-result' !== $v) {
return true;
}
--$argc;
return false;
});
} elseif (filter_var(getenv('SYMFONY_PHPUNIT_DISABLE_RESULT_CACHE'), FILTER_VALIDATE_BOOLEAN)) {
$argv[] = '--do-not-cache-result';
++$argc;
}
$components = array();
$components = [];
$cmd = array_map('escapeshellarg', $argv);
$exit = 0;
@ -274,7 +281,7 @@ if ('\\' === DIRECTORY_SEPARATOR) {
if ($components) {
$skippedTests = isset($_SERVER['SYMFONY_PHPUNIT_SKIPPED_TESTS']) ? $_SERVER['SYMFONY_PHPUNIT_SKIPPED_TESTS'] : false;
$runningProcs = array();
$runningProcs = [];
foreach ($components as $component) {
// Run phpunit tests in parallel
@ -285,7 +292,7 @@ if ($components) {
$c = escapeshellarg($component);
if ($proc = proc_open(sprintf($cmd, $c, " > $c/phpunit.stdout 2> $c/phpunit.stderr"), array(), $pipes)) {
if ($proc = proc_open(sprintf($cmd, $c, " > $c/phpunit.stdout 2> $c/phpunit.stderr"), [], $pipes)) {
$runningProcs[$component] = $proc;
} else {
$exit = 1;
@ -295,7 +302,7 @@ if ($components) {
while ($runningProcs) {
usleep(300000);
$terminatedProcs = array();
$terminatedProcs = [];
foreach ($runningProcs as $component => $proc) {
$procStatus = proc_get_status($proc);
if (!$procStatus['running']) {
@ -306,7 +313,7 @@ if ($components) {
}
foreach ($terminatedProcs as $component => $procStatus) {
foreach (array('out', 'err') as $file) {
foreach (['out', 'err'] as $file) {
$file = "$component/phpunit.std$file";
readfile($file);
unlink($file);
@ -316,7 +323,7 @@ if ($components) {
// STATUS_STACK_BUFFER_OVERRUN (-1073740791/0xC0000409)
// STATUS_ACCESS_VIOLATION (-1073741819/0xC0000005)
// 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, array(-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;
echo "\033[41mKO\033[0m $component\n\n";
} else {
@ -326,9 +333,11 @@ if ($components) {
}
} elseif (!isset($argv[1]) || 'install' !== $argv[1] || file_exists('install')) {
if (!class_exists('SymfonyBlacklistSimplePhpunit', false)) {
class SymfonyBlacklistSimplePhpunit {}
class SymfonyBlacklistSimplePhpunit
{
}
}
array_splice($argv, 1, 0, array('--colors=always'));
array_splice($argv, 1, 0, ['--colors=always']);
$_SERVER['argv'] = $argv;
$_SERVER['argc'] = ++$argc;
include "$PHPUNIT_DIR/$PHPUNIT_VERSION_DIR/phpunit";

View File

@ -49,7 +49,7 @@ class RouterCacheWarmer implements CacheWarmerInterface, ServiceSubscriberInterf
return;
}
@trigger_error(sprintf('Passing a %s without implementing %s is deprecated since Symfony 4.1.', RouterInterface::class, WarmableInterface::class), \E_USER_DEPRECATED);
@trigger_error(sprintf('Passing a %s without implementing %s is deprecated since Symfony 4.1.', RouterInterface::class, WarmableInterface::class), E_USER_DEPRECATED);
}
/**

View File

@ -65,7 +65,7 @@ abstract class AbstractController implements ServiceSubscriberInterface
protected function getParameter(string $name)
{
if (!$this->container->has('parameter_bag')) {
throw new ServiceNotFoundException('parameter_bag', null, null, [], sprintf('The "%s::getParameter()" method is missing a parameter bag to work properly. Did you forget to register your controller as a service subscriber? This can be fixed either by using autoconfiguration or by manually wiring a "parameter_bag" in the service locator passed to the controller.', \get_class($this)));
throw new ServiceNotFoundException('parameter_bag', null, null, [], sprintf('The "%s::getParameter()" method is missing a parameter bag to work properly. Did you forget to register your controller as a service subscriber? This can be fixed either by using autoconfiguration or by manually wiring a "parameter_bag" in the service locator passed to the controller.', static::class));
}
return $this->container->get('parameter_bag')->get($name);

View File

@ -49,7 +49,7 @@ class ResolveControllerNameSubscriber implements EventSubscriberInterface
public function __call(string $method, array $args)
{
if ('onKernelRequest' !== $method && 'onKernelRequest' !== strtolower($method)) {
throw new \Error(sprintf('Error: Call to undefined method %s::%s()', \get_class($this), $method));
throw new \Error(sprintf('Error: Call to undefined method %s::%s()', static::class, $method));
}
$event = $args[0];

View File

@ -432,7 +432,7 @@ abstract class CompleteConfigurationTest extends TestCase
],
'JMS\FooBundle\Entity\User7' => [
'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());
}
@ -547,7 +547,7 @@ abstract class CompleteConfigurationTest extends TestCase
],
'JMS\FooBundle\Entity\User7' => [
'class' => NativePasswordEncoder::class,
'arguments' => [null, null, 15, \PASSWORD_BCRYPT],
'arguments' => [null, null, 15, PASSWORD_BCRYPT],
],
]], $container->getDefinition('security.encoder_factory.generic')->getArguments());
}

View File

@ -199,7 +199,7 @@ abstract class Client
public function getCrawler()
{
if (null === $this->crawler) {
@trigger_error(sprintf('Calling the "%s()" method before the "request()" one is deprecated since Symfony 4.1 and will throw an exception in 5.0.', \get_class($this).'::'.__FUNCTION__), E_USER_DEPRECATED);
@trigger_error(sprintf('Calling the "%s()" method before the "request()" one is deprecated since Symfony 4.1 and will throw an exception in 5.0.', static::class.'::'.__FUNCTION__), E_USER_DEPRECATED);
// throw new BadMethodCallException(sprintf('The "request()" method must be called before "%s()".', __METHOD__));
}
@ -214,7 +214,7 @@ abstract class Client
public function getInternalResponse()
{
if (null === $this->internalResponse) {
@trigger_error(sprintf('Calling the "%s()" method before the "request()" one is deprecated since Symfony 4.1 and will throw an exception in 5.0.', \get_class($this).'::'.__FUNCTION__), E_USER_DEPRECATED);
@trigger_error(sprintf('Calling the "%s()" method before the "request()" one is deprecated since Symfony 4.1 and will throw an exception in 5.0.', static::class.'::'.__FUNCTION__), E_USER_DEPRECATED);
// throw new BadMethodCallException(sprintf('The "request()" method must be called before "%s()".', __METHOD__));
}
@ -234,7 +234,7 @@ abstract class Client
public function getResponse()
{
if (null === $this->response) {
@trigger_error(sprintf('Calling the "%s()" method before the "request()" one is deprecated since Symfony 4.1 and will throw an exception in 5.0.', \get_class($this).'::'.__FUNCTION__), E_USER_DEPRECATED);
@trigger_error(sprintf('Calling the "%s()" method before the "request()" one is deprecated since Symfony 4.1 and will throw an exception in 5.0.', static::class.'::'.__FUNCTION__), E_USER_DEPRECATED);
// throw new BadMethodCallException(sprintf('The "request()" method must be called before "%s()".', __METHOD__));
}
@ -249,7 +249,7 @@ abstract class Client
public function getInternalRequest()
{
if (null === $this->internalRequest) {
@trigger_error(sprintf('Calling the "%s()" method before the "request()" one is deprecated since Symfony 4.1 and will throw an exception in 5.0.', \get_class($this).'::'.__FUNCTION__), E_USER_DEPRECATED);
@trigger_error(sprintf('Calling the "%s()" method before the "request()" one is deprecated since Symfony 4.1 and will throw an exception in 5.0.', static::class.'::'.__FUNCTION__), E_USER_DEPRECATED);
// throw new BadMethodCallException(sprintf('The "request()" method must be called before "%s()".', __METHOD__));
}
@ -269,7 +269,7 @@ abstract class Client
public function getRequest()
{
if (null === $this->request) {
@trigger_error(sprintf('Calling the "%s()" method before the "request()" one is deprecated since Symfony 4.1 and will throw an exception in 5.0.', \get_class($this).'::'.__FUNCTION__), E_USER_DEPRECATED);
@trigger_error(sprintf('Calling the "%s()" method before the "request()" one is deprecated since Symfony 4.1 and will throw an exception in 5.0.', static::class.'::'.__FUNCTION__), E_USER_DEPRECATED);
// throw new BadMethodCallException(sprintf('The "request()" method must be called before "%s()".', __METHOD__));
}
@ -314,8 +314,8 @@ abstract class Client
*/
public function submit(Form $form, array $values = []/*, array $serverParameters = []*/)
{
if (\func_num_args() < 3 && __CLASS__ !== \get_class($this) && __CLASS__ !== (new \ReflectionMethod($this, __FUNCTION__))->getDeclaringClass()->getName() && !$this instanceof \PHPUnit\Framework\MockObject\MockObject && !$this instanceof \Prophecy\Prophecy\ProphecySubjectInterface) {
@trigger_error(sprintf('The "%s()" method will have a new "array $serverParameters = []" argument in version 5.0, not defining it is deprecated since Symfony 4.2.', \get_class($this).'::'.__FUNCTION__), E_USER_DEPRECATED);
if (\func_num_args() < 3 && __CLASS__ !== static::class && __CLASS__ !== (new \ReflectionMethod($this, __FUNCTION__))->getDeclaringClass()->getName() && !$this instanceof \PHPUnit\Framework\MockObject\MockObject && !$this instanceof \Prophecy\Prophecy\ProphecySubjectInterface) {
@trigger_error(sprintf('The "%s()" method will have a new "array $serverParameters = []" argument in version 5.0, not defining it is deprecated since Symfony 4.2.', static::class.'::'.__FUNCTION__), E_USER_DEPRECATED);
}
$form->setValues($values);

View File

@ -80,7 +80,7 @@ class RedisTagAwareAdapter extends AbstractTagAwareAdapter
foreach (\is_array($compression) ? $compression : [$compression] as $c) {
if (\Redis::COMPRESSION_NONE !== $c) {
throw new InvalidArgumentException(sprintf('phpredis compression must be disabled when using "%s", use "%s" instead.', \get_class($this), DeflateMarshaller::class));
throw new InvalidArgumentException(sprintf('phpredis compression must be disabled when using "%s", use "%s" instead.', static::class, DeflateMarshaller::class));
}
}
}

View File

@ -52,7 +52,7 @@ trait ContractsTrait
private function doGet(AdapterInterface $pool, string $key, callable $callback, ?float $beta, array &$metadata = null)
{
if (0 > $beta = $beta ?? 1.0) {
throw new InvalidArgumentException(sprintf('Argument "$beta" provided to "%s::get()" must be a positive number, %f given.', \get_class($this), $beta));
throw new InvalidArgumentException(sprintf('Argument "$beta" provided to "%s::get()" must be a positive number, %f given.', static::class, $beta));
}
static $setMetadata;

View File

@ -403,7 +403,7 @@ trait PdoTrait
} else {
switch ($this->driver = $this->conn->getDriver()->getName()) {
case 'mysqli':
throw new \LogicException(sprintf('The adapter "%s" does not support the mysqli driver, use pdo_mysql instead.', \get_class($this)));
throw new \LogicException(sprintf('The adapter "%s" does not support the mysqli driver, use pdo_mysql instead.', static::class));
case 'pdo_mysql':
case 'drizzle_pdo_mysql':
$this->driver = 'mysql';

View File

@ -524,7 +524,7 @@ abstract class BaseNode implements NodeInterface
private function doValidateType($value): void
{
if (null !== $this->handlingPlaceholder && !$this->allowPlaceholders()) {
$e = new InvalidTypeException(sprintf('A dynamic value is not compatible with a "%s" node type at path "%s".', \get_class($this), $this->getPath()));
$e = new InvalidTypeException(sprintf('A dynamic value is not compatible with a "%s" node type at path "%s".', static::class, $this->getPath()));
$e->setPath($this->getPath());
throw $e;

View File

@ -362,7 +362,7 @@ abstract class NodeDefinition implements NodeParentInterface
$child->setPathSeparator($separator);
}
} else {
@trigger_error(sprintf('Not implementing the "%s::getChildNodeDefinitions()" method in "%s" is deprecated since Symfony 4.1.', ParentNodeDefinitionInterface::class, \get_class($this)), E_USER_DEPRECATED);
@trigger_error(sprintf('Not implementing the "%s::getChildNodeDefinitions()" method in "%s" is deprecated since Symfony 4.1.', ParentNodeDefinitionInterface::class, static::class), E_USER_DEPRECATED);
}
}

View File

@ -73,7 +73,7 @@ abstract class FileLoader extends Loader
*/
public function import($resource, $type = null, $ignoreErrors = false, $sourceResource = null/*, $exclude = null*/)
{
if (\func_num_args() < 5 && __CLASS__ !== \get_class($this) && 0 !== strpos(\get_class($this), 'Symfony\Component\\') && __CLASS__ !== (new \ReflectionMethod($this, __FUNCTION__))->getDeclaringClass()->getName() && !$this instanceof \PHPUnit\Framework\MockObject\MockObject && !$this instanceof \Prophecy\Prophecy\ProphecySubjectInterface) {
if (\func_num_args() < 5 && __CLASS__ !== static::class && 0 !== strpos(static::class, 'Symfony\Component\\') && __CLASS__ !== (new \ReflectionMethod($this, __FUNCTION__))->getDeclaringClass()->getName() && !$this instanceof \PHPUnit\Framework\MockObject\MockObject && !$this instanceof \Prophecy\Prophecy\ProphecySubjectInterface) {
@trigger_error(sprintf('The "%s()" method will have a new "$exclude = null" argument in version 5.0, not defining it is deprecated since Symfony 4.4.', __METHOD__), E_USER_DEPRECATED);
}
$exclude = \func_num_args() >= 5 ? func_get_arg(4) : null;

View File

@ -805,7 +805,7 @@ class Application implements ResetInterface
public function renderThrowable(\Throwable $e, OutputInterface $output): void
{
if (__CLASS__ !== \get_class($this) && __CLASS__ === (new \ReflectionMethod($this, 'renderThrowable'))->getDeclaringClass()->getName() && __CLASS__ !== (new \ReflectionMethod($this, 'renderException'))->getDeclaringClass()->getName()) {
if (__CLASS__ !== static::class && __CLASS__ === (new \ReflectionMethod($this, 'renderThrowable'))->getDeclaringClass()->getName() && __CLASS__ !== (new \ReflectionMethod($this, 'renderException'))->getDeclaringClass()->getName()) {
@trigger_error(sprintf('The "%s::renderException()" method is deprecated since Symfony 4.4, use "renderThrowable()" instead.', __CLASS__), E_USER_DEPRECATED);
if (!$e instanceof \Exception) {
@ -844,7 +844,7 @@ class Application implements ResetInterface
protected function doRenderThrowable(\Throwable $e, OutputInterface $output): void
{
if (__CLASS__ !== \get_class($this) && __CLASS__ === (new \ReflectionMethod($this, 'doRenderThrowable'))->getDeclaringClass()->getName() && __CLASS__ !== (new \ReflectionMethod($this, 'doRenderException'))->getDeclaringClass()->getName()) {
if (__CLASS__ !== static::class && __CLASS__ === (new \ReflectionMethod($this, 'doRenderThrowable'))->getDeclaringClass()->getName() && __CLASS__ !== (new \ReflectionMethod($this, 'doRenderException'))->getDeclaringClass()->getName()) {
@trigger_error(sprintf('The "%s::doRenderException()" method is deprecated since Symfony 4.4, use "doRenderThrowable()" instead.', __CLASS__), E_USER_DEPRECATED);
if (!$e instanceof \Exception) {

View File

@ -255,7 +255,7 @@ class Command
$statusCode = $this->execute($input, $output);
if (!\is_int($statusCode)) {
@trigger_error(sprintf('Return value of "%s::execute()" should always be of the type int since Symfony 4.4, %s returned.', \get_class($this), \gettype($statusCode)), E_USER_DEPRECATED);
@trigger_error(sprintf('Return value of "%s::execute()" should always be of the type int since Symfony 4.4, %s returned.', static::class, \gettype($statusCode)), E_USER_DEPRECATED);
}
}

View File

@ -897,8 +897,7 @@ class ApplicationTest extends TestCase
$application = new Application();
$application->setAutoExit(false);
$application->register('foo')->setCode(function () {
throw new class('') extends \InvalidArgumentException {
};
throw new class('') extends \InvalidArgumentException { };
});
$tester = new ApplicationTester($application);
@ -908,8 +907,7 @@ class ApplicationTest extends TestCase
$application = new Application();
$application->setAutoExit(false);
$application->register('foo')->setCode(function () {
throw new \InvalidArgumentException(sprintf('Dummy type "%s" is invalid.', \get_class(new class() {
})));
throw new \InvalidArgumentException(sprintf('Dummy type "%s" is invalid.', \get_class(new class() { })));
});
$tester = new ApplicationTester($application);
@ -922,8 +920,7 @@ class ApplicationTest extends TestCase
$application = new Application();
$application->setAutoExit(false);
$application->register('foo')->setCode(function () {
throw new class('') extends \InvalidArgumentException {
};
throw new class('') extends \InvalidArgumentException { };
});
$tester = new ApplicationTester($application);
@ -933,8 +930,7 @@ class ApplicationTest extends TestCase
$application = new Application();
$application->setAutoExit(false);
$application->register('foo')->setCode(function () {
throw new \InvalidArgumentException(sprintf('Dummy type "%s" is invalid.', \get_class(new class() {
})));
throw new \InvalidArgumentException(sprintf('Dummy type "%s" is invalid.', \get_class(new class() { })));
});
$tester = new ApplicationTester($application);

View File

@ -214,7 +214,7 @@ abstract class AbstractRecursivePass implements CompilerPassInterface
$arg = $this->processValue(new Reference($id));
$this->inExpression = false;
if (!$arg instanceof Reference) {
throw new RuntimeException(sprintf('"%s::processValue()" must return a Reference when processing an expression, %s returned for service("%s").', \get_class($this), \is_object($arg) ? \get_class($arg) : \gettype($arg), $id));
throw new RuntimeException(sprintf('"%s::processValue()" must return a Reference when processing an expression, %s returned for service("%s").', static::class, \is_object($arg) ? \get_class($arg) : \gettype($arg), $id));
}
$arg = sprintf('"%s"', $arg);
}

View File

@ -58,7 +58,7 @@ abstract class FileLoader extends BaseFileLoader
if ($ignoreNotFound = 'not_found' === $ignoreErrors) {
$args[2] = false;
} elseif (!\is_bool($ignoreErrors)) {
@trigger_error(sprintf('Invalid argument $ignoreErrors provided to %s::import(): boolean or "not_found" expected, %s given.', \get_class($this), \gettype($ignoreErrors)), E_USER_DEPRECATED);
@trigger_error(sprintf('Invalid argument $ignoreErrors provided to %s::import(): boolean or "not_found" expected, %s given.', static::class, \gettype($ignoreErrors)), E_USER_DEPRECATED);
$args[2] = (bool) $ignoreErrors;
}

View File

@ -533,7 +533,7 @@ class Crawler implements \Countable, \IteratorAggregate
*/
public function children(/* string $selector = null */)
{
if (\func_num_args() < 1 && __CLASS__ !== \get_class($this) && __CLASS__ !== (new \ReflectionMethod($this, __FUNCTION__))->getDeclaringClass()->getName() && !$this instanceof \PHPUnit\Framework\MockObject\MockObject && !$this instanceof \Prophecy\Prophecy\ProphecySubjectInterface) {
if (\func_num_args() < 1 && __CLASS__ !== static::class && __CLASS__ !== (new \ReflectionMethod($this, __FUNCTION__))->getDeclaringClass()->getName() && !$this instanceof \PHPUnit\Framework\MockObject\MockObject && !$this instanceof \Prophecy\Prophecy\ProphecySubjectInterface) {
@trigger_error(sprintf('The "%s()" method will have a new "string $selector = null" argument in version 5.0, not defining it is deprecated since Symfony 4.2.', __METHOD__), E_USER_DEPRECATED);
}
$selector = 0 < \func_num_args() ? func_get_arg(0) : null;

View File

@ -38,7 +38,7 @@ class EventDispatcher implements EventDispatcherInterface
public function __construct()
{
if (__CLASS__ === \get_class($this)) {
if (__CLASS__ === static::class) {
$this->optimized = [];
}
}

View File

@ -440,7 +440,7 @@ class Finder implements \IteratorAggregate, \Countable
*/
public function sortByName(/* bool $useNaturalSort = false */)
{
if (\func_num_args() < 1 && __CLASS__ !== \get_class($this) && __CLASS__ !== (new \ReflectionMethod($this, __FUNCTION__))->getDeclaringClass()->getName() && !$this instanceof \PHPUnit\Framework\MockObject\MockObject && !$this instanceof \Prophecy\Prophecy\ProphecySubjectInterface) {
if (\func_num_args() < 1 && __CLASS__ !== static::class && __CLASS__ !== (new \ReflectionMethod($this, __FUNCTION__))->getDeclaringClass()->getName() && !$this instanceof \PHPUnit\Framework\MockObject\MockObject && !$this instanceof \Prophecy\Prophecy\ProphecySubjectInterface) {
@trigger_error(sprintf('The "%s()" method will have a new "bool $useNaturalSort = false" argument in version 5.0, not defining it is deprecated since Symfony 4.2.', __METHOD__), E_USER_DEPRECATED);
}
$useNaturalSort = 0 < \func_num_args() && func_get_arg(0);

View File

@ -58,7 +58,7 @@ abstract class AbstractTypeExtension implements FormTypeExtensionInterface
throw new LogicException(sprintf('You need to implement the static getExtendedTypes() method when implementing the %s in %s.', FormTypeExtensionInterface::class, static::class));
}
@trigger_error(sprintf('The %s::getExtendedType() method is deprecated since Symfony 4.2 and will be removed in 5.0. Use getExtendedTypes() instead.', \get_class($this)), E_USER_DEPRECATED);
@trigger_error(sprintf('The %s::getExtendedType() method is deprecated since Symfony 4.2 and will be removed in 5.0. Use getExtendedTypes() instead.', static::class), E_USER_DEPRECATED);
foreach (static::getExtendedTypes() as $extendedType) {
return $extendedType;

View File

@ -120,7 +120,7 @@ abstract class AbstractLayoutTest extends FormIntegrationTestCase
protected function renderHelp(FormView $view)
{
$this->markTestSkipped(sprintf('%s::renderHelp() is not implemented.', \get_class($this)));
$this->markTestSkipped(sprintf('%s::renderHelp() is not implemented.', static::class));
}
abstract protected function renderErrors(FormView $view);

View File

@ -341,7 +341,7 @@ trait HttpClientTrait
$flags = $flags ?? (JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_AMP | JSON_HEX_QUOT | JSON_PRESERVE_ZERO_FRACTION);
try {
$value = json_encode($value, $flags | (\PHP_VERSION_ID >= 70300 ? \JSON_THROW_ON_ERROR : 0), $maxDepth);
$value = json_encode($value, $flags | (\PHP_VERSION_ID >= 70300 ? JSON_THROW_ON_ERROR : 0), $maxDepth);
} catch (\JsonException $e) {
throw new InvalidArgumentException(sprintf('Invalid value for "json" option: %s.', $e->getMessage()));
}

View File

@ -262,7 +262,7 @@ final class CurlResponse implements ResponseInterface
$id = (int) $ch = $info['handle'];
$waitFor = @curl_getinfo($ch, CURLINFO_PRIVATE) ?: '_0';
if (\in_array($result, [\CURLE_SEND_ERROR, \CURLE_RECV_ERROR, /*CURLE_HTTP2*/ 16, /*CURLE_HTTP2_STREAM*/ 92], true) && $waitFor[1] && 'C' !== $waitFor[0]) {
if (\in_array($result, [CURLE_SEND_ERROR, CURLE_RECV_ERROR, /*CURLE_HTTP2*/ 16, /*CURLE_HTTP2_STREAM*/ 92], true) && $waitFor[1] && 'C' !== $waitFor[0]) {
curl_multi_remove_handle($multi->handle, $ch);
$waitFor[1] = (string) ((int) $waitFor[1] - 1); // decrement the retry counter
curl_setopt($ch, CURLOPT_PRIVATE, $waitFor);
@ -277,7 +277,7 @@ final class CurlResponse implements ResponseInterface
}
$multi->handlesActivity[$id][] = null;
$multi->handlesActivity[$id][] = \in_array($result, [\CURLE_OK, \CURLE_TOO_MANY_REDIRECTS], true) || '_0' === $waitFor || curl_getinfo($ch, CURLINFO_SIZE_DOWNLOAD) === curl_getinfo($ch, CURLINFO_CONTENT_LENGTH_DOWNLOAD) ? null : new TransportException(sprintf('%s for "%s".', curl_strerror($result), curl_getinfo($ch, CURLINFO_EFFECTIVE_URL)));
$multi->handlesActivity[$id][] = \in_array($result, [CURLE_OK, CURLE_TOO_MANY_REDIRECTS], true) || '_0' === $waitFor || curl_getinfo($ch, CURLINFO_SIZE_DOWNLOAD) === curl_getinfo($ch, CURLINFO_CONTENT_LENGTH_DOWNLOAD) ? null : new TransportException(sprintf('%s for "%s".', curl_strerror($result), curl_getinfo($ch, CURLINFO_EFFECTIVE_URL)));
}
} finally {
self::$performing = false;

View File

@ -151,7 +151,7 @@ trait ResponseTrait
}
try {
$content = json_decode($content, true, 512, JSON_BIGINT_AS_STRING | (\PHP_VERSION_ID >= 70300 ? \JSON_THROW_ON_ERROR : 0));
$content = json_decode($content, true, 512, JSON_BIGINT_AS_STRING | (\PHP_VERSION_ID >= 70300 ? JSON_THROW_ON_ERROR : 0));
} catch (\JsonException $e) {
throw new JsonException($e->getMessage(), $e->getCode());
}

View File

@ -61,12 +61,12 @@ class PhpBridgeSessionStorageTest extends TestCase
{
$storage = $this->getStorage();
$this->assertNotSame(\PHP_SESSION_ACTIVE, session_status());
$this->assertNotSame(PHP_SESSION_ACTIVE, session_status());
$this->assertFalse($storage->isStarted());
session_start();
$this->assertTrue(isset($_SESSION));
$this->assertSame(\PHP_SESSION_ACTIVE, session_status());
$this->assertSame(PHP_SESSION_ACTIVE, session_status());
// PHP session might have started, but the storage driver has not, so false is correct here
$this->assertFalse($storage->isStarted());

View File

@ -228,7 +228,7 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl
public function getBundle($name)
{
if (!isset($this->bundles[$name])) {
$class = \get_class($this);
$class = static::class;
$class = 'c' === $class[0] && 0 === strpos($class, "class@anonymous\0") ? get_parent_class($class).'@anonymous' : $class;
throw new \InvalidArgumentException(sprintf('Bundle "%s" does not exist or it is not enabled. Maybe you forgot to add it in the registerBundles() method of your %s.php file?', $name, $class));
@ -473,7 +473,7 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl
*/
protected function getContainerClass()
{
$class = \get_class($this);
$class = static::class;
$class = 'c' === $class[0] && 0 === strpos($class, "class@anonymous\0") ? get_parent_class($class).str_replace('.', '_', ContainerBuilder::hash($class)) : $class;
$class = $this->name.str_replace('\\', '_', $class).ucfirst($this->environment).($this->debug ? 'Debug' : '').'Container';
@ -510,7 +510,7 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl
$cachePath = $cache->getPath();
// Silence E_WARNING to ignore "include" failures - don't use "@" to prevent silencing fatal errors
$errorLevel = error_reporting(\E_ALL ^ \E_WARNING);
$errorLevel = error_reporting(E_ALL ^ E_WARNING);
try {
if (file_exists($cachePath) && \is_object($this->container = include $cachePath)

View File

@ -67,7 +67,7 @@ class LocaleDataGenerator extends AbstractDataGenerator
// Write parents locale file for the Translation component
file_put_contents(
__DIR__.'/../../../Translation/Resources/data/parents.json',
json_encode($this->localeParents, \JSON_PRETTY_PRINT).\PHP_EOL
json_encode($this->localeParents, JSON_PRETTY_PRINT).PHP_EOL
);
}

View File

@ -100,7 +100,7 @@ class CombinedStore implements StoreInterface, LoggerAwareInterface
public function waitAndSave(Key $key)
{
@trigger_error(sprintf('%s() is deprecated since Symfony 4.4 and will be removed in Symfony 5.0.', __METHOD__), E_USER_DEPRECATED);
throw new NotSupportedException(sprintf('The store "%s" does not support blocking locks.', \get_class($this)));
throw new NotSupportedException(sprintf('The store "%s" does not support blocking locks.', static::class));
}
/**

View File

@ -77,7 +77,7 @@ class MemcachedStore implements StoreInterface
public function waitAndSave(Key $key)
{
@trigger_error(sprintf('%s() is deprecated since Symfony 4.4 and will be removed in Symfony 5.0.', __METHOD__), E_USER_DEPRECATED);
throw new NotSupportedException(sprintf('The store "%s" does not support blocking locks.', \get_class($this)));
throw new NotSupportedException(sprintf('The store "%s" does not support blocking locks.', static::class));
}
/**

View File

@ -317,7 +317,7 @@ class PdoStore implements StoreInterface
} else {
switch ($this->driver = $con->getDriver()->getName()) {
case 'mysqli':
throw new NotSupportedException(sprintf('The store "%s" does not support the mysqli driver, use pdo_mysql instead.', \get_class($this)));
throw new NotSupportedException(sprintf('The store "%s" does not support the mysqli driver, use pdo_mysql instead.', static::class));
case 'pdo_mysql':
case 'drizzle_pdo_mysql':
$this->driver = 'mysql';

View File

@ -81,7 +81,7 @@ class RedisStore implements StoreInterface
public function waitAndSave(Key $key)
{
@trigger_error(sprintf('%s() is deprecated since Symfony 4.4 and will be removed in Symfony 5.0.', __METHOD__), E_USER_DEPRECATED);
throw new NotSupportedException(sprintf('The store "%s" does not support blocking locks.', \get_class($this)));
throw new NotSupportedException(sprintf('The store "%s" does not support blocking locks.', static::class));
}
/**

View File

@ -37,7 +37,7 @@ trait HandleTrait
private function handle($message)
{
if (!$this->messageBus instanceof MessageBusInterface) {
throw new LogicException(sprintf('You must provide a "%s" instance in the "%s::$messageBus" property, "%s" given.', MessageBusInterface::class, \get_class($this), \is_object($this->messageBus) ? \get_class($this->messageBus) : \gettype($this->messageBus)));
throw new LogicException(sprintf('You must provide a "%s" instance in the "%s::$messageBus" property, "%s" given.', MessageBusInterface::class, static::class, \is_object($this->messageBus) ? \get_class($this->messageBus) : \gettype($this->messageBus)));
}
$envelope = $this->messageBus->dispatch($message);
@ -45,7 +45,7 @@ trait HandleTrait
$handledStamps = $envelope->all(HandledStamp::class);
if (!$handledStamps) {
throw new LogicException(sprintf('Message of type "%s" was handled zero times. Exactly one handler is expected when using "%s::%s()".', \get_class($envelope->getMessage()), \get_class($this), __FUNCTION__));
throw new LogicException(sprintf('Message of type "%s" was handled zero times. Exactly one handler is expected when using "%s::%s()".', \get_class($envelope->getMessage()), static::class, __FUNCTION__));
}
if (\count($handledStamps) > 1) {
@ -53,7 +53,7 @@ trait HandleTrait
return sprintf('"%s"', $stamp->getHandlerName());
}, $handledStamps));
throw new LogicException(sprintf('Message of type "%s" was handled multiple times. Only one handler is expected when using "%s::%s()", got %d: %s.', \get_class($envelope->getMessage()), \get_class($this), __FUNCTION__, \count($handledStamps), $handlers));
throw new LogicException(sprintf('Message of type "%s" was handled multiple times. Only one handler is expected when using "%s::%s()", got %d: %s.', \get_class($envelope->getMessage()), static::class, __FUNCTION__, \count($handledStamps), $handlers));
}
return $handledStamps[0]->getResult();

View File

@ -24,7 +24,7 @@ final class Base64ContentEncoder extends Base64Encoder implements ContentEncoder
throw new \TypeError(sprintf('Method "%s" takes a stream as a first argument.', __METHOD__));
}
$filter = stream_filter_append($stream, 'convert.base64-encode', \STREAM_FILTER_READ, [
$filter = stream_filter_append($stream, 'convert.base64-encode', STREAM_FILTER_READ, [
'line-length' => 0 >= $maxLineLength || 76 < $maxLineLength ? 76 : $maxLineLength,
'line-break-chars' => "\r\n",
]);

View File

@ -89,7 +89,7 @@ class QpEncoder implements EncoderInterface
public function __construct()
{
$id = \get_class($this);
$id = static::class;
if (!isset(self::$safeMapShare[$id])) {
$this->initSafeMap();
self::$safeMapShare[$id] = $this->safeMap;

View File

@ -43,7 +43,7 @@ class Route
public function __construct(array $data)
{
if (isset($data['localized_paths'])) {
throw new \BadMethodCallException(sprintf('Unknown property "localized_paths" on annotation "%s".', \get_class($this)));
throw new \BadMethodCallException(sprintf('Unknown property "localized_paths" on annotation "%s".', static::class));
}
if (isset($data['value'])) {

View File

@ -57,7 +57,7 @@ abstract class ObjectLoader extends Loader
$loaderObject = $this->getObject($parts[0]);
if (!\is_object($loaderObject)) {
throw new \TypeError(sprintf('%s:getObject() must return an object: %s returned', \get_class($this), \gettype($loaderObject)));
throw new \TypeError(sprintf('%s:getObject() must return an object: %s returned', static::class, \gettype($loaderObject)));
}
if (!\is_callable([$loaderObject, $method])) {

View File

@ -38,9 +38,9 @@ class Argon2iPasswordEncoder extends BasePasswordEncoder implements SelfSaltingE
{
if (\defined('PASSWORD_ARGON2I')) {
$this->config = [
'memory_cost' => $memoryCost ?? \PASSWORD_ARGON2_DEFAULT_MEMORY_COST,
'time_cost' => $timeCost ?? \PASSWORD_ARGON2_DEFAULT_TIME_COST,
'threads' => $threads ?? \PASSWORD_ARGON2_DEFAULT_THREADS,
'memory_cost' => $memoryCost ?? PASSWORD_ARGON2_DEFAULT_MEMORY_COST,
'time_cost' => $timeCost ?? PASSWORD_ARGON2_DEFAULT_TIME_COST,
'threads' => $threads ?? PASSWORD_ARGON2_DEFAULT_THREADS,
];
}
}

View File

@ -33,8 +33,8 @@ final class NativePasswordEncoder implements PasswordEncoderInterface, SelfSalti
public function __construct(int $opsLimit = null, int $memLimit = null, int $cost = null, string $algo = null)
{
$cost = $cost ?? 13;
$opsLimit = $opsLimit ?? max(4, \defined('SODIUM_CRYPTO_PWHASH_OPSLIMIT_INTERACTIVE') ? \SODIUM_CRYPTO_PWHASH_OPSLIMIT_INTERACTIVE : 4);
$memLimit = $memLimit ?? max(64 * 1024 * 1024, \defined('SODIUM_CRYPTO_PWHASH_MEMLIMIT_INTERACTIVE') ? \SODIUM_CRYPTO_PWHASH_MEMLIMIT_INTERACTIVE : 64 * 1024 * 1024);
$opsLimit = $opsLimit ?? max(4, \defined('SODIUM_CRYPTO_PWHASH_OPSLIMIT_INTERACTIVE') ? SODIUM_CRYPTO_PWHASH_OPSLIMIT_INTERACTIVE : 4);
$memLimit = $memLimit ?? max(64 * 1024 * 1024, \defined('SODIUM_CRYPTO_PWHASH_MEMLIMIT_INTERACTIVE') ? SODIUM_CRYPTO_PWHASH_MEMLIMIT_INTERACTIVE : 64 * 1024 * 1024);
if (3 > $opsLimit) {
throw new \InvalidArgumentException('$opsLimit must be 3 or greater.');
@ -89,7 +89,7 @@ final class NativePasswordEncoder implements PasswordEncoderInterface, SelfSalti
return (72 >= \strlen($raw) || 0 !== strpos($encoded, '$2')) && password_verify($raw, $encoded);
}
if (\extension_loaded('sodium') && version_compare(\SODIUM_LIBRARY_VERSION, '1.0.14', '>=')) {
if (\extension_loaded('sodium') && version_compare(SODIUM_LIBRARY_VERSION, '1.0.14', '>=')) {
return sodium_crypto_pwhash_str_verify($encoded, $raw);
}

View File

@ -34,8 +34,8 @@ final class SodiumPasswordEncoder implements PasswordEncoderInterface, SelfSalti
throw new LogicException('Libsodium is not available. You should either install the sodium extension, upgrade to PHP 7.2+ or use a different encoder.');
}
$this->opsLimit = $opsLimit ?? max(4, \defined('SODIUM_CRYPTO_PWHASH_OPSLIMIT_INTERACTIVE') ? \SODIUM_CRYPTO_PWHASH_OPSLIMIT_INTERACTIVE : 4);
$this->memLimit = $memLimit ?? max(64 * 1024 * 1024, \defined('SODIUM_CRYPTO_PWHASH_MEMLIMIT_INTERACTIVE') ? \SODIUM_CRYPTO_PWHASH_MEMLIMIT_INTERACTIVE : 64 * 1024 * 2014);
$this->opsLimit = $opsLimit ?? max(4, \defined('SODIUM_CRYPTO_PWHASH_OPSLIMIT_INTERACTIVE') ? SODIUM_CRYPTO_PWHASH_OPSLIMIT_INTERACTIVE : 4);
$this->memLimit = $memLimit ?? max(64 * 1024 * 1024, \defined('SODIUM_CRYPTO_PWHASH_MEMLIMIT_INTERACTIVE') ? SODIUM_CRYPTO_PWHASH_MEMLIMIT_INTERACTIVE : 64 * 1024 * 2014);
if (3 > $this->opsLimit) {
throw new \InvalidArgumentException('$opsLimit must be 3 or greater.');
@ -48,7 +48,7 @@ final class SodiumPasswordEncoder implements PasswordEncoderInterface, SelfSalti
public static function isSupported(): bool
{
return version_compare(\extension_loaded('sodium') ? \SODIUM_LIBRARY_VERSION : phpversion('libsodium'), '1.0.14', '>=');
return version_compare(\extension_loaded('sodium') ? SODIUM_LIBRARY_VERSION : phpversion('libsodium'), '1.0.14', '>=');
}
/**

View File

@ -150,7 +150,7 @@ class EncoderFactoryTest extends TestCase
$this->assertInstanceOf(MigratingPasswordEncoder::class, $encoder);
$this->assertTrue($encoder->isPasswordValid((new SodiumPasswordEncoder())->encodePassword('foo', null), 'foo', null));
$this->assertTrue($encoder->isPasswordValid((new NativePasswordEncoder(null, null, null, \PASSWORD_BCRYPT))->encodePassword('foo', null), 'foo', null));
$this->assertTrue($encoder->isPasswordValid((new NativePasswordEncoder(null, null, null, PASSWORD_BCRYPT))->encodePassword('foo', null), 'foo', null));
$this->assertTrue($encoder->isPasswordValid($digest->encodePassword('foo', null), 'foo', null));
$this->assertStringStartsWith(SODIUM_CRYPTO_PWHASH_STRPREFIX, $encoder->encodePassword('foo', null));
}

View File

@ -352,8 +352,9 @@ class ContextListenerTest extends TestCase
$session->set('_security_session', $original);
}
$tokenStorage = new UsageTrackingTokenStorage(new TokenStorage(), new class([
'session' => function () use ($session) { return $session; }
$tokenStorage = new UsageTrackingTokenStorage(new TokenStorage(), new class(['session' => function () use ($session) {
return $session;
},
]) implements ContainerInterface {
use ServiceLocatorTrait;
});
@ -404,8 +405,9 @@ class ContextListenerTest extends TestCase
if (method_exists(Request::class, 'getPreferredFormat')) {
$usageIndex = $session->getUsageIndex();
$tokenStorage = new UsageTrackingTokenStorage($tokenStorage, new class([
'session' => function () use ($session) { return $session; }
$tokenStorage = new UsageTrackingTokenStorage($tokenStorage, new class(['session' => function () use ($session) {
return $session;
},
]) implements ContainerInterface {
use ServiceLocatorTrait;
});

View File

@ -39,11 +39,11 @@ class DiscriminatorMap
public function __construct(array $data)
{
if (empty($data['typeProperty'])) {
throw new InvalidArgumentException(sprintf('Parameter "typeProperty" of annotation "%s" cannot be empty.', \get_class($this)));
throw new InvalidArgumentException(sprintf('Parameter "typeProperty" of annotation "%s" cannot be empty.', static::class));
}
if (empty($data['mapping'])) {
throw new InvalidArgumentException(sprintf('Parameter "mapping" of annotation "%s" cannot be empty.', \get_class($this)));
throw new InvalidArgumentException(sprintf('Parameter "mapping" of annotation "%s" cannot be empty.', static::class));
}
$this->typeProperty = $data['typeProperty'];

View File

@ -31,11 +31,11 @@ final class SerializedName
public function __construct(array $data)
{
if (!isset($data['value'])) {
throw new InvalidArgumentException(sprintf('Parameter of annotation "%s" should be set.', \get_class($this)));
throw new InvalidArgumentException(sprintf('Parameter of annotation "%s" should be set.', static::class));
}
if (!\is_string($data['value']) || empty($data['value'])) {
throw new InvalidArgumentException(sprintf('Parameter of annotation "%s" must be a non-empty string.', \get_class($this)));
throw new InvalidArgumentException(sprintf('Parameter of annotation "%s" must be a non-empty string.', static::class));
}
$this->serializedName = $data['value'];

View File

@ -316,7 +316,7 @@ abstract class AbstractNormalizer implements NormalizerInterface, DenormalizerIn
*/
protected function handleCircularReference($object/*, string $format = null, array $context = []*/)
{
if (\func_num_args() < 2 && __CLASS__ !== \get_class($this) && __CLASS__ !== (new \ReflectionMethod($this, __FUNCTION__))->getDeclaringClass()->getName() && !$this instanceof \PHPUnit\Framework\MockObject\MockObject && !$this instanceof \Prophecy\Prophecy\ProphecySubjectInterface) {
if (\func_num_args() < 2 && __CLASS__ !== static::class && __CLASS__ !== (new \ReflectionMethod($this, __FUNCTION__))->getDeclaringClass()->getName() && !$this instanceof \PHPUnit\Framework\MockObject\MockObject && !$this instanceof \Prophecy\Prophecy\ProphecySubjectInterface) {
@trigger_error(sprintf('The "%s()" method will have two new "string $format = null" and "array $context = []" arguments in version 5.0, not defining it is deprecated since Symfony 4.2.', __METHOD__), E_USER_DEPRECATED);
}
$format = \func_num_args() > 1 ? func_get_arg(1) : null;
@ -549,7 +549,7 @@ abstract class AbstractNormalizer implements NormalizerInterface, DenormalizerIn
protected function createChildContext(array $parentContext, $attribute/*, ?string $format */): array
{
if (\func_num_args() < 3) {
@trigger_error(sprintf('Method "%s::%s()" will have a third "?string $format" argument in version 5.0; not defining it is deprecated since Symfony 4.3.', \get_class($this), __FUNCTION__), E_USER_DEPRECATED);
@trigger_error(sprintf('Method "%s::%s()" will have a third "?string $format" argument in version 5.0; not defining it is deprecated since Symfony 4.3.', static::class, __FUNCTION__), E_USER_DEPRECATED);
}
if (isset($parentContext[self::ATTRIBUTES][$attribute])) {
$parentContext[self::ATTRIBUTES] = $parentContext[self::ATTRIBUTES][$attribute];

View File

@ -594,7 +594,7 @@ abstract class AbstractObjectNormalizer extends AbstractNormalizer
if (\func_num_args() >= 3) {
$format = func_get_arg(2);
} else {
@trigger_error(sprintf('Method "%s::%s()" will have a third "?string $format" argument in version 5.0; not defining it is deprecated since Symfony 4.3.', \get_class($this), __FUNCTION__), E_USER_DEPRECATED);
@trigger_error(sprintf('Method "%s::%s()" will have a third "?string $format" argument in version 5.0; not defining it is deprecated since Symfony 4.3.', static::class, __FUNCTION__), E_USER_DEPRECATED);
$format = null;
}

View File

@ -93,6 +93,6 @@ class ConstraintViolationListNormalizer implements NormalizerInterface, Cacheabl
*/
public function hasCacheableSupportsMethod(): bool
{
return __CLASS__ === \get_class($this);
return __CLASS__ === static::class;
}
}

View File

@ -73,6 +73,6 @@ class CustomNormalizer implements NormalizerInterface, DenormalizerInterface, Se
*/
public function hasCacheableSupportsMethod(): bool
{
return __CLASS__ === \get_class($this);
return __CLASS__ === static::class;
}
}

View File

@ -138,7 +138,7 @@ class DataUriNormalizer implements NormalizerInterface, DenormalizerInterface, C
*/
public function hasCacheableSupportsMethod(): bool
{
return __CLASS__ === \get_class($this);
return __CLASS__ === static::class;
}
/**

View File

@ -69,7 +69,7 @@ class DateIntervalNormalizer implements NormalizerInterface, DenormalizerInterfa
*/
public function hasCacheableSupportsMethod(): bool
{
return __CLASS__ === \get_class($this);
return __CLASS__ === static::class;
}
/**

View File

@ -129,7 +129,7 @@ class DateTimeNormalizer implements NormalizerInterface, DenormalizerInterface,
*/
public function hasCacheableSupportsMethod(): bool
{
return __CLASS__ === \get_class($this);
return __CLASS__ === static::class;
}
/**

View File

@ -74,6 +74,6 @@ class DateTimeZoneNormalizer implements NormalizerInterface, DenormalizerInterfa
*/
public function hasCacheableSupportsMethod(): bool
{
return __CLASS__ === \get_class($this);
return __CLASS__ === static::class;
}
}

View File

@ -57,7 +57,7 @@ class GetSetMethodNormalizer extends AbstractObjectNormalizer
*/
public function hasCacheableSupportsMethod(): bool
{
return __CLASS__ === \get_class($this);
return __CLASS__ === static::class;
}
/**

View File

@ -70,6 +70,6 @@ class JsonSerializableNormalizer extends AbstractNormalizer
*/
public function hasCacheableSupportsMethod(): bool
{
return __CLASS__ === \get_class($this);
return __CLASS__ === static::class;
}
}

View File

@ -54,7 +54,7 @@ class ObjectNormalizer extends AbstractObjectNormalizer
*/
public function hasCacheableSupportsMethod(): bool
{
return __CLASS__ === \get_class($this);
return __CLASS__ === static::class;
}
/**

View File

@ -51,7 +51,7 @@ class PropertyNormalizer extends AbstractObjectNormalizer
*/
public function hasCacheableSupportsMethod(): bool
{
return __CLASS__ === \get_class($this);
return __CLASS__ === static::class;
}
/**

View File

@ -200,7 +200,7 @@ class PhpExtractor extends AbstractFileExtractor implements ExtractorInterface
*/
protected function parseTokens($tokens, MessageCatalogue $catalog/*, string $filename*/)
{
if (\func_num_args() < 3 && __CLASS__ !== \get_class($this) && __CLASS__ !== (new \ReflectionMethod($this, __FUNCTION__))->getDeclaringClass()->getName() && !$this instanceof \PHPUnit\Framework\MockObject\MockObject && !$this instanceof \Prophecy\Prophecy\ProphecySubjectInterface) {
if (\func_num_args() < 3 && __CLASS__ !== static::class && __CLASS__ !== (new \ReflectionMethod($this, __FUNCTION__))->getDeclaringClass()->getName() && !$this instanceof \PHPUnit\Framework\MockObject\MockObject && !$this instanceof \Prophecy\Prophecy\ProphecySubjectInterface) {
@trigger_error(sprintf('The "%s()" method will have a new "string $filename" argument in version 5.0, not defining it is deprecated since Symfony 4.3.', __METHOD__), E_USER_DEPRECATED);
}
$filename = 2 < \func_num_args() ? func_get_arg(2) : '';

View File

@ -33,7 +33,7 @@ class IdentityTranslator implements LegacyTranslatorInterface, TranslatorInterfa
{
$this->selector = $selector;
if (__CLASS__ !== \get_class($this)) {
if (__CLASS__ !== static::class) {
@trigger_error(sprintf('Calling "%s()" is deprecated since Symfony 4.2.', __METHOD__), E_USER_DEPRECATED);
}
}

View File

@ -47,7 +47,7 @@ abstract class AbstractComparison extends Constraint
}
if (isset($options['propertyPath']) && !class_exists(PropertyAccess::class)) {
throw new LogicException(sprintf('The "%s" constraint requires the Symfony PropertyAccess component to use the "propertyPath" option.', \get_class($this)));
throw new LogicException(sprintf('The "%s" constraint requires the Symfony PropertyAccess component to use the "propertyPath" option.', static::class));
}
}

View File

@ -27,11 +27,11 @@ trait NumberConstraintTrait
}
if (isset($options['propertyPath'])) {
throw new ConstraintDefinitionException(sprintf('The "propertyPath" option of the "%s" constraint cannot be set.', \get_class($this)));
throw new ConstraintDefinitionException(sprintf('The "propertyPath" option of the "%s" constraint cannot be set.', static::class));
}
if (isset($options['value'])) {
throw new ConstraintDefinitionException(sprintf('The "value" option of the "%s" constraint cannot be set.', \get_class($this)));
throw new ConstraintDefinitionException(sprintf('The "value" option of the "%s" constraint cannot be set.', static::class));
}
$options['value'] = 0;

View File

@ -50,15 +50,15 @@ class Range extends Constraint
{
if (\is_array($options)) {
if (isset($options['min']) && isset($options['minPropertyPath'])) {
throw new ConstraintDefinitionException(sprintf('The "%s" constraint requires only one of the "min" or "minPropertyPath" options to be set, not both.', \get_class($this)));
throw new ConstraintDefinitionException(sprintf('The "%s" constraint requires only one of the "min" or "minPropertyPath" options to be set, not both.', static::class));
}
if (isset($options['max']) && isset($options['maxPropertyPath'])) {
throw new ConstraintDefinitionException(sprintf('The "%s" constraint requires only one of the "max" or "maxPropertyPath" options to be set, not both.', \get_class($this)));
throw new ConstraintDefinitionException(sprintf('The "%s" constraint requires only one of the "max" or "maxPropertyPath" options to be set, not both.', static::class));
}
if ((isset($options['minPropertyPath']) || isset($options['maxPropertyPath'])) && !class_exists(PropertyAccess::class)) {
throw new LogicException(sprintf('The "%s" constraint requires the Symfony PropertyAccess component to use the "minPropertyPath" or "maxPropertyPath" option.', \get_class($this)));
throw new LogicException(sprintf('The "%s" constraint requires the Symfony PropertyAccess component to use the "minPropertyPath" or "maxPropertyPath" option.', static::class));
}
}

View File

@ -38,6 +38,6 @@ if (!function_exists('dd')) {
VarDumper::dump($v);
}
die(1);
exit(1);
}
}

View File

@ -41,8 +41,7 @@ trait CacheTrait
private function doGet(CacheItemPoolInterface $pool, string $key, callable $callback, ?float $beta, array &$metadata = null, LoggerInterface $logger = null)
{
if (0 > $beta = $beta ?? 1.0) {
throw new class(sprintf('Argument "$beta" provided to "%s::get()" must be a positive number, %f given.', \get_class($this), $beta)) extends \InvalidArgumentException implements InvalidArgumentException {
};
throw new class(sprintf('Argument "$beta" provided to "%s::get()" must be a positive number, %f given.', static::class, $beta)) extends \InvalidArgumentException implements InvalidArgumentException { };
}
$item = $pool->getItem($key);