minor #32786 add parameter type declarations to private methods (xabbuh)
This PR was merged into the 4.4 branch.
Discussion
----------
add parameter type declarations to private methods
| Q | A
| ------------- | ---
| Branch? | 4.4
| Bug fix? | no
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets |
| License | MIT
| Doc PR |
Commits
-------
1b2aaa4a06
add parameter type declarations to private methods
This commit is contained in:
commit
f830226271
@ -248,7 +248,7 @@ EOF
|
||||
}
|
||||
}
|
||||
|
||||
private function displayGeneralJson(SymfonyStyle $io, $filter)
|
||||
private function displayGeneralJson(SymfonyStyle $io, ?string $filter)
|
||||
{
|
||||
$decorated = $io->isDecorated();
|
||||
$types = ['functions', 'filters', 'tests', 'globals'];
|
||||
@ -302,7 +302,7 @@ EOF
|
||||
return $loaderPaths;
|
||||
}
|
||||
|
||||
private function getMetadata($type, $entity)
|
||||
private function getMetadata(string $type, $entity)
|
||||
{
|
||||
if ('globals' === $type) {
|
||||
return $entity;
|
||||
@ -358,7 +358,7 @@ EOF
|
||||
}
|
||||
}
|
||||
|
||||
private function getPrettyMetadata($type, $entity, $decorated)
|
||||
private function getPrettyMetadata(string $type, $entity, bool $decorated)
|
||||
{
|
||||
if ('tests' === $type) {
|
||||
return '';
|
||||
|
@ -118,7 +118,7 @@ EOF
|
||||
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 {
|
||||
@ -136,7 +136,7 @@ EOF
|
||||
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':
|
||||
@ -148,7 +148,7 @@ EOF
|
||||
}
|
||||
}
|
||||
|
||||
private function displayTxt(OutputInterface $output, SymfonyStyle $io, $filesInfo)
|
||||
private function displayTxt(OutputInterface $output, SymfonyStyle $io, array $filesInfo)
|
||||
{
|
||||
$errors = 0;
|
||||
|
||||
@ -170,7 +170,7 @@ EOF
|
||||
return min($errors, 1);
|
||||
}
|
||||
|
||||
private function displayJson(OutputInterface $output, $filesInfo)
|
||||
private function displayJson(OutputInterface $output, array $filesInfo)
|
||||
{
|
||||
$errors = 0;
|
||||
|
||||
@ -189,7 +189,7 @@ EOF
|
||||
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();
|
||||
|
||||
@ -212,7 +212,7 @@ EOF
|
||||
}
|
||||
}
|
||||
|
||||
private function getContext($template, $line, $context = 3)
|
||||
private function getContext(string $template, int $line, int $context = 3)
|
||||
{
|
||||
$lines = explode("\n", $template);
|
||||
|
||||
|
@ -147,7 +147,7 @@ class TwigDataCollector extends DataCollector implements LateDataCollectorInterf
|
||||
return $this->profile;
|
||||
}
|
||||
|
||||
private function getComputedData($index)
|
||||
private function getComputedData(string $index)
|
||||
{
|
||||
if (null === $this->computed) {
|
||||
$this->computed = $this->computeData($this->getProfile());
|
||||
|
@ -116,7 +116,7 @@ class TranslationDefaultDomainNodeVisitor extends AbstractNodeVisitor
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
private function isNamedArguments($arguments)
|
||||
private function isNamedArguments(Node $arguments)
|
||||
{
|
||||
foreach ($arguments as $name => $node) {
|
||||
if (!\is_int($name)) {
|
||||
|
@ -70,11 +70,9 @@ class TemplateFinder implements TemplateFinderInterface
|
||||
/**
|
||||
* 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 = [];
|
||||
|
||||
|
@ -295,7 +295,7 @@ EOF
|
||||
$io->table($headers, $rows);
|
||||
}
|
||||
|
||||
private function formatState($state): string
|
||||
private function formatState(int $state): string
|
||||
{
|
||||
if (self::MESSAGE_MISSING === $state) {
|
||||
return '<error> missing </error>';
|
||||
|
@ -165,7 +165,7 @@ class JsonDescriptor extends Descriptor
|
||||
*/
|
||||
protected function describeCallable($callable, array $options = [])
|
||||
{
|
||||
$this->writeData($this->getCallableData($callable, $options), $options);
|
||||
$this->writeData($this->getCallableData($callable), $options);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -315,7 +315,7 @@ class JsonDescriptor extends Descriptor
|
||||
return $data;
|
||||
}
|
||||
|
||||
private function getCallableData($callable, array $options = []): array
|
||||
private function getCallableData($callable): array
|
||||
{
|
||||
$data = [];
|
||||
|
||||
@ -386,7 +386,7 @@ class JsonDescriptor extends Descriptor
|
||||
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 = [];
|
||||
|
@ -503,7 +503,7 @@ class TextDescriptor extends Descriptor
|
||||
$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 = [];
|
||||
|
@ -449,7 +449,7 @@ class XmlDescriptor extends Descriptor
|
||||
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'));
|
||||
@ -485,7 +485,7 @@ class XmlDescriptor extends Descriptor
|
||||
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);
|
||||
|
@ -1060,7 +1060,7 @@ class FrameworkExtension extends Extension
|
||||
/**
|
||||
* 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.');
|
||||
@ -1076,7 +1076,7 @@ class FrameworkExtension extends Extension
|
||||
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) {
|
||||
@ -1331,7 +1331,7 @@ class FrameworkExtension extends Extension
|
||||
$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());
|
||||
@ -1355,7 +1355,7 @@ class FrameworkExtension extends Extension
|
||||
}
|
||||
}
|
||||
|
||||
private function registerAnnotationsConfiguration(array $config, ContainerBuilder $container, $loader)
|
||||
private function registerAnnotationsConfiguration(array $config, ContainerBuilder $container, LoaderInterface $loader)
|
||||
{
|
||||
if (!$this->annotationsConfigEnabled) {
|
||||
return;
|
||||
|
@ -92,7 +92,7 @@ class GuardAuthenticationFactory implements SecurityFactoryInterface
|
||||
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
|
||||
|
@ -176,7 +176,7 @@ class SecurityExtension extends Extension implements PrependExtensionInterface
|
||||
$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(
|
||||
@ -206,7 +206,7 @@ class SecurityExtension extends Extension implements PrependExtensionInterface
|
||||
}
|
||||
}
|
||||
|
||||
private function createFirewalls($config, ContainerBuilder $container)
|
||||
private function createFirewalls(array $config, ContainerBuilder $container)
|
||||
{
|
||||
if (!isset($config['firewalls'])) {
|
||||
return;
|
||||
@ -273,7 +273,7 @@ class SecurityExtension extends Extension implements PrependExtensionInterface
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
@ -406,7 +406,7 @@ class SecurityExtension extends Extension implements PrependExtensionInterface
|
||||
// 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
|
||||
@ -439,7 +439,7 @@ class SecurityExtension extends Extension implements PrependExtensionInterface
|
||||
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];
|
||||
@ -452,7 +452,7 @@ class SecurityExtension extends Extension implements PrependExtensionInterface
|
||||
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;
|
||||
@ -519,11 +519,11 @@ class SecurityExtension extends Extension implements PrependExtensionInterface
|
||||
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
|
||||
@ -532,7 +532,7 @@ class SecurityExtension extends Extension implements PrependExtensionInterface
|
||||
;
|
||||
}
|
||||
|
||||
private function createEncoder($config, ContainerBuilder $container)
|
||||
private function createEncoder(array $config)
|
||||
{
|
||||
// a custom encoder service
|
||||
if (isset($config['id'])) {
|
||||
@ -624,7 +624,7 @@ class SecurityExtension extends Extension implements PrependExtensionInterface
|
||||
}
|
||||
|
||||
// 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) {
|
||||
@ -636,7 +636,7 @@ class SecurityExtension extends Extension implements PrependExtensionInterface
|
||||
}
|
||||
|
||||
// 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);
|
||||
|
||||
@ -675,12 +675,12 @@ class SecurityExtension extends Extension implements PrependExtensionInterface
|
||||
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'));
|
||||
@ -698,7 +698,7 @@ class SecurityExtension extends Extension implements PrependExtensionInterface
|
||||
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;
|
||||
|
||||
@ -718,7 +718,7 @@ class SecurityExtension extends Extension implements PrependExtensionInterface
|
||||
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];
|
||||
@ -737,7 +737,7 @@ class SecurityExtension extends Extension implements PrependExtensionInterface
|
||||
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);
|
||||
|
@ -103,12 +103,9 @@ class TemplateCacheCacheWarmer implements CacheWarmerInterface, ServiceSubscribe
|
||||
/**
|
||||
* 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 [];
|
||||
|
@ -197,7 +197,7 @@ class TwigExtension extends Extension
|
||||
return $bundleHierarchy;
|
||||
}
|
||||
|
||||
private function normalizeBundleName($name)
|
||||
private function normalizeBundleName(string $name)
|
||||
{
|
||||
if ('Bundle' === substr($name, -6)) {
|
||||
$name = substr($name, 0, -6);
|
||||
|
@ -382,7 +382,7 @@ class ProfilerController
|
||||
$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);
|
||||
|
||||
|
@ -186,11 +186,9 @@ class ContentSecurityPolicyHandler
|
||||
/**
|
||||
* Converts a Content-Security-Policy header value into a directive set array.
|
||||
*
|
||||
* @param string $header The header value
|
||||
*
|
||||
* @return array The directive set
|
||||
*/
|
||||
private function parseDirectives($header)
|
||||
private function parseDirectives(string $header)
|
||||
{
|
||||
$directives = [];
|
||||
|
||||
@ -214,7 +212,7 @@ class ContentSecurityPolicyHandler
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private function authorizesInline(array $directivesSet, $type)
|
||||
private function authorizesInline(array $directivesSet, string $type)
|
||||
{
|
||||
if (isset($directivesSet[$type])) {
|
||||
$directives = $directivesSet[$type];
|
||||
|
@ -119,7 +119,7 @@ class WebServerConfig
|
||||
return gethostbyname($localHostname).':'.$this->port;
|
||||
}
|
||||
|
||||
private function findFrontController($documentRoot, $env)
|
||||
private function findFrontController(string $documentRoot, string $env)
|
||||
{
|
||||
$fileNames = $this->getFrontControllerFileNames($env);
|
||||
|
||||
@ -130,7 +130,7 @@ class WebServerConfig
|
||||
}
|
||||
}
|
||||
|
||||
private function getFrontControllerFileNames($env)
|
||||
private function getFrontControllerFileNames(string $env)
|
||||
{
|
||||
return ['app_'.$env.'.php', 'app.php', 'index_'.$env.'.php', 'index.php'];
|
||||
}
|
||||
|
@ -123,7 +123,7 @@ class UrlPackage extends Package
|
||||
return (int) fmod(hexdec(substr(hash('sha256', $path), 0, 10)), \count($this->baseUrls));
|
||||
}
|
||||
|
||||
private function getSslUrls($urls)
|
||||
private function getSslUrls(array $urls)
|
||||
{
|
||||
$sslUrls = [];
|
||||
foreach ($urls as $url) {
|
||||
|
@ -50,7 +50,7 @@ class JsonManifestVersionStrategy implements VersionStrategyInterface
|
||||
return $this->getManifestPath($path) ?: $path;
|
||||
}
|
||||
|
||||
private function getManifestPath($path)
|
||||
private function getManifestPath(string $path)
|
||||
{
|
||||
if (null === $this->manifestData) {
|
||||
if (!file_exists($this->manifestPath)) {
|
||||
|
@ -716,7 +716,7 @@ abstract class Client
|
||||
return $this->request($request->getMethod(), $request->getUri(), $request->getParameters(), $request->getFiles(), $request->getServer(), $request->getContent(), $changeHistory);
|
||||
}
|
||||
|
||||
private function updateServerFromUri($server, $uri)
|
||||
private function updateServerFromUri(array $server, string $uri)
|
||||
{
|
||||
$server['HTTP_HOST'] = $this->extractHost($uri);
|
||||
$scheme = parse_url($uri, PHP_URL_SCHEME);
|
||||
@ -726,7 +726,7 @@ abstract class Client
|
||||
return $server;
|
||||
}
|
||||
|
||||
private function extractHost($uri)
|
||||
private function extractHost(string $uri)
|
||||
{
|
||||
$host = parse_url($uri, PHP_URL_HOST);
|
||||
|
||||
|
@ -145,7 +145,7 @@ class ChainAdapter implements AdapterInterface, CacheInterface, PruneableInterfa
|
||||
return $this->generateItems($this->adapters[0]->getItems($keys), 0);
|
||||
}
|
||||
|
||||
private function generateItems($items, $adapterIndex)
|
||||
private function generateItems(iterable $items, int $adapterIndex)
|
||||
{
|
||||
$missing = [];
|
||||
$misses = [];
|
||||
|
@ -207,7 +207,7 @@ class ProxyAdapter implements AdapterInterface, CacheInterface, PruneableInterfa
|
||||
return $this->pool->commit();
|
||||
}
|
||||
|
||||
private function doSave(CacheItemInterface $item, $method)
|
||||
private function doSave(CacheItemInterface $item, string $method)
|
||||
{
|
||||
if (!$item instanceof CacheItem) {
|
||||
return false;
|
||||
@ -233,7 +233,7 @@ class ProxyAdapter implements AdapterInterface, CacheInterface, PruneableInterfa
|
||||
return $this->pool->$method($innerItem);
|
||||
}
|
||||
|
||||
private function generateItems($items)
|
||||
private function generateItems(iterable $items)
|
||||
{
|
||||
$f = $this->createCacheItem;
|
||||
|
||||
|
@ -298,7 +298,7 @@ class TagAwareAdapter implements TagAwareAdapterInterface, TagAwareCacheInterfac
|
||||
$this->commit();
|
||||
}
|
||||
|
||||
private function generateItems($items, array $tagKeys)
|
||||
private function generateItems(iterable $items, array $tagKeys)
|
||||
{
|
||||
$bufferedItems = $itemTags = [];
|
||||
$f = $this->setCacheItemTags;
|
||||
|
@ -192,7 +192,7 @@ class CachePoolPass implements CompilerPassInterface
|
||||
}
|
||||
}
|
||||
|
||||
private function getNamespace($seed, $id)
|
||||
private function getNamespace(string $seed, string $id)
|
||||
{
|
||||
return substr(str_replace('/', '-', base64_encode(hash('sha256', $id.$seed, true))), 0, 10);
|
||||
}
|
||||
|
@ -169,7 +169,7 @@ abstract class AbstractCache implements Psr16CacheInterface, LoggerAwareInterfac
|
||||
throw new InvalidArgumentException(sprintf('Expiration date must be an integer, a DateInterval or null, "%s" given', \is_object($ttl) ? \get_class($ttl) : \gettype($ttl)));
|
||||
}
|
||||
|
||||
private function generateValues($values, &$keys, $default)
|
||||
private function generateValues(iterable $values, array &$keys, $default)
|
||||
{
|
||||
try {
|
||||
foreach ($values as $id => $value) {
|
||||
|
@ -90,7 +90,7 @@ class ChainCache implements Psr16CacheInterface, PruneableInterface, ResettableI
|
||||
return $this->generateItems($this->caches[0]->getMultiple($keys, $miss), 0, $miss, $default);
|
||||
}
|
||||
|
||||
private function generateItems($values, $cacheIndex, $miss, $default)
|
||||
private function generateItems(iterable $values, int $cacheIndex, $miss, $default)
|
||||
{
|
||||
$missing = [];
|
||||
$nextCacheIndex = $cacheIndex + 1;
|
||||
|
@ -222,7 +222,7 @@ class TraceableCache implements Psr16CacheInterface, PruneableInterface, Resetta
|
||||
}
|
||||
}
|
||||
|
||||
private function start($name)
|
||||
private function start(string $name)
|
||||
{
|
||||
$this->calls[] = $event = new TraceableCacheEvent();
|
||||
$event->name = $name;
|
||||
|
@ -115,7 +115,7 @@ trait AbstractAdapterTrait
|
||||
}
|
||||
}
|
||||
|
||||
private function generateItems($items, &$keys)
|
||||
private function generateItems(iterable $items, array &$keys)
|
||||
{
|
||||
$f = $this->createCacheItem;
|
||||
|
||||
|
@ -26,7 +26,7 @@ trait ApcuTrait
|
||||
return \function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN);
|
||||
}
|
||||
|
||||
private function init($namespace, $defaultLifetime, $version)
|
||||
private function init(string $namespace, int $defaultLifetime, ?string $version)
|
||||
{
|
||||
if (!static::isSupported()) {
|
||||
throw new CacheException('APCu is not enabled');
|
||||
|
@ -107,7 +107,7 @@ trait ArrayTrait
|
||||
$this->clear();
|
||||
}
|
||||
|
||||
private function generateItems(array $keys, $now, $f)
|
||||
private function generateItems(array $keys, float $now, callable $f)
|
||||
{
|
||||
foreach ($keys as $i => $key) {
|
||||
if (!$isHit = isset($this->expiries[$key]) && ($this->expiries[$key] > $now || !$this->deleteItem($key))) {
|
||||
|
@ -23,7 +23,7 @@ trait FilesystemCommonTrait
|
||||
private $directory;
|
||||
private $tmp;
|
||||
|
||||
private function init($namespace, $directory)
|
||||
private function init(string $namespace, ?string $directory)
|
||||
{
|
||||
if (!isset($directory[0])) {
|
||||
$directory = sys_get_temp_dir().'/symfony-cache';
|
||||
@ -86,7 +86,7 @@ trait FilesystemCommonTrait
|
||||
return @unlink($file);
|
||||
}
|
||||
|
||||
private function write($file, $data, $expiresAt = null)
|
||||
private function write(string $file, string $data, int $expiresAt = null)
|
||||
{
|
||||
set_error_handler(__CLASS__.'::throwError');
|
||||
try {
|
||||
@ -105,7 +105,7 @@ trait FilesystemCommonTrait
|
||||
}
|
||||
}
|
||||
|
||||
private function getFile($id, $mkdir = false, string $directory = null)
|
||||
private function getFile(string $id, bool $mkdir = false, string $directory = null)
|
||||
{
|
||||
// Use MD5 to favor speed over security, which is not an issue here
|
||||
$hash = str_replace('/', '-', base64_encode(hash('md5', static::class.$id, true)));
|
||||
|
@ -40,7 +40,7 @@ trait MemcachedTrait
|
||||
return \extension_loaded('memcached') && version_compare(phpversion('memcached'), '2.2.0', '>=');
|
||||
}
|
||||
|
||||
private function init(\Memcached $client, $namespace, $defaultLifetime, ?MarshallerInterface $marshaller)
|
||||
private function init(\Memcached $client, string $namespace, int $defaultLifetime, ?MarshallerInterface $marshaller)
|
||||
{
|
||||
if (!static::isSupported()) {
|
||||
throw new CacheException('Memcached >= 2.2.0 is required');
|
||||
|
@ -40,7 +40,7 @@ trait PdoTrait
|
||||
private $connectionOptions = [];
|
||||
private $namespace;
|
||||
|
||||
private function init($connOrDsn, $namespace, $defaultLifetime, array $options, ?MarshallerInterface $marshaller)
|
||||
private function init($connOrDsn, string $namespace, int $defaultLifetime, array $options, ?MarshallerInterface $marshaller)
|
||||
{
|
||||
if (isset($namespace[0]) && preg_match('#[^-+.A-Za-z0-9]#', $namespace, $match)) {
|
||||
throw new InvalidArgumentException(sprintf('Namespace contains "%s" but only characters in [-+.A-Za-z0-9] are allowed.', $match[0]));
|
||||
|
@ -48,7 +48,7 @@ trait RedisTrait
|
||||
/**
|
||||
* @param \Redis|\RedisArray|\RedisCluster|\Predis\Client $redisClient
|
||||
*/
|
||||
private function init($redisClient, $namespace, $defaultLifetime, ?MarshallerInterface $marshaller)
|
||||
private function init($redisClient, string $namespace, int $defaultLifetime, ?MarshallerInterface $marshaller)
|
||||
{
|
||||
parent::__construct($namespace, $defaultLifetime);
|
||||
|
||||
|
@ -182,7 +182,7 @@ class YamlReferenceDumper
|
||||
$this->reference .= sprintf($format, $text)."\n";
|
||||
}
|
||||
|
||||
private function writeArray(array $array, $depth)
|
||||
private function writeArray(array $array, int $depth)
|
||||
{
|
||||
$isIndexed = array_values($array) === $array;
|
||||
|
||||
|
@ -81,7 +81,7 @@ class FileLocator implements FileLocatorInterface
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private function isAbsolutePath($file)
|
||||
private function isAbsolutePath(string $file)
|
||||
{
|
||||
if ('/' === $file[0] || '\\' === $file[0]
|
||||
|| (\strlen($file) > 3 && ctype_alpha($file[0])
|
||||
|
@ -125,7 +125,7 @@ abstract class FileLoader extends Loader
|
||||
yield from $resource;
|
||||
}
|
||||
|
||||
private function doImport($resource, $type = null, bool $ignoreErrors = false, $sourceResource = null)
|
||||
private function doImport($resource, string $type = null, bool $ignoreErrors = false, $sourceResource = null)
|
||||
{
|
||||
try {
|
||||
$loader = $this->resolve($resource, $type);
|
||||
|
@ -152,7 +152,7 @@ class ResourceCheckerConfigCache implements ConfigCacheInterface
|
||||
return $this->file.'.meta';
|
||||
}
|
||||
|
||||
private function safelyUnserialize($file)
|
||||
private function safelyUnserialize(string $file)
|
||||
{
|
||||
$e = null;
|
||||
$meta = false;
|
||||
|
@ -1029,11 +1029,9 @@ class Application implements ResetInterface
|
||||
/**
|
||||
* Returns abbreviated suggestions in string format.
|
||||
*
|
||||
* @param array $abbrevs Abbreviated suggestions to convert
|
||||
*
|
||||
* @return string A formatted string of abbreviated suggestions
|
||||
*/
|
||||
private function getAbbreviationSuggestions($abbrevs)
|
||||
private function getAbbreviationSuggestions(array $abbrevs)
|
||||
{
|
||||
return ' '.implode("\n ", $abbrevs);
|
||||
}
|
||||
@ -1060,12 +1058,9 @@ class Application implements ResetInterface
|
||||
* Finds alternative of $name among $collection,
|
||||
* if nothing is found in $collection, try in $abbrevs.
|
||||
*
|
||||
* @param string $name The string
|
||||
* @param iterable $collection The collection
|
||||
*
|
||||
* @return string[] A sorted array of similar string
|
||||
*/
|
||||
private function findAlternatives($name, $collection)
|
||||
private function findAlternatives(string $name, iterable $collection)
|
||||
{
|
||||
$threshold = 1e3;
|
||||
$alternatives = [];
|
||||
@ -1137,7 +1132,7 @@ class Application implements ResetInterface
|
||||
return $this->singleCommand;
|
||||
}
|
||||
|
||||
private function splitStringByWidth($string, $width)
|
||||
private function splitStringByWidth(string $string, int $width)
|
||||
{
|
||||
// str_split is not suitable for multi-byte characters, we should use preg_split to get char array properly.
|
||||
// additionally, array_slice() is not enough as some character has doubled width.
|
||||
@ -1176,11 +1171,9 @@ class Application implements ResetInterface
|
||||
/**
|
||||
* Returns all namespaces of the command name.
|
||||
*
|
||||
* @param string $name The full name of the command
|
||||
*
|
||||
* @return string[] The namespaces of the command
|
||||
*/
|
||||
private function extractAllNamespaces($name)
|
||||
private function extractAllNamespaces(string $name)
|
||||
{
|
||||
// -1 as third argument is needed to skip the command short name when exploding
|
||||
$parts = explode(':', $name, -1);
|
||||
|
@ -32,7 +32,7 @@ trait LockableTrait
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private function lock($name = null, $blocking = false)
|
||||
private function lock(string $name = null, bool $blocking = false)
|
||||
{
|
||||
if (!class_exists(SemaphoreStore::class)) {
|
||||
throw new LogicException('To enable the locking feature you must install the symfony/lock component.');
|
||||
|
@ -250,7 +250,7 @@ class TextDescriptor extends Descriptor
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
private function writeText($content, array $options = [])
|
||||
private function writeText(string $content, array $options = [])
|
||||
{
|
||||
$this->write(
|
||||
isset($options['raw_text']) && $options['raw_text'] ? strip_tags($content) : $content,
|
||||
|
@ -108,11 +108,9 @@ class DebugFormatterHelper extends Helper
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $id The id of the formatting session
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function getBorder($id)
|
||||
private function getBorder(string $id)
|
||||
{
|
||||
return sprintf('<bg=%s> </>', $this->colors[$this->started[$id]['border']]);
|
||||
}
|
||||
|
@ -141,7 +141,7 @@ class ProcessHelper extends Helper
|
||||
};
|
||||
}
|
||||
|
||||
private function escapeString($str)
|
||||
private function escapeString(string $str)
|
||||
{
|
||||
return str_replace('<', '\\<', $str);
|
||||
}
|
||||
|
@ -335,7 +335,7 @@ class QuestionHelper extends Helper
|
||||
return $fullChoice;
|
||||
}
|
||||
|
||||
private function mostRecentlyEnteredValue($entered)
|
||||
private function mostRecentlyEnteredValue(string $entered)
|
||||
{
|
||||
// Determine the most recent value that the user entered
|
||||
if (false === strpos($entered, ',')) {
|
||||
@ -359,7 +359,7 @@ class QuestionHelper extends Helper
|
||||
*
|
||||
* @throws RuntimeException In case the fallback is deactivated and the response cannot be hidden
|
||||
*/
|
||||
private function getHiddenResponse(OutputInterface $output, $inputStream, $trimmable = true): string
|
||||
private function getHiddenResponse(OutputInterface $output, $inputStream, bool $trimmable = true): string
|
||||
{
|
||||
if ('\\' === \DIRECTORY_SEPARATOR) {
|
||||
$exe = __DIR__.'/../Resources/bin/hiddeninput.exe';
|
||||
|
@ -439,7 +439,7 @@ class Table
|
||||
/**
|
||||
* Renders vertical column separator.
|
||||
*/
|
||||
private function renderColumnSeparator($type = self::BORDER_OUTSIDE)
|
||||
private function renderColumnSeparator(int $type = self::BORDER_OUTSIDE)
|
||||
{
|
||||
$borders = $this->style->getBorderChars();
|
||||
|
||||
@ -499,7 +499,7 @@ class Table
|
||||
/**
|
||||
* Calculate number of columns for this table.
|
||||
*/
|
||||
private function calculateNumberOfColumns($rows)
|
||||
private function calculateNumberOfColumns(array $rows)
|
||||
{
|
||||
$columns = [0];
|
||||
foreach ($rows as $row) {
|
||||
@ -513,7 +513,7 @@ class Table
|
||||
$this->numberOfColumns = max($columns);
|
||||
}
|
||||
|
||||
private function buildTableRows($rows)
|
||||
private function buildTableRows(array $rows)
|
||||
{
|
||||
/** @var WrappableOutputFormatterInterface $formatter */
|
||||
$formatter = $this->output->getFormatter();
|
||||
|
@ -90,10 +90,8 @@ class ArgvInput extends Input
|
||||
|
||||
/**
|
||||
* Parses a short option.
|
||||
*
|
||||
* @param string $token The current token
|
||||
*/
|
||||
private function parseShortOption($token)
|
||||
private function parseShortOption(string $token)
|
||||
{
|
||||
$name = substr($token, 1);
|
||||
|
||||
@ -112,11 +110,9 @@ class ArgvInput extends Input
|
||||
/**
|
||||
* Parses a short option set.
|
||||
*
|
||||
* @param string $name The current token
|
||||
*
|
||||
* @throws RuntimeException When option given doesn't exist
|
||||
*/
|
||||
private function parseShortOptionSet($name)
|
||||
private function parseShortOptionSet(string $name)
|
||||
{
|
||||
$len = \strlen($name);
|
||||
for ($i = 0; $i < $len; ++$i) {
|
||||
@ -138,10 +134,8 @@ class ArgvInput extends Input
|
||||
|
||||
/**
|
||||
* Parses a long option.
|
||||
*
|
||||
* @param string $token The current token
|
||||
*/
|
||||
private function parseLongOption($token)
|
||||
private function parseLongOption(string $token)
|
||||
{
|
||||
$name = substr($token, 2);
|
||||
|
||||
@ -158,11 +152,9 @@ class ArgvInput extends Input
|
||||
/**
|
||||
* Parses an argument.
|
||||
*
|
||||
* @param string $token The current token
|
||||
*
|
||||
* @throws RuntimeException When too many arguments are given
|
||||
*/
|
||||
private function parseArgument($token)
|
||||
private function parseArgument(string $token)
|
||||
{
|
||||
$c = \count($this->arguments);
|
||||
|
||||
@ -190,12 +182,9 @@ class ArgvInput extends Input
|
||||
/**
|
||||
* Adds a short option value.
|
||||
*
|
||||
* @param string $shortcut The short option key
|
||||
* @param mixed $value The value for the option
|
||||
*
|
||||
* @throws RuntimeException When option given doesn't exist
|
||||
*/
|
||||
private function addShortOption($shortcut, $value)
|
||||
private function addShortOption(string $shortcut, $value)
|
||||
{
|
||||
if (!$this->definition->hasShortcut($shortcut)) {
|
||||
throw new RuntimeException(sprintf('The "-%s" option does not exist.', $shortcut));
|
||||
@ -207,12 +196,9 @@ class ArgvInput extends Input
|
||||
/**
|
||||
* Adds a long option value.
|
||||
*
|
||||
* @param string $name The long option key
|
||||
* @param mixed $value The value for the option
|
||||
*
|
||||
* @throws RuntimeException When option given doesn't exist
|
||||
*/
|
||||
private function addLongOption($name, $value)
|
||||
private function addLongOption(string $name, $value)
|
||||
{
|
||||
if (!$this->definition->hasOption($name)) {
|
||||
throw new RuntimeException(sprintf('The "--%s" option does not exist.', $name));
|
||||
|
@ -143,12 +143,9 @@ class ArrayInput extends Input
|
||||
/**
|
||||
* Adds a short option value.
|
||||
*
|
||||
* @param string $shortcut The short option key
|
||||
* @param mixed $value The value for the option
|
||||
*
|
||||
* @throws InvalidOptionException When option given doesn't exist
|
||||
*/
|
||||
private function addShortOption($shortcut, $value)
|
||||
private function addShortOption(string $shortcut, $value)
|
||||
{
|
||||
if (!$this->definition->hasShortcut($shortcut)) {
|
||||
throw new InvalidOptionException(sprintf('The "-%s" option does not exist.', $shortcut));
|
||||
@ -160,13 +157,10 @@ class ArrayInput extends Input
|
||||
/**
|
||||
* Adds a long option value.
|
||||
*
|
||||
* @param string $name The long option key
|
||||
* @param mixed $value The value for the option
|
||||
*
|
||||
* @throws InvalidOptionException When option given doesn't exist
|
||||
* @throws InvalidOptionException When a required value is missing
|
||||
*/
|
||||
private function addLongOption($name, $value)
|
||||
private function addLongOption(string $name, $value)
|
||||
{
|
||||
if (!$this->definition->hasOption($name)) {
|
||||
throw new InvalidOptionException(sprintf('The "--%s" option does not exist.', $name));
|
||||
@ -190,8 +184,8 @@ class ArrayInput extends Input
|
||||
/**
|
||||
* Adds an argument value.
|
||||
*
|
||||
* @param string $name The argument name
|
||||
* @param mixed $value The value for the argument
|
||||
* @param string|int $name The argument name
|
||||
* @param mixed $value The value for the argument
|
||||
*
|
||||
* @throws InvalidArgumentException When argument given doesn't exist
|
||||
*/
|
||||
|
@ -40,13 +40,11 @@ class StringInput extends ArgvInput
|
||||
/**
|
||||
* Tokenizes a string.
|
||||
*
|
||||
* @param string $input The input to tokenize
|
||||
*
|
||||
* @return array An array of tokens
|
||||
*
|
||||
* @throws InvalidArgumentException When unable to parse input (should never happen)
|
||||
*/
|
||||
private function tokenize($input)
|
||||
private function tokenize(string $input)
|
||||
{
|
||||
$tokens = [];
|
||||
$length = \strlen($input);
|
||||
|
@ -93,7 +93,7 @@ class ReaderTest extends TestCase
|
||||
$this->assertTrue($reader->isEOF());
|
||||
}
|
||||
|
||||
private function assignPosition(Reader $reader, $value)
|
||||
private function assignPosition(Reader $reader, int $value)
|
||||
{
|
||||
$position = new \ReflectionProperty($reader, 'position');
|
||||
$position->setAccessible(true);
|
||||
|
@ -174,7 +174,7 @@ class DebugClassLoader
|
||||
$this->checkClass($class, $file);
|
||||
}
|
||||
|
||||
private function checkClass($class, $file = null)
|
||||
private function checkClass(string $class, string $file = null)
|
||||
{
|
||||
$exists = null === $file || class_exists($class, false) || interface_exists($class, false) || trait_exists($class, false);
|
||||
|
||||
@ -262,7 +262,7 @@ class DebugClassLoader
|
||||
}
|
||||
|
||||
$parent = get_parent_class($class);
|
||||
$parentAndOwnInterfaces = $this->getOwnInterfaces($class, $parent);
|
||||
$parentAndOwnInterfaces = $this->getOwnInterfaces($class, $parent ?: null);
|
||||
if ($parent) {
|
||||
$parentAndOwnInterfaces[$parent] = $parent;
|
||||
|
||||
@ -436,7 +436,7 @@ class DebugClassLoader
|
||||
/**
|
||||
* `realpath` on MacOSX doesn't normalize the case of characters.
|
||||
*/
|
||||
private function darwinRealpath($real)
|
||||
private function darwinRealpath(string $real)
|
||||
{
|
||||
$i = 1 + strrpos($real, '/');
|
||||
$file = substr($real, $i);
|
||||
@ -503,12 +503,9 @@ class DebugClassLoader
|
||||
/**
|
||||
* `class_implements` includes interfaces from the parents so we have to manually exclude them.
|
||||
*
|
||||
* @param string $class
|
||||
* @param string|false $parent
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
private function getOwnInterfaces($class, $parent)
|
||||
private function getOwnInterfaces(string $class, ?string $parent)
|
||||
{
|
||||
$ownInterfaces = class_implements($class, false);
|
||||
|
||||
|
@ -353,7 +353,7 @@ class ErrorHandler
|
||||
/**
|
||||
* Re-registers as a PHP error handler if levels changed.
|
||||
*/
|
||||
private function reRegister($prev)
|
||||
private function reRegister(int $prev)
|
||||
{
|
||||
if ($prev !== $this->thrownErrors | $this->loggedErrors) {
|
||||
$handler = set_error_handler('var_dump');
|
||||
@ -691,7 +691,7 @@ class ErrorHandler
|
||||
/**
|
||||
* Cleans the trace by removing function arguments and the frames added by the error handler and DebugClassLoader.
|
||||
*/
|
||||
private function cleanTrace($backtrace, $type, $file, $line, $throw)
|
||||
private function cleanTrace(array $backtrace, int $type, string $file, int $line, bool $throw)
|
||||
{
|
||||
$lightTrace = $backtrace;
|
||||
|
||||
|
@ -294,7 +294,7 @@ class FlattenException
|
||||
return $this;
|
||||
}
|
||||
|
||||
private function flattenArgs($args, $level = 0, &$count = 0)
|
||||
private function flattenArgs(array $args, int $level = 0, int &$count = 0)
|
||||
{
|
||||
$result = [];
|
||||
foreach ($args as $key => $value) {
|
||||
|
@ -359,7 +359,7 @@ EOF;
|
||||
EOF;
|
||||
}
|
||||
|
||||
private function decorate($content, $css)
|
||||
private function decorate(string $content, string $css)
|
||||
{
|
||||
return <<<EOF
|
||||
<!DOCTYPE html>
|
||||
@ -376,14 +376,14 @@ EOF;
|
||||
EOF;
|
||||
}
|
||||
|
||||
private function formatClass($class)
|
||||
private function formatClass(string $class)
|
||||
{
|
||||
$parts = explode('\\', $class);
|
||||
|
||||
return sprintf('<abbr title="%s">%s</abbr>', $class, array_pop($parts));
|
||||
}
|
||||
|
||||
private function formatPath($path, $line)
|
||||
private function formatPath(string $path, int $line)
|
||||
{
|
||||
$file = $this->escapeHtml(preg_match('#[^/\\\\]*+$#', $path, $file) ? $file[0] : $path);
|
||||
$fmt = $this->fileLinkFormat ?: ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format');
|
||||
@ -449,7 +449,7 @@ EOF;
|
||||
/**
|
||||
* HTML-encodes a string.
|
||||
*/
|
||||
private function escapeHtml($str)
|
||||
private function escapeHtml(string $str)
|
||||
{
|
||||
return htmlspecialchars($str, ENT_COMPAT | ENT_SUBSTITUTE, $this->charset);
|
||||
}
|
||||
|
@ -81,7 +81,7 @@ class AutowirePass extends AbstractRecursivePass
|
||||
}
|
||||
}
|
||||
|
||||
private function doProcessValue($value, $isRoot = false)
|
||||
private function doProcessValue($value, bool $isRoot = false)
|
||||
{
|
||||
if ($value instanceof TypedReference) {
|
||||
if ($ref = $this->getAutowiredReference($value)) {
|
||||
@ -374,7 +374,7 @@ class AutowirePass extends AbstractRecursivePass
|
||||
$this->ambiguousServiceTypes[$type][] = $id;
|
||||
}
|
||||
|
||||
private function createTypeNotFoundMessageCallback(TypedReference $reference, $label)
|
||||
private function createTypeNotFoundMessageCallback(TypedReference $reference, string $label)
|
||||
{
|
||||
if (null === $this->typesClone->container) {
|
||||
$this->typesClone->container = new ContainerBuilder($this->container->getParameterBag());
|
||||
@ -389,7 +389,7 @@ class AutowirePass extends AbstractRecursivePass
|
||||
})->bindTo($this->typesClone);
|
||||
}
|
||||
|
||||
private function createTypeNotFoundMessage(TypedReference $reference, $label, string $currentId)
|
||||
private function createTypeNotFoundMessage(TypedReference $reference, string $label, string $currentId)
|
||||
{
|
||||
if (!$r = $this->container->getReflectionClass($type = $reference->getType(), false)) {
|
||||
// either $type does not exist or a parent class does not exist
|
||||
@ -447,7 +447,7 @@ class AutowirePass extends AbstractRecursivePass
|
||||
return sprintf(' You should maybe alias this %s to %s.', class_exists($type, false) ? 'class' : 'interface', $message);
|
||||
}
|
||||
|
||||
private function getAliasesSuggestionForType(ContainerBuilder $container, $type, $extraContext = null)
|
||||
private function getAliasesSuggestionForType(ContainerBuilder $container, string $type)
|
||||
{
|
||||
$aliases = [];
|
||||
foreach (class_parents($type) + class_implements($type) as $parent) {
|
||||
@ -456,9 +456,8 @@ class AutowirePass extends AbstractRecursivePass
|
||||
}
|
||||
}
|
||||
|
||||
$extraContext = $extraContext ? ' '.$extraContext : '';
|
||||
if (1 < $len = \count($aliases)) {
|
||||
$message = sprintf('Try changing the type-hint%s to one of its parents: ', $extraContext);
|
||||
$message = 'Try changing the type-hint to one of its parents: ';
|
||||
for ($i = 0, --$len; $i < $len; ++$i) {
|
||||
$message .= sprintf('%s "%s", ', class_exists($aliases[$i], false) ? 'class' : 'interface', $aliases[$i]);
|
||||
}
|
||||
@ -468,7 +467,7 @@ class AutowirePass extends AbstractRecursivePass
|
||||
}
|
||||
|
||||
if ($aliases) {
|
||||
return sprintf('Try changing the type-hint%s to "%s" instead.', $extraContext, $aliases[0]);
|
||||
return sprintf('Try changing the type-hint to "%s" instead.', $aliases[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -169,7 +169,7 @@ class InlineServiceDefinitionsPass extends AbstractRecursivePass implements Repe
|
||||
*
|
||||
* @return bool If the definition is inlineable
|
||||
*/
|
||||
private function isInlineableDefinition($id, Definition $definition)
|
||||
private function isInlineableDefinition(string $id, Definition $definition)
|
||||
{
|
||||
if ($definition->hasErrors() || $definition->isDeprecated() || $definition->isLazy() || $definition->isSynthetic()) {
|
||||
return false;
|
||||
|
@ -44,7 +44,7 @@ class ResolveInstanceofConditionalsPass implements CompilerPassInterface
|
||||
}
|
||||
}
|
||||
|
||||
private function processDefinition(ContainerBuilder $container, $id, Definition $definition)
|
||||
private function processDefinition(ContainerBuilder $container, string $id, Definition $definition)
|
||||
{
|
||||
$instanceofConditionals = $definition->getInstanceofConditionals();
|
||||
$autoconfiguredInstanceof = $definition->isAutoconfigured() ? $container->getAutoconfiguredInstanceof() : [];
|
||||
|
@ -53,7 +53,7 @@ class ResolveInvalidReferencesPass implements CompilerPassInterface
|
||||
*
|
||||
* @throws RuntimeException When an invalid reference is found
|
||||
*/
|
||||
private function processValue($value, $rootLevel = 0, $level = 0)
|
||||
private function processValue($value, int $rootLevel = 0, int $level = 0)
|
||||
{
|
||||
if ($value instanceof ServiceClosureArgument) {
|
||||
$value->setValues($this->processValue($value->getValues(), 1, 1));
|
||||
|
@ -558,7 +558,7 @@ class ContainerBuilder extends Container implements TaggedContainerInterface
|
||||
return $this->doGet($id, $invalidBehavior);
|
||||
}
|
||||
|
||||
private function doGet($id, $invalidBehavior = ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE, array &$inlineServices = null, $isConstructorArgument = false)
|
||||
private function doGet(string $id, int $invalidBehavior = ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE, array &$inlineServices = null, bool $isConstructorArgument = false)
|
||||
{
|
||||
if (isset($inlineServices[$id])) {
|
||||
return $inlineServices[$id];
|
||||
@ -1066,17 +1066,13 @@ class ContainerBuilder extends Container implements TaggedContainerInterface
|
||||
/**
|
||||
* Creates a service for a service definition.
|
||||
*
|
||||
* @param Definition $definition A service definition instance
|
||||
* @param string $id The service identifier
|
||||
* @param bool $tryProxy Whether to try proxying the service with a lazy proxy
|
||||
*
|
||||
* @return object The service described by the service definition
|
||||
*
|
||||
* @throws RuntimeException When the factory definition is incomplete
|
||||
* @throws RuntimeException When the service is a synthetic service
|
||||
* @throws InvalidArgumentException When configure callable is not callable
|
||||
*/
|
||||
private function createService(Definition $definition, array &$inlineServices, $isConstructorArgument = false, $id = null, $tryProxy = true)
|
||||
private function createService(Definition $definition, array &$inlineServices, bool $isConstructorArgument = false, string $id = null, bool $tryProxy = true)
|
||||
{
|
||||
if (null === $id && isset($inlineServices[$h = spl_object_hash($definition)])) {
|
||||
return $inlineServices[$h];
|
||||
@ -1207,7 +1203,7 @@ class ContainerBuilder extends Container implements TaggedContainerInterface
|
||||
return $this->doResolveServices($value);
|
||||
}
|
||||
|
||||
private function doResolveServices($value, array &$inlineServices = [], $isConstructorArgument = false)
|
||||
private function doResolveServices($value, array &$inlineServices = [], bool $isConstructorArgument = false)
|
||||
{
|
||||
if (\is_array($value)) {
|
||||
foreach ($value as $k => $v) {
|
||||
@ -1614,7 +1610,7 @@ class ContainerBuilder extends Container implements TaggedContainerInterface
|
||||
}
|
||||
}
|
||||
|
||||
private function callMethod($service, $call, array &$inlineServices)
|
||||
private function callMethod($service, array $call, array &$inlineServices)
|
||||
{
|
||||
foreach (self::getServiceConditionals($call[1]) as $s) {
|
||||
if (!$this->has($s)) {
|
||||
@ -1635,11 +1631,9 @@ class ContainerBuilder extends Container implements TaggedContainerInterface
|
||||
/**
|
||||
* Shares a given service in the container.
|
||||
*
|
||||
* @param Definition $definition
|
||||
* @param object $service
|
||||
* @param string|null $id
|
||||
* @param object $service
|
||||
*/
|
||||
private function shareService(Definition $definition, $service, $id, array &$inlineServices)
|
||||
private function shareService(Definition $definition, $service, ?string $id, array &$inlineServices)
|
||||
{
|
||||
$inlineServices[null !== $id ? $id : spl_object_hash($definition)] = $service;
|
||||
|
||||
@ -1661,7 +1655,7 @@ class ContainerBuilder extends Container implements TaggedContainerInterface
|
||||
return $this->expressionLanguage;
|
||||
}
|
||||
|
||||
private function inVendors($path)
|
||||
private function inVendors(string $path)
|
||||
{
|
||||
if (null === $this->vendors) {
|
||||
$resource = new ComposerResource();
|
||||
|
@ -358,7 +358,7 @@ EOF;
|
||||
return $this->proxyDumper;
|
||||
}
|
||||
|
||||
private function analyzeCircularReferences($sourceId, array $edges, &$checkedNodes, &$currentPath = [], $byConstructor = true)
|
||||
private function analyzeCircularReferences(string $sourceId, array $edges, array &$checkedNodes, array &$currentPath = [], bool $byConstructor = true)
|
||||
{
|
||||
$checkedNodes[$sourceId] = true;
|
||||
$currentPath[$sourceId] = $byConstructor;
|
||||
@ -380,7 +380,7 @@ EOF;
|
||||
unset($currentPath[$sourceId]);
|
||||
}
|
||||
|
||||
private function connectCircularReferences($sourceId, &$currentPath, $byConstructor, &$subPath = [])
|
||||
private function connectCircularReferences(string $sourceId, array &$currentPath, bool $byConstructor, array &$subPath = [])
|
||||
{
|
||||
$currentPath[$sourceId] = $subPath[$sourceId] = $byConstructor;
|
||||
|
||||
@ -394,7 +394,7 @@ EOF;
|
||||
unset($currentPath[$sourceId], $subPath[$sourceId]);
|
||||
}
|
||||
|
||||
private function addCircularReferences($id, $currentPath, $byConstructor)
|
||||
private function addCircularReferences(string $id, array $currentPath, bool $byConstructor)
|
||||
{
|
||||
$currentPath[$id] = $byConstructor;
|
||||
$circularRefs = [];
|
||||
@ -418,7 +418,7 @@ EOF;
|
||||
}
|
||||
}
|
||||
|
||||
private function collectLineage($class, array &$lineage)
|
||||
private function collectLineage(string $class, array &$lineage)
|
||||
{
|
||||
if (isset($lineage[$class])) {
|
||||
return;
|
||||
@ -1965,7 +1965,7 @@ EOF;
|
||||
return $this->doExport($value, true);
|
||||
}
|
||||
|
||||
private function doExport($value, $resolveEnv = false)
|
||||
private function doExport($value, bool $resolveEnv = false)
|
||||
{
|
||||
$shouldCacheValue = $resolveEnv && \is_string($value);
|
||||
if ($shouldCacheValue && isset($this->exportedVariables[$value])) {
|
||||
|
@ -91,14 +91,7 @@ class XmlDumper extends Dumper
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a service.
|
||||
*
|
||||
* @param Definition $definition
|
||||
* @param string $id
|
||||
* @param \DOMElement $parent
|
||||
*/
|
||||
private function addService($definition, $id, \DOMElement $parent)
|
||||
private function addService(Definition $definition, ?string $id, \DOMElement $parent)
|
||||
{
|
||||
$service = $this->document->createElement('service');
|
||||
if (null !== $id) {
|
||||
@ -215,14 +208,7 @@ class XmlDumper extends Dumper
|
||||
$parent->appendChild($service);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a service alias.
|
||||
*
|
||||
* @param string $alias
|
||||
* @param Alias $id
|
||||
* @param \DOMElement $parent
|
||||
*/
|
||||
private function addServiceAlias($alias, Alias $id, \DOMElement $parent)
|
||||
private function addServiceAlias(string $alias, Alias $id, \DOMElement $parent)
|
||||
{
|
||||
$service = $this->document->createElement('service');
|
||||
$service->setAttribute('id', $alias);
|
||||
@ -263,15 +249,7 @@ class XmlDumper extends Dumper
|
||||
$parent->appendChild($services);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts parameters.
|
||||
*
|
||||
* @param array $parameters
|
||||
* @param string $type
|
||||
* @param \DOMElement $parent
|
||||
* @param string $keyAttribute
|
||||
*/
|
||||
private function convertParameters(array $parameters, $type, \DOMElement $parent, $keyAttribute = 'key')
|
||||
private function convertParameters(array $parameters, string $type, \DOMElement $parent, string $keyAttribute = 'key')
|
||||
{
|
||||
$withKeys = array_keys($parameters) !== range(0, \count($parameters) - 1);
|
||||
foreach ($parameters as $key => $value) {
|
||||
|
@ -220,8 +220,6 @@ class YamlDumper extends Dumper
|
||||
/**
|
||||
* Dumps the value to YAML format.
|
||||
*
|
||||
* @param mixed $value
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws RuntimeException When trying to dump object or resource
|
||||
@ -303,7 +301,7 @@ class YamlDumper extends Dumper
|
||||
return sprintf('%%%s%%', $id);
|
||||
}
|
||||
|
||||
private function getExpressionCall($expression)
|
||||
private function getExpressionCall(string $expression)
|
||||
{
|
||||
return sprintf('@=%s', $expression);
|
||||
}
|
||||
|
@ -103,7 +103,7 @@ abstract class FileLoader extends BaseFileLoader
|
||||
}
|
||||
}
|
||||
|
||||
private function findClasses($namespace, $pattern, array $excludePatterns)
|
||||
private function findClasses(string $namespace, string $pattern, array $excludePatterns)
|
||||
{
|
||||
$parameterBag = $this->container->getParameterBag();
|
||||
|
||||
|
@ -67,7 +67,7 @@ class IniFileLoader extends FileLoader
|
||||
* * strings with escaped quotes are not supported "foo\"bar";
|
||||
* * string concatenation ("foo" "bar").
|
||||
*/
|
||||
private function phpize($value)
|
||||
private function phpize(string $value)
|
||||
{
|
||||
// trim on the right as comments removal keep whitespaces
|
||||
if ($value !== $v = rtrim($value)) {
|
||||
|
@ -50,7 +50,7 @@ class XmlFileLoader extends FileLoader
|
||||
$defaults = $this->getServiceDefaults($xml, $path);
|
||||
|
||||
// anonymous services
|
||||
$this->processAnonymousServices($xml, $path, $defaults);
|
||||
$this->processAnonymousServices($xml, $path);
|
||||
|
||||
// imports
|
||||
$this->parseImports($xml, $path);
|
||||
@ -85,26 +85,14 @@ class XmlFileLoader extends FileLoader
|
||||
return 'xml' === $type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses parameters.
|
||||
*
|
||||
* @param \DOMDocument $xml
|
||||
* @param string $file
|
||||
*/
|
||||
private function parseParameters(\DOMDocument $xml, $file)
|
||||
private function parseParameters(\DOMDocument $xml, string $file)
|
||||
{
|
||||
if ($parameters = $this->getChildren($xml->documentElement, 'parameters')) {
|
||||
$this->container->getParameterBag()->add($this->getArgumentsAsPhp($parameters[0], 'parameter', $file));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses imports.
|
||||
*
|
||||
* @param \DOMDocument $xml
|
||||
* @param string $file
|
||||
*/
|
||||
private function parseImports(\DOMDocument $xml, $file)
|
||||
private function parseImports(\DOMDocument $xml, string $file)
|
||||
{
|
||||
$xpath = new \DOMXPath($xml);
|
||||
$xpath->registerNamespace('container', self::NS);
|
||||
@ -120,13 +108,7 @@ class XmlFileLoader extends FileLoader
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses multiple definitions.
|
||||
*
|
||||
* @param \DOMDocument $xml
|
||||
* @param string $file
|
||||
*/
|
||||
private function parseDefinitions(\DOMDocument $xml, $file, $defaults)
|
||||
private function parseDefinitions(\DOMDocument $xml, string $file, array $defaults)
|
||||
{
|
||||
$xpath = new \DOMXPath($xml);
|
||||
$xpath->registerNamespace('container', self::NS);
|
||||
@ -167,7 +149,7 @@ class XmlFileLoader extends FileLoader
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function getServiceDefaults(\DOMDocument $xml, $file)
|
||||
private function getServiceDefaults(\DOMDocument $xml, string $file)
|
||||
{
|
||||
$xpath = new \DOMXPath($xml);
|
||||
$xpath->registerNamespace('container', self::NS);
|
||||
@ -208,13 +190,9 @@ class XmlFileLoader extends FileLoader
|
||||
/**
|
||||
* Parses an individual Definition.
|
||||
*
|
||||
* @param \DOMElement $service
|
||||
* @param string $file
|
||||
* @param array $defaults
|
||||
*
|
||||
* @return Definition|null
|
||||
*/
|
||||
private function parseDefinition(\DOMElement $service, $file, array $defaults)
|
||||
private function parseDefinition(\DOMElement $service, string $file, array $defaults)
|
||||
{
|
||||
if ($alias = $service->getAttribute('alias')) {
|
||||
$this->validateAlias($service, $file);
|
||||
@ -309,7 +287,7 @@ class XmlFileLoader extends FileLoader
|
||||
$definition->setDeprecated(true, $deprecated[0]->nodeValue ?: null);
|
||||
}
|
||||
|
||||
$definition->setArguments($this->getArgumentsAsPhp($service, 'argument', $file, false, $definition instanceof ChildDefinition));
|
||||
$definition->setArguments($this->getArgumentsAsPhp($service, 'argument', $file, $definition instanceof ChildDefinition));
|
||||
$definition->setProperties($this->getArgumentsAsPhp($service, 'property', $file));
|
||||
|
||||
if ($factories = $this->getChildren($service, 'factory')) {
|
||||
@ -399,13 +377,11 @@ class XmlFileLoader extends FileLoader
|
||||
/**
|
||||
* Parses a XML file to a \DOMDocument.
|
||||
*
|
||||
* @param string $file Path to a file
|
||||
*
|
||||
* @return \DOMDocument
|
||||
*
|
||||
* @throws InvalidArgumentException When loading of XML file returns error
|
||||
*/
|
||||
private function parseFileToDOM($file)
|
||||
private function parseFileToDOM(string $file)
|
||||
{
|
||||
try {
|
||||
$dom = XmlUtils::loadFile($file, [$this, 'validateSchema']);
|
||||
@ -420,12 +396,8 @@ class XmlFileLoader extends FileLoader
|
||||
|
||||
/**
|
||||
* Processes anonymous services.
|
||||
*
|
||||
* @param \DOMDocument $xml
|
||||
* @param string $file
|
||||
* @param array $defaults
|
||||
*/
|
||||
private function processAnonymousServices(\DOMDocument $xml, $file, $defaults)
|
||||
private function processAnonymousServices(\DOMDocument $xml, string $file)
|
||||
{
|
||||
$definitions = [];
|
||||
$count = 0;
|
||||
@ -469,17 +441,7 @@ class XmlFileLoader extends FileLoader
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns arguments as valid php types.
|
||||
*
|
||||
* @param \DOMElement $node
|
||||
* @param string $name
|
||||
* @param string $file
|
||||
* @param bool $lowercase
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
private function getArgumentsAsPhp(\DOMElement $node, $name, $file, $lowercase = true, $isChildDefinition = false)
|
||||
private function getArgumentsAsPhp(\DOMElement $node, string $name, string $file, bool $isChildDefinition = false)
|
||||
{
|
||||
$arguments = [];
|
||||
foreach ($this->getChildren($node, $name) as $arg) {
|
||||
@ -526,10 +488,10 @@ class XmlFileLoader extends FileLoader
|
||||
$arguments[$key] = new Expression($arg->nodeValue);
|
||||
break;
|
||||
case 'collection':
|
||||
$arguments[$key] = $this->getArgumentsAsPhp($arg, $name, $file, false);
|
||||
$arguments[$key] = $this->getArgumentsAsPhp($arg, $name, $file);
|
||||
break;
|
||||
case 'iterator':
|
||||
$arg = $this->getArgumentsAsPhp($arg, $name, $file, false);
|
||||
$arg = $this->getArgumentsAsPhp($arg, $name, $file);
|
||||
try {
|
||||
$arguments[$key] = new IteratorArgument($arg);
|
||||
} catch (InvalidArgumentException $e) {
|
||||
@ -537,7 +499,7 @@ class XmlFileLoader extends FileLoader
|
||||
}
|
||||
break;
|
||||
case 'service_locator':
|
||||
$arg = $this->getArgumentsAsPhp($arg, $name, $file, false);
|
||||
$arg = $this->getArgumentsAsPhp($arg, $name, $file);
|
||||
try {
|
||||
$arguments[$key] = new ServiceLocatorArgument($arg);
|
||||
} catch (InvalidArgumentException $e) {
|
||||
@ -585,12 +547,9 @@ class XmlFileLoader extends FileLoader
|
||||
/**
|
||||
* Get child elements by name.
|
||||
*
|
||||
* @param \DOMNode $node
|
||||
* @param mixed $name
|
||||
*
|
||||
* @return \DOMElement[]
|
||||
*/
|
||||
private function getChildren(\DOMNode $node, $name)
|
||||
private function getChildren(\DOMNode $node, string $name)
|
||||
{
|
||||
$children = [];
|
||||
foreach ($node->childNodes as $child) {
|
||||
@ -681,13 +640,7 @@ EOF
|
||||
return $valid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates an alias.
|
||||
*
|
||||
* @param \DOMElement $alias
|
||||
* @param string $file
|
||||
*/
|
||||
private function validateAlias(\DOMElement $alias, $file)
|
||||
private function validateAlias(\DOMElement $alias, string $file)
|
||||
{
|
||||
foreach ($alias->attributes as $name => $node) {
|
||||
if (!\in_array($name, ['alias', 'id', 'public'])) {
|
||||
@ -708,12 +661,9 @@ EOF
|
||||
/**
|
||||
* Validates an extension.
|
||||
*
|
||||
* @param \DOMDocument $dom
|
||||
* @param string $file
|
||||
*
|
||||
* @throws InvalidArgumentException When no extension is found corresponding to a tag
|
||||
*/
|
||||
private function validateExtensions(\DOMDocument $dom, $file)
|
||||
private function validateExtensions(\DOMDocument $dom, string $file)
|
||||
{
|
||||
foreach ($dom->documentElement->childNodes as $node) {
|
||||
if (!$node instanceof \DOMElement || 'http://symfony.com/schema/dic/services' === $node->namespaceURI) {
|
||||
|
@ -306,14 +306,11 @@ class YamlFileLoader extends FileLoader
|
||||
/**
|
||||
* Parses a definition.
|
||||
*
|
||||
* @param string $id
|
||||
* @param array|string $service
|
||||
* @param string $file
|
||||
* @param array $defaults
|
||||
*
|
||||
* @throws InvalidArgumentException When tags are invalid
|
||||
*/
|
||||
private function parseDefinition($id, $service, $file, array $defaults)
|
||||
private function parseDefinition(string $id, $service, string $file, array $defaults)
|
||||
{
|
||||
if (preg_match('/^_[a-zA-Z0-9_]*$/', $id)) {
|
||||
throw new InvalidArgumentException(sprintf('Service names that start with an underscore are reserved. Rename the "%s" service or define it in XML instead.', $id));
|
||||
@ -575,7 +572,6 @@ class YamlFileLoader extends FileLoader
|
||||
* Parses a callable.
|
||||
*
|
||||
* @param string|array $callable A callable reference
|
||||
* @param string $parameter The type of callable (e.g. 'factory' or 'configurator')
|
||||
*
|
||||
* @throws InvalidArgumentException When errors occur
|
||||
*
|
||||
@ -657,14 +653,11 @@ class YamlFileLoader extends FileLoader
|
||||
/**
|
||||
* Validates a YAML file.
|
||||
*
|
||||
* @param mixed $content
|
||||
* @param string $file
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @throws InvalidArgumentException When service file is not valid
|
||||
*/
|
||||
private function validate($content, $file)
|
||||
private function validate($content, string $file)
|
||||
{
|
||||
if (null === $content) {
|
||||
return $content;
|
||||
@ -691,13 +684,9 @@ class YamlFileLoader extends FileLoader
|
||||
/**
|
||||
* Resolves services.
|
||||
*
|
||||
* @param mixed $value
|
||||
* @param string $file
|
||||
* @param bool $isParameter
|
||||
*
|
||||
* @return array|string|Reference|ArgumentInterface
|
||||
*/
|
||||
private function resolveServices($value, $file, $isParameter = false)
|
||||
private function resolveServices($value, string $file, bool $isParameter = false)
|
||||
{
|
||||
if ($value instanceof TaggedValue) {
|
||||
$argument = $value->getValue();
|
||||
@ -833,12 +822,8 @@ class YamlFileLoader extends FileLoader
|
||||
|
||||
/**
|
||||
* Checks the keywords used to define a service.
|
||||
*
|
||||
* @param string $id The service name
|
||||
* @param array $definition The service definition to check
|
||||
* @param string $file The loaded YAML file
|
||||
*/
|
||||
private function checkDefinition($id, array $definition, $file)
|
||||
private function checkDefinition(string $id, array $definition, string $file)
|
||||
{
|
||||
if ($this->isLoadingInstanceof) {
|
||||
$keywords = self::$instanceofKeywords;
|
||||
|
@ -127,7 +127,7 @@ class ServiceLocator implements ServiceProviderInterface
|
||||
return new ServiceCircularReferenceException($id, $path);
|
||||
}
|
||||
|
||||
private function formatAlternatives(array $alternatives = null, $separator = 'and')
|
||||
private function formatAlternatives(array $alternatives = null, string $separator = 'and')
|
||||
{
|
||||
$format = '"%s"%s';
|
||||
if (null === $alternatives) {
|
||||
|
@ -949,11 +949,9 @@ class Crawler implements \Countable, \IteratorAggregate
|
||||
*
|
||||
* The XPath expression should already be processed to apply it in the context of each node.
|
||||
*
|
||||
* @param string $xpath
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
private function filterRelativeXPath($xpath)
|
||||
private function filterRelativeXPath(string $xpath)
|
||||
{
|
||||
$prefixes = $this->findNamespacePrefixes($xpath);
|
||||
|
||||
|
@ -163,13 +163,9 @@ class FormFieldRegistry
|
||||
/**
|
||||
* Transforms a PHP array in a list of fully qualified name / value.
|
||||
*
|
||||
* @param array $array The PHP array
|
||||
* @param string $base The name of the base field
|
||||
* @param array $output The initial values
|
||||
*
|
||||
* @return array The list of fields as [string] Fully qualified name => (mixed) value)
|
||||
*/
|
||||
private function walk(array $array, $base = '', array &$output = [])
|
||||
private function walk(array $array, ?string $base = '', array &$output = [])
|
||||
{
|
||||
foreach ($array as $k => $v) {
|
||||
$path = empty($base) ? $k : sprintf('%s[%s]', $base, $k);
|
||||
@ -188,11 +184,9 @@ class FormFieldRegistry
|
||||
*
|
||||
* getSegments('base[foo][3][]') = ['base', 'foo, '3', ''];
|
||||
*
|
||||
* @param string $name The name of the field
|
||||
*
|
||||
* @return string[] The list of segments
|
||||
*/
|
||||
private function getSegments($name)
|
||||
private function getSegments(string $name)
|
||||
{
|
||||
if (preg_match('/^(?P<base>[^[]+)(?P<extra>(\[.*)|$)/', $name, $m)) {
|
||||
$segments = [$m['base']];
|
||||
|
@ -372,7 +372,7 @@ final class Dotenv
|
||||
}
|
||||
}
|
||||
|
||||
private function resolveCommands($value)
|
||||
private function resolveCommands(string $value)
|
||||
{
|
||||
if (false === strpos($value, '$')) {
|
||||
return $value;
|
||||
@ -419,7 +419,7 @@ final class Dotenv
|
||||
}, $value);
|
||||
}
|
||||
|
||||
private function resolveVariables($value)
|
||||
private function resolveVariables(string $value)
|
||||
{
|
||||
if (false === strpos($value, '$')) {
|
||||
return $value;
|
||||
@ -471,13 +471,13 @@ final class Dotenv
|
||||
return $value;
|
||||
}
|
||||
|
||||
private function moveCursor($text)
|
||||
private function moveCursor(string $text)
|
||||
{
|
||||
$this->cursor += \strlen($text);
|
||||
$this->lineno += substr_count($text, "\n");
|
||||
}
|
||||
|
||||
private function createFormatException($message)
|
||||
private function createFormatException(string $message)
|
||||
{
|
||||
return new FormatException($message, new FormatExceptionContext($this->data, $this->path, $this->lineno, $this->cursor));
|
||||
}
|
||||
|
@ -496,7 +496,6 @@ class DebugClassLoader
|
||||
/**
|
||||
* `class_implements` includes interfaces from the parents so we have to manually exclude them.
|
||||
*
|
||||
* @param string $class
|
||||
* @param string|false $parent
|
||||
*
|
||||
* @return string[]
|
||||
|
@ -153,7 +153,7 @@ class HtmlErrorRenderer implements ErrorRendererInterface
|
||||
return implode(', ', $result);
|
||||
}
|
||||
|
||||
private function formatArgsAsText($args)
|
||||
private function formatArgsAsText(array $args)
|
||||
{
|
||||
return strip_tags($this->formatArgs($args));
|
||||
}
|
||||
@ -264,7 +264,7 @@ class HtmlErrorRenderer implements ErrorRendererInterface
|
||||
return '';
|
||||
}
|
||||
|
||||
private function fixCodeMarkup($line)
|
||||
private function fixCodeMarkup(string $line)
|
||||
{
|
||||
// </span> ending tag from previous line
|
||||
$opening = strpos($line, '<span');
|
||||
@ -283,7 +283,7 @@ class HtmlErrorRenderer implements ErrorRendererInterface
|
||||
return trim($line);
|
||||
}
|
||||
|
||||
private function formatFileFromText($text)
|
||||
private function formatFileFromText(string $text)
|
||||
{
|
||||
return preg_replace_callback('/in ("|")?(.+?)\1(?: +(?:on|at))? +line (\d+)/s', function ($match) {
|
||||
return 'in '.$this->formatFile($match[2], $match[3]);
|
||||
|
@ -302,7 +302,7 @@ class FlattenException
|
||||
return $this;
|
||||
}
|
||||
|
||||
private function flattenArgs($args, $level = 0, &$count = 0)
|
||||
private function flattenArgs(array $args, int $level = 0, int &$count = 0)
|
||||
{
|
||||
$result = [];
|
||||
foreach ($args as $key => $value) {
|
||||
|
@ -323,7 +323,7 @@ class TraceableEventDispatcher implements TraceableEventDispatcherInterface
|
||||
{
|
||||
}
|
||||
|
||||
private function preProcess($eventName)
|
||||
private function preProcess(string $eventName)
|
||||
{
|
||||
if (!$this->dispatcher->hasListeners($eventName)) {
|
||||
$this->orphanedEvents[$this->currentRequestHash][] = $eventName;
|
||||
@ -341,7 +341,7 @@ class TraceableEventDispatcher implements TraceableEventDispatcherInterface
|
||||
}
|
||||
}
|
||||
|
||||
private function postProcess($eventName)
|
||||
private function postProcess(string $eventName)
|
||||
{
|
||||
unset($this->wrappedListeners[$eventName]);
|
||||
$skipped = false;
|
||||
|
@ -294,13 +294,11 @@ class Filesystem
|
||||
/**
|
||||
* Tells whether a file exists and is readable.
|
||||
*
|
||||
* @param string $filename Path to the file
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
* @throws IOException When windows path is longer than 258 characters
|
||||
*/
|
||||
private function isReadable($filename)
|
||||
private function isReadable(string $filename)
|
||||
{
|
||||
$maxPathLength = PHP_MAXPATHLEN - 2;
|
||||
|
||||
@ -381,11 +379,9 @@ class Filesystem
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $origin
|
||||
* @param string $target
|
||||
* @param string $linkType Name of the link type, typically 'symbolic' or 'hard'
|
||||
*/
|
||||
private function linkException($origin, $target, $linkType)
|
||||
private function linkException(string $origin, string $target, string $linkType)
|
||||
{
|
||||
if (self::$lastError) {
|
||||
if ('\\' === \DIRECTORY_SEPARATOR && false !== strpos(self::$lastError, 'error code(1314)')) {
|
||||
|
@ -794,11 +794,9 @@ class Finder implements \IteratorAggregate, \Countable
|
||||
*
|
||||
* Excluding: (s)ftp:// wrapper
|
||||
*
|
||||
* @param string $dir
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function normalizeDir($dir)
|
||||
private function normalizeDir(string $dir)
|
||||
{
|
||||
$dir = rtrim($dir, '/'.\DIRECTORY_SEPARATOR);
|
||||
|
||||
|
@ -127,18 +127,9 @@ abstract class AbstractRendererEngine implements FormRendererEngineInterface
|
||||
*
|
||||
* @see getResourceForBlockHierarchy()
|
||||
*
|
||||
* @param string $cacheKey The cache key used for storing the
|
||||
* resource
|
||||
* @param FormView $view The form view for finding the applying
|
||||
* themes
|
||||
* @param string[] $blockNameHierarchy The block hierarchy, with the most
|
||||
* specific block name at the end
|
||||
* @param int $hierarchyLevel The level in the block hierarchy that
|
||||
* should be loaded
|
||||
*
|
||||
* @return bool True if the resource could be loaded, false otherwise
|
||||
*/
|
||||
private function loadResourceForBlockNameHierarchy($cacheKey, FormView $view, array $blockNameHierarchy, $hierarchyLevel)
|
||||
private function loadResourceForBlockNameHierarchy(string $cacheKey, FormView $view, array $blockNameHierarchy, $hierarchyLevel)
|
||||
{
|
||||
$blockName = $blockNameHierarchy[$hierarchyLevel];
|
||||
|
||||
|
@ -154,7 +154,7 @@ EOF
|
||||
$helper->describe($io, $object, $options);
|
||||
}
|
||||
|
||||
private function getFqcnTypeClass(InputInterface $input, SymfonyStyle $io, $shortClassName)
|
||||
private function getFqcnTypeClass(InputInterface $input, SymfonyStyle $io, string $shortClassName)
|
||||
{
|
||||
$classes = [];
|
||||
sort($this->namespaces);
|
||||
@ -223,7 +223,7 @@ EOF
|
||||
return $typesWithDeprecatedOptions;
|
||||
}
|
||||
|
||||
private function findAlternatives($name, array $collection)
|
||||
private function findAlternatives(string $name, array $collection)
|
||||
{
|
||||
$alternatives = [];
|
||||
foreach ($collection as $item) {
|
||||
|
@ -94,7 +94,7 @@ class DateIntervalToStringTransformer implements DataTransformerInterface
|
||||
return $dateInterval;
|
||||
}
|
||||
|
||||
private function isISO8601($string)
|
||||
private function isISO8601(string $string)
|
||||
{
|
||||
return preg_match('/^P(?=\w*(?:\d|%\w))(?:\d+Y|%[yY]Y)?(?:\d+M|%[mM]M)?(?:(?:\d+D|%[dD]D)|(?:\d+W|%[wW]W))?(?:T(?:\d+H|[hH]H)?(?:\d+M|[iI]M)?(?:\d+S|[sS]S)?)?$/', $string);
|
||||
}
|
||||
|
@ -326,7 +326,7 @@ class DateType extends AbstractType
|
||||
return 'date';
|
||||
}
|
||||
|
||||
private function formatTimestamps(\IntlDateFormatter $formatter, $regex, array $timestamps)
|
||||
private function formatTimestamps(\IntlDateFormatter $formatter, string $regex, array $timestamps)
|
||||
{
|
||||
$pattern = $formatter->getPattern();
|
||||
$timezone = $formatter->getTimeZoneId();
|
||||
|
@ -148,7 +148,7 @@ class FileType extends AbstractType
|
||||
return 'file';
|
||||
}
|
||||
|
||||
private function getFileUploadError($errorCode)
|
||||
private function getFileUploadError(int $errorCode)
|
||||
{
|
||||
$messageParameters = [];
|
||||
|
||||
@ -217,7 +217,7 @@ class FileType extends AbstractType
|
||||
*
|
||||
* This method should be kept in sync with Symfony\Component\Validator\Constraints\FileValidator::factorizeSizes().
|
||||
*/
|
||||
private function factorizeSizes($size, $limit)
|
||||
private function factorizeSizes(int $size, int $limit)
|
||||
{
|
||||
$coef = self::MIB_BYTES;
|
||||
$coefFactor = self::KIB_BYTES;
|
||||
|
@ -1045,8 +1045,6 @@ class Form implements \IteratorAggregate, FormInterface, ClearableErrorsInterfac
|
||||
/**
|
||||
* Normalizes the underlying data if a model transformer is set.
|
||||
*
|
||||
* @param mixed $value The value to transform
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws TransformationFailedException If the underlying data cannot be transformed to "normalized" format
|
||||
@ -1067,8 +1065,6 @@ class Form implements \IteratorAggregate, FormInterface, ClearableErrorsInterfac
|
||||
/**
|
||||
* Reverse transforms a value if a model transformer is set.
|
||||
*
|
||||
* @param string $value The value to reverse transform
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws TransformationFailedException If the value cannot be transformed to "model" format
|
||||
@ -1091,8 +1087,6 @@ class Form implements \IteratorAggregate, FormInterface, ClearableErrorsInterfac
|
||||
/**
|
||||
* Transforms the value if a view transformer is set.
|
||||
*
|
||||
* @param mixed $value The value to transform
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws TransformationFailedException If the normalized value cannot be transformed to "view" format
|
||||
@ -1122,8 +1116,6 @@ class Form implements \IteratorAggregate, FormInterface, ClearableErrorsInterfac
|
||||
/**
|
||||
* Reverse transforms a value if a view transformer is set.
|
||||
*
|
||||
* @param string $value The value to reverse transform
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws TransformationFailedException If the submitted value cannot be transformed to "normalized" format
|
||||
|
@ -269,7 +269,7 @@ class BinaryFileResponse extends Response
|
||||
return $this;
|
||||
}
|
||||
|
||||
private function hasValidIfRangeHeader($header)
|
||||
private function hasValidIfRangeHeader(?string $header)
|
||||
{
|
||||
if ($this->getEtag() === $header) {
|
||||
return true;
|
||||
|
@ -1983,7 +1983,7 @@ class Request
|
||||
return self::$trustedProxies && IpUtils::checkIp($this->server->get('REMOTE_ADDR'), self::$trustedProxies);
|
||||
}
|
||||
|
||||
private function getTrustedValues($type, $ip = null)
|
||||
private function getTrustedValues(int $type, string $ip = null)
|
||||
{
|
||||
$clientValues = [];
|
||||
$forwardedValues = [];
|
||||
@ -2034,7 +2034,7 @@ class Request
|
||||
throw new ConflictingHeadersException(sprintf('The request has both a trusted "%s" header and a trusted "%s" header, conflicting with each other. You should either configure your proxy to remove one of them, or configure your project to distrust the offending one.', self::$trustedHeaders[self::HEADER_FORWARDED], self::$trustedHeaders[$type]));
|
||||
}
|
||||
|
||||
private function normalizeAndFilterClientIps(array $clientIps, $ip)
|
||||
private function normalizeAndFilterClientIps(array $clientIps, string $ip)
|
||||
{
|
||||
if (!$clientIps) {
|
||||
return [];
|
||||
|
@ -423,10 +423,8 @@ class PdoSessionHandler extends AbstractSessionHandler
|
||||
|
||||
/**
|
||||
* Lazy-connects to the database.
|
||||
*
|
||||
* @param string $dsn DSN string
|
||||
*/
|
||||
private function connect($dsn)
|
||||
private function connect(string $dsn)
|
||||
{
|
||||
$this->pdo = new \PDO($dsn, $this->username, $this->password, $this->connectionOptions);
|
||||
$this->pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
|
||||
@ -436,13 +434,11 @@ class PdoSessionHandler extends AbstractSessionHandler
|
||||
/**
|
||||
* Builds a PDO DSN from a URL-like connection string.
|
||||
*
|
||||
* @param string $dsnOrUrl
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @todo implement missing support for oci DSN (which look totally different from other PDO ones)
|
||||
*/
|
||||
private function buildDsnFromUrl($dsnOrUrl)
|
||||
private function buildDsnFromUrl(string $dsnOrUrl)
|
||||
{
|
||||
// (pdo_)?sqlite3?:///... => (pdo_)?sqlite3?://localhost/... or else the URL will be invalid
|
||||
$url = preg_replace('#^((?:pdo_)?sqlite3?):///#', '$1://localhost/', $dsnOrUrl);
|
||||
@ -775,13 +771,9 @@ class PdoSessionHandler extends AbstractSessionHandler
|
||||
/**
|
||||
* Returns an insert statement supported by the database for writing session data.
|
||||
*
|
||||
* @param string $sessionId Session ID
|
||||
* @param string $sessionData Encoded session data
|
||||
* @param int $maxlifetime session.gc_maxlifetime
|
||||
*
|
||||
* @return \PDOStatement The insert statement
|
||||
*/
|
||||
private function getInsertStatement($sessionId, $sessionData, $maxlifetime)
|
||||
private function getInsertStatement(string $sessionId, string $sessionData, int $maxlifetime)
|
||||
{
|
||||
switch ($this->driver) {
|
||||
case 'oci':
|
||||
@ -808,13 +800,9 @@ class PdoSessionHandler extends AbstractSessionHandler
|
||||
/**
|
||||
* Returns an update statement supported by the database for writing session data.
|
||||
*
|
||||
* @param string $sessionId Session ID
|
||||
* @param string $sessionData Encoded session data
|
||||
* @param int $maxlifetime session.gc_maxlifetime
|
||||
*
|
||||
* @return \PDOStatement The update statement
|
||||
*/
|
||||
private function getUpdateStatement($sessionId, $sessionData, $maxlifetime)
|
||||
private function getUpdateStatement(string $sessionId, string $sessionData, int $maxlifetime)
|
||||
{
|
||||
switch ($this->driver) {
|
||||
case 'oci':
|
||||
|
@ -159,7 +159,7 @@ class MetadataBag implements SessionBagInterface
|
||||
$this->name = $name;
|
||||
}
|
||||
|
||||
private function stampCreated($lifetime = null)
|
||||
private function stampCreated(int $lifetime = null)
|
||||
{
|
||||
$timeStamp = time();
|
||||
$this->meta[self::CREATED] = $this->meta[self::UPDATED] = $this->lastUsed = $timeStamp;
|
||||
|
@ -256,7 +256,7 @@ class DumpDataCollector extends DataCollector implements DataDumperInterface
|
||||
}
|
||||
}
|
||||
|
||||
private function doDump(DataDumperInterface $dumper, $data, $name, $file, $line)
|
||||
private function doDump(DataDumperInterface $dumper, $data, string $name, string $file, int $line)
|
||||
{
|
||||
if ($dumper instanceof CliDumper) {
|
||||
$contextDumper = function ($name, $file, $line, $fmt) {
|
||||
|
@ -168,7 +168,7 @@ class LoggerDataCollector extends DataCollector implements LateDataCollectorInte
|
||||
return $logs;
|
||||
}
|
||||
|
||||
private function sanitizeLogs($logs)
|
||||
private function sanitizeLogs(array $logs)
|
||||
{
|
||||
$sanitizedLogs = [];
|
||||
$silencedLogs = [];
|
||||
|
@ -89,7 +89,7 @@ class MemoryDataCollector extends DataCollector implements LateDataCollectorInte
|
||||
return 'memory';
|
||||
}
|
||||
|
||||
private function convertToBytes($memoryLimit)
|
||||
private function convertToBytes(string $memoryLimit)
|
||||
{
|
||||
if ('-1' === $memoryLimit) {
|
||||
return -1;
|
||||
|
@ -104,7 +104,7 @@ class AddAnnotatedClassesToCachePass implements CompilerPassInterface
|
||||
return array_keys($classes);
|
||||
}
|
||||
|
||||
private function patternsToRegexps($patterns)
|
||||
private function patternsToRegexps(array $patterns)
|
||||
{
|
||||
$regexps = [];
|
||||
|
||||
@ -126,7 +126,7 @@ class AddAnnotatedClassesToCachePass implements CompilerPassInterface
|
||||
return $regexps;
|
||||
}
|
||||
|
||||
private function matchAnyRegexps($class, $regexps)
|
||||
private function matchAnyRegexps(string $class, array $regexps)
|
||||
{
|
||||
$blacklisted = false !== strpos($class, 'Test');
|
||||
|
||||
|
@ -83,7 +83,7 @@ abstract class AbstractSurrogateFragmentRenderer extends RoutableFragmentRendere
|
||||
return new Response($tag);
|
||||
}
|
||||
|
||||
private function generateSignedFragmentUri($uri, Request $request): string
|
||||
private function generateSignedFragmentUri(ControllerReference $uri, Request $request): string
|
||||
{
|
||||
if (null === $this->signer) {
|
||||
throw new \LogicException('You must use a URI when using the ESI rendering strategy or set a URL signer.');
|
||||
|
@ -77,7 +77,7 @@ abstract class RoutableFragmentRenderer implements FragmentRendererInterface
|
||||
return $request->getBaseUrl().$path;
|
||||
}
|
||||
|
||||
private function checkNonScalar($values)
|
||||
private function checkNonScalar(array $values)
|
||||
{
|
||||
foreach ($values as $key => $value) {
|
||||
if (\is_array($value)) {
|
||||
|
@ -203,12 +203,8 @@ class ResponseCacheStrategy implements ResponseCacheStrategyInterface
|
||||
*
|
||||
* If the value is lower than the currently stored value, we update the value, to keep a rolling
|
||||
* minimal value of each instruction. If the value is NULL, the directive will not be set on the final response.
|
||||
*
|
||||
* @param string $directive
|
||||
* @param int|null $value
|
||||
* @param int $age
|
||||
*/
|
||||
private function storeRelativeAgeDirective($directive, $value, $age)
|
||||
private function storeRelativeAgeDirective(string $directive, ?int $value, int $age)
|
||||
{
|
||||
if (null === $value) {
|
||||
$this->ageDirectives[$directive] = false;
|
||||
|
@ -261,7 +261,7 @@ class Store implements StoreInterface
|
||||
*
|
||||
* @return bool true if the two environments match, false otherwise
|
||||
*/
|
||||
private function requestsMatch($vary, $env1, $env2)
|
||||
private function requestsMatch(?string $vary, array $env1, array $env2)
|
||||
{
|
||||
if (empty($vary)) {
|
||||
return true;
|
||||
@ -284,11 +284,9 @@ class Store implements StoreInterface
|
||||
*
|
||||
* Use this method only if you know what you are doing.
|
||||
*
|
||||
* @param string $key The store key
|
||||
*
|
||||
* @return array An array of data associated with the key
|
||||
*/
|
||||
private function getMetadata($key)
|
||||
private function getMetadata(string $key)
|
||||
{
|
||||
if (!$entries = $this->load($key)) {
|
||||
return [];
|
||||
@ -320,11 +318,9 @@ class Store implements StoreInterface
|
||||
/**
|
||||
* Purges data for the given URL.
|
||||
*
|
||||
* @param string $url A URL
|
||||
*
|
||||
* @return bool true if the URL exists and has been purged, false otherwise
|
||||
*/
|
||||
private function doPurge($url)
|
||||
private function doPurge(string $url)
|
||||
{
|
||||
$key = $this->getCacheKey(Request::create($url));
|
||||
if (isset($this->locks[$key])) {
|
||||
@ -345,11 +341,9 @@ class Store implements StoreInterface
|
||||
/**
|
||||
* Loads data for the given key.
|
||||
*
|
||||
* @param string $key The store key
|
||||
*
|
||||
* @return string The data associated with the key
|
||||
*/
|
||||
private function load($key)
|
||||
private function load(string $key)
|
||||
{
|
||||
$path = $this->getPath($key);
|
||||
|
||||
@ -359,12 +353,9 @@ class Store implements StoreInterface
|
||||
/**
|
||||
* Save data for the given key.
|
||||
*
|
||||
* @param string $key The store key
|
||||
* @param string $data The data to store
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private function save($key, $data)
|
||||
private function save(string $key, string $data)
|
||||
{
|
||||
$path = $this->getPath($key);
|
||||
|
||||
@ -470,12 +461,9 @@ class Store implements StoreInterface
|
||||
/**
|
||||
* Restores a Response from the HTTP headers and body.
|
||||
*
|
||||
* @param array $headers An array of HTTP headers for the Response
|
||||
* @param string $body The Response body
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
private function restoreResponse($headers, $body = null)
|
||||
private function restoreResponse(array $headers, string $body = null)
|
||||
{
|
||||
$status = $headers['X-Status'][0];
|
||||
unset($headers['X-Status']);
|
||||
|
@ -242,7 +242,7 @@ class Profiler implements ResetInterface
|
||||
return $this->collectors[$name];
|
||||
}
|
||||
|
||||
private function getTimestamp($value)
|
||||
private function getTimestamp(?string $value)
|
||||
{
|
||||
if (null === $value || '' == $value) {
|
||||
return;
|
||||
|
@ -82,7 +82,7 @@ class UriSigner
|
||||
return $this->computeHash($this->buildUrl($url, $params)) === $hash;
|
||||
}
|
||||
|
||||
private function computeHash($uri)
|
||||
private function computeHash(string $uri)
|
||||
{
|
||||
return base64_encode(hash_hmac('sha256', $uri, $this->secret, true));
|
||||
}
|
||||
|
@ -43,15 +43,12 @@ class TextBundleWriter implements BundleWriterInterface
|
||||
/**
|
||||
* Writes a "resourceBundle" node.
|
||||
*
|
||||
* @param resource $file The file handle to write to
|
||||
* @param string $bundleName The name of the bundle
|
||||
* @param mixed $value The value of the node
|
||||
* @param bool $fallback Whether the resource bundle should be merged
|
||||
* with the fallback locale
|
||||
* @param resource $file The file handle to write to
|
||||
* @param mixed $value The value of the node
|
||||
*
|
||||
* @see http://source.icu-project.org/repos/icu/icuhtml/trunk/design/bnf_rb.txt
|
||||
*/
|
||||
private function writeResourceBundle($file, $bundleName, $value, $fallback)
|
||||
private function writeResourceBundle($file, string $bundleName, $value, bool $fallback)
|
||||
{
|
||||
fwrite($file, $bundleName);
|
||||
|
||||
@ -63,14 +60,12 @@ class TextBundleWriter implements BundleWriterInterface
|
||||
/**
|
||||
* Writes a "resource" node.
|
||||
*
|
||||
* @param resource $file The file handle to write to
|
||||
* @param mixed $value The value of the node
|
||||
* @param int $indentation The number of levels to indent
|
||||
* @param bool $requireBraces Whether to require braces to be printedaround the value
|
||||
* @param resource $file The file handle to write to
|
||||
* @param mixed $value The value of the node
|
||||
*
|
||||
* @see http://source.icu-project.org/repos/icu/icuhtml/trunk/design/bnf_rb.txt
|
||||
*/
|
||||
private function writeResource($file, $value, $indentation, $requireBraces = true)
|
||||
private function writeResource($file, $value, int $indentation, bool $requireBraces = true)
|
||||
{
|
||||
if (\is_int($value)) {
|
||||
$this->writeInteger($file, $value);
|
||||
@ -117,12 +112,11 @@ class TextBundleWriter implements BundleWriterInterface
|
||||
/**
|
||||
* Writes an "integer" node.
|
||||
*
|
||||
* @param resource $file The file handle to write to
|
||||
* @param int $value The value of the node
|
||||
* @param resource $file The file handle to write to
|
||||
*
|
||||
* @see http://source.icu-project.org/repos/icu/icuhtml/trunk/design/bnf_rb.txt
|
||||
*/
|
||||
private function writeInteger($file, $value)
|
||||
private function writeInteger($file, int $value)
|
||||
{
|
||||
fprintf($file, ':int{%d}', $value);
|
||||
}
|
||||
@ -130,13 +124,11 @@ class TextBundleWriter implements BundleWriterInterface
|
||||
/**
|
||||
* Writes an "intvector" node.
|
||||
*
|
||||
* @param resource $file The file handle to write to
|
||||
* @param array $value The value of the node
|
||||
* @param int $indentation The number of levels to indent
|
||||
* @param resource $file The file handle to write to
|
||||
*
|
||||
* @see http://source.icu-project.org/repos/icu/icuhtml/trunk/design/bnf_rb.txt
|
||||
*/
|
||||
private function writeIntVector($file, array $value, $indentation)
|
||||
private function writeIntVector($file, array $value, int $indentation)
|
||||
{
|
||||
fwrite($file, ":intvector{\n");
|
||||
|
||||
@ -150,14 +142,11 @@ class TextBundleWriter implements BundleWriterInterface
|
||||
/**
|
||||
* Writes a "string" node.
|
||||
*
|
||||
* @param resource $file The file handle to write to
|
||||
* @param string $value The value of the node
|
||||
* @param bool $requireBraces Whether to require braces to be printed
|
||||
* around the value
|
||||
* @param resource $file The file handle to write to
|
||||
*
|
||||
* @see http://source.icu-project.org/repos/icu/icuhtml/trunk/design/bnf_rb.txt
|
||||
*/
|
||||
private function writeString($file, $value, $requireBraces = true)
|
||||
private function writeString($file, string $value, bool $requireBraces = true)
|
||||
{
|
||||
if ($requireBraces) {
|
||||
fprintf($file, '{"%s"}', $value);
|
||||
@ -171,13 +160,11 @@ class TextBundleWriter implements BundleWriterInterface
|
||||
/**
|
||||
* Writes an "array" node.
|
||||
*
|
||||
* @param resource $file The file handle to write to
|
||||
* @param array $value The value of the node
|
||||
* @param int $indentation The number of levels to indent
|
||||
* @param resource $file The file handle to write to
|
||||
*
|
||||
* @see http://source.icu-project.org/repos/icu/icuhtml/trunk/design/bnf_rb.txt
|
||||
*/
|
||||
private function writeArray($file, array $value, $indentation)
|
||||
private function writeArray($file, array $value, int $indentation)
|
||||
{
|
||||
fwrite($file, "{\n");
|
||||
|
||||
@ -195,16 +182,12 @@ class TextBundleWriter implements BundleWriterInterface
|
||||
/**
|
||||
* Writes a "table" node.
|
||||
*
|
||||
* @param resource $file The file handle to write to
|
||||
* @param iterable $value The value of the node
|
||||
* @param int $indentation The number of levels to indent
|
||||
* @param bool $fallback Whether the table should be merged
|
||||
* with the fallback locale
|
||||
* @param resource $file The file handle to write to
|
||||
*
|
||||
* @throws UnexpectedTypeException when $value is not an array and not a
|
||||
* \Traversable instance
|
||||
*/
|
||||
private function writeTable($file, $value, $indentation, $fallback = true)
|
||||
private function writeTable($file, iterable $value, int $indentation, bool $fallback = true)
|
||||
{
|
||||
if (!\is_array($value) && !$value instanceof \Traversable) {
|
||||
throw new UnexpectedTypeException($value, 'array or \Traversable');
|
||||
|
@ -151,7 +151,7 @@ class LocaleDataGenerator extends AbstractDataGenerator
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
private function generateLocaleName(BundleEntryReaderInterface $reader, $tempDir, $locale, $displayLocale, $pattern, $separator)
|
||||
private function generateLocaleName(BundleEntryReaderInterface $reader, string $tempDir, string $locale, string $displayLocale, string $pattern, string $separator)
|
||||
{
|
||||
// Apply generic notation using square brackets as described per http://cldr.unicode.org/translation/language-names
|
||||
$name = str_replace(['(', ')'], ['[', ']'], $reader->readEntry($tempDir.'/lang', $displayLocale, ['Languages', \Locale::getPrimaryLanguage($locale)]));
|
||||
|
@ -672,15 +672,12 @@ class NumberFormatter
|
||||
*
|
||||
* The only actual rounding data as of this writing, is CHF.
|
||||
*
|
||||
* @param float $value The numeric currency value
|
||||
* @param string $currency The 3-letter ISO 4217 currency code indicating the currency to use
|
||||
*
|
||||
* @return float The rounded numeric currency value
|
||||
*
|
||||
* @see http://en.wikipedia.org/wiki/Swedish_rounding
|
||||
* @see http://www.docjar.com/html/api/com/ibm/icu/util/Currency.java.html#1007
|
||||
*/
|
||||
private function roundCurrency($value, $currency)
|
||||
private function roundCurrency(float $value, string $currency)
|
||||
{
|
||||
$fractionDigits = Currencies::getFractionDigits($currency);
|
||||
$roundingIncrement = Currencies::getRoundingIncrement($currency);
|
||||
@ -700,12 +697,11 @@ class NumberFormatter
|
||||
/**
|
||||
* Rounds a value.
|
||||
*
|
||||
* @param int|float $value The value to round
|
||||
* @param int $precision The number of decimal digits to round to
|
||||
* @param int|float $value The value to round
|
||||
*
|
||||
* @return int|float The rounded value
|
||||
*/
|
||||
private function round($value, $precision)
|
||||
private function round($value, int $precision)
|
||||
{
|
||||
$precision = $this->getUninitializedPrecision($value, $precision);
|
||||
|
||||
@ -741,12 +737,11 @@ class NumberFormatter
|
||||
/**
|
||||
* Formats a number.
|
||||
*
|
||||
* @param int|float $value The numeric value to format
|
||||
* @param int $precision The number of decimal digits to use
|
||||
* @param int|float $value The numeric value to format
|
||||
*
|
||||
* @return string The formatted number
|
||||
*/
|
||||
private function formatNumber($value, $precision)
|
||||
private function formatNumber($value, int $precision)
|
||||
{
|
||||
$precision = $this->getUninitializedPrecision($value, $precision);
|
||||
|
||||
@ -756,12 +751,11 @@ class NumberFormatter
|
||||
/**
|
||||
* Returns the precision value if the DECIMAL style is being used and the FRACTION_DIGITS attribute is uninitialized.
|
||||
*
|
||||
* @param int|float $value The value to get the precision from if the FRACTION_DIGITS attribute is uninitialized
|
||||
* @param int $precision The precision value to returns if the FRACTION_DIGITS attribute is initialized
|
||||
* @param int|float $value The value to get the precision from if the FRACTION_DIGITS attribute is uninitialized
|
||||
*
|
||||
* @return int The precision value
|
||||
*/
|
||||
private function getUninitializedPrecision($value, $precision)
|
||||
private function getUninitializedPrecision($value, int $precision)
|
||||
{
|
||||
if (self::CURRENCY == $this->style) {
|
||||
return $precision;
|
||||
@ -780,11 +774,9 @@ class NumberFormatter
|
||||
/**
|
||||
* Check if the attribute is initialized (value set by client code).
|
||||
*
|
||||
* @param string $attr The attribute name
|
||||
*
|
||||
* @return bool true if the value was set by client, false otherwise
|
||||
*/
|
||||
private function isInitializedAttribute($attr)
|
||||
private function isInitializedAttribute(string $attr)
|
||||
{
|
||||
return isset($this->initializedAttributes[$attr]);
|
||||
}
|
||||
@ -793,11 +785,10 @@ class NumberFormatter
|
||||
* Returns the numeric value using the $type to convert to the right data type.
|
||||
*
|
||||
* @param mixed $value The value to be converted
|
||||
* @param int $type The type to convert. Can be TYPE_DOUBLE (float) or TYPE_INT32 (int)
|
||||
*
|
||||
* @return int|float|false The converted value
|
||||
*/
|
||||
private function convertValueDataType($value, $type)
|
||||
private function convertValueDataType($value, int $type)
|
||||
{
|
||||
if (self::TYPE_DOUBLE == $type) {
|
||||
$value = (float) $value;
|
||||
@ -813,8 +804,6 @@ class NumberFormatter
|
||||
/**
|
||||
* Convert the value data type to int or returns false if the value is out of the integer value range.
|
||||
*
|
||||
* @param mixed $value The value to be converted
|
||||
*
|
||||
* @return int|false The converted value
|
||||
*/
|
||||
private function getInt32Value($value)
|
||||
@ -829,8 +818,6 @@ class NumberFormatter
|
||||
/**
|
||||
* Convert the value data type to int or returns false if the value is out of the integer value range.
|
||||
*
|
||||
* @param mixed $value The value to be converted
|
||||
*
|
||||
* @return int|float|false The converted value
|
||||
*/
|
||||
private function getInt64Value($value)
|
||||
@ -849,11 +836,9 @@ class NumberFormatter
|
||||
/**
|
||||
* Check if the rounding mode is invalid.
|
||||
*
|
||||
* @param int $value The rounding mode value to check
|
||||
*
|
||||
* @return bool true if the rounding mode is invalid, false otherwise
|
||||
*/
|
||||
private function isInvalidRoundingMode($value)
|
||||
private function isInvalidRoundingMode(int $value)
|
||||
{
|
||||
if (\in_array($value, self::$roundingModes, true)) {
|
||||
return false;
|
||||
@ -866,8 +851,6 @@ class NumberFormatter
|
||||
* Returns the normalized value for the GROUPING_USED attribute. Any value that can be converted to int will be
|
||||
* cast to Boolean and then to int again. This way, negative values are converted to 1 and string values to 0.
|
||||
*
|
||||
* @param mixed $value The value to be normalized
|
||||
*
|
||||
* @return int The normalized value for the attribute (0 or 1)
|
||||
*/
|
||||
private function normalizeGroupingUsedValue($value)
|
||||
@ -878,8 +861,6 @@ class NumberFormatter
|
||||
/**
|
||||
* Returns the normalized value for the FRACTION_DIGITS attribute.
|
||||
*
|
||||
* @param mixed $value The value to be normalized
|
||||
*
|
||||
* @return int The normalized value for the attribute
|
||||
*/
|
||||
private function normalizeFractionDigitsValue($value)
|
||||
|
@ -59,7 +59,7 @@ class NumberFormatterTest extends AbstractNumberFormatterTest
|
||||
public function testSetAttributeInvalidRoundingMode()
|
||||
{
|
||||
$formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL);
|
||||
$formatter->setAttribute(NumberFormatter::ROUNDING_MODE, null);
|
||||
$formatter->setAttribute(NumberFormatter::ROUNDING_MODE, -1);
|
||||
}
|
||||
|
||||
public function testConstructWithoutLocale()
|
||||
|
@ -85,7 +85,7 @@ final class GitRepository
|
||||
$this->execInPath(sprintf('git checkout %s', escapeshellarg($branch)));
|
||||
}
|
||||
|
||||
private function execInPath($command)
|
||||
private function execInPath(string $command)
|
||||
{
|
||||
return self::exec(sprintf('cd %s && %s', escapeshellarg($this->path), $command));
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user