Thanks to visit codestin.com
Credit goes to github.com

Skip to content

add parameter type declarations to private methods #32786

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/Symfony/Bridge/Twig/Command/DebugCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ private function displayGeneralText(SymfonyStyle $io, string $filter = null)
}
}

private function displayGeneralJson(SymfonyStyle $io, $filter)
private function displayGeneralJson(SymfonyStyle $io, ?string $filter)
{
$decorated = $io->isDecorated();
$types = ['functions', 'filters', 'tests', 'globals'];
Expand Down Expand Up @@ -302,7 +302,7 @@ private function getLoaderPaths(string $name = null): array
return $loaderPaths;
}

private function getMetadata($type, $entity)
private function getMetadata(string $type, $entity)
{
if ('globals' === $type) {
return $entity;
Expand Down Expand Up @@ -358,7 +358,7 @@ private function getMetadata($type, $entity)
}
}

private function getPrettyMetadata($type, $entity, $decorated)
private function getPrettyMetadata(string $type, $entity, bool $decorated)
{
if ('tests' === $type) {
return '';
Expand Down
12 changes: 6 additions & 6 deletions src/Symfony/Bridge/Twig/Command/LintCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ protected function findFiles($filename)
throw new RuntimeException(sprintf('File or directory "%s" is not readable', $filename));
}

private function validate($template, $file)
private function validate(string $template, $file)
{
$realLoader = $this->twig->getLoader();
try {
Expand All @@ -136,7 +136,7 @@ private function validate($template, $file)
return ['template' => $template, 'file' => $file, 'valid' => true];
}

private function display(InputInterface $input, OutputInterface $output, SymfonyStyle $io, $files)
private function display(InputInterface $input, OutputInterface $output, SymfonyStyle $io, array $files)
{
switch ($input->getOption('format')) {
case 'txt':
Expand All @@ -148,7 +148,7 @@ private function display(InputInterface $input, OutputInterface $output, Symfony
}
}

private function displayTxt(OutputInterface $output, SymfonyStyle $io, $filesInfo)
private function displayTxt(OutputInterface $output, SymfonyStyle $io, array $filesInfo)
{
$errors = 0;

Expand All @@ -170,7 +170,7 @@ private function displayTxt(OutputInterface $output, SymfonyStyle $io, $filesInf
return min($errors, 1);
}

private function displayJson(OutputInterface $output, $filesInfo)
private function displayJson(OutputInterface $output, array $filesInfo)
{
$errors = 0;

Expand All @@ -189,7 +189,7 @@ private function displayJson(OutputInterface $output, $filesInfo)
return min($errors, 1);
}

private function renderException(OutputInterface $output, $template, Error $exception, $file = null)
private function renderException(OutputInterface $output, string $template, Error $exception, string $file = null)
{
$line = $exception->getTemplateLine();

Expand All @@ -212,7 +212,7 @@ private function renderException(OutputInterface $output, $template, Error $exce
}
}

private function getContext($template, $line, $context = 3)
private function getContext(string $template, int $line, int $context = 3)
{
$lines = explode("\n", $template);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ public function getProfile()
return $this->profile;
}

private function getComputedData($index)
private function getComputedData(string $index)
{
if (null === $this->computed) {
$this->computed = $this->computeData($this->getProfile());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public function getPriority()
/**
* @return bool
*/
private function isNamedArguments($arguments)
private function isNamedArguments(Node $arguments)
{
foreach ($arguments as $name => $node) {
if (!\is_int($name)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,9 @@ public function findAllTemplates()
/**
* Find templates in the given directory.
*
* @param string $dir The folder where to look for templates
*
* @return TemplateReferenceInterface[]
*/
private function findTemplatesInFolder($dir)
private function findTemplatesInFolder(string $dir)
{
$templates = [];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$io->table($headers, $rows);
}

private function formatState($state): string
private function formatState(int $state): string
{
if (self::MESSAGE_MISSING === $state) {
return '<error> missing </error>';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ protected function describeEventDispatcherListeners(EventDispatcherInterface $ev
*/
protected function describeCallable($callable, array $options = [])
{
$this->writeData($this->getCallableData($callable, $options), $options);
$this->writeData($this->getCallableData($callable), $options);
}

/**
Expand Down Expand Up @@ -315,7 +315,7 @@ private function getEventDispatcherListenersData(EventDispatcherInterface $event
return $data;
}

private function getCallableData($callable, array $options = []): array
private function getCallableData($callable): array
{
$data = [];

Expand Down Expand Up @@ -386,7 +386,7 @@ private function getCallableData($callable, array $options = []): array
throw new \InvalidArgumentException('Callable is not describable.');
}

private function describeValue($value, $omitTags, $showArguments)
private function describeValue($value, bool $omitTags, bool $showArguments)
{
if (\is_array($value)) {
$data = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@ protected function describeCallable($callable, array $options = [])
$this->writeText($this->formatCallable($callable), $options);
}

private function renderEventListenerTable(EventDispatcherInterface $eventDispatcher, $event, array $eventListeners, SymfonyStyle $io)
private function renderEventListenerTable(EventDispatcherInterface $eventDispatcher, string $event, array $eventListeners, SymfonyStyle $io)
{
$tableHeaders = ['Order', 'Callable', 'Priority'];
$tableRows = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ private function getContainerAliasDocument(Alias $alias, string $id = null): \DO
return $dom;
}

private function getContainerParameterDocument($parameter, $options = []): \DOMDocument
private function getContainerParameterDocument($parameter, array $options = []): \DOMDocument
{
$dom = new \DOMDocument('1.0', 'UTF-8');
$dom->appendChild($parameterXML = $dom->createElement('parameter'));
Expand Down Expand Up @@ -485,7 +485,7 @@ private function getEventDispatcherListenersDocument(EventDispatcherInterface $e
return $dom;
}

private function appendEventListenerDocument(EventDispatcherInterface $eventDispatcher, $event, \DOMElement $element, array $eventListeners)
private function appendEventListenerDocument(EventDispatcherInterface $eventDispatcher, string $event, \DOMElement $element, array $eventListeners)
{
foreach ($eventListeners as $listener) {
$callableXML = $this->getCallableDocument($listener);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1060,7 +1060,7 @@ private function registerAssetsConfiguration(array $config, ContainerBuilder $co
/**
* Returns a definition for an asset package.
*/
private function createPackageDefinition($basePath, array $baseUrls, Reference $version)
private function createPackageDefinition(?string $basePath, array $baseUrls, Reference $version)
{
if ($basePath && $baseUrls) {
throw new \LogicException('An asset package cannot have base URLs and base paths.');
Expand All @@ -1076,7 +1076,7 @@ private function createPackageDefinition($basePath, array $baseUrls, Reference $
return $package;
}

private function createVersion(ContainerBuilder $container, $version, $format, $jsonManifestPath, $name)
private function createVersion(ContainerBuilder $container, ?string $version, ?string $format, ?string $jsonManifestPath, string $name)
{
// Configuration prevents $version and $jsonManifestPath from being set
if (null !== $version) {
Expand Down Expand Up @@ -1331,7 +1331,7 @@ private function registerValidatorMapping(ContainerBuilder $container, array $co
$this->registerMappingFilesFromConfig($container, $config, $fileRecorder);
}

private function registerMappingFilesFromDir($dir, callable $fileRecorder)
private function registerMappingFilesFromDir(string $dir, callable $fileRecorder)
{
foreach (Finder::create()->followLinks()->files()->in($dir)->name('/\.(xml|ya?ml)$/')->sortByName() as $file) {
$fileRecorder($file->getExtension(), $file->getRealPath());
Expand All @@ -1355,7 +1355,7 @@ private function registerMappingFilesFromConfig(ContainerBuilder $container, arr
}
}

private function registerAnnotationsConfiguration(array $config, ContainerBuilder $container, $loader)
private function registerAnnotationsConfiguration(array $config, ContainerBuilder $container, LoaderInterface $loader)
{
if (!$this->annotationsConfigEnabled) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public function create(ContainerBuilder $container, $id, $config, $userProvider,
return [$providerId, $listenerId, $entryPointId];
}

private function determineEntryPoint($defaultEntryPointId, array $config)
private function determineEntryPoint(?string $defaultEntryPointId, array $config)
{
if ($defaultEntryPointId) {
// explode if they've configured the entry_point, but there is already one
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ private function createRoleHierarchy(array $config, ContainerBuilder $container)
$container->removeDefinition('security.access.simple_role_voter');
}

private function createAuthorization($config, ContainerBuilder $container)
private function createAuthorization(array $config, ContainerBuilder $container)
{
foreach ($config['access_control'] as $access) {
$matcher = $this->createRequestMatcher(
Expand Down Expand Up @@ -206,7 +206,7 @@ private function createAuthorization($config, ContainerBuilder $container)
}
}

private function createFirewalls($config, ContainerBuilder $container)
private function createFirewalls(array $config, ContainerBuilder $container)
{
if (!isset($config['firewalls'])) {
return;
Expand Down Expand Up @@ -273,7 +273,7 @@ private function createFirewalls($config, ContainerBuilder $container)
}
}

private function createFirewall(ContainerBuilder $container, $id, $firewall, &$authenticationProviders, $providerIds, $configId)
private function createFirewall(ContainerBuilder $container, string $id, array $firewall, array &$authenticationProviders, array $providerIds, string $configId)
{
$config = $container->setDefinition($configId, new ChildDefinition('security.firewall.config'));
$config->replaceArgument(0, $id);
Expand Down Expand Up @@ -406,7 +406,7 @@ private function createFirewall(ContainerBuilder $container, $id, $firewall, &$a
// Switch user listener
if (isset($firewall['switch_user'])) {
$listenerKeys[] = 'switch_user';
$listeners[] = new Reference($this->createSwitchUserListener($container, $id, $firewall['switch_user'], $defaultProvider, $firewall['stateless'], $providerIds));
$listeners[] = new Reference($this->createSwitchUserListener($container, $id, $firewall['switch_user'], $defaultProvider, $firewall['stateless']));
}

// Access listener
Expand Down Expand Up @@ -439,7 +439,7 @@ private function createFirewall(ContainerBuilder $container, $id, $firewall, &$a
return [$matcher, $listeners, $exceptionListener, null !== $logoutListenerId ? new Reference($logoutListenerId) : null];
}

private function createContextListener($container, $contextKey)
private function createContextListener(ContainerBuilder $container, string $contextKey)
{
if (isset($this->contextListeners[$contextKey])) {
return $this->contextListeners[$contextKey];
Expand All @@ -452,7 +452,7 @@ private function createContextListener($container, $contextKey)
return $this->contextListeners[$contextKey] = $listenerId;
}

private function createAuthenticationListeners($container, $id, $firewall, &$authenticationProviders, $defaultProvider = null, array $providerIds, $defaultEntryPoint)
private function createAuthenticationListeners(ContainerBuilder $container, string $id, array $firewall, array &$authenticationProviders, ?string $defaultProvider, array $providerIds, ?string $defaultEntryPoint)
{
$listeners = [];
$hasListeners = false;
Expand Down Expand Up @@ -519,11 +519,11 @@ private function createAuthenticationListeners($container, $id, $firewall, &$aut
return [$listeners, $defaultEntryPoint];
}

private function createEncoders($encoders, ContainerBuilder $container)
private function createEncoders(array $encoders, ContainerBuilder $container)
{
$encoderMap = [];
foreach ($encoders as $class => $encoder) {
$encoderMap[$class] = $this->createEncoder($encoder, $container);
$encoderMap[$class] = $this->createEncoder($encoder);
}

$container
Expand All @@ -532,7 +532,7 @@ private function createEncoders($encoders, ContainerBuilder $container)
;
}

private function createEncoder($config, ContainerBuilder $container)
private function createEncoder(array $config)
{
// a custom encoder service
if (isset($config['id'])) {
Expand Down Expand Up @@ -624,7 +624,7 @@ private function createEncoder($config, ContainerBuilder $container)
}

// Parses user providers and returns an array of their ids
private function createUserProviders($config, ContainerBuilder $container)
private function createUserProviders(array $config, ContainerBuilder $container)
{
$providerIds = [];
foreach ($config['providers'] as $name => $provider) {
Expand All @@ -636,7 +636,7 @@ private function createUserProviders($config, ContainerBuilder $container)
}

// Parses a <provider> tag and returns the id for the related user provider service
private function createUserDaoProvider($name, $provider, ContainerBuilder $container)
private function createUserDaoProvider(string $name, array $provider, ContainerBuilder $container)
{
$name = $this->getUserProviderId($name);

Expand Down Expand Up @@ -675,12 +675,12 @@ private function createUserDaoProvider($name, $provider, ContainerBuilder $conta
throw new InvalidConfigurationException(sprintf('Unable to create definition for "%s" user provider', $name));
}

private function getUserProviderId($name)
private function getUserProviderId(string $name)
{
return 'security.user.provider.concrete.'.strtolower($name);
}

private function createExceptionListener($container, $config, $id, $defaultEntryPoint, $stateless)
private function createExceptionListener(ContainerBuilder $container, array $config, string $id, ?string $defaultEntryPoint, bool $stateless)
{
$exceptionListenerId = 'security.exception_listener.'.$id;
$listener = $container->setDefinition($exceptionListenerId, new ChildDefinition('security.exception_listener'));
Expand All @@ -698,7 +698,7 @@ private function createExceptionListener($container, $config, $id, $defaultEntry
return $exceptionListenerId;
}

private function createSwitchUserListener($container, $id, $config, $defaultProvider, $stateless, $providerIds)
private function createSwitchUserListener(ContainerBuilder $container, string $id, array $config, string $defaultProvider, bool $stateless)
{
$userProvider = isset($config['provider']) ? $this->getUserProviderId($config['provider']) : $defaultProvider;

Expand All @@ -718,7 +718,7 @@ private function createSwitchUserListener($container, $id, $config, $defaultProv
return $switchUserListenerId;
}

private function createExpression($container, $expression)
private function createExpression(ContainerBuilder $container, string $expression)
{
if (isset($this->expressions[$id = '.security.expression.'.ContainerBuilder::hash($expression)])) {
return $this->expressions[$id];
Expand All @@ -737,7 +737,7 @@ private function createExpression($container, $expression)
return $this->expressions[$id] = new Reference($id);
}

private function createRequestMatcher(ContainerBuilder $container, $path = null, $host = null, int $port = null, $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 = [])
{
if ($methods) {
$methods = array_map('strtoupper', (array) $methods);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,9 @@ public static function getSubscribedServices()
/**
* Find templates in the given directory.
*
* @param string $namespace The namespace for these templates
* @param string $dir The folder where to look for templates
*
* @return array An array of templates
*/
private function findTemplatesInFolder($namespace, $dir)
private function findTemplatesInFolder(string $namespace, string $dir)
{
if (!is_dir($dir)) {
return [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ private function getBundleTemplatePaths(ContainerBuilder $container, array $conf
return $bundleHierarchy;
}

private function normalizeBundleName($name)
private function normalizeBundleName(string $name)
{
if ('Bundle' === substr($name, -6)) {
$name = substr($name, 0, -6);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ private function denyAccessIfProfilerDisabled()
$this->profiler->disable();
}

private function renderWithCspNonces(Request $request, $template, $variables, $code = 200, $headers = ['Content-Type' => 'text/html'])
private function renderWithCspNonces(Request $request, string $template, array $variables, int $code = 200, array $headers = ['Content-Type' => 'text/html'])
{
$response = new Response('', $code, $headers);

Expand Down
Loading