feature #31996 [5.0] Add return types in final classes (dFayet)

This PR was merged into the 5.0-dev branch.

Discussion
----------

[5.0] Add return types in final classes

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes/no <!-- please update src/**/CHANGELOG.md files -->
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | no
| Fixed tickets | #31981
| License       | MIT
| Doc PR        | symfony/symfony-docs#... <!-- required for new features -->

This is the first step for the issue #31981

I have some questions:

-  ~I have not added type for methods with `@inheritdoc` annotation, should I?~
- ~Don't we want to type also functions without `@return` annotation? (still in `final` classes)~
- ~If yes is the answer of the previous one, do we also want the `void` return type?~
- ~I have also added the return type in the `DependencyInjection` PhpDumper, but is it also wanted? (if yes, I will clean a bit the code changed)~
- ~Should we update the documentation's code samples when they display `final` classes?~

Todo:
- [x] Adjust the PR, following the answers of the questions
- [x] Add return type also when there is no `@return`, or with `@inheritdoc`
- [x] [src/Symfony/Component/Debug/ErrorHandler.php#L383](https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Debug/ErrorHandler.php#L383) `@return` annotation is not correct according to the return, investigate and adjust if needed
- [x] [src/Symfony/Component/HttpKernel/ControllerMetadata/ArgumentMetadataFactory.php#L50](https://github.com/symfony/symfony/blob/master/src/Symfony/Component/HttpKernel/ControllerMetadata/ArgumentMetadataFactory.php#L50) `@return` annotation is not correct according to the return, investigate and adjust if needed
- [x] Do a PR on documentation to add return type on code snippets with final classes => unneeded as they were already typed

Commits
-------

ca5ae1989e Replace @return annotation by return type in final classes
This commit is contained in:
Tobias Schultze 2019-06-23 23:15:46 +01:00
commit 18793b7ca7
147 changed files with 326 additions and 398 deletions

View File

@ -29,7 +29,7 @@ final class TestRepositoryFactory implements RepositoryFactory
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function getRepository(EntityManagerInterface $entityManager, $entityName) public function getRepository(EntityManagerInterface $entityManager, $entityName): ObjectRepository
{ {
$repositoryHash = $this->getRepositoryHash($entityManager, $entityName); $repositoryHash = $this->getRepositoryHash($entityManager, $entityName);
@ -47,10 +47,7 @@ final class TestRepositoryFactory implements RepositoryFactory
$this->repositoryList[$repositoryHash] = $repository; $this->repositoryList[$repositoryHash] = $repository;
} }
/** private function createRepository(EntityManagerInterface $entityManager, $entityName): ObjectRepository
* @return ObjectRepository
*/
private function createRepository(EntityManagerInterface $entityManager, $entityName)
{ {
/* @var $metadata ClassMetadata */ /* @var $metadata ClassMetadata */
$metadata = $entityManager->getClassMetadata($entityName); $metadata = $entityManager->getClassMetadata($entityName);
@ -59,7 +56,7 @@ final class TestRepositoryFactory implements RepositoryFactory
return new $repositoryClassName($entityManager, $metadata); return new $repositoryClassName($entityManager, $metadata);
} }
private function getRepositoryHash(EntityManagerInterface $entityManager, $entityName) private function getRepositoryHash(EntityManagerInterface $entityManager, $entityName): string
{ {
return $entityManager->getClassMetadata($entityName)->getName().spl_object_hash($entityManager); return $entityManager->getClassMetadata($entityName)->getName().spl_object_hash($entityManager);
} }

View File

@ -73,7 +73,7 @@ class ChromePhpHandler extends BaseChromePhpHandler
/** /**
* Override default behavior since we check it in onKernelResponse. * Override default behavior since we check it in onKernelResponse.
*/ */
protected function headersAccepted() protected function headersAccepted(): bool
{ {
return true; return true;
} }

View File

@ -75,7 +75,7 @@ class FirePHPHandler extends BaseFirePHPHandler
/** /**
* Override default behavior since we check the user agent in onKernelResponse. * Override default behavior since we check the user agent in onKernelResponse.
*/ */
protected function headersAccepted() protected function headersAccepted(): bool
{ {
return true; return true;
} }

View File

@ -35,7 +35,7 @@ class RouteProcessor implements EventSubscriberInterface, ResetInterface
$this->reset(); $this->reset();
} }
public function __invoke(array $records) public function __invoke(array $records): array
{ {
if ($this->routeData && !isset($records['extra']['requests'])) { if ($this->routeData && !isset($records['extra']['requests'])) {
$records['extra']['requests'] = array_values($this->routeData); $records['extra']['requests'] = array_values($this->routeData);
@ -78,7 +78,7 @@ class RouteProcessor implements EventSubscriberInterface, ResetInterface
unset($this->routeData[$requestId]); unset($this->routeData[$requestId]);
} }
public static function getSubscribedEvents() public static function getSubscribedEvents(): array
{ {
return [ return [
KernelEvents::REQUEST => ['addRouteData', 1], KernelEvents::REQUEST => ['addRouteData', 1],

View File

@ -39,7 +39,7 @@ class WebProcessor extends BaseWebProcessor implements EventSubscriberInterface
} }
} }
public static function getSubscribedEvents() public static function getSubscribedEvents(): array
{ {
return [ return [
KernelEvents::REQUEST => ['onKernelRequest', 4096], KernelEvents::REQUEST => ['onKernelRequest', 4096],

View File

@ -40,7 +40,7 @@ class ProxyDumper implements DumperInterface
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function isProxyCandidate(Definition $definition) public function isProxyCandidate(Definition $definition): bool
{ {
return ($definition->isLazy() || $definition->hasTag('proxy')) && $this->proxyGenerator->getProxifiedClass($definition); return ($definition->isLazy() || $definition->hasTag('proxy')) && $this->proxyGenerator->getProxifiedClass($definition);
} }
@ -48,7 +48,7 @@ class ProxyDumper implements DumperInterface
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function getProxyFactoryCode(Definition $definition, $id, $factoryCode = null) public function getProxyFactoryCode(Definition $definition, $id, $factoryCode = null): string
{ {
$instantiation = 'return'; $instantiation = 'return';
@ -82,7 +82,7 @@ EOF;
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function getProxyCode(Definition $definition) public function getProxyCode(Definition $definition): string
{ {
$code = $this->classGenerator->generate($this->generateProxyClass($definition)); $code = $this->classGenerator->generate($this->generateProxyClass($definition));

View File

@ -93,7 +93,7 @@ class RoutingExtension extends AbstractExtension
* *
* @final * @final
*/ */
public function isUrlGenerationSafe(Node $argsNode) public function isUrlGenerationSafe(Node $argsNode): array
{ {
// support named arguments // support named arguments
$paramsNode = $argsNode->hasNode('parameters') ? $argsNode->getNode('parameters') : ( $paramsNode = $argsNode->hasNode('parameters') ? $argsNode->getNode('parameters') : (

View File

@ -58,7 +58,7 @@ class TranslationExtension extends AbstractExtension
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function getFilters() public function getFilters(): array
{ {
return [ return [
new TwigFilter('trans', [$this, 'trans']), new TwigFilter('trans', [$this, 'trans']),
@ -70,7 +70,7 @@ class TranslationExtension extends AbstractExtension
* *
* @return AbstractTokenParser[] * @return AbstractTokenParser[]
*/ */
public function getTokenParsers() public function getTokenParsers(): array
{ {
return [ return [
// {% trans %}Symfony is great!{% endtrans %} // {% trans %}Symfony is great!{% endtrans %}
@ -84,17 +84,17 @@ class TranslationExtension extends AbstractExtension
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function getNodeVisitors() public function getNodeVisitors(): array
{ {
return [$this->getTranslationNodeVisitor(), new TranslationDefaultDomainNodeVisitor()]; return [$this->getTranslationNodeVisitor(), new TranslationDefaultDomainNodeVisitor()];
} }
public function getTranslationNodeVisitor() public function getTranslationNodeVisitor(): TranslationNodeVisitor
{ {
return $this->translationNodeVisitor ?: $this->translationNodeVisitor = new TranslationNodeVisitor(); return $this->translationNodeVisitor ?: $this->translationNodeVisitor = new TranslationNodeVisitor();
} }
public function trans($message, array $arguments = [], $domain = null, $locale = null, $count = null) public function trans($message, array $arguments = [], $domain = null, $locale = null, $count = null): string
{ {
if (null !== $count) { if (null !== $count) {
$arguments['%count%'] = $count; $arguments['%count%'] = $count;
@ -106,7 +106,7 @@ class TranslationExtension extends AbstractExtension
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function getName() public function getName(): string
{ {
return 'translator'; return 'translator';
} }

View File

@ -65,7 +65,7 @@ final class WrappedTemplatedEmail
/** /**
* @return $this * @return $this
*/ */
public function setSubject(string $subject) public function setSubject(string $subject): object
{ {
$this->message->subject($subject); $this->message->subject($subject);
@ -80,7 +80,7 @@ final class WrappedTemplatedEmail
/** /**
* @return $this * @return $this
*/ */
public function setReturnPath(string $address) public function setReturnPath(string $address): object
{ {
$this->message->returnPath($address); $this->message->returnPath($address);
@ -95,7 +95,7 @@ final class WrappedTemplatedEmail
/** /**
* @return $this * @return $this
*/ */
public function addFrom(string $address, string $name = null) public function addFrom(string $address, string $name = null): object
{ {
$this->message->addFrom($name ? new NamedAddress($address, $name) : new Address($address)); $this->message->addFrom($name ? new NamedAddress($address, $name) : new Address($address));
@ -113,7 +113,7 @@ final class WrappedTemplatedEmail
/** /**
* @return $this * @return $this
*/ */
public function addReplyTo(string $address) public function addReplyTo(string $address): object
{ {
$this->message->addReplyTo($address); $this->message->addReplyTo($address);
@ -131,7 +131,7 @@ final class WrappedTemplatedEmail
/** /**
* @return $this * @return $this
*/ */
public function addTo(string $address, string $name = null) public function addTo(string $address, string $name = null): object
{ {
$this->message->addTo($name ? new NamedAddress($address, $name) : new Address($address)); $this->message->addTo($name ? new NamedAddress($address, $name) : new Address($address));
@ -149,7 +149,7 @@ final class WrappedTemplatedEmail
/** /**
* @return $this * @return $this
*/ */
public function addCc(string $address, string $name = null) public function addCc(string $address, string $name = null): object
{ {
$this->message->addCc($name ? new NamedAddress($address, $name) : new Address($address)); $this->message->addCc($name ? new NamedAddress($address, $name) : new Address($address));
@ -167,7 +167,7 @@ final class WrappedTemplatedEmail
/** /**
* @return $this * @return $this
*/ */
public function addBcc(string $address, string $name = null) public function addBcc(string $address, string $name = null): object
{ {
$this->message->addBcc($name ? new NamedAddress($address, $name) : new Address($address)); $this->message->addBcc($name ? new NamedAddress($address, $name) : new Address($address));
@ -185,7 +185,7 @@ final class WrappedTemplatedEmail
/** /**
* @return $this * @return $this
*/ */
public function setPriority(int $priority) public function setPriority(int $priority): object
{ {
$this->message->setPriority($priority); $this->message->setPriority($priority);

View File

@ -57,7 +57,7 @@ class RouterCacheWarmer implements CacheWarmerInterface, ServiceSubscriberInterf
* *
* @return bool always true * @return bool always true
*/ */
public function isOptional() public function isOptional(): bool
{ {
return true; return true;
} }
@ -65,7 +65,7 @@ class RouterCacheWarmer implements CacheWarmerInterface, ServiceSubscriberInterf
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public static function getSubscribedServices() public static function getSubscribedServices(): array
{ {
return [ return [
'router' => RouterInterface::class, 'router' => RouterInterface::class,

View File

@ -258,7 +258,7 @@ EOT
return self::METHOD_COPY; return self::METHOD_COPY;
} }
private function getPublicDirectory(ContainerInterface $container) private function getPublicDirectory(ContainerInterface $container): string
{ {
$defaultPublicDir = 'public'; $defaultPublicDir = 'public';

View File

@ -208,11 +208,9 @@ EOF
/** /**
* Loads the ContainerBuilder from the cache. * Loads the ContainerBuilder from the cache.
* *
* @return ContainerBuilder
*
* @throws \LogicException * @throws \LogicException
*/ */
protected function getContainerBuilder() protected function getContainerBuilder(): ContainerBuilder
{ {
if ($this->containerBuilder) { if ($this->containerBuilder) {
return $this->containerBuilder; return $this->containerBuilder;

View File

@ -24,12 +24,12 @@ class ControllerResolver extends ContainerControllerResolver
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function instantiateController($class) protected function instantiateController($class): object
{ {
return $this->configureController(parent::instantiateController($class), $class); return $this->configureController(parent::instantiateController($class), $class);
} }
private function configureController($controller, string $class) private function configureController($controller, string $class): object
{ {
if ($controller instanceof ContainerAwareInterface) { if ($controller instanceof ContainerAwareInterface) {
$controller->setContainer($this->container); $controller->setContainer($this->container);

View File

@ -180,7 +180,7 @@ EOF
})->setHidden(true)->setMaxAttempts(20); })->setHidden(true)->setMaxAttempts(20);
} }
private function generateSalt() private function generateSalt(): string
{ {
return base64_encode(random_bytes(30)); return base64_encode(random_bytes(30));
} }

View File

@ -54,7 +54,7 @@ final class WrappedListener
return $this->listener->{$method}(...$arguments); return $this->listener->{$method}(...$arguments);
} }
public function getWrappedListener() public function getWrappedListener(): callable
{ {
return $this->listener; return $this->listener;
} }

View File

@ -55,7 +55,7 @@ class WebDebugToolbarListener implements EventSubscriberInterface
$this->cspHandler = $cspHandler; $this->cspHandler = $cspHandler;
} }
public function isEnabled() public function isEnabled(): bool
{ {
return self::DISABLED !== $this->mode; return self::DISABLED !== $this->mode;
} }
@ -136,7 +136,7 @@ class WebDebugToolbarListener implements EventSubscriberInterface
} }
} }
public static function getSubscribedEvents() public static function getSubscribedEvents(): array
{ {
return [ return [
KernelEvents::RESPONSE => ['onKernelResponse', -128], KernelEvents::RESPONSE => ['onKernelResponse', -128],

View File

@ -41,7 +41,7 @@ class HttpBrowser extends AbstractBrowser
parent::__construct([], $history, $cookieJar); parent::__construct([], $history, $cookieJar);
} }
protected function doRequest($request) protected function doRequest($request): Response
{ {
$headers = $this->getHeaders($request); $headers = $this->getHeaders($request);
[$body, $extraHeaders] = $this->getBodyAndExtraHeaders($request); [$body, $extraHeaders] = $this->getBodyAndExtraHeaders($request);

View File

@ -40,7 +40,7 @@ final class Response
* *
* @return string The response with headers and content * @return string The response with headers and content
*/ */
public function __toString() public function __toString(): string
{ {
$headers = ''; $headers = '';
foreach ($this->headers as $name => $value) { foreach ($this->headers as $name => $value) {
@ -61,7 +61,7 @@ final class Response
* *
* @return string The response content * @return string The response content
*/ */
public function getContent() public function getContent(): string
{ {
return $this->content; return $this->content;
} }
@ -76,7 +76,7 @@ final class Response
* *
* @return array The response headers * @return array The response headers
*/ */
public function getHeaders() public function getHeaders(): array
{ {
return $this->headers; return $this->headers;
} }

View File

@ -59,7 +59,7 @@ class TestHttpClient extends HttpBrowser
return $response; return $response;
} }
protected function doRequest($request) protected function doRequest($request): Response
{ {
$response = parent::doRequest($request); $response = parent::doRequest($request);

View File

@ -37,7 +37,7 @@ final class CacheItem implements ItemInterface
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function getKey() public function getKey(): string
{ {
return $this->key; return $this->key;
} }
@ -53,7 +53,7 @@ final class CacheItem implements ItemInterface
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function isHit() public function isHit(): bool
{ {
return $this->isHit; return $this->isHit;
} }
@ -145,11 +145,9 @@ final class CacheItem implements ItemInterface
* *
* @param string $key The key to validate * @param string $key The key to validate
* *
* @return string
*
* @throws InvalidArgumentException When $key is not valid * @throws InvalidArgumentException When $key is not valid
*/ */
public static function validateKey($key) public static function validateKey($key): string
{ {
if (!\is_string($key)) { if (!\is_string($key)) {
throw new InvalidArgumentException(sprintf('Cache key must be string, "%s" given', \is_object($key) ? \get_class($key) : \gettype($key))); throw new InvalidArgumentException(sprintf('Cache key must be string, "%s" given', \is_object($key) ? \get_class($key) : \gettype($key)));

View File

@ -28,7 +28,7 @@ class Processor
* *
* @return array The processed configuration * @return array The processed configuration
*/ */
public function process(NodeInterface $configTree, array $configs) public function process(NodeInterface $configTree, array $configs): array
{ {
$currentConfig = []; $currentConfig = [];
foreach ($configs as $config) { foreach ($configs as $config) {
@ -47,7 +47,7 @@ class Processor
* *
* @return array The processed configuration * @return array The processed configuration
*/ */
public function processConfiguration(ConfigurationInterface $configuration, array $configs) public function processConfiguration(ConfigurationInterface $configuration, array $configs): array
{ {
return $this->process($configuration->getConfigTreeBuilder()->buildTree(), $configs); return $this->process($configuration->getConfigTreeBuilder()->buildTree(), $configs);
} }
@ -75,7 +75,7 @@ class Processor
* *
* @return array * @return array
*/ */
public static function normalizeConfig(array $config, string $key, string $plural = null) public static function normalizeConfig(array $config, string $key, string $plural = null): array
{ {
if (null === $plural) { if (null === $plural) {
$plural = $key.'s'; $plural = $key.'s';

View File

@ -43,7 +43,7 @@ class ClassExistenceResource implements SelfCheckingResourceInterface
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function __toString() public function __toString(): string
{ {
return $this->resource; return $this->resource;
} }
@ -51,7 +51,7 @@ class ClassExistenceResource implements SelfCheckingResourceInterface
/** /**
* @return string The file path to the resource * @return string The file path to the resource
*/ */
public function getResource() public function getResource(): string
{ {
return $this->resource; return $this->resource;
} }
@ -61,7 +61,7 @@ class ClassExistenceResource implements SelfCheckingResourceInterface
* *
* @throws \ReflectionException when a parent class/interface/trait is not found * @throws \ReflectionException when a parent class/interface/trait is not found
*/ */
public function isFresh(int $timestamp) public function isFresh(int $timestamp): bool
{ {
$loaded = class_exists($this->resource, false) || interface_exists($this->resource, false) || trait_exists($this->resource, false); $loaded = class_exists($this->resource, false) || interface_exists($this->resource, false) || trait_exists($this->resource, false);

View File

@ -30,7 +30,7 @@ class ComposerResource implements SelfCheckingResourceInterface
$this->vendors = self::$runtimeVendors; $this->vendors = self::$runtimeVendors;
} }
public function getVendors() public function getVendors(): array
{ {
return array_keys($this->vendors); return array_keys($this->vendors);
} }
@ -38,7 +38,7 @@ class ComposerResource implements SelfCheckingResourceInterface
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function __toString() public function __toString(): string
{ {
return __CLASS__; return __CLASS__;
} }
@ -46,7 +46,7 @@ class ComposerResource implements SelfCheckingResourceInterface
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function isFresh(int $timestamp) public function isFresh(int $timestamp): bool
{ {
self::refresh(); self::refresh();

View File

@ -42,7 +42,7 @@ class DirectoryResource implements SelfCheckingResourceInterface
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function __toString() public function __toString(): string
{ {
return md5(serialize([$this->resource, $this->pattern])); return md5(serialize([$this->resource, $this->pattern]));
} }
@ -50,17 +50,15 @@ class DirectoryResource implements SelfCheckingResourceInterface
/** /**
* @return string The file path to the resource * @return string The file path to the resource
*/ */
public function getResource() public function getResource(): string
{ {
return $this->resource; return $this->resource;
} }
/** /**
* Returns the pattern to restrict monitored files. * Returns the pattern to restrict monitored files.
*
* @return string|null
*/ */
public function getPattern() public function getPattern(): ?string
{ {
return $this->pattern; return $this->pattern;
} }
@ -68,7 +66,7 @@ class DirectoryResource implements SelfCheckingResourceInterface
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function isFresh(int $timestamp) public function isFresh(int $timestamp): bool
{ {
if (!is_dir($this->resource)) { if (!is_dir($this->resource)) {
return false; return false;

View File

@ -39,7 +39,7 @@ class FileExistenceResource implements SelfCheckingResourceInterface
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function __toString() public function __toString(): string
{ {
return $this->resource; return $this->resource;
} }
@ -47,7 +47,7 @@ class FileExistenceResource implements SelfCheckingResourceInterface
/** /**
* @return string The file path to the resource * @return string The file path to the resource
*/ */
public function getResource() public function getResource(): string
{ {
return $this->resource; return $this->resource;
} }
@ -55,7 +55,7 @@ class FileExistenceResource implements SelfCheckingResourceInterface
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function isFresh(int $timestamp) public function isFresh(int $timestamp): bool
{ {
return file_exists($this->resource) === $this->exists; return file_exists($this->resource) === $this->exists;
} }

View File

@ -44,7 +44,7 @@ class FileResource implements SelfCheckingResourceInterface
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function __toString() public function __toString(): string
{ {
return $this->resource; return $this->resource;
} }
@ -52,7 +52,7 @@ class FileResource implements SelfCheckingResourceInterface
/** /**
* @return string The canonicalized, absolute path to the resource * @return string The canonicalized, absolute path to the resource
*/ */
public function getResource() public function getResource(): string
{ {
return $this->resource; return $this->resource;
} }
@ -60,7 +60,7 @@ class FileResource implements SelfCheckingResourceInterface
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function isFresh(int $timestamp) public function isFresh(int $timestamp): bool
{ {
return false !== ($filemtime = @filemtime($this->resource)) && $filemtime <= $timestamp; return false !== ($filemtime = @filemtime($this->resource)) && $filemtime <= $timestamp;
} }

View File

@ -52,7 +52,7 @@ class GlobResource implements \IteratorAggregate, SelfCheckingResourceInterface
} }
} }
public function getPrefix() public function getPrefix(): string
{ {
return $this->prefix; return $this->prefix;
} }
@ -60,7 +60,7 @@ class GlobResource implements \IteratorAggregate, SelfCheckingResourceInterface
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function __toString() public function __toString(): string
{ {
return 'glob.'.$this->prefix.$this->pattern.(int) $this->recursive; return 'glob.'.$this->prefix.$this->pattern.(int) $this->recursive;
} }
@ -68,7 +68,7 @@ class GlobResource implements \IteratorAggregate, SelfCheckingResourceInterface
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function isFresh(int $timestamp) public function isFresh(int $timestamp): bool
{ {
$hash = $this->computeHash(); $hash = $this->computeHash();
@ -91,7 +91,7 @@ class GlobResource implements \IteratorAggregate, SelfCheckingResourceInterface
return ['prefix', 'pattern', 'recursive', 'hash', 'forExclusion', 'excludedPrefixes']; return ['prefix', 'pattern', 'recursive', 'hash', 'forExclusion', 'excludedPrefixes'];
} }
public function getIterator() public function getIterator(): \Traversable
{ {
if (!file_exists($this->prefix) || (!$this->recursive && '' === $this->pattern)) { if (!file_exists($this->prefix) || (!$this->recursive && '' === $this->pattern)) {
return; return;
@ -171,7 +171,7 @@ class GlobResource implements \IteratorAggregate, SelfCheckingResourceInterface
} }
} }
private function computeHash() private function computeHash(): string
{ {
$hash = hash_init('md5'); $hash = hash_init('md5');

View File

@ -38,7 +38,7 @@ class ReflectionClassResource implements SelfCheckingResourceInterface
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function isFresh(int $timestamp) public function isFresh(int $timestamp): bool
{ {
if (null === $this->hash) { if (null === $this->hash) {
$this->hash = $this->computeHash(); $this->hash = $this->computeHash();
@ -58,7 +58,7 @@ class ReflectionClassResource implements SelfCheckingResourceInterface
return true; return true;
} }
public function __toString() public function __toString(): string
{ {
return 'reflection.'.$this->className; return 'reflection.'.$this->className;
} }

View File

@ -109,7 +109,7 @@ EOPHP;
} }
} }
public function provideHashedSignature() public function provideHashedSignature(): iterable
{ {
yield [0, 0, "// line change\n\n"]; yield [0, 0, "// line change\n\n"];
yield [1, 0, '/** class docblock */']; yield [1, 0, '/** class docblock */'];

View File

@ -37,7 +37,7 @@ class ProcessHelper extends Helper
* *
* @return Process The process that ran * @return Process The process that ran
*/ */
public function run(OutputInterface $output, $cmd, $error = null, callable $callback = null, $verbosity = OutputInterface::VERBOSITY_VERY_VERBOSE) public function run(OutputInterface $output, $cmd, $error = null, callable $callback = null, $verbosity = OutputInterface::VERBOSITY_VERY_VERBOSE): Process
{ {
if ($output instanceof ConsoleOutputInterface) { if ($output instanceof ConsoleOutputInterface) {
$output = $output->getErrorOutput(); $output = $output->getErrorOutput();
@ -103,7 +103,7 @@ class ProcessHelper extends Helper
* *
* @see run() * @see run()
*/ */
public function mustRun(OutputInterface $output, $cmd, $error = null, callable $callback = null) public function mustRun(OutputInterface $output, $cmd, $error = null, callable $callback = null): Process
{ {
$process = $this->run($output, $cmd, $error, $callback); $process = $this->run($output, $cmd, $error, $callback);
@ -120,10 +120,8 @@ class ProcessHelper extends Helper
* @param OutputInterface $output An OutputInterface interface * @param OutputInterface $output An OutputInterface interface
* @param Process $process The Process * @param Process $process The Process
* @param callable|null $callback A PHP callable * @param callable|null $callback A PHP callable
*
* @return callable
*/ */
public function wrapCallback(OutputInterface $output, Process $process, callable $callback = null) public function wrapCallback(OutputInterface $output, Process $process, callable $callback = null): callable
{ {
if ($output instanceof ConsoleOutputInterface) { if ($output instanceof ConsoleOutputInterface) {
$output = $output->getErrorOutput(); $output = $output->getErrorOutput();
@ -148,7 +146,7 @@ class ProcessHelper extends Helper
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function getName() public function getName(): string
{ {
return 'process'; return 'process';
} }

View File

@ -112,7 +112,7 @@ class ErrorHandler
* *
* @return self The registered error handler * @return self The registered error handler
*/ */
public static function register(self $handler = null, $replace = true) public static function register(self $handler = null, $replace = true): self
{ {
if (null === self::$reservedMemory) { if (null === self::$reservedMemory) {
self::$reservedMemory = str_repeat('x', 10240); self::$reservedMemory = str_repeat('x', 10240);
@ -210,7 +210,7 @@ class ErrorHandler
* *
* @throws \InvalidArgumentException * @throws \InvalidArgumentException
*/ */
public function setLoggers(array $loggers) public function setLoggers(array $loggers): array
{ {
$prevLogged = $this->loggedErrors; $prevLogged = $this->loggedErrors;
$prev = $this->loggers; $prev = $this->loggers;
@ -261,7 +261,7 @@ class ErrorHandler
* *
* @return callable|null The previous exception handler * @return callable|null The previous exception handler
*/ */
public function setExceptionHandler(callable $handler = null) public function setExceptionHandler(callable $handler = null): ?callable
{ {
$prev = $this->exceptionHandler; $prev = $this->exceptionHandler;
$this->exceptionHandler = $handler; $this->exceptionHandler = $handler;
@ -277,7 +277,7 @@ class ErrorHandler
* *
* @return int The previous value * @return int The previous value
*/ */
public function throwAt($levels, $replace = false) public function throwAt($levels, $replace = false): int
{ {
$prev = $this->thrownErrors; $prev = $this->thrownErrors;
$this->thrownErrors = ($levels | E_RECOVERABLE_ERROR | E_USER_ERROR) & ~E_USER_DEPRECATED & ~E_DEPRECATED; $this->thrownErrors = ($levels | E_RECOVERABLE_ERROR | E_USER_ERROR) & ~E_USER_DEPRECATED & ~E_DEPRECATED;
@ -297,7 +297,7 @@ class ErrorHandler
* *
* @return int The previous value * @return int The previous value
*/ */
public function scopeAt($levels, $replace = false) public function scopeAt($levels, $replace = false): int
{ {
$prev = $this->scopedErrors; $prev = $this->scopedErrors;
$this->scopedErrors = (int) $levels; $this->scopedErrors = (int) $levels;
@ -316,7 +316,7 @@ class ErrorHandler
* *
* @return int The previous value * @return int The previous value
*/ */
public function traceAt($levels, $replace = false) public function traceAt($levels, $replace = false): int
{ {
$prev = $this->tracedErrors; $prev = $this->tracedErrors;
$this->tracedErrors = (int) $levels; $this->tracedErrors = (int) $levels;
@ -335,7 +335,7 @@ class ErrorHandler
* *
* @return int The previous value * @return int The previous value
*/ */
public function screamAt($levels, $replace = false) public function screamAt($levels, $replace = false): int
{ {
$prev = $this->screamedErrors; $prev = $this->screamedErrors;
$this->screamedErrors = (int) $levels; $this->screamedErrors = (int) $levels;
@ -374,7 +374,7 @@ class ErrorHandler
* @param string $file * @param string $file
* @param int $line * @param int $line
* *
* @return bool Returns false when no handling happens so that the PHP engine can handle the error itself * @return bool|void Returns false when no handling happens so that the PHP engine can handle the error itself
* *
* @throws \ErrorException When $this->thrownErrors requests so * @throws \ErrorException When $this->thrownErrors requests so
* *
@ -670,7 +670,7 @@ class ErrorHandler
* *
* @return FatalErrorHandlerInterface[] An array of FatalErrorHandlerInterface * @return FatalErrorHandlerInterface[] An array of FatalErrorHandlerInterface
*/ */
protected function getFatalErrorHandlers() protected function getFatalErrorHandlers(): array
{ {
return [ return [
new UndefinedFunctionFatalErrorHandler(), new UndefinedFunctionFatalErrorHandler(),
@ -682,7 +682,7 @@ class ErrorHandler
/** /**
* Cleans the trace by removing function arguments and the frames added by the error handler and DebugClassLoader. * 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($backtrace, $type, $file, $line, $throw): array
{ {
$lightTrace = $backtrace; $lightTrace = $backtrace;

File diff suppressed because one or more lines are too long

View File

@ -43,7 +43,7 @@ final class BoundArgument implements ArgumentInterface
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function getValues() public function getValues(): array
{ {
return [$this->value, $this->identifier, $this->used, $this->type, $this->file]; return [$this->value, $this->identifier, $this->used, $this->type, $this->file];
} }

View File

@ -90,10 +90,8 @@ final class ServiceLocatorTagPass extends AbstractRecursivePass
* @param ContainerBuilder $container * @param ContainerBuilder $container
* @param Reference[] $refMap * @param Reference[] $refMap
* @param string|null $callerId * @param string|null $callerId
*
* @return Reference
*/ */
public static function register(ContainerBuilder $container, array $refMap, $callerId = null) public static function register(ContainerBuilder $container, array $refMap, $callerId = null): Reference
{ {
foreach ($refMap as $id => $ref) { foreach ($refMap as $id => $ref) {
if (!$ref instanceof Reference) { if (!$ref instanceof Reference) {

View File

@ -35,7 +35,7 @@ class ContainerParametersResource implements ResourceInterface
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function __toString() public function __toString(): string
{ {
return 'container_parameters_'.md5(serialize($this->parameters)); return 'container_parameters_'.md5(serialize($this->parameters));
} }
@ -43,7 +43,7 @@ class ContainerParametersResource implements ResourceInterface
/** /**
* @return array Tracked parameters * @return array Tracked parameters
*/ */
public function getParameters() public function getParameters(): array
{ {
return $this->parameters; return $this->parameters;
} }

View File

@ -384,8 +384,6 @@ class ContainerBuilder extends Container implements TaggedContainerInterface
* @param bool|string $trackContents Whether to track contents of the given resource. If a string is passed, * @param bool|string $trackContents Whether to track contents of the given resource. If a string is passed,
* it will be used as pattern for tracking contents of the requested directory * it will be used as pattern for tracking contents of the requested directory
* *
* @return bool
*
* @final * @final
*/ */
public function fileExists(string $path, $trackContents = true): bool public function fileExists(string $path, $trackContents = true): bool

View File

@ -25,7 +25,7 @@ class NullDumper implements DumperInterface
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function isProxyCandidate(Definition $definition) public function isProxyCandidate(Definition $definition): bool
{ {
return false; return false;
} }
@ -33,7 +33,7 @@ class NullDumper implements DumperInterface
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function getProxyFactoryCode(Definition $definition, $id, $factoryCode = null) public function getProxyFactoryCode(Definition $definition, $id, $factoryCode = null): string
{ {
return ''; return '';
} }
@ -41,7 +41,7 @@ class NullDumper implements DumperInterface
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function getProxyCode(Definition $definition) public function getProxyCode(Definition $definition): string
{ {
return ''; return '';
} }

View File

@ -42,7 +42,7 @@ class DefaultsConfigurator extends AbstractServiceConfigurator
* *
* @throws InvalidArgumentException when an invalid tag name or attribute is provided * @throws InvalidArgumentException when an invalid tag name or attribute is provided
*/ */
final public function tag(string $name, array $attributes = []) final public function tag(string $name, array $attributes = []): object
{ {
if ('' === $name) { if ('' === $name) {
throw new InvalidArgumentException('The tag name in "_defaults" must be a non-empty string.'); throw new InvalidArgumentException('The tag name in "_defaults" must be a non-empty string.');
@ -61,10 +61,8 @@ class DefaultsConfigurator extends AbstractServiceConfigurator
/** /**
* Defines an instanceof-conditional to be applied to following service definitions. * Defines an instanceof-conditional to be applied to following service definitions.
*
* @return InstanceofConfigurator
*/ */
final public function instanceof(string $fqcn) final public function instanceof(string $fqcn): InstanceofConfigurator
{ {
return $this->parent->instanceof($fqcn); return $this->parent->instanceof($fqcn);
} }

View File

@ -32,7 +32,7 @@ class ParametersConfigurator extends AbstractConfigurator
* *
* @return $this * @return $this
*/ */
final public function set(string $name, $value) final public function set(string $name, $value): object
{ {
$this->container->setParameter($name, static::processValue($value, true)); $this->container->setParameter($name, static::processValue($value, true));
@ -44,7 +44,7 @@ class ParametersConfigurator extends AbstractConfigurator
* *
* @return $this * @return $this
*/ */
final public function __invoke(string $name, $value) final public function __invoke(string $name, $value): object
{ {
return $this->set($name, $value); return $this->set($name, $value);
} }

View File

@ -75,7 +75,7 @@ class PrototypeConfigurator extends AbstractServiceConfigurator
* *
* @return $this * @return $this
*/ */
final public function exclude($excludes) final public function exclude($excludes): object
{ {
$this->excludes = (array) $excludes; $this->excludes = (array) $excludes;

View File

@ -32,7 +32,7 @@ class ReferenceConfigurator extends AbstractConfigurator
/** /**
* @return $this * @return $this
*/ */
final public function ignoreOnInvalid() final public function ignoreOnInvalid(): object
{ {
$this->invalidBehavior = ContainerInterface::IGNORE_ON_INVALID_REFERENCE; $this->invalidBehavior = ContainerInterface::IGNORE_ON_INVALID_REFERENCE;
@ -42,7 +42,7 @@ class ReferenceConfigurator extends AbstractConfigurator
/** /**
* @return $this * @return $this
*/ */
final public function nullOnInvalid() final public function nullOnInvalid(): object
{ {
$this->invalidBehavior = ContainerInterface::NULL_ON_INVALID_REFERENCE; $this->invalidBehavior = ContainerInterface::NULL_ON_INVALID_REFERENCE;
@ -52,14 +52,14 @@ class ReferenceConfigurator extends AbstractConfigurator
/** /**
* @return $this * @return $this
*/ */
final public function ignoreOnUninitialized() final public function ignoreOnUninitialized(): object
{ {
$this->invalidBehavior = ContainerInterface::IGNORE_ON_UNINITIALIZED_REFERENCE; $this->invalidBehavior = ContainerInterface::IGNORE_ON_UNINITIALIZED_REFERENCE;
return $this; return $this;
} }
public function __toString() public function __toString(): string
{ {
return $this->id; return $this->id;
} }

View File

@ -19,7 +19,7 @@ trait AbstractTrait
* *
* @return $this * @return $this
*/ */
final public function abstract(bool $abstract = true) final public function abstract(bool $abstract = true): object
{ {
$this->definition->setAbstract($abstract); $this->definition->setAbstract($abstract);

View File

@ -20,7 +20,7 @@ trait ArgumentTrait
* *
* @return $this * @return $this
*/ */
final public function args(array $arguments) final public function args(array $arguments): object
{ {
$this->definition->setArguments(static::processValue($arguments, true)); $this->definition->setArguments(static::processValue($arguments, true));
@ -35,7 +35,7 @@ trait ArgumentTrait
* *
* @return $this * @return $this
*/ */
final public function arg($key, $value) final public function arg($key, $value): object
{ {
$this->definition->setArgument($key, static::processValue($value, true)); $this->definition->setArgument($key, static::processValue($value, true));

View File

@ -23,7 +23,7 @@ trait AutoconfigureTrait
* *
* @throws InvalidArgumentException when a parent is already set * @throws InvalidArgumentException when a parent is already set
*/ */
final public function autoconfigure(bool $autoconfigured = true) final public function autoconfigure(bool $autoconfigured = true): object
{ {
if ($autoconfigured && $this->definition instanceof ChildDefinition) { if ($autoconfigured && $this->definition instanceof ChildDefinition) {
throw new InvalidArgumentException(sprintf('The service "%s" cannot have a "parent" and also have "autoconfigure". Try disabling autoconfiguration for the service.', $this->id)); throw new InvalidArgumentException(sprintf('The service "%s" cannot have a "parent" and also have "autoconfigure". Try disabling autoconfiguration for the service.', $this->id));

View File

@ -18,7 +18,7 @@ trait AutowireTrait
* *
* @return $this * @return $this
*/ */
final public function autowire(bool $autowired = true) final public function autowire(bool $autowired = true): object
{ {
$this->definition->setAutowired($autowired); $this->definition->setAutowired($autowired);

View File

@ -31,7 +31,7 @@ trait BindTrait
* *
* @return $this * @return $this
*/ */
final public function bind($nameOrFqcn, $valueOrRef) final public function bind($nameOrFqcn, $valueOrRef): object
{ {
$valueOrRef = static::processValue($valueOrRef, true); $valueOrRef = static::processValue($valueOrRef, true);
if (!preg_match('/^(?:(?:array|bool|float|int|string)[ \t]*+)?\$/', $nameOrFqcn) && !$valueOrRef instanceof Reference) { if (!preg_match('/^(?:(?:array|bool|float|int|string)[ \t]*+)?\$/', $nameOrFqcn) && !$valueOrRef instanceof Reference) {

View File

@ -25,7 +25,7 @@ trait CallTrait
* *
* @throws InvalidArgumentException on empty $method param * @throws InvalidArgumentException on empty $method param
*/ */
final public function call($method, array $arguments = []) final public function call($method, array $arguments = []): object
{ {
$this->definition->addMethodCall($method, static::processValue($arguments, true)); $this->definition->addMethodCall($method, static::processValue($arguments, true));

View File

@ -18,7 +18,7 @@ trait ClassTrait
* *
* @return $this * @return $this
*/ */
final public function class($class) final public function class($class): object
{ {
$this->definition->setClass($class); $this->definition->setClass($class);

View File

@ -20,7 +20,7 @@ trait ConfiguratorTrait
* *
* @return $this * @return $this
*/ */
final public function configurator($configurator) final public function configurator($configurator): object
{ {
$this->definition->setConfigurator(static::processValue($configurator, true)); $this->definition->setConfigurator(static::processValue($configurator, true));

View File

@ -26,7 +26,7 @@ trait DecorateTrait
* *
* @throws InvalidArgumentException in case the decorated service id and the new decorated service id are equals * @throws InvalidArgumentException in case the decorated service id and the new decorated service id are equals
*/ */
final public function decorate($id, $renamedId = null, $priority = 0) final public function decorate($id, $renamedId = null, $priority = 0): object
{ {
$this->definition->setDecoratedService($id, $renamedId, $priority); $this->definition->setDecoratedService($id, $renamedId, $priority);

View File

@ -24,7 +24,7 @@ trait DeprecateTrait
* *
* @throws InvalidArgumentException when the message template is invalid * @throws InvalidArgumentException when the message template is invalid
*/ */
final public function deprecate($template = null) final public function deprecate($template = null): object
{ {
$this->definition->setDeprecated(true, $template); $this->definition->setDeprecated(true, $template);

View File

@ -22,7 +22,7 @@ trait FactoryTrait
* *
* @return $this * @return $this
*/ */
final public function factory($factory) final public function factory($factory): object
{ {
if (\is_string($factory) && 1 === substr_count($factory, ':')) { if (\is_string($factory) && 1 === substr_count($factory, ':')) {
$factoryParts = explode(':', $factory); $factoryParts = explode(':', $factory);

View File

@ -20,7 +20,7 @@ trait FileTrait
* *
* @return $this * @return $this
*/ */
final public function file($file) final public function file($file): object
{ {
$this->definition->setFile($file); $this->definition->setFile($file);

View File

@ -20,7 +20,7 @@ trait LazyTrait
* *
* @return $this * @return $this
*/ */
final public function lazy($lazy = true) final public function lazy($lazy = true): object
{ {
$this->definition->setLazy((bool) $lazy); $this->definition->setLazy((bool) $lazy);
if (\is_string($lazy)) { if (\is_string($lazy)) {

View File

@ -23,7 +23,7 @@ trait ParentTrait
* *
* @throws InvalidArgumentException when parent cannot be set * @throws InvalidArgumentException when parent cannot be set
*/ */
final public function parent(string $parent) final public function parent(string $parent): object
{ {
if (!$this->allowParent) { if (!$this->allowParent) {
throw new InvalidArgumentException(sprintf('A parent cannot be defined when either "_instanceof" or "_defaults" are also defined for service prototype "%s".', $this->id)); throw new InvalidArgumentException(sprintf('A parent cannot be defined when either "_instanceof" or "_defaults" are also defined for service prototype "%s".', $this->id));

View File

@ -18,7 +18,7 @@ trait PropertyTrait
* *
* @return $this * @return $this
*/ */
final public function property(string $name, $value) final public function property(string $name, $value): object
{ {
$this->definition->setProperty($name, static::processValue($value, true)); $this->definition->setProperty($name, static::processValue($value, true));

View File

@ -16,7 +16,7 @@ trait PublicTrait
/** /**
* @return $this * @return $this
*/ */
final public function public() final public function public(): object
{ {
$this->definition->setPublic(true); $this->definition->setPublic(true);
@ -26,7 +26,7 @@ trait PublicTrait
/** /**
* @return $this * @return $this
*/ */
final public function private() final public function private(): object
{ {
$this->definition->setPublic(false); $this->definition->setPublic(false);

View File

@ -20,7 +20,7 @@ trait ShareTrait
* *
* @return $this * @return $this
*/ */
final public function share($shared = true) final public function share($shared = true): object
{ {
$this->definition->setShared($shared); $this->definition->setShared($shared);

View File

@ -19,7 +19,7 @@ trait SyntheticTrait
* *
* @return $this * @return $this
*/ */
final public function synthetic(bool $synthetic = true) final public function synthetic(bool $synthetic = true): object
{ {
$this->definition->setSynthetic($synthetic); $this->definition->setSynthetic($synthetic);

View File

@ -23,7 +23,7 @@ trait TagTrait
* *
* @return $this * @return $this
*/ */
final public function tag($name, array $attributes = []) final public function tag($name, array $attributes = []): object
{ {
if (!\is_string($name) || '' === $name) { if (!\is_string($name) || '' === $name) {
throw new InvalidArgumentException(sprintf('The tag name for service "%s" must be a non-empty string.', $this->id)); throw new InvalidArgumentException(sprintf('The tag name for service "%s" must be a non-empty string.', $this->id));

View File

@ -61,11 +61,9 @@ final class ReverseContainer
} }
/** /**
* @return object
*
* @throws ServiceNotFoundException When the service is not reversible * @throws ServiceNotFoundException When the service is not reversible
*/ */
public function getService(string $id) public function getService(string $id): object
{ {
if ($this->serviceContainer->has($id)) { if ($this->serviceContainer->has($id)) {
return $this->serviceContainer->get($id); return $this->serviceContainer->get($id);

View File

@ -211,7 +211,7 @@ final class Dotenv
} }
} }
private function lexVarname() private function lexVarname(): string
{ {
// var name + optional export // var name + optional export
if (!preg_match('/(export[ \t]++)?('.self::VARNAME_REGEX.')/A', $this->data, $matches, 0, $this->cursor)) { if (!preg_match('/(export[ \t]++)?('.self::VARNAME_REGEX.')/A', $this->data, $matches, 0, $this->cursor)) {
@ -239,7 +239,7 @@ final class Dotenv
return $matches[2]; return $matches[2];
} }
private function lexValue() private function lexValue(): string
{ {
if (preg_match('/[ \t]*+(?:#.*)?$/Am', $this->data, $matches, 0, $this->cursor)) { if (preg_match('/[ \t]*+(?:#.*)?$/Am', $this->data, $matches, 0, $this->cursor)) {
$this->moveCursor($matches[0]); $this->moveCursor($matches[0]);
@ -334,7 +334,7 @@ final class Dotenv
return $v; return $v;
} }
private function lexNestedExpression() private function lexNestedExpression(): string
{ {
++$this->cursor; ++$this->cursor;
$value = ''; $value = '';
@ -467,7 +467,7 @@ final class Dotenv
$this->lineno += substr_count($text, "\n"); $this->lineno += substr_count($text, "\n");
} }
private function createFormatException($message) private function createFormatException($message): FormatException
{ {
return new FormatException($message, new FormatExceptionContext($this->data, $this->path, $this->lineno, $this->cursor)); return new FormatException($message, new FormatExceptionContext($this->data, $this->path, $this->lineno, $this->cursor));
} }

View File

@ -27,7 +27,7 @@ final class FormatException extends \LogicException implements ExceptionInterfac
parent::__construct(sprintf("%s in \"%s\" at line %d.\n%s", $message, $context->getPath(), $context->getLineno(), $context->getDetails()), $code, $previous); parent::__construct(sprintf("%s in \"%s\" at line %d.\n%s", $message, $context->getPath(), $context->getLineno(), $context->getDetails()), $code, $previous);
} }
public function getContext() public function getContext(): FormatExceptionContext
{ {
return $this->context; return $this->context;
} }

View File

@ -29,17 +29,17 @@ final class FormatExceptionContext
$this->cursor = $cursor; $this->cursor = $cursor;
} }
public function getPath() public function getPath(): string
{ {
return $this->path; return $this->path;
} }
public function getLineno() public function getLineno(): int
{ {
return $this->lineno; return $this->lineno;
} }
public function getDetails() public function getDetails(): string
{ {
$before = str_replace("\n", '\n', substr($this->data, max(0, $this->cursor - 20), min(20, $this->cursor))); $before = str_replace("\n", '\n', substr($this->data, max(0, $this->cursor - 20), min(20, $this->cursor)));
$after = str_replace("\n", '\n', substr($this->data, $this->cursor, 20)); $after = str_replace("\n", '\n', substr($this->data, $this->cursor, 20));

View File

@ -26,11 +26,9 @@ final class DateTimeImmutableToDateTimeTransformer implements DataTransformerInt
* *
* @param \DateTimeImmutable|null $value A DateTimeImmutable object * @param \DateTimeImmutable|null $value A DateTimeImmutable object
* *
* @return \DateTime|null A \DateTime object
*
* @throws TransformationFailedException If the given value is not a \DateTimeImmutable * @throws TransformationFailedException If the given value is not a \DateTimeImmutable
*/ */
public function transform($value) public function transform($value): ?\DateTime
{ {
if (null === $value) { if (null === $value) {
return null; return null;
@ -48,11 +46,9 @@ final class DateTimeImmutableToDateTimeTransformer implements DataTransformerInt
* *
* @param \DateTime|null $value A DateTime object * @param \DateTime|null $value A DateTime object
* *
* @return \DateTimeImmutable|null A DateTimeImmutable object
*
* @throws TransformationFailedException If the given value is not a \DateTime * @throws TransformationFailedException If the given value is not a \DateTime
*/ */
public function reverseTransform($value) public function reverseTransform($value): ?\DateTimeImmutable
{ {
if (null === $value) { if (null === $value) {
return null; return null;

View File

@ -218,7 +218,7 @@ class FormDataCollector extends DataCollector implements FormDataCollectorInterf
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function getName() public function getName(): string
{ {
return 'form'; return 'form';
} }
@ -226,7 +226,7 @@ class FormDataCollector extends DataCollector implements FormDataCollectorInterf
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function getData() public function getData(): array
{ {
return $this->data; return $this->data;
} }
@ -250,7 +250,7 @@ class FormDataCollector extends DataCollector implements FormDataCollectorInterf
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function getCasters() protected function getCasters(): array
{ {
return parent::getCasters() + [ return parent::getCasters() + [
\Exception::class => function (\Exception $e, array $a, Stub $s) { \Exception::class => function (\Exception $e, array $a, Stub $s) {

View File

@ -402,7 +402,7 @@ final class NativeHttpClient implements HttpClientInterface, LoggerAwareInterfac
}; };
} }
private static function configureHeadersAndProxy($context, string $host, array $requestHeaders, ?array $proxy, array $noProxy) private static function configureHeadersAndProxy($context, string $host, array $requestHeaders, ?array $proxy, array $noProxy): bool
{ {
if (null === $proxy) { if (null === $proxy) {
return stream_context_set_option($context, 'http', 'header', $requestHeaders); return stream_context_set_option($context, 'http', 'header', $requestHeaders);

View File

@ -418,7 +418,7 @@ class Response
* *
* @final * @final
*/ */
public function setProtocolVersion(string $version) public function setProtocolVersion(string $version): object
{ {
$this->version = $version; $this->version = $version;
@ -447,7 +447,7 @@ class Response
* *
* @final * @final
*/ */
public function setStatusCode(int $code, $text = null) public function setStatusCode(int $code, $text = null): object
{ {
$this->statusCode = $code; $this->statusCode = $code;
if ($this->isInvalid()) { if ($this->isInvalid()) {
@ -488,7 +488,7 @@ class Response
* *
* @final * @final
*/ */
public function setCharset(string $charset) public function setCharset(string $charset): object
{ {
$this->charset = $charset; $this->charset = $charset;
@ -569,7 +569,7 @@ class Response
* *
* @final * @final
*/ */
public function setPrivate() public function setPrivate(): object
{ {
$this->headers->removeCacheControlDirective('public'); $this->headers->removeCacheControlDirective('public');
$this->headers->addCacheControlDirective('private'); $this->headers->addCacheControlDirective('private');
@ -586,7 +586,7 @@ class Response
* *
* @final * @final
*/ */
public function setPublic() public function setPublic(): object
{ {
$this->headers->addCacheControlDirective('public'); $this->headers->addCacheControlDirective('public');
$this->headers->removeCacheControlDirective('private'); $this->headers->removeCacheControlDirective('private');
@ -601,7 +601,7 @@ class Response
* *
* @final * @final
*/ */
public function setImmutable(bool $immutable = true) public function setImmutable(bool $immutable = true): object
{ {
if ($immutable) { if ($immutable) {
$this->headers->addCacheControlDirective('immutable'); $this->headers->addCacheControlDirective('immutable');
@ -656,7 +656,7 @@ class Response
* *
* @final * @final
*/ */
public function setDate(\DateTimeInterface $date) public function setDate(\DateTimeInterface $date): object
{ {
if ($date instanceof \DateTime) { if ($date instanceof \DateTime) {
$date = \DateTimeImmutable::createFromMutable($date); $date = \DateTimeImmutable::createFromMutable($date);
@ -721,7 +721,7 @@ class Response
* *
* @final * @final
*/ */
public function setExpires(\DateTimeInterface $date = null) public function setExpires(\DateTimeInterface $date = null): object
{ {
if (null === $date) { if (null === $date) {
$this->headers->remove('Expires'); $this->headers->remove('Expires');
@ -774,7 +774,7 @@ class Response
* *
* @final * @final
*/ */
public function setMaxAge(int $value) public function setMaxAge(int $value): object
{ {
$this->headers->addCacheControlDirective('max-age', $value); $this->headers->addCacheControlDirective('max-age', $value);
@ -790,7 +790,7 @@ class Response
* *
* @final * @final
*/ */
public function setSharedMaxAge(int $value) public function setSharedMaxAge(int $value): object
{ {
$this->setPublic(); $this->setPublic();
$this->headers->addCacheControlDirective('s-maxage', $value); $this->headers->addCacheControlDirective('s-maxage', $value);
@ -824,7 +824,7 @@ class Response
* *
* @final * @final
*/ */
public function setTtl(int $seconds) public function setTtl(int $seconds): object
{ {
$this->setSharedMaxAge($this->getAge() + $seconds); $this->setSharedMaxAge($this->getAge() + $seconds);
@ -840,7 +840,7 @@ class Response
* *
* @final * @final
*/ */
public function setClientTtl(int $seconds) public function setClientTtl(int $seconds): object
{ {
$this->setMaxAge($this->getAge() + $seconds); $this->setMaxAge($this->getAge() + $seconds);
@ -868,7 +868,7 @@ class Response
* *
* @final * @final
*/ */
public function setLastModified(\DateTimeInterface $date = null) public function setLastModified(\DateTimeInterface $date = null): object
{ {
if (null === $date) { if (null === $date) {
$this->headers->remove('Last-Modified'); $this->headers->remove('Last-Modified');
@ -906,7 +906,7 @@ class Response
* *
* @final * @final
*/ */
public function setEtag(string $etag = null, bool $weak = false) public function setEtag(string $etag = null, bool $weak = false): object
{ {
if (null === $etag) { if (null === $etag) {
$this->headers->remove('Etag'); $this->headers->remove('Etag');
@ -932,7 +932,7 @@ class Response
* *
* @final * @final
*/ */
public function setCache(array $options) public function setCache(array $options): object
{ {
if ($diff = array_diff(array_keys($options), ['etag', 'last_modified', 'max_age', 's_maxage', 'private', 'public', 'immutable'])) { if ($diff = array_diff(array_keys($options), ['etag', 'last_modified', 'max_age', 's_maxage', 'private', 'public', 'immutable'])) {
throw new \InvalidArgumentException(sprintf('Response does not support the following options: "%s".', implode('", "', $diff))); throw new \InvalidArgumentException(sprintf('Response does not support the following options: "%s".', implode('", "', $diff)));
@ -989,7 +989,7 @@ class Response
* *
* @final * @final
*/ */
public function setNotModified() public function setNotModified(): object
{ {
$this->setStatusCode(304); $this->setStatusCode(304);
$this->setContent(null); $this->setContent(null);
@ -1041,7 +1041,7 @@ class Response
* *
* @final * @final
*/ */
public function setVary($headers, bool $replace = true) public function setVary($headers, bool $replace = true): object
{ {
$this->headers->set('Vary', $headers, $replace); $this->headers->set('Vary', $headers, $replace);

View File

@ -29,20 +29,14 @@ final class SessionBagProxy implements SessionBagInterface
$this->usageIndex = &$usageIndex; $this->usageIndex = &$usageIndex;
} }
/** public function getBag(): SessionBagInterface
* @return SessionBagInterface
*/
public function getBag()
{ {
++$this->usageIndex; ++$this->usageIndex;
return $this->bag; return $this->bag;
} }
/** public function isEmpty(): bool
* @return bool
*/
public function isEmpty()
{ {
if (!isset($this->data[$this->bag->getStorageKey()])) { if (!isset($this->data[$this->bag->getStorageKey()])) {
return true; return true;
@ -55,7 +49,7 @@ final class SessionBagProxy implements SessionBagInterface
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function getName() public function getName(): string
{ {
return $this->bag->getName(); return $this->bag->getName();
} }
@ -74,7 +68,7 @@ final class SessionBagProxy implements SessionBagInterface
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function getStorageKey() public function getStorageKey(): string
{ {
return $this->bag->getStorageKey(); return $this->bag->getStorageKey();
} }

View File

@ -119,10 +119,8 @@ abstract class Bundle implements BundleInterface
/** /**
* Returns the bundle name (the class short name). * Returns the bundle name (the class short name).
*
* @return string The Bundle name
*/ */
final public function getName() final public function getName(): string
{ {
if (null === $this->name) { if (null === $this->name) {
$this->parseClassName(); $this->parseClassName();

View File

@ -114,7 +114,7 @@ class CacheWarmerAggregate implements CacheWarmerInterface
* *
* @return bool always false * @return bool always false
*/ */
public function isOptional() public function isOptional(): bool
{ {
return false; return false;
} }

View File

@ -43,7 +43,7 @@ final class ArgumentResolver implements ArgumentResolverInterface
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function getArguments(Request $request, $controller) public function getArguments(Request $request, $controller): array
{ {
$arguments = []; $arguments = [];

View File

@ -25,7 +25,7 @@ final class DefaultValueResolver implements ArgumentValueResolverInterface
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function supports(Request $request, ArgumentMetadata $argument) public function supports(Request $request, ArgumentMetadata $argument): bool
{ {
return $argument->hasDefaultValue() || (null !== $argument->getType() && $argument->isNullable() && !$argument->isVariadic()); return $argument->hasDefaultValue() || (null !== $argument->getType() && $argument->isNullable() && !$argument->isVariadic());
} }
@ -33,7 +33,7 @@ final class DefaultValueResolver implements ArgumentValueResolverInterface
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function resolve(Request $request, ArgumentMetadata $argument) public function resolve(Request $request, ArgumentMetadata $argument): iterable
{ {
yield $argument->hasDefaultValue() ? $argument->getDefaultValue() : null; yield $argument->hasDefaultValue() ? $argument->getDefaultValue() : null;
} }

View File

@ -34,7 +34,7 @@ final class NotTaggedControllerValueResolver implements ArgumentValueResolverInt
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function supports(Request $request, ArgumentMetadata $argument) public function supports(Request $request, ArgumentMetadata $argument): bool
{ {
$controller = $request->attributes->get('_controller'); $controller = $request->attributes->get('_controller');

View File

@ -25,7 +25,7 @@ final class RequestAttributeValueResolver implements ArgumentValueResolverInterf
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function supports(Request $request, ArgumentMetadata $argument) public function supports(Request $request, ArgumentMetadata $argument): bool
{ {
return !$argument->isVariadic() && $request->attributes->has($argument->getName()); return !$argument->isVariadic() && $request->attributes->has($argument->getName());
} }
@ -33,7 +33,7 @@ final class RequestAttributeValueResolver implements ArgumentValueResolverInterf
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function resolve(Request $request, ArgumentMetadata $argument) public function resolve(Request $request, ArgumentMetadata $argument): iterable
{ {
yield $request->attributes->get($argument->getName()); yield $request->attributes->get($argument->getName());
} }

View File

@ -25,7 +25,7 @@ final class RequestValueResolver implements ArgumentValueResolverInterface
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function supports(Request $request, ArgumentMetadata $argument) public function supports(Request $request, ArgumentMetadata $argument): bool
{ {
return Request::class === $argument->getType() || is_subclass_of($argument->getType(), Request::class); return Request::class === $argument->getType() || is_subclass_of($argument->getType(), Request::class);
} }
@ -33,7 +33,7 @@ final class RequestValueResolver implements ArgumentValueResolverInterface
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function resolve(Request $request, ArgumentMetadata $argument) public function resolve(Request $request, ArgumentMetadata $argument): iterable
{ {
yield $request; yield $request;
} }

View File

@ -34,7 +34,7 @@ final class ServiceValueResolver implements ArgumentValueResolverInterface
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function supports(Request $request, ArgumentMetadata $argument) public function supports(Request $request, ArgumentMetadata $argument): bool
{ {
$controller = $request->attributes->get('_controller'); $controller = $request->attributes->get('_controller');
@ -58,7 +58,7 @@ final class ServiceValueResolver implements ArgumentValueResolverInterface
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function resolve(Request $request, ArgumentMetadata $argument) public function resolve(Request $request, ArgumentMetadata $argument): iterable
{ {
if (\is_array($controller = $request->attributes->get('_controller'))) { if (\is_array($controller = $request->attributes->get('_controller'))) {
$controller = $controller[0].'::'.$controller[1]; $controller = $controller[0].'::'.$controller[1];

View File

@ -26,7 +26,7 @@ final class SessionValueResolver implements ArgumentValueResolverInterface
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function supports(Request $request, ArgumentMetadata $argument) public function supports(Request $request, ArgumentMetadata $argument): bool
{ {
if (!$request->hasSession()) { if (!$request->hasSession()) {
return false; return false;
@ -43,7 +43,7 @@ final class SessionValueResolver implements ArgumentValueResolverInterface
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function resolve(Request $request, ArgumentMetadata $argument) public function resolve(Request $request, ArgumentMetadata $argument): iterable
{ {
yield $request->getSession(); yield $request->getSession();
} }

View File

@ -25,7 +25,7 @@ final class VariadicValueResolver implements ArgumentValueResolverInterface
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function supports(Request $request, ArgumentMetadata $argument) public function supports(Request $request, ArgumentMetadata $argument): bool
{ {
return $argument->isVariadic() && $request->attributes->has($argument->getName()); return $argument->isVariadic() && $request->attributes->has($argument->getName());
} }
@ -33,7 +33,7 @@ final class VariadicValueResolver implements ArgumentValueResolverInterface
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function resolve(Request $request, ArgumentMetadata $argument) public function resolve(Request $request, ArgumentMetadata $argument): iterable
{ {
$values = $request->attributes->get($argument->getName()); $values = $request->attributes->get($argument->getName());

View File

@ -21,7 +21,7 @@ final class ArgumentMetadataFactory implements ArgumentMetadataFactoryInterface
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function createArgumentMetadata($controller) public function createArgumentMetadata($controller): array
{ {
$arguments = []; $arguments = [];
@ -45,7 +45,7 @@ final class ArgumentMetadataFactory implements ArgumentMetadataFactoryInterface
* *
* @param \ReflectionParameter $parameter * @param \ReflectionParameter $parameter
* *
* @return string|null * @return string|null|void
*/ */
private function getType(\ReflectionParameter $parameter, \ReflectionFunctionAbstract $function) private function getType(\ReflectionParameter $parameter, \ReflectionFunctionAbstract $function)
{ {

View File

@ -148,7 +148,7 @@ class DumpDataCollector extends DataCollector implements DataDumperInterface
/** /**
* @internal * @internal
*/ */
public function __sleep() public function __sleep(): array
{ {
if (!$this->dataCount) { if (!$this->dataCount) {
$this->data = []; $this->data = [];
@ -180,12 +180,12 @@ class DumpDataCollector extends DataCollector implements DataDumperInterface
self::__construct($this->stopwatch, $fileLinkFormat, $charset); self::__construct($this->stopwatch, $fileLinkFormat, $charset);
} }
public function getDumpsCount() public function getDumpsCount(): int
{ {
return $this->dataCount; return $this->dataCount;
} }
public function getDumps($format, $maxDepthLimit = -1, $maxItemsPerDepth = -1) public function getDumps($format, $maxDepthLimit = -1, $maxItemsPerDepth = -1): array
{ {
$data = fopen('php://memory', 'r+b'); $data = fopen('php://memory', 'r+b');
@ -212,7 +212,7 @@ class DumpDataCollector extends DataCollector implements DataDumperInterface
return $dumps; return $dumps;
} }
public function getName() public function getName(): string
{ {
return 'dump'; return 'dump';
} }

View File

@ -76,7 +76,7 @@ class FileLinkFormatter
/** /**
* @internal * @internal
*/ */
public static function generateUrlFormat(UrlGeneratorInterface $router, $routeName, $queryString) public static function generateUrlFormat(UrlGeneratorInterface $router, $routeName, $queryString): ?string
{ {
try { try {
return $router->generate($routeName).$queryString; return $router->generate($routeName).$queryString;

View File

@ -45,7 +45,7 @@ class AddRequestFormatsListener implements EventSubscriberInterface
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public static function getSubscribedEvents() public static function getSubscribedEvents(): array
{ {
return [KernelEvents::REQUEST => ['onKernelRequest', 100]]; return [KernelEvents::REQUEST => ['onKernelRequest', 100]];
} }

View File

@ -167,7 +167,7 @@ class DebugHandlersListener implements EventSubscriberInterface
(new ExceptionListener($controller, $this->logger, $debug))->onKernelException($event); (new ExceptionListener($controller, $this->logger, $debug))->onKernelException($event);
} }
public static function getSubscribedEvents() public static function getSubscribedEvents(): array
{ {
$events = [KernelEvents::REQUEST => ['configure', 2048]]; $events = [KernelEvents::REQUEST => ['configure', 2048]];

View File

@ -94,7 +94,7 @@ class ExceptionListener implements EventSubscriberInterface
} }
} }
public static function getSubscribedEvents() public static function getSubscribedEvents(): array
{ {
return [ return [
KernelEvents::EXCEPTION => [ KernelEvents::EXCEPTION => [
@ -126,10 +126,8 @@ class ExceptionListener implements EventSubscriberInterface
* *
* @param \Exception $exception The thrown exception * @param \Exception $exception The thrown exception
* @param Request $request The original request * @param Request $request The original request
*
* @return Request The cloned request
*/ */
protected function duplicateRequest(\Exception $exception, Request $request) protected function duplicateRequest(\Exception $exception, Request $request): Request
{ {
$attributes = [ $attributes = [
'_controller' => $this->controller, '_controller' => $this->controller,

View File

@ -92,7 +92,7 @@ class FragmentListener implements EventSubscriberInterface
throw new AccessDeniedHttpException(); throw new AccessDeniedHttpException();
} }
public static function getSubscribedEvents() public static function getSubscribedEvents(): array
{ {
return [ return [
KernelEvents::REQUEST => [['onKernelRequest', 48]], KernelEvents::REQUEST => [['onKernelRequest', 48]],

View File

@ -79,7 +79,7 @@ class LocaleListener implements EventSubscriberInterface
} }
} }
public static function getSubscribedEvents() public static function getSubscribedEvents(): array
{ {
return [ return [
KernelEvents::REQUEST => [ KernelEvents::REQUEST => [

View File

@ -119,7 +119,7 @@ class ProfilerListener implements EventSubscriberInterface
$this->parents = new \SplObjectStorage(); $this->parents = new \SplObjectStorage();
} }
public static function getSubscribedEvents() public static function getSubscribedEvents(): array
{ {
return [ return [
KernelEvents::RESPONSE => ['onKernelResponse', -100], KernelEvents::RESPONSE => ['onKernelResponse', -100],

View File

@ -49,7 +49,7 @@ class ResponseListener implements EventSubscriberInterface
$response->prepare($event->getRequest()); $response->prepare($event->getRequest());
} }
public static function getSubscribedEvents() public static function getSubscribedEvents(): array
{ {
return [ return [
KernelEvents::RESPONSE => 'onKernelResponse', KernelEvents::RESPONSE => 'onKernelResponse',

View File

@ -157,7 +157,7 @@ class RouterListener implements EventSubscriberInterface
} }
} }
public static function getSubscribedEvents() public static function getSubscribedEvents(): array
{ {
return [ return [
KernelEvents::REQUEST => [['onKernelRequest', 32]], KernelEvents::REQUEST => [['onKernelRequest', 32]],
@ -166,7 +166,7 @@ class RouterListener implements EventSubscriberInterface
]; ];
} }
private function createWelcomeResponse() private function createWelcomeResponse(): Response
{ {
$version = Kernel::VERSION; $version = Kernel::VERSION;
$baseDir = realpath($this->projectDir).\DIRECTORY_SEPARATOR; $baseDir = realpath($this->projectDir).\DIRECTORY_SEPARATOR;

View File

@ -42,7 +42,7 @@ class StreamedResponseListener implements EventSubscriberInterface
} }
} }
public static function getSubscribedEvents() public static function getSubscribedEvents(): array
{ {
return [ return [
KernelEvents::RESPONSE => ['onKernelResponse', -1024], KernelEvents::RESPONSE => ['onKernelResponse', -1024],

View File

@ -58,7 +58,7 @@ class SurrogateListener implements EventSubscriberInterface
$surrogate->addSurrogateControl($event->getResponse()); $surrogate->addSurrogateControl($event->getResponse());
} }
public static function getSubscribedEvents() public static function getSubscribedEvents(): array
{ {
return [ return [
KernelEvents::RESPONSE => 'onKernelResponse', KernelEvents::RESPONSE => 'onKernelResponse',

View File

@ -44,7 +44,7 @@ class ValidateRequestListener implements EventSubscriberInterface
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public static function getSubscribedEvents() public static function getSubscribedEvents(): array
{ {
return [ return [
KernelEvents::REQUEST => [ KernelEvents::REQUEST => [

View File

@ -60,7 +60,7 @@ final class Countries extends ResourceBundle
/** /**
* @return string[] * @return string[]
*/ */
public static function getNames($displayLocale = null) public static function getNames($displayLocale = null): array
{ {
return self::asort(self::readEntry(['Names'], $displayLocale), $displayLocale); return self::asort(self::readEntry(['Names'], $displayLocale), $displayLocale);
} }

View File

@ -69,7 +69,7 @@ final class Intl
* *
* @return bool Returns true if the intl extension is installed, false otherwise * @return bool Returns true if the intl extension is installed, false otherwise
*/ */
public static function isExtensionLoaded() public static function isExtensionLoaded(): bool
{ {
return class_exists('\ResourceBundle'); return class_exists('\ResourceBundle');
} }
@ -79,7 +79,7 @@ final class Intl
* *
* @return string|null The ICU version or NULL if it could not be determined * @return string|null The ICU version or NULL if it could not be determined
*/ */
public static function getIcuVersion() public static function getIcuVersion(): ?string
{ {
if (false === self::$icuVersion) { if (false === self::$icuVersion) {
if (!self::isExtensionLoaded()) { if (!self::isExtensionLoaded()) {
@ -109,7 +109,7 @@ final class Intl
* *
* @return string The version of the installed ICU data * @return string The version of the installed ICU data
*/ */
public static function getIcuDataVersion() public static function getIcuDataVersion(): string
{ {
if (false === self::$icuDataVersion) { if (false === self::$icuDataVersion) {
self::$icuDataVersion = trim(file_get_contents(self::getDataDirectory().'/version.txt')); self::$icuDataVersion = trim(file_get_contents(self::getDataDirectory().'/version.txt'));
@ -123,7 +123,7 @@ final class Intl
* *
* @return string The ICU version of the stub classes * @return string The ICU version of the stub classes
*/ */
public static function getIcuStubVersion() public static function getIcuStubVersion(): string
{ {
return '64.2'; return '64.2';
} }
@ -133,7 +133,7 @@ final class Intl
* *
* @return string The absolute path to the data directory * @return string The absolute path to the data directory
*/ */
public static function getDataDirectory() public static function getDataDirectory(): string
{ {
return __DIR__.'/Resources/data'; return __DIR__.'/Resources/data';
} }

View File

@ -67,7 +67,7 @@ final class Locales extends ResourceBundle
/** /**
* @return string[] * @return string[]
*/ */
public static function getNames($displayLocale = null) public static function getNames($displayLocale = null): array
{ {
return self::asort(self::readEntry(['Names'], $displayLocale), $displayLocale); return self::asort(self::readEntry(['Names'], $displayLocale), $displayLocale);
} }

View File

@ -51,7 +51,7 @@ final class Scripts extends ResourceBundle
/** /**
* @return string[] * @return string[]
*/ */
public static function getNames($displayLocale = null) public static function getNames($displayLocale = null): array
{ {
return self::asort(self::readEntry(['Names'], $displayLocale), $displayLocale); return self::asort(self::readEntry(['Names'], $displayLocale), $displayLocale);
} }

View File

@ -44,7 +44,7 @@ final class GitRepository
return new self(realpath($targetDir)); return new self(realpath($targetDir));
} }
public function getPath() public function getPath(): string
{ {
return $this->path; return $this->path;
} }
@ -64,7 +64,7 @@ final class GitRepository
return $this->getLastLine($this->execInPath('git log -1 --format="%an"')); return $this->getLastLine($this->execInPath('git log -1 --format="%an"'));
} }
public function getLastAuthoredDate() public function getLastAuthoredDate(): \DateTime
{ {
return new \DateTime($this->getLastLine($this->execInPath('git log -1 --format="%ai"'))); return new \DateTime($this->getLastLine($this->execInPath('git log -1 --format="%ai"')));
} }

View File

@ -45,7 +45,7 @@ final class ConnectionOptions
const X_SASL_AUTHCID = 0x6102; const X_SASL_AUTHCID = 0x6102;
const X_SASL_AUTHZID = 0x6103; const X_SASL_AUTHZID = 0x6103;
public static function getOptionName($name) public static function getOptionName($name): string
{ {
return sprintf('%s::%s', self::class, strtoupper($name)); return sprintf('%s::%s', self::class, strtoupper($name));
} }
@ -56,11 +56,9 @@ final class ConnectionOptions
* *
* @param string $name * @param string $name
* *
* @return int
*
* @throws LdapException * @throws LdapException
*/ */
public static function getOption($name) public static function getOption($name): int
{ {
// Convert // Convert
$constantName = self::getOptionName($name); $constantName = self::getOptionName($name);
@ -72,7 +70,7 @@ final class ConnectionOptions
return \constant($constantName); return \constant($constantName);
} }
public static function isOption($name) public static function isOption($name): bool
{ {
return \defined(self::getOptionName($name)); return \defined(self::getOptionName($name));
} }

View File

@ -12,6 +12,8 @@
namespace Symfony\Component\Ldap; namespace Symfony\Component\Ldap;
use Symfony\Component\Ldap\Adapter\AdapterInterface; use Symfony\Component\Ldap\Adapter\AdapterInterface;
use Symfony\Component\Ldap\Adapter\EntryManagerInterface;
use Symfony\Component\Ldap\Adapter\QueryInterface;
use Symfony\Component\Ldap\Exception\DriverNotFoundException; use Symfony\Component\Ldap\Exception\DriverNotFoundException;
/** /**
@ -41,7 +43,7 @@ final class Ldap implements LdapInterface
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function query($dn, $query, array $options = []) public function query($dn, $query, array $options = []): ?QueryInterface
{ {
return $this->adapter->createQuery($dn, $query, $options); return $this->adapter->createQuery($dn, $query, $options);
} }
@ -49,7 +51,7 @@ final class Ldap implements LdapInterface
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function getEntryManager() public function getEntryManager(): ?EntryManagerInterface
{ {
return $this->adapter->getEntryManager(); return $this->adapter->getEntryManager();
} }
@ -57,7 +59,7 @@ final class Ldap implements LdapInterface
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function escape($subject, $ignore = '', $flags = 0) public function escape($subject, $ignore = '', $flags = 0): ?string
{ {
return $this->adapter->escape($subject, $ignore, $flags); return $this->adapter->escape($subject, $ignore, $flags);
} }

Some files were not shown because too many files have changed in this diff Show More