Add types to constructors and private/final/internal methods (Batch III)
This commit is contained in:
parent
001777ac07
commit
6493902287
@ -71,7 +71,7 @@ class DbalLogger implements SQLLogger
|
|||||||
$this->logger->debug($message, $params);
|
$this->logger->debug($message, $params);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function normalizeParams(array $params)
|
private function normalizeParams(array $params): array
|
||||||
{
|
{
|
||||||
foreach ($params as $index => $param) {
|
foreach ($params as $index => $param) {
|
||||||
// normalize recursively
|
// normalize recursively
|
||||||
|
@ -12,6 +12,9 @@
|
|||||||
namespace Symfony\Bridge\Doctrine\Security\User;
|
namespace Symfony\Bridge\Doctrine\Security\User;
|
||||||
|
|
||||||
use Doctrine\Common\Persistence\ManagerRegistry;
|
use Doctrine\Common\Persistence\ManagerRegistry;
|
||||||
|
use Doctrine\Common\Persistence\Mapping\ClassMetadata;
|
||||||
|
use Doctrine\Common\Persistence\ObjectManager;
|
||||||
|
use Doctrine\Common\Persistence\ObjectRepository;
|
||||||
use Symfony\Component\Security\Core\Exception\UnsupportedUserException;
|
use Symfony\Component\Security\Core\Exception\UnsupportedUserException;
|
||||||
use Symfony\Component\Security\Core\Exception\UsernameNotFoundException;
|
use Symfony\Component\Security\Core\Exception\UsernameNotFoundException;
|
||||||
use Symfony\Component\Security\Core\User\PasswordUpgraderInterface;
|
use Symfony\Component\Security\Core\User\PasswordUpgraderInterface;
|
||||||
@ -124,17 +127,17 @@ class EntityUserProvider implements UserProviderInterface, PasswordUpgraderInter
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getObjectManager()
|
private function getObjectManager(): ObjectManager
|
||||||
{
|
{
|
||||||
return $this->registry->getManager($this->managerName);
|
return $this->registry->getManager($this->managerName);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getRepository()
|
private function getRepository(): ObjectRepository
|
||||||
{
|
{
|
||||||
return $this->getObjectManager()->getRepository($this->classOrAlias);
|
return $this->getObjectManager()->getRepository($this->classOrAlias);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getClass()
|
private function getClass(): string
|
||||||
{
|
{
|
||||||
if (null === $this->class) {
|
if (null === $this->class) {
|
||||||
$class = $this->classOrAlias;
|
$class = $this->classOrAlias;
|
||||||
@ -149,7 +152,7 @@ class EntityUserProvider implements UserProviderInterface, PasswordUpgraderInter
|
|||||||
return $this->class;
|
return $this->class;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getClassMetadata()
|
private function getClassMetadata(): ClassMetadata
|
||||||
{
|
{
|
||||||
return $this->getObjectManager()->getClassMetadata($this->classOrAlias);
|
return $this->getObjectManager()->getClassMetadata($this->classOrAlias);
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,7 @@ final class TestRepositoryFactory implements RepositoryFactory
|
|||||||
return $this->repositoryList[$repositoryHash] = $this->createRepository($entityManager, $entityName);
|
return $this->repositoryList[$repositoryHash] = $this->createRepository($entityManager, $entityName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setRepository(EntityManagerInterface $entityManager, $entityName, ObjectRepository $repository)
|
public function setRepository(EntityManagerInterface $entityManager, string $entityName, ObjectRepository $repository)
|
||||||
{
|
{
|
||||||
$repositoryHash = $this->getRepositoryHash($entityManager, $entityName);
|
$repositoryHash = $this->getRepositoryHash($entityManager, $entityName);
|
||||||
|
|
||||||
@ -56,7 +56,7 @@ final class TestRepositoryFactory implements RepositoryFactory
|
|||||||
return new $repositoryClassName($entityManager, $metadata);
|
return new $repositoryClassName($entityManager, $metadata);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getRepositoryHash(EntityManagerInterface $entityManager, string $entityName)
|
private function getRepositoryHash(EntityManagerInterface $entityManager, string $entityName): string
|
||||||
{
|
{
|
||||||
return $entityManager->getClassMetadata($entityName)->getName().spl_object_hash($entityManager);
|
return $entityManager->getClassMetadata($entityName)->getName().spl_object_hash($entityManager);
|
||||||
}
|
}
|
||||||
|
@ -11,9 +11,11 @@
|
|||||||
|
|
||||||
namespace Symfony\Bridge\Doctrine\Tests\Security\User;
|
namespace Symfony\Bridge\Doctrine\Tests\Security\User;
|
||||||
|
|
||||||
|
use Doctrine\Common\Persistence\ObjectRepository;
|
||||||
use Doctrine\ORM\Tools\SchemaTool;
|
use Doctrine\ORM\Tools\SchemaTool;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
use Symfony\Bridge\Doctrine\Security\User\EntityUserProvider;
|
use Symfony\Bridge\Doctrine\Security\User\EntityUserProvider;
|
||||||
|
use Symfony\Bridge\Doctrine\Security\User\UserLoaderInterface;
|
||||||
use Symfony\Bridge\Doctrine\Test\DoctrineTestHelper;
|
use Symfony\Bridge\Doctrine\Test\DoctrineTestHelper;
|
||||||
use Symfony\Bridge\Doctrine\Tests\Fixtures\User;
|
use Symfony\Bridge\Doctrine\Tests\Fixtures\User;
|
||||||
use Symfony\Component\Security\Core\User\PasswordUpgraderInterface;
|
use Symfony\Component\Security\Core\User\PasswordUpgraderInterface;
|
||||||
@ -59,9 +61,7 @@ class EntityUserProviderTest extends TestCase
|
|||||||
{
|
{
|
||||||
$user = new User(1, 1, 'user1');
|
$user = new User(1, 1, 'user1');
|
||||||
|
|
||||||
$repository = $this->getMockBuilder('Symfony\Bridge\Doctrine\Security\User\UserLoaderInterface')
|
$repository = $this->createMock([ObjectRepository::class, UserLoaderInterface::class]);
|
||||||
->disableOriginalConstructor()
|
|
||||||
->getMock();
|
|
||||||
$repository
|
$repository
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('loadUserByUsername')
|
->method('loadUserByUsername')
|
||||||
@ -147,7 +147,7 @@ class EntityUserProviderTest extends TestCase
|
|||||||
|
|
||||||
public function testLoadUserByUserNameShouldLoadUserWhenProperInterfaceProvided()
|
public function testLoadUserByUserNameShouldLoadUserWhenProperInterfaceProvided()
|
||||||
{
|
{
|
||||||
$repository = $this->getMockBuilder('\Symfony\Bridge\Doctrine\Security\User\UserLoaderInterface')->getMock();
|
$repository = $this->createMock([ObjectRepository::class, UserLoaderInterface::class]);
|
||||||
$repository->expects($this->once())
|
$repository->expects($this->once())
|
||||||
->method('loadUserByUsername')
|
->method('loadUserByUsername')
|
||||||
->with('name')
|
->with('name')
|
||||||
@ -166,7 +166,7 @@ class EntityUserProviderTest extends TestCase
|
|||||||
public function testLoadUserByUserNameShouldDeclineInvalidInterface()
|
public function testLoadUserByUserNameShouldDeclineInvalidInterface()
|
||||||
{
|
{
|
||||||
$this->expectException('InvalidArgumentException');
|
$this->expectException('InvalidArgumentException');
|
||||||
$repository = $this->getMockBuilder('\Symfony\Component\Security\Core\User\AdvancedUserInterface')->getMock();
|
$repository = $this->createMock(ObjectRepository::class);
|
||||||
|
|
||||||
$provider = new EntityUserProvider(
|
$provider = new EntityUserProvider(
|
||||||
$this->getManager($this->getObjectManager($repository)),
|
$this->getManager($this->getObjectManager($repository)),
|
||||||
@ -180,7 +180,7 @@ class EntityUserProviderTest extends TestCase
|
|||||||
{
|
{
|
||||||
$user = new User(1, 1, 'user1');
|
$user = new User(1, 1, 'user1');
|
||||||
|
|
||||||
$repository = $this->getMockBuilder(PasswordUpgraderInterface::class)->getMock();
|
$repository = $this->createMock([ObjectRepository::class, PasswordUpgraderInterface::class]);
|
||||||
$repository->expects($this->once())
|
$repository->expects($this->once())
|
||||||
->method('upgradePassword')
|
->method('upgradePassword')
|
||||||
->with($user, 'foobar');
|
->with($user, 'foobar');
|
||||||
|
@ -133,7 +133,7 @@ class ConsoleFormatter implements FormatterInterface
|
|||||||
/**
|
/**
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
public function echoLine($line, $depth, $indentPad)
|
public function echoLine(string $line, int $depth, string $indentPad)
|
||||||
{
|
{
|
||||||
if (-1 !== $depth) {
|
if (-1 !== $depth) {
|
||||||
fwrite($this->outputBuffer, $line);
|
fwrite($this->outputBuffer, $line);
|
||||||
@ -143,7 +143,7 @@ class ConsoleFormatter implements FormatterInterface
|
|||||||
/**
|
/**
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
public function castObject($v, array $a, Stub $s, $isNested)
|
public function castObject($v, array $a, Stub $s, bool $isNested): array
|
||||||
{
|
{
|
||||||
if ($this->options['multiline']) {
|
if ($this->options['multiline']) {
|
||||||
return $a;
|
return $a;
|
||||||
@ -157,7 +157,7 @@ class ConsoleFormatter implements FormatterInterface
|
|||||||
return $a;
|
return $a;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function replacePlaceHolder(array $record)
|
private function replacePlaceHolder(array $record): array
|
||||||
{
|
{
|
||||||
$message = $record['message'];
|
$message = $record['message'];
|
||||||
|
|
||||||
|
@ -103,7 +103,7 @@ class ServerLogHandler extends AbstractHandler
|
|||||||
return $socket;
|
return $socket;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function formatRecord(array $record)
|
private function formatRecord(array $record): string
|
||||||
{
|
{
|
||||||
if ($this->processors) {
|
if ($this->processors) {
|
||||||
foreach ($this->processors as $processor) {
|
foreach ($this->processors as $processor) {
|
||||||
|
@ -360,7 +360,7 @@ EOF
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getPrettyMetadata(string $type, $entity, bool $decorated)
|
private function getPrettyMetadata(string $type, $entity, bool $decorated): ?string
|
||||||
{
|
{
|
||||||
if ('tests' === $type) {
|
if ('tests' === $type) {
|
||||||
return '';
|
return '';
|
||||||
|
@ -119,7 +119,7 @@ EOF
|
|||||||
return $template;
|
return $template;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getFilesInfo(array $filenames)
|
private function getFilesInfo(array $filenames): array
|
||||||
{
|
{
|
||||||
$filesInfo = [];
|
$filesInfo = [];
|
||||||
foreach ($filenames as $filename) {
|
foreach ($filenames as $filename) {
|
||||||
|
@ -236,7 +236,7 @@ class CodeExtension extends AbstractExtension
|
|||||||
/**
|
/**
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
public function formatLogMessage($message, array $context)
|
public function formatLogMessage(string $message, array $context): string
|
||||||
{
|
{
|
||||||
if ($context && false !== strpos($message, '{')) {
|
if ($context && false !== strpos($message, '{')) {
|
||||||
$replacements = [];
|
$replacements = [];
|
||||||
|
@ -111,7 +111,7 @@ class FormExtension extends AbstractExtension
|
|||||||
*
|
*
|
||||||
* @see ChoiceView::isSelected()
|
* @see ChoiceView::isSelected()
|
||||||
*/
|
*/
|
||||||
function twig_is_selected_choice(ChoiceView $choice, $selectedValue)
|
function twig_is_selected_choice(ChoiceView $choice, $selectedValue): bool
|
||||||
{
|
{
|
||||||
if (\is_array($selectedValue)) {
|
if (\is_array($selectedValue)) {
|
||||||
return \in_array($choice->value, $selectedValue, true);
|
return \in_array($choice->value, $selectedValue, true);
|
||||||
@ -123,7 +123,7 @@ function twig_is_selected_choice(ChoiceView $choice, $selectedValue)
|
|||||||
/**
|
/**
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
function twig_is_root_form(FormView $formView)
|
function twig_is_root_form(FormView $formView): bool
|
||||||
{
|
{
|
||||||
return null === $formView->parent;
|
return null === $formView->parent;
|
||||||
}
|
}
|
||||||
|
@ -132,7 +132,7 @@ class TranslationDefaultDomainNodeVisitor extends AbstractNodeVisitor
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getVarName()
|
private function getVarName(): string
|
||||||
{
|
{
|
||||||
return sprintf('__internal_%s', hash('sha256', uniqid(mt_rand(), true), false));
|
return sprintf('__internal_%s', hash('sha256', uniqid(mt_rand(), true), false));
|
||||||
}
|
}
|
||||||
|
@ -65,7 +65,7 @@ class UndefinedCallableHandler
|
|||||||
'workflow' => 'enable "framework.workflows"',
|
'workflow' => 'enable "framework.workflows"',
|
||||||
];
|
];
|
||||||
|
|
||||||
public static function onUndefinedFilter($name)
|
public static function onUndefinedFilter(string $name): bool
|
||||||
{
|
{
|
||||||
if (!isset(self::$filterComponents[$name])) {
|
if (!isset(self::$filterComponents[$name])) {
|
||||||
return false;
|
return false;
|
||||||
@ -76,7 +76,7 @@ class UndefinedCallableHandler
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function onUndefinedFunction($name)
|
public static function onUndefinedFunction(string $name): bool
|
||||||
{
|
{
|
||||||
if (!isset(self::$functionComponents[$name])) {
|
if (!isset(self::$functionComponents[$name])) {
|
||||||
return false;
|
return false;
|
||||||
@ -87,7 +87,7 @@ class UndefinedCallableHandler
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function onUndefined($name, $type, $component)
|
private static function onUndefined(string $name, string $type, string $component)
|
||||||
{
|
{
|
||||||
if (class_exists(FullStack::class) && isset(self::$fullStackEnable[$component])) {
|
if (class_exists(FullStack::class) && isset(self::$fullStackEnable[$component])) {
|
||||||
throw new SyntaxError(sprintf('Did you forget to %s? Unknown %s "%s".', self::$fullStackEnable[$component], $type, $name));
|
throw new SyntaxError(sprintf('Did you forget to %s? Unknown %s "%s".', self::$fullStackEnable[$component], $type, $name));
|
||||||
|
@ -262,7 +262,7 @@ EOT
|
|||||||
return self::METHOD_COPY;
|
return self::METHOD_COPY;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getPublicDirectory(ContainerInterface $container)
|
private function getPublicDirectory(ContainerInterface $container): string
|
||||||
{
|
{
|
||||||
$defaultPublicDir = 'public';
|
$defaultPublicDir = 'public';
|
||||||
|
|
||||||
|
@ -236,7 +236,7 @@ EOF
|
|||||||
return $this->containerBuilder = $container;
|
return $this->containerBuilder = $container;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function findProperServiceName(InputInterface $input, SymfonyStyle $io, ContainerBuilder $builder, string $name, bool $showHidden)
|
private function findProperServiceName(InputInterface $input, SymfonyStyle $io, ContainerBuilder $builder, string $name, bool $showHidden): string
|
||||||
{
|
{
|
||||||
$name = ltrim($name, '\\');
|
$name = ltrim($name, '\\');
|
||||||
|
|
||||||
@ -256,7 +256,7 @@ EOF
|
|||||||
return $io->choice('Select one of the following services to display its information', $matchingServices);
|
return $io->choice('Select one of the following services to display its information', $matchingServices);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function findServiceIdsContaining(ContainerBuilder $builder, string $name, bool $showHidden)
|
private function findServiceIdsContaining(ContainerBuilder $builder, string $name, bool $showHidden): array
|
||||||
{
|
{
|
||||||
$serviceIds = $builder->getServiceIds();
|
$serviceIds = $builder->getServiceIds();
|
||||||
$foundServiceIds = $foundServiceIdsIgnoringBackslashes = [];
|
$foundServiceIds = $foundServiceIdsIgnoringBackslashes = [];
|
||||||
@ -278,7 +278,7 @@ EOF
|
|||||||
/**
|
/**
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
public function filterToServiceTypes($serviceId)
|
public function filterToServiceTypes(string $serviceId): bool
|
||||||
{
|
{
|
||||||
// filter out things that could not be valid class names
|
// filter out things that could not be valid class names
|
||||||
if (!preg_match('/(?(DEFINE)(?<V>[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*+))^(?&V)(?:\\\\(?&V))*+(?: \$(?&V))?$/', $serviceId)) {
|
if (!preg_match('/(?(DEFINE)(?<V>[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*+))^(?&V)(?:\\\\(?&V))*+(?: \$(?&V))?$/', $serviceId)) {
|
||||||
|
@ -47,7 +47,7 @@ abstract class AbstractController implements ServiceSubscriberInterface
|
|||||||
* @internal
|
* @internal
|
||||||
* @required
|
* @required
|
||||||
*/
|
*/
|
||||||
public function setContainer(ContainerInterface $container)
|
public function setContainer(ContainerInterface $container): ?ContainerInterface
|
||||||
{
|
{
|
||||||
$previous = $this->container;
|
$previous = $this->container;
|
||||||
$this->container = $container;
|
$this->container = $container;
|
||||||
|
@ -13,6 +13,7 @@ namespace Symfony\Bundle\FrameworkBundle\Templating\Helper;
|
|||||||
|
|
||||||
@trigger_error('The '.RequestHelper::class.' class is deprecated since version 4.3 and will be removed in 5.0; use Twig instead.', E_USER_DEPRECATED);
|
@trigger_error('The '.RequestHelper::class.' class is deprecated since version 4.3 and will be removed in 5.0; use Twig instead.', E_USER_DEPRECATED);
|
||||||
|
|
||||||
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpFoundation\RequestStack;
|
use Symfony\Component\HttpFoundation\RequestStack;
|
||||||
use Symfony\Component\Templating\Helper\Helper;
|
use Symfony\Component\Templating\Helper\Helper;
|
||||||
|
|
||||||
@ -57,7 +58,7 @@ class RequestHelper extends Helper
|
|||||||
return $this->getRequest()->getLocale();
|
return $this->getRequest()->getLocale();
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getRequest()
|
private function getRequest(): Request
|
||||||
{
|
{
|
||||||
if (!$this->requestStack->getCurrentRequest()) {
|
if (!$this->requestStack->getCurrentRequest()) {
|
||||||
throw new \LogicException('A Request must be available.');
|
throw new \LogicException('A Request must be available.');
|
||||||
|
@ -14,6 +14,7 @@ namespace Symfony\Bundle\FrameworkBundle\Templating\Helper;
|
|||||||
@trigger_error('The '.SessionHelper::class.' class is deprecated since version 4.3 and will be removed in 5.0; use Twig instead.', E_USER_DEPRECATED);
|
@trigger_error('The '.SessionHelper::class.' class is deprecated since version 4.3 and will be removed in 5.0; use Twig instead.', E_USER_DEPRECATED);
|
||||||
|
|
||||||
use Symfony\Component\HttpFoundation\RequestStack;
|
use Symfony\Component\HttpFoundation\RequestStack;
|
||||||
|
use Symfony\Component\HttpFoundation\Session\SessionInterface;
|
||||||
use Symfony\Component\Templating\Helper\Helper;
|
use Symfony\Component\Templating\Helper\Helper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -61,7 +62,7 @@ class SessionHelper extends Helper
|
|||||||
return $this->getSession()->getFlashBag()->has($name);
|
return $this->getSession()->getFlashBag()->has($name);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getSession()
|
private function getSession(): SessionInterface
|
||||||
{
|
{
|
||||||
if (null === $this->session) {
|
if (null === $this->session) {
|
||||||
if (!$this->requestStack->getMasterRequest()) {
|
if (!$this->requestStack->getMasterRequest()) {
|
||||||
|
@ -93,7 +93,7 @@ class TestAbstractController extends AbstractController
|
|||||||
return $this->$method(...$arguments);
|
return $this->$method(...$arguments);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setContainer(ContainerInterface $container)
|
public function setContainer(ContainerInterface $container): ?ContainerInterface
|
||||||
{
|
{
|
||||||
if (!$this->throwOnUnexpectedService) {
|
if (!$this->throwOnUnexpectedService) {
|
||||||
return parent::setContainer($container);
|
return parent::setContainer($container);
|
||||||
|
@ -182,12 +182,12 @@ EOF
|
|||||||
})->setHidden(true)->setMaxAttempts(20);
|
})->setHidden(true)->setMaxAttempts(20);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function generateSalt()
|
private function generateSalt(): string
|
||||||
{
|
{
|
||||||
return base64_encode(random_bytes(30));
|
return base64_encode(random_bytes(30));
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getUserClass(InputInterface $input, SymfonyStyle $io)
|
private function getUserClass(InputInterface $input, SymfonyStyle $io): string
|
||||||
{
|
{
|
||||||
if (null !== $userClass = $input->getArgument('user-class')) {
|
if (null !== $userClass = $input->getArgument('user-class')) {
|
||||||
return $userClass;
|
return $userClass;
|
||||||
|
@ -60,7 +60,7 @@ final class WrappedListener implements ListenerInterface
|
|||||||
/**
|
/**
|
||||||
* Proxies all method calls to the original listener.
|
* Proxies all method calls to the original listener.
|
||||||
*/
|
*/
|
||||||
public function __call($method, $arguments)
|
public function __call(string $method, array $arguments)
|
||||||
{
|
{
|
||||||
return $this->listener->{$method}(...$arguments);
|
return $this->listener->{$method}(...$arguments);
|
||||||
}
|
}
|
||||||
|
@ -89,7 +89,7 @@ abstract class AbstractFactory implements SecurityFactoryInterface
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final public function addOption($name, $default = null)
|
final public function addOption(string $name, $default = null)
|
||||||
{
|
{
|
||||||
$this->options[$name] = $default;
|
$this->options[$name] = $default;
|
||||||
}
|
}
|
||||||
|
@ -92,7 +92,7 @@ class GuardAuthenticationFactory implements SecurityFactoryInterface
|
|||||||
return [$providerId, $listenerId, $entryPointId];
|
return [$providerId, $listenerId, $entryPointId];
|
||||||
}
|
}
|
||||||
|
|
||||||
private function determineEntryPoint(?string $defaultEntryPointId, array $config)
|
private function determineEntryPoint(?string $defaultEntryPointId, array $config): string
|
||||||
{
|
{
|
||||||
if ($defaultEntryPointId) {
|
if ($defaultEntryPointId) {
|
||||||
// explode if they've configured the entry_point, but there is already one
|
// explode if they've configured the entry_point, but there is already one
|
||||||
|
@ -598,7 +598,7 @@ class SecurityExtension extends Extension implements PrependExtensionInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Parses user providers and returns an array of their ids
|
// Parses user providers and returns an array of their ids
|
||||||
private function createUserProviders(array $config, ContainerBuilder $container)
|
private function createUserProviders(array $config, ContainerBuilder $container): array
|
||||||
{
|
{
|
||||||
$providerIds = [];
|
$providerIds = [];
|
||||||
foreach ($config['providers'] as $name => $provider) {
|
foreach ($config['providers'] as $name => $provider) {
|
||||||
@ -610,7 +610,7 @@ class SecurityExtension extends Extension implements PrependExtensionInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Parses a <provider> tag and returns the id for the related user provider service
|
// Parses a <provider> tag and returns the id for the related user provider service
|
||||||
private function createUserDaoProvider(string $name, array $provider, ContainerBuilder $container)
|
private function createUserDaoProvider(string $name, array $provider, ContainerBuilder $container): string
|
||||||
{
|
{
|
||||||
$name = $this->getUserProviderId($name);
|
$name = $this->getUserProviderId($name);
|
||||||
|
|
||||||
@ -649,12 +649,12 @@ class SecurityExtension extends Extension implements PrependExtensionInterface
|
|||||||
throw new InvalidConfigurationException(sprintf('Unable to create definition for "%s" user provider', $name));
|
throw new InvalidConfigurationException(sprintf('Unable to create definition for "%s" user provider', $name));
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getUserProviderId(string $name)
|
private function getUserProviderId(string $name): string
|
||||||
{
|
{
|
||||||
return 'security.user.provider.concrete.'.strtolower($name);
|
return 'security.user.provider.concrete.'.strtolower($name);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function createExceptionListener(ContainerBuilder $container, array $config, string $id, ?string $defaultEntryPoint, bool $stateless)
|
private function createExceptionListener(ContainerBuilder $container, array $config, string $id, ?string $defaultEntryPoint, bool $stateless): string
|
||||||
{
|
{
|
||||||
$exceptionListenerId = 'security.exception_listener.'.$id;
|
$exceptionListenerId = 'security.exception_listener.'.$id;
|
||||||
$listener = $container->setDefinition($exceptionListenerId, new ChildDefinition('security.exception_listener'));
|
$listener = $container->setDefinition($exceptionListenerId, new ChildDefinition('security.exception_listener'));
|
||||||
@ -672,7 +672,7 @@ class SecurityExtension extends Extension implements PrependExtensionInterface
|
|||||||
return $exceptionListenerId;
|
return $exceptionListenerId;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function createSwitchUserListener(ContainerBuilder $container, string $id, array $config, string $defaultProvider, bool $stateless)
|
private function createSwitchUserListener(ContainerBuilder $container, string $id, array $config, string $defaultProvider, bool $stateless): string
|
||||||
{
|
{
|
||||||
$userProvider = isset($config['provider']) ? $this->getUserProviderId($config['provider']) : $defaultProvider;
|
$userProvider = isset($config['provider']) ? $this->getUserProviderId($config['provider']) : $defaultProvider;
|
||||||
|
|
||||||
@ -692,7 +692,7 @@ class SecurityExtension extends Extension implements PrependExtensionInterface
|
|||||||
return $switchUserListenerId;
|
return $switchUserListenerId;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function createExpression(ContainerBuilder $container, string $expression)
|
private function createExpression(ContainerBuilder $container, string $expression): Reference
|
||||||
{
|
{
|
||||||
if (isset($this->expressions[$id = '.security.expression.'.ContainerBuilder::hash($expression)])) {
|
if (isset($this->expressions[$id = '.security.expression.'.ContainerBuilder::hash($expression)])) {
|
||||||
return $this->expressions[$id];
|
return $this->expressions[$id];
|
||||||
@ -711,7 +711,7 @@ class SecurityExtension extends Extension implements PrependExtensionInterface
|
|||||||
return $this->expressions[$id] = new Reference($id);
|
return $this->expressions[$id] = new Reference($id);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function createRequestMatcher(ContainerBuilder $container, string $path = null, string $host = null, int $port = null, array $methods = [], array $ips = null, array $attributes = [])
|
private function createRequestMatcher(ContainerBuilder $container, string $path = null, string $host = null, int $port = null, array $methods = [], array $ips = null, array $attributes = []): Reference
|
||||||
{
|
{
|
||||||
if ($methods) {
|
if ($methods) {
|
||||||
$methods = array_map('strtoupper', (array) $methods);
|
$methods = array_map('strtoupper', (array) $methods);
|
||||||
|
@ -42,7 +42,7 @@ EOF
|
|||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function findFiles($filename)
|
protected function findFiles($filename): iterable
|
||||||
{
|
{
|
||||||
if (0 === strpos($filename, '@')) {
|
if (0 === strpos($filename, '@')) {
|
||||||
$dir = $this->getApplication()->getKernel()->locateResource($filename);
|
$dir = $this->getApplication()->getKernel()->locateResource($filename);
|
||||||
|
@ -172,7 +172,7 @@ class TwigExtension extends Extension
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getBundleTemplatePaths(ContainerBuilder $container, array $config)
|
private function getBundleTemplatePaths(ContainerBuilder $container, array $config): array
|
||||||
{
|
{
|
||||||
$bundleHierarchy = [];
|
$bundleHierarchy = [];
|
||||||
foreach ($container->getParameter('kernel.bundles_metadata') as $name => $bundle) {
|
foreach ($container->getParameter('kernel.bundles_metadata') as $name => $bundle) {
|
||||||
@ -199,7 +199,7 @@ class TwigExtension extends Extension
|
|||||||
return $bundleHierarchy;
|
return $bundleHierarchy;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function normalizeBundleName(string $name)
|
private function normalizeBundleName(string $name): string
|
||||||
{
|
{
|
||||||
if ('Bundle' === substr($name, -6)) {
|
if ('Bundle' === substr($name, -6)) {
|
||||||
$name = substr($name, 0, -6);
|
$name = substr($name, 0, -6);
|
||||||
|
@ -379,7 +379,7 @@ class ProfilerController
|
|||||||
$this->profiler->disable();
|
$this->profiler->disable();
|
||||||
}
|
}
|
||||||
|
|
||||||
private function renderWithCspNonces(Request $request, string $template, array $variables, int $code = 200, array $headers = ['Content-Type' => 'text/html'])
|
private function renderWithCspNonces(Request $request, string $template, array $variables, int $code = 200, array $headers = ['Content-Type' => 'text/html']): Response
|
||||||
{
|
{
|
||||||
$response = new Response('', $code, $headers);
|
$response = new Response('', $code, $headers);
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ namespace Symfony\Bundle\WebProfilerBundle\Csp;
|
|||||||
*/
|
*/
|
||||||
class NonceGenerator
|
class NonceGenerator
|
||||||
{
|
{
|
||||||
public function generate()
|
public function generate(): string
|
||||||
{
|
{
|
||||||
return bin2hex(random_bytes(16));
|
return bin2hex(random_bytes(16));
|
||||||
}
|
}
|
||||||
|
@ -125,7 +125,7 @@ EOF
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getLogs($socket)
|
private function getLogs($socket): iterable
|
||||||
{
|
{
|
||||||
$sockets = [(int) $socket => $socket];
|
$sockets = [(int) $socket => $socket];
|
||||||
$write = [];
|
$write = [];
|
||||||
@ -148,7 +148,7 @@ EOF
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function displayLog(InputInterface $input, OutputInterface $output, $clientId, array $record)
|
private function displayLog(InputInterface $input, OutputInterface $output, int $clientId, array $record)
|
||||||
{
|
{
|
||||||
if (isset($record['log_id'])) {
|
if (isset($record['log_id'])) {
|
||||||
$clientId = unpack('H*', $record['log_id'])[1];
|
$clientId = unpack('H*', $record['log_id'])[1];
|
||||||
|
@ -46,7 +46,7 @@ class WebServerExtension extends Extension
|
|||||||
@trigger_error('Using the WebserverBundle is deprecated since Symfony 4.4, the new symfony local server has more feature, you should use it instead.', E_USER_DEPRECATED);
|
@trigger_error('Using the WebserverBundle is deprecated since Symfony 4.4, the new symfony local server has more feature, you should use it instead.', E_USER_DEPRECATED);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getPublicDirectory(ContainerBuilder $container)
|
private function getPublicDirectory(ContainerBuilder $container): string
|
||||||
{
|
{
|
||||||
$kernelProjectDir = $container->getParameter('kernel.project_dir');
|
$kernelProjectDir = $container->getParameter('kernel.project_dir');
|
||||||
$publicDir = 'public';
|
$publicDir = 'public';
|
||||||
|
@ -174,7 +174,7 @@ class WebServer
|
|||||||
return $process;
|
return $process;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getDefaultPidFile()
|
private function getDefaultPidFile(): string
|
||||||
{
|
{
|
||||||
return ($this->pidFileDirectory ?? getcwd()).'/.web-server-pid';
|
return ($this->pidFileDirectory ?? getcwd()).'/.web-server-pid';
|
||||||
}
|
}
|
||||||
|
@ -91,7 +91,7 @@ abstract class AbstractComparisonValidator extends ConstraintValidator
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getPropertyAccessor()
|
private function getPropertyAccessor(): PropertyAccessorInterface
|
||||||
{
|
{
|
||||||
if (null === $this->propertyAccessor) {
|
if (null === $this->propertyAccessor) {
|
||||||
$this->propertyAccessor = PropertyAccess::createPropertyAccessor();
|
$this->propertyAccessor = PropertyAccess::createPropertyAccessor();
|
||||||
|
@ -63,7 +63,7 @@ class ExpressionValidator extends ConstraintValidator
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getExpressionLanguage()
|
private function getExpressionLanguage(): ExpressionLanguage
|
||||||
{
|
{
|
||||||
if (null === $this->expressionLanguage) {
|
if (null === $this->expressionLanguage) {
|
||||||
if (!class_exists('Symfony\Component\ExpressionLanguage\ExpressionLanguage')) {
|
if (!class_exists('Symfony\Component\ExpressionLanguage\ExpressionLanguage')) {
|
||||||
|
@ -208,7 +208,7 @@ class FileValidator extends ConstraintValidator
|
|||||||
* Convert the limit to the smallest possible number
|
* Convert the limit to the smallest possible number
|
||||||
* (i.e. try "MB", then "kB", then "bytes").
|
* (i.e. try "MB", then "kB", then "bytes").
|
||||||
*/
|
*/
|
||||||
private function factorizeSizes(int $size, int $limit, bool $binaryFormat)
|
private function factorizeSizes(int $size, int $limit, bool $binaryFormat): array
|
||||||
{
|
{
|
||||||
if ($binaryFormat) {
|
if ($binaryFormat) {
|
||||||
$coef = self::MIB_BYTES;
|
$coef = self::MIB_BYTES;
|
||||||
|
@ -225,7 +225,7 @@ class IbanValidator extends ConstraintValidator
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function toBigInt($string)
|
private static function toBigInt(string $string): string
|
||||||
{
|
{
|
||||||
$chars = str_split($string);
|
$chars = str_split($string);
|
||||||
$bigInt = '';
|
$bigInt = '';
|
||||||
@ -245,7 +245,7 @@ class IbanValidator extends ConstraintValidator
|
|||||||
return $bigInt;
|
return $bigInt;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function bigModulo97($bigInt)
|
private static function bigModulo97(string $bigInt): int
|
||||||
{
|
{
|
||||||
$parts = str_split($bigInt, 7);
|
$parts = str_split($bigInt, 7);
|
||||||
$rest = 0;
|
$rest = 0;
|
||||||
|
@ -15,6 +15,7 @@ use Symfony\Component\Translation\TranslatorInterface as LegacyTranslatorInterfa
|
|||||||
use Symfony\Component\Validator\Constraint;
|
use Symfony\Component\Validator\Constraint;
|
||||||
use Symfony\Component\Validator\ConstraintViolation;
|
use Symfony\Component\Validator\ConstraintViolation;
|
||||||
use Symfony\Component\Validator\ConstraintViolationList;
|
use Symfony\Component\Validator\ConstraintViolationList;
|
||||||
|
use Symfony\Component\Validator\ConstraintViolationListInterface;
|
||||||
use Symfony\Component\Validator\Mapping\ClassMetadataInterface;
|
use Symfony\Component\Validator\Mapping\ClassMetadataInterface;
|
||||||
use Symfony\Component\Validator\Mapping\MemberMetadata;
|
use Symfony\Component\Validator\Mapping\MemberMetadata;
|
||||||
use Symfony\Component\Validator\Mapping\MetadataInterface;
|
use Symfony\Component\Validator\Mapping\MetadataInterface;
|
||||||
@ -22,6 +23,7 @@ use Symfony\Component\Validator\Mapping\PropertyMetadataInterface;
|
|||||||
use Symfony\Component\Validator\Util\PropertyPath;
|
use Symfony\Component\Validator\Util\PropertyPath;
|
||||||
use Symfony\Component\Validator\Validator\ValidatorInterface;
|
use Symfony\Component\Validator\Validator\ValidatorInterface;
|
||||||
use Symfony\Component\Validator\Violation\ConstraintViolationBuilder;
|
use Symfony\Component\Validator\Violation\ConstraintViolationBuilder;
|
||||||
|
use Symfony\Component\Validator\Violation\ConstraintViolationBuilderInterface;
|
||||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -200,7 +202,7 @@ class ExecutionContext implements ExecutionContextInterface
|
|||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function buildViolation($message, array $parameters = [])
|
public function buildViolation($message, array $parameters = []): ConstraintViolationBuilderInterface
|
||||||
{
|
{
|
||||||
return new ConstraintViolationBuilder(
|
return new ConstraintViolationBuilder(
|
||||||
$this->violations,
|
$this->violations,
|
||||||
@ -218,7 +220,7 @@ class ExecutionContext implements ExecutionContextInterface
|
|||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function getViolations()
|
public function getViolations(): ConstraintViolationListInterface
|
||||||
{
|
{
|
||||||
return $this->violations;
|
return $this->violations;
|
||||||
}
|
}
|
||||||
@ -226,7 +228,7 @@ class ExecutionContext implements ExecutionContextInterface
|
|||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function getValidator()
|
public function getValidator(): ValidatorInterface
|
||||||
{
|
{
|
||||||
return $this->validator;
|
return $this->validator;
|
||||||
}
|
}
|
||||||
@ -258,7 +260,7 @@ class ExecutionContext implements ExecutionContextInterface
|
|||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function getMetadata()
|
public function getMetadata(): ?MetadataInterface
|
||||||
{
|
{
|
||||||
return $this->metadata;
|
return $this->metadata;
|
||||||
}
|
}
|
||||||
@ -266,12 +268,12 @@ class ExecutionContext implements ExecutionContextInterface
|
|||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function getGroup()
|
public function getGroup(): ?string
|
||||||
{
|
{
|
||||||
return $this->group;
|
return $this->group;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getConstraint()
|
public function getConstraint(): ?Constraint
|
||||||
{
|
{
|
||||||
return $this->constraint;
|
return $this->constraint;
|
||||||
}
|
}
|
||||||
@ -279,7 +281,7 @@ class ExecutionContext implements ExecutionContextInterface
|
|||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function getClassName()
|
public function getClassName(): ?string
|
||||||
{
|
{
|
||||||
return $this->metadata instanceof MemberMetadata || $this->metadata instanceof ClassMetadataInterface ? $this->metadata->getClassName() : null;
|
return $this->metadata instanceof MemberMetadata || $this->metadata instanceof ClassMetadataInterface ? $this->metadata->getClassName() : null;
|
||||||
}
|
}
|
||||||
@ -287,7 +289,7 @@ class ExecutionContext implements ExecutionContextInterface
|
|||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function getPropertyName()
|
public function getPropertyName(): ?string
|
||||||
{
|
{
|
||||||
return $this->metadata instanceof PropertyMetadataInterface ? $this->metadata->getPropertyName() : null;
|
return $this->metadata instanceof PropertyMetadataInterface ? $this->metadata->getPropertyName() : null;
|
||||||
}
|
}
|
||||||
@ -295,7 +297,7 @@ class ExecutionContext implements ExecutionContextInterface
|
|||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function getPropertyPath($subPath = '')
|
public function getPropertyPath($subPath = ''): string
|
||||||
{
|
{
|
||||||
return PropertyPath::append($this->propertyPath, $subPath);
|
return PropertyPath::append($this->propertyPath, $subPath);
|
||||||
}
|
}
|
||||||
@ -315,7 +317,7 @@ class ExecutionContext implements ExecutionContextInterface
|
|||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function isGroupValidated($cacheKey, $groupHash)
|
public function isGroupValidated($cacheKey, $groupHash): bool
|
||||||
{
|
{
|
||||||
return isset($this->validatedObjects[$cacheKey][$groupHash]);
|
return isset($this->validatedObjects[$cacheKey][$groupHash]);
|
||||||
}
|
}
|
||||||
@ -331,7 +333,7 @@ class ExecutionContext implements ExecutionContextInterface
|
|||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function isConstraintValidated($cacheKey, $constraintHash)
|
public function isConstraintValidated($cacheKey, $constraintHash): bool
|
||||||
{
|
{
|
||||||
return isset($this->validatedConstraints[$cacheKey.':'.$constraintHash]);
|
return isset($this->validatedConstraints[$cacheKey.':'.$constraintHash]);
|
||||||
}
|
}
|
||||||
@ -347,7 +349,7 @@ class ExecutionContext implements ExecutionContextInterface
|
|||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function isObjectInitialized($cacheKey)
|
public function isObjectInitialized($cacheKey): bool
|
||||||
{
|
{
|
||||||
return isset($this->initializedObjects[$cacheKey]);
|
return isset($this->initializedObjects[$cacheKey]);
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,7 @@ final class DoctrineCache implements CacheInterface
|
|||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function has($class)
|
public function has($class): bool
|
||||||
{
|
{
|
||||||
return $this->cache->contains($class);
|
return $this->cache->contains($class);
|
||||||
}
|
}
|
||||||
|
@ -236,7 +236,7 @@ class ConstraintViolationAssertion
|
|||||||
private $constraint;
|
private $constraint;
|
||||||
private $cause;
|
private $cause;
|
||||||
|
|
||||||
public function __construct(ExecutionContextInterface $context, $message, Constraint $constraint = null, array $assertions = [])
|
public function __construct(ExecutionContextInterface $context, string $message, Constraint $constraint = null, array $assertions = [])
|
||||||
{
|
{
|
||||||
$this->context = $context;
|
$this->context = $context;
|
||||||
$this->message = $message;
|
$this->message = $message;
|
||||||
@ -244,14 +244,14 @@ class ConstraintViolationAssertion
|
|||||||
$this->assertions = $assertions;
|
$this->assertions = $assertions;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function atPath($path)
|
public function atPath(string $path)
|
||||||
{
|
{
|
||||||
$this->propertyPath = $path;
|
$this->propertyPath = $path;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setParameter($key, $value)
|
public function setParameter(string $key, $value)
|
||||||
{
|
{
|
||||||
$this->parameters[$key] = $value;
|
$this->parameters[$key] = $value;
|
||||||
|
|
||||||
@ -279,14 +279,14 @@ class ConstraintViolationAssertion
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setPlural($number)
|
public function setPlural(int $number)
|
||||||
{
|
{
|
||||||
$this->plural = $number;
|
$this->plural = $number;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setCode($code)
|
public function setCode(string $code)
|
||||||
{
|
{
|
||||||
$this->code = $code;
|
$this->code = $code;
|
||||||
|
|
||||||
@ -300,7 +300,7 @@ class ConstraintViolationAssertion
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function buildNextViolation($message)
|
public function buildNextViolation(string $message): self
|
||||||
{
|
{
|
||||||
$assertions = $this->assertions;
|
$assertions = $this->assertions;
|
||||||
$assertions[] = $this;
|
$assertions[] = $this;
|
||||||
@ -328,7 +328,7 @@ class ConstraintViolationAssertion
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getViolation()
|
private function getViolation(): ConstraintViolation
|
||||||
{
|
{
|
||||||
return new ConstraintViolation(
|
return new ConstraintViolation(
|
||||||
$this->message,
|
$this->message,
|
||||||
|
@ -57,7 +57,7 @@ class LegacyTranslatorProxy implements LegacyTranslatorInterface, TranslatorInte
|
|||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function getLocale()
|
public function getLocale(): string
|
||||||
{
|
{
|
||||||
return $this->translator->getLocale();
|
return $this->translator->getLocale();
|
||||||
}
|
}
|
||||||
@ -65,7 +65,7 @@ class LegacyTranslatorProxy implements LegacyTranslatorInterface, TranslatorInte
|
|||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function trans($id, array $parameters = [], $domain = null, $locale = null)
|
public function trans($id, array $parameters = [], $domain = null, $locale = null): string
|
||||||
{
|
{
|
||||||
return $this->translator->trans($id, $parameters, $domain, $locale);
|
return $this->translator->trans($id, $parameters, $domain, $locale);
|
||||||
}
|
}
|
||||||
@ -73,7 +73,7 @@ class LegacyTranslatorProxy implements LegacyTranslatorInterface, TranslatorInte
|
|||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function transChoice($id, $number, array $parameters = [], $domain = null, $locale = null)
|
public function transChoice($id, $number, array $parameters = [], $domain = null, $locale = null): string
|
||||||
{
|
{
|
||||||
return $this->translator->trans($id, ['%count%' => $number] + $parameters, $domain, $locale);
|
return $this->translator->trans($id, ['%count%' => $number] + $parameters, $domain, $locale);
|
||||||
}
|
}
|
||||||
|
@ -25,8 +25,6 @@ final class Validation
|
|||||||
*
|
*
|
||||||
* If you want to configure the validator, use
|
* If you want to configure the validator, use
|
||||||
* {@link createValidatorBuilder()} instead.
|
* {@link createValidatorBuilder()} instead.
|
||||||
*
|
|
||||||
* @return ValidatorInterface The new validator
|
|
||||||
*/
|
*/
|
||||||
public static function createValidator(): ValidatorInterface
|
public static function createValidator(): ValidatorInterface
|
||||||
{
|
{
|
||||||
@ -35,8 +33,6 @@ final class Validation
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a configurable builder for validator objects.
|
* Creates a configurable builder for validator objects.
|
||||||
*
|
|
||||||
* @return ValidatorBuilderInterface The new builder
|
|
||||||
*/
|
*/
|
||||||
public static function createValidatorBuilder(): ValidatorBuilder
|
public static function createValidatorBuilder(): ValidatorBuilder
|
||||||
{
|
{
|
||||||
|
@ -41,12 +41,11 @@ class Caster
|
|||||||
* Casts objects to arrays and adds the dynamic property prefix.
|
* Casts objects to arrays and adds the dynamic property prefix.
|
||||||
*
|
*
|
||||||
* @param object $obj The object to cast
|
* @param object $obj The object to cast
|
||||||
* @param string $class The class of the object
|
|
||||||
* @param bool $hasDebugInfo Whether the __debugInfo method exists on $obj or not
|
* @param bool $hasDebugInfo Whether the __debugInfo method exists on $obj or not
|
||||||
*
|
*
|
||||||
* @return array The array-cast of the object, with prefixed dynamic properties
|
* @return array The array-cast of the object, with prefixed dynamic properties
|
||||||
*/
|
*/
|
||||||
public static function castObject($obj, $class, $hasDebugInfo = false): array
|
public static function castObject($obj, string $class, bool $hasDebugInfo = false): array
|
||||||
{
|
{
|
||||||
$a = $obj instanceof \Closure ? [] : (array) $obj;
|
$a = $obj instanceof \Closure ? [] : (array) $obj;
|
||||||
|
|
||||||
@ -110,7 +109,7 @@ class Caster
|
|||||||
*
|
*
|
||||||
* @return array The filtered array
|
* @return array The filtered array
|
||||||
*/
|
*/
|
||||||
public static function filter(array $a, $filter, array $listedProperties = [], &$count = 0): array
|
public static function filter(array $a, int $filter, array $listedProperties = [], ?int &$count = 0): array
|
||||||
{
|
{
|
||||||
$count = 0;
|
$count = 0;
|
||||||
|
|
||||||
@ -151,7 +150,7 @@ class Caster
|
|||||||
return $a;
|
return $a;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function castPhpIncompleteClass(\__PHP_Incomplete_Class $c, array $a, Stub $stub, $isNested)
|
public static function castPhpIncompleteClass(\__PHP_Incomplete_Class $c, array $a, Stub $stub, bool $isNested): array
|
||||||
{
|
{
|
||||||
if (isset($a['__PHP_Incomplete_Class_Name'])) {
|
if (isset($a['__PHP_Incomplete_Class_Name'])) {
|
||||||
$stub->class .= '('.$a['__PHP_Incomplete_Class_Name'].')';
|
$stub->class .= '('.$a['__PHP_Incomplete_Class_Name'].')';
|
||||||
|
@ -52,7 +52,7 @@ class DateCaster
|
|||||||
return $filter & Caster::EXCLUDE_VERBOSE ? $i : $i + $a;
|
return $filter & Caster::EXCLUDE_VERBOSE ? $i : $i + $a;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function formatInterval(\DateInterval $i)
|
private static function formatInterval(\DateInterval $i): string
|
||||||
{
|
{
|
||||||
$format = '%R ';
|
$format = '%R ';
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ class MemcachedCaster
|
|||||||
return $a;
|
return $a;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function getNonDefaultOptions(\Memcached $c)
|
private static function getNonDefaultOptions(\Memcached $c): array
|
||||||
{
|
{
|
||||||
self::$defaultOptions = self::$defaultOptions ?? self::discoverDefaultOptions();
|
self::$defaultOptions = self::$defaultOptions ?? self::discoverDefaultOptions();
|
||||||
self::$optionConstants = self::$optionConstants ?? self::getOptionConstants();
|
self::$optionConstants = self::$optionConstants ?? self::getOptionConstants();
|
||||||
@ -48,7 +48,7 @@ class MemcachedCaster
|
|||||||
return $nonDefaultOptions;
|
return $nonDefaultOptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function discoverDefaultOptions()
|
private static function discoverDefaultOptions(): array
|
||||||
{
|
{
|
||||||
$defaultMemcached = new \Memcached();
|
$defaultMemcached = new \Memcached();
|
||||||
$defaultMemcached->addServer('127.0.0.1', 11211);
|
$defaultMemcached->addServer('127.0.0.1', 11211);
|
||||||
@ -63,7 +63,7 @@ class MemcachedCaster
|
|||||||
return $defaultOptions;
|
return $defaultOptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function getOptionConstants()
|
private static function getOptionConstants(): array
|
||||||
{
|
{
|
||||||
$reflectedMemcached = new \ReflectionClass(\Memcached::class);
|
$reflectedMemcached = new \ReflectionClass(\Memcached::class);
|
||||||
|
|
||||||
|
@ -361,7 +361,7 @@ class ReflectionCaster
|
|||||||
return $signature;
|
return $signature;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function addExtra(&$a, \Reflector $c)
|
private static function addExtra(array &$a, \Reflector $c)
|
||||||
{
|
{
|
||||||
$x = isset($a[Caster::PREFIX_VIRTUAL.'extra']) ? $a[Caster::PREFIX_VIRTUAL.'extra']->value : [];
|
$x = isset($a[Caster::PREFIX_VIRTUAL.'extra']) ? $a[Caster::PREFIX_VIRTUAL.'extra']->value : [];
|
||||||
|
|
||||||
@ -377,7 +377,7 @@ class ReflectionCaster
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function addMap(&$a, \Reflector $c, $map, $prefix = Caster::PREFIX_VIRTUAL)
|
private static function addMap(array &$a, \Reflector $c, array $map, string $prefix = Caster::PREFIX_VIRTUAL)
|
||||||
{
|
{
|
||||||
foreach ($map as $k => $m) {
|
foreach ($map as $k => $m) {
|
||||||
if (method_exists($c, $m) && false !== ($m = $c->$m()) && null !== $m) {
|
if (method_exists($c, $m) && false !== ($m = $c->$m()) && null !== $m) {
|
||||||
|
@ -195,7 +195,7 @@ class SplCaster
|
|||||||
return $a;
|
return $a;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function castSplArray($c, array $a, Stub $stub, $isNested)
|
private static function castSplArray($c, array $a, Stub $stub, bool $isNested): array
|
||||||
{
|
{
|
||||||
$prefix = Caster::PREFIX_VIRTUAL;
|
$prefix = Caster::PREFIX_VIRTUAL;
|
||||||
$class = $stub->class;
|
$class = $stub->class;
|
||||||
|
@ -76,7 +76,7 @@ trait VarDumperTestTrait
|
|||||||
return rtrim($dumper->dump($data, true));
|
return rtrim($dumper->dump($data, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
private function prepareExpectation($expected, int $filter)
|
private function prepareExpectation($expected, int $filter): string
|
||||||
{
|
{
|
||||||
if (!\is_string($expected)) {
|
if (!\is_string($expected)) {
|
||||||
$expected = $this->getDump($expected, null, $filter);
|
$expected = $this->getDump($expected, null, $filter);
|
||||||
|
@ -61,7 +61,7 @@ class GraphvizDumper implements DumperInterface
|
|||||||
/**
|
/**
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
protected function findPlaces(Definition $definition, Marking $marking = null)
|
protected function findPlaces(Definition $definition, Marking $marking = null): array
|
||||||
{
|
{
|
||||||
$workflowMetadata = $definition->getMetadataStore();
|
$workflowMetadata = $definition->getMetadataStore();
|
||||||
|
|
||||||
@ -96,7 +96,7 @@ class GraphvizDumper implements DumperInterface
|
|||||||
/**
|
/**
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
protected function findTransitions(Definition $definition)
|
protected function findTransitions(Definition $definition): array
|
||||||
{
|
{
|
||||||
$workflowMetadata = $definition->getMetadataStore();
|
$workflowMetadata = $definition->getMetadataStore();
|
||||||
|
|
||||||
@ -124,7 +124,7 @@ class GraphvizDumper implements DumperInterface
|
|||||||
/**
|
/**
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
protected function addPlaces(array $places)
|
protected function addPlaces(array $places): string
|
||||||
{
|
{
|
||||||
$code = '';
|
$code = '';
|
||||||
|
|
||||||
@ -145,7 +145,7 @@ class GraphvizDumper implements DumperInterface
|
|||||||
/**
|
/**
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
protected function addTransitions(array $transitions)
|
protected function addTransitions(array $transitions): string
|
||||||
{
|
{
|
||||||
$code = '';
|
$code = '';
|
||||||
|
|
||||||
@ -159,7 +159,7 @@ class GraphvizDumper implements DumperInterface
|
|||||||
/**
|
/**
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
protected function findEdges(Definition $definition)
|
protected function findEdges(Definition $definition): array
|
||||||
{
|
{
|
||||||
$workflowMetadata = $definition->getMetadataStore();
|
$workflowMetadata = $definition->getMetadataStore();
|
||||||
|
|
||||||
@ -192,7 +192,7 @@ class GraphvizDumper implements DumperInterface
|
|||||||
/**
|
/**
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
protected function addEdges(array $edges)
|
protected function addEdges(array $edges): string
|
||||||
{
|
{
|
||||||
$code = '';
|
$code = '';
|
||||||
|
|
||||||
@ -216,7 +216,7 @@ class GraphvizDumper implements DumperInterface
|
|||||||
/**
|
/**
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
protected function startDot(array $options)
|
protected function startDot(array $options): string
|
||||||
{
|
{
|
||||||
return sprintf("digraph workflow {\n %s\n node [%s];\n edge [%s];\n\n",
|
return sprintf("digraph workflow {\n %s\n node [%s];\n edge [%s];\n\n",
|
||||||
$this->addOptions($options['graph']),
|
$this->addOptions($options['graph']),
|
||||||
@ -228,7 +228,7 @@ class GraphvizDumper implements DumperInterface
|
|||||||
/**
|
/**
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
protected function endDot()
|
protected function endDot(): string
|
||||||
{
|
{
|
||||||
return "}\n";
|
return "}\n";
|
||||||
}
|
}
|
||||||
@ -236,7 +236,7 @@ class GraphvizDumper implements DumperInterface
|
|||||||
/**
|
/**
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
protected function dotize($id)
|
protected function dotize(string $id): string
|
||||||
{
|
{
|
||||||
return hash('sha1', $id);
|
return hash('sha1', $id);
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,7 @@ class StateMachineGraphvizDumper extends GraphvizDumper
|
|||||||
/**
|
/**
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
protected function findEdges(Definition $definition)
|
protected function findEdges(Definition $definition): array
|
||||||
{
|
{
|
||||||
$workflowMetadata = $definition->getMetadataStore();
|
$workflowMetadata = $definition->getMetadataStore();
|
||||||
|
|
||||||
@ -82,7 +82,7 @@ class StateMachineGraphvizDumper extends GraphvizDumper
|
|||||||
/**
|
/**
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
protected function addEdges(array $edges)
|
protected function addEdges(array $edges): string
|
||||||
{
|
{
|
||||||
$code = '';
|
$code = '';
|
||||||
|
|
||||||
|
@ -250,7 +250,7 @@ class Workflow implements WorkflowInterface
|
|||||||
return $this->definition->getMetadataStore();
|
return $this->definition->getMetadataStore();
|
||||||
}
|
}
|
||||||
|
|
||||||
private function buildTransitionBlockerListForTransition($subject, Marking $marking, Transition $transition)
|
private function buildTransitionBlockerListForTransition($subject, Marking $marking, Transition $transition): TransitionBlockerList
|
||||||
{
|
{
|
||||||
foreach ($transition->getFroms() as $place) {
|
foreach ($transition->getFroms() as $place) {
|
||||||
if (!$marking->has($place)) {
|
if (!$marking->has($place)) {
|
||||||
|
@ -137,7 +137,7 @@ EOF
|
|||||||
return ['file' => $file, 'valid' => true];
|
return ['file' => $file, 'valid' => true];
|
||||||
}
|
}
|
||||||
|
|
||||||
private function display(SymfonyStyle $io, array $files)
|
private function display(SymfonyStyle $io, array $files): int
|
||||||
{
|
{
|
||||||
switch ($this->format) {
|
switch ($this->format) {
|
||||||
case 'txt':
|
case 'txt':
|
||||||
@ -149,7 +149,7 @@ EOF
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function displayTxt(SymfonyStyle $io, array $filesInfo)
|
private function displayTxt(SymfonyStyle $io, array $filesInfo): int
|
||||||
{
|
{
|
||||||
$countFiles = \count($filesInfo);
|
$countFiles = \count($filesInfo);
|
||||||
$erroredFiles = 0;
|
$erroredFiles = 0;
|
||||||
@ -178,7 +178,7 @@ EOF
|
|||||||
return min($erroredFiles, 1);
|
return min($erroredFiles, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function displayJson(SymfonyStyle $io, array $filesInfo)
|
private function displayJson(SymfonyStyle $io, array $filesInfo): int
|
||||||
{
|
{
|
||||||
$errors = 0;
|
$errors = 0;
|
||||||
|
|
||||||
@ -198,7 +198,7 @@ EOF
|
|||||||
return min($errors, 1);
|
return min($errors, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getFiles(string $fileOrDirectory)
|
private function getFiles(string $fileOrDirectory): iterable
|
||||||
{
|
{
|
||||||
if (is_file($fileOrDirectory)) {
|
if (is_file($fileOrDirectory)) {
|
||||||
yield new \SplFileInfo($fileOrDirectory);
|
yield new \SplFileInfo($fileOrDirectory);
|
||||||
@ -225,7 +225,7 @@ EOF
|
|||||||
return $yaml;
|
return $yaml;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getParser()
|
private function getParser(): Parser
|
||||||
{
|
{
|
||||||
if (!$this->parser) {
|
if (!$this->parser) {
|
||||||
$this->parser = new Parser();
|
$this->parser = new Parser();
|
||||||
@ -234,7 +234,7 @@ EOF
|
|||||||
return $this->parser;
|
return $this->parser;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getDirectoryIterator(string $directory)
|
private function getDirectoryIterator(string $directory): iterable
|
||||||
{
|
{
|
||||||
$default = function ($directory) {
|
$default = function ($directory) {
|
||||||
return new \RecursiveIteratorIterator(
|
return new \RecursiveIteratorIterator(
|
||||||
@ -250,7 +250,7 @@ EOF
|
|||||||
return $default($directory);
|
return $default($directory);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function isReadable(string $fileOrDirectory)
|
private function isReadable(string $fileOrDirectory): bool
|
||||||
{
|
{
|
||||||
$default = function ($fileOrDirectory) {
|
$default = function ($fileOrDirectory) {
|
||||||
return is_readable($fileOrDirectory);
|
return is_readable($fileOrDirectory);
|
||||||
|
@ -1134,7 +1134,7 @@ class Parser
|
|||||||
throw new ParseException(sprintf('Tags support is not enabled. You must use the flag "Yaml::PARSE_CUSTOM_TAGS" to use "%s".', $matches['tag']), $this->getRealCurrentLineNb() + 1, $value, $this->filename);
|
throw new ParseException(sprintf('Tags support is not enabled. You must use the flag "Yaml::PARSE_CUSTOM_TAGS" to use "%s".', $matches['tag']), $this->getRealCurrentLineNb() + 1, $value, $this->filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function parseQuotedString($yaml)
|
private function parseQuotedString(string $yaml): ?string
|
||||||
{
|
{
|
||||||
if ('' === $yaml || ('"' !== $yaml[0] && "'" !== $yaml[0])) {
|
if ('' === $yaml || ('"' !== $yaml[0] && "'" !== $yaml[0])) {
|
||||||
throw new \InvalidArgumentException(sprintf('"%s" is not a quoted string.', $yaml));
|
throw new \InvalidArgumentException(sprintf('"%s" is not a quoted string.', $yaml));
|
||||||
@ -1223,7 +1223,7 @@ class Parser
|
|||||||
return implode("\n", $lines);
|
return implode("\n", $lines);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function lexInlineSequence($yaml)
|
private function lexInlineSequence(string $yaml): string
|
||||||
{
|
{
|
||||||
if ('' === $yaml || '[' !== $yaml[0]) {
|
if ('' === $yaml || '[' !== $yaml[0]) {
|
||||||
throw new \InvalidArgumentException(sprintf('"%s" is not a sequence.', $yaml));
|
throw new \InvalidArgumentException(sprintf('"%s" is not a sequence.', $yaml));
|
||||||
|
Reference in New Issue
Block a user