From 606775cdbd7627d1c8e1fe98559e2f7fd9710ddc Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Thu, 12 Aug 2021 17:01:43 +0200 Subject: [PATCH] Add return types - batch 2/n --- .../Asset/Context/ContextInterface.php | 4 +- .../Component/Asset/Context/NullContext.php | 4 +- .../Asset/Context/RequestStackContext.php | 4 +- src/Symfony/Component/Asset/Package.php | 19 +-- .../Component/Asset/PackageInterface.php | 4 +- src/Symfony/Component/Asset/Packages.php | 6 +- src/Symfony/Component/Asset/PathPackage.php | 4 +- src/Symfony/Component/Asset/UrlPackage.php | 6 +- .../VersionStrategy/EmptyVersionStrategy.php | 4 +- .../JsonManifestVersionStrategy.php | 4 +- .../VersionStrategy/StaticVersionStrategy.php | 4 +- .../VersionStrategyInterface.php | 4 +- .../CssSelector/CssSelectorConverter.php | 4 +- .../Exception/SyntaxErrorException.php | 25 +--- .../Component/CssSelector/Parser/Reader.php | 2 +- .../CssSelector/Parser/TokenStream.php | 4 +- .../XPath/Extension/NodeExtension.php | 2 +- .../CssSelector/XPath/Translator.php | 4 +- .../Component/CssSelector/XPath/XPathExpr.php | 2 +- .../DomCrawler/AbstractUriElement.php | 16 +-- src/Symfony/Component/DomCrawler/Crawler.php | 110 +++++------------- .../DomCrawler/Field/ChoiceFormField.php | 10 +- .../Component/DomCrawler/Field/FormField.php | 16 +-- src/Symfony/Component/DomCrawler/Form.php | 30 +++-- .../DomCrawler/FormFieldRegistry.php | 2 +- src/Symfony/Component/DomCrawler/Image.php | 2 +- src/Symfony/Component/DomCrawler/Link.php | 2 +- .../Finder/Comparator/Comparator.php | 8 +- src/Symfony/Component/Finder/Finder.php | 62 +++++----- src/Symfony/Component/Finder/Glob.php | 4 +- .../Iterator/FilecontentFilterIterator.php | 2 +- .../Iterator/FilenameFilterIterator.php | 2 +- .../Iterator/MultiplePcreFilterIterator.php | 6 +- .../Finder/Iterator/PathFilterIterator.php | 2 +- .../Iterator/RecursiveDirectoryIterator.php | 2 +- src/Symfony/Component/Finder/SplFileInfo.php | 6 +- .../Ldap/Adapter/AdapterInterface.php | 8 +- .../Ldap/Adapter/CollectionInterface.php | 2 +- .../Ldap/Adapter/ConnectionInterface.php | 2 +- .../Ldap/Adapter/ExtLdap/Adapter.php | 11 +- .../Ldap/Adapter/ExtLdap/Collection.php | 2 +- .../Ldap/Adapter/ExtLdap/Connection.php | 4 +- .../Component/Ldap/Adapter/ExtLdap/Query.php | 6 +- .../Component/Ldap/Adapter/QueryInterface.php | 2 +- src/Symfony/Component/Ldap/Entry.php | 8 +- src/Symfony/Component/Ldap/LdapInterface.php | 6 +- .../Ldap/Security/LdapUserProvider.php | 8 +- .../Component/Process/ExecutableFinder.php | 2 +- .../Component/Process/PhpExecutableFinder.php | 4 +- src/Symfony/Component/Process/PhpProcess.php | 2 +- src/Symfony/Component/Process/Process.php | 86 +++++++------- .../Component/Process/ProcessUtils.php | 2 +- 52 files changed, 227 insertions(+), 320 deletions(-) diff --git a/src/Symfony/Component/Asset/Context/ContextInterface.php b/src/Symfony/Component/Asset/Context/ContextInterface.php index 83282021aef17..ca5fbe6acf03c 100644 --- a/src/Symfony/Component/Asset/Context/ContextInterface.php +++ b/src/Symfony/Component/Asset/Context/ContextInterface.php @@ -23,12 +23,12 @@ interface ContextInterface * * @return string The base path */ - public function getBasePath(); + public function getBasePath(): string; /** * Checks whether the request is secure or not. * * @return bool true if the request is secure, false otherwise */ - public function isSecure(); + public function isSecure(): bool; } diff --git a/src/Symfony/Component/Asset/Context/NullContext.php b/src/Symfony/Component/Asset/Context/NullContext.php index 0743d8ccbd615..d662fef4e49de 100644 --- a/src/Symfony/Component/Asset/Context/NullContext.php +++ b/src/Symfony/Component/Asset/Context/NullContext.php @@ -21,7 +21,7 @@ class NullContext implements ContextInterface /** * {@inheritdoc} */ - public function getBasePath() + public function getBasePath(): string { return ''; } @@ -29,7 +29,7 @@ public function getBasePath() /** * {@inheritdoc} */ - public function isSecure() + public function isSecure(): bool { return false; } diff --git a/src/Symfony/Component/Asset/Context/RequestStackContext.php b/src/Symfony/Component/Asset/Context/RequestStackContext.php index 39d86b14eaf80..19cd52613cb97 100644 --- a/src/Symfony/Component/Asset/Context/RequestStackContext.php +++ b/src/Symfony/Component/Asset/Context/RequestStackContext.php @@ -34,7 +34,7 @@ public function __construct(RequestStack $requestStack, string $basePath = '', b /** * {@inheritdoc} */ - public function getBasePath() + public function getBasePath(): string { if (!$request = $this->requestStack->getMainRequest()) { return $this->basePath; @@ -46,7 +46,7 @@ public function getBasePath() /** * {@inheritdoc} */ - public function isSecure() + public function isSecure(): bool { if (!$request = $this->requestStack->getMainRequest()) { return $this->secure; diff --git a/src/Symfony/Component/Asset/Package.php b/src/Symfony/Component/Asset/Package.php index 21148c2f25247..610e858e910c0 100644 --- a/src/Symfony/Component/Asset/Package.php +++ b/src/Symfony/Component/Asset/Package.php @@ -35,7 +35,7 @@ public function __construct(VersionStrategyInterface $versionStrategy, ContextIn /** * {@inheritdoc} */ - public function getVersion(string $path) + public function getVersion(string $path): string { return $this->versionStrategy->getVersion($path); } @@ -43,7 +43,7 @@ public function getVersion(string $path) /** * {@inheritdoc} */ - public function getUrl(string $path) + public function getUrl(string $path): string { if ($this->isAbsoluteUrl($path)) { return $path; @@ -52,26 +52,17 @@ public function getUrl(string $path) return $this->versionStrategy->applyVersion($path); } - /** - * @return ContextInterface - */ - protected function getContext() + protected function getContext(): ContextInterface { return $this->context; } - /** - * @return VersionStrategyInterface - */ - protected function getVersionStrategy() + protected function getVersionStrategy(): VersionStrategyInterface { return $this->versionStrategy; } - /** - * @return bool - */ - protected function isAbsoluteUrl(string $url) + protected function isAbsoluteUrl(string $url): bool { return str_contains($url, '://') || '//' === substr($url, 0, 2); } diff --git a/src/Symfony/Component/Asset/PackageInterface.php b/src/Symfony/Component/Asset/PackageInterface.php index 644a30acaf956..fbc65e747b7d9 100644 --- a/src/Symfony/Component/Asset/PackageInterface.php +++ b/src/Symfony/Component/Asset/PackageInterface.php @@ -23,12 +23,12 @@ interface PackageInterface * * @return string The version string */ - public function getVersion(string $path); + public function getVersion(string $path): string; /** * Returns an absolute or root-relative public path. * * @return string The public path */ - public function getUrl(string $path); + public function getUrl(string $path): string; } diff --git a/src/Symfony/Component/Asset/Packages.php b/src/Symfony/Component/Asset/Packages.php index cbfa5ef674c23..39f6b2b1b24ba 100644 --- a/src/Symfony/Component/Asset/Packages.php +++ b/src/Symfony/Component/Asset/Packages.php @@ -57,7 +57,7 @@ public function addPackage(string $name, PackageInterface $package) * @throws InvalidArgumentException If there is no package by that name * @throws LogicException If no default package is defined */ - public function getPackage(string $name = null) + public function getPackage(string $name = null): PackageInterface { if (null === $name) { if (null === $this->defaultPackage) { @@ -82,7 +82,7 @@ public function getPackage(string $name = null) * * @return string The current version */ - public function getVersion(string $path, string $packageName = null) + public function getVersion(string $path, string $packageName = null): string { return $this->getPackage($packageName)->getVersion($path); } @@ -97,7 +97,7 @@ public function getVersion(string $path, string $packageName = null) * * @return string A public path which takes into account the base path and URL path */ - public function getUrl(string $path, string $packageName = null) + public function getUrl(string $path, string $packageName = null): string { return $this->getPackage($packageName)->getUrl($path); } diff --git a/src/Symfony/Component/Asset/PathPackage.php b/src/Symfony/Component/Asset/PathPackage.php index 7c16959977132..229fb35e8cbee 100644 --- a/src/Symfony/Component/Asset/PathPackage.php +++ b/src/Symfony/Component/Asset/PathPackage.php @@ -49,7 +49,7 @@ public function __construct(string $basePath, VersionStrategyInterface $versionS /** * {@inheritdoc} */ - public function getUrl(string $path) + public function getUrl(string $path): string { $versionedPath = parent::getUrl($path); @@ -66,7 +66,7 @@ public function getUrl(string $path) * * @return string The base path */ - public function getBasePath() + public function getBasePath(): string { return $this->getContext()->getBasePath().$this->basePath; } diff --git a/src/Symfony/Component/Asset/UrlPackage.php b/src/Symfony/Component/Asset/UrlPackage.php index 01fe614eed5c8..ce6ae0c040b0c 100644 --- a/src/Symfony/Component/Asset/UrlPackage.php +++ b/src/Symfony/Component/Asset/UrlPackage.php @@ -67,7 +67,7 @@ public function __construct(string|array $baseUrls, VersionStrategyInterface $ve /** * {@inheritdoc} */ - public function getUrl(string $path) + public function getUrl(string $path): string { if ($this->isAbsoluteUrl($path)) { return $path; @@ -95,7 +95,7 @@ public function getUrl(string $path) * * @return string The base URL */ - public function getBaseUrl(string $path) + public function getBaseUrl(string $path): string { if (1 === \count($this->baseUrls)) { return $this->baseUrls[0]; @@ -112,7 +112,7 @@ public function getBaseUrl(string $path) * * @return int The base URL index for the given path */ - protected function chooseBaseUrl(string $path) + protected function chooseBaseUrl(string $path): int { return (int) fmod(hexdec(substr(hash('sha256', $path), 0, 10)), \count($this->baseUrls)); } diff --git a/src/Symfony/Component/Asset/VersionStrategy/EmptyVersionStrategy.php b/src/Symfony/Component/Asset/VersionStrategy/EmptyVersionStrategy.php index 8ee048c279838..93dbbb9e265de 100644 --- a/src/Symfony/Component/Asset/VersionStrategy/EmptyVersionStrategy.php +++ b/src/Symfony/Component/Asset/VersionStrategy/EmptyVersionStrategy.php @@ -21,7 +21,7 @@ class EmptyVersionStrategy implements VersionStrategyInterface /** * {@inheritdoc} */ - public function getVersion(string $path) + public function getVersion(string $path): string { return ''; } @@ -29,7 +29,7 @@ public function getVersion(string $path) /** * {@inheritdoc} */ - public function applyVersion(string $path) + public function applyVersion(string $path): string { return $path; } diff --git a/src/Symfony/Component/Asset/VersionStrategy/JsonManifestVersionStrategy.php b/src/Symfony/Component/Asset/VersionStrategy/JsonManifestVersionStrategy.php index daa1d21bc4090..7fa5b30f3f2f3 100644 --- a/src/Symfony/Component/Asset/VersionStrategy/JsonManifestVersionStrategy.php +++ b/src/Symfony/Component/Asset/VersionStrategy/JsonManifestVersionStrategy.php @@ -56,12 +56,12 @@ public function __construct(string $manifestPath, HttpClientInterface $httpClien * the version is. Instead, this returns the path to the * versioned file. */ - public function getVersion(string $path) + public function getVersion(string $path): string { return $this->applyVersion($path); } - public function applyVersion(string $path) + public function applyVersion(string $path): string { return $this->getManifestPath($path) ?: $path; } diff --git a/src/Symfony/Component/Asset/VersionStrategy/StaticVersionStrategy.php b/src/Symfony/Component/Asset/VersionStrategy/StaticVersionStrategy.php index 58bc1a58efe55..6c6a3434ae545 100644 --- a/src/Symfony/Component/Asset/VersionStrategy/StaticVersionStrategy.php +++ b/src/Symfony/Component/Asset/VersionStrategy/StaticVersionStrategy.php @@ -34,7 +34,7 @@ public function __construct(string $version, string $format = null) /** * {@inheritdoc} */ - public function getVersion(string $path) + public function getVersion(string $path): string { return $this->version; } @@ -42,7 +42,7 @@ public function getVersion(string $path) /** * {@inheritdoc} */ - public function applyVersion(string $path) + public function applyVersion(string $path): string { $versionized = sprintf($this->format, ltrim($path, '/'), $this->getVersion($path)); diff --git a/src/Symfony/Component/Asset/VersionStrategy/VersionStrategyInterface.php b/src/Symfony/Component/Asset/VersionStrategy/VersionStrategyInterface.php index 338192866f334..ddd7eb3480d92 100644 --- a/src/Symfony/Component/Asset/VersionStrategy/VersionStrategyInterface.php +++ b/src/Symfony/Component/Asset/VersionStrategy/VersionStrategyInterface.php @@ -23,12 +23,12 @@ interface VersionStrategyInterface * * @return string The version string */ - public function getVersion(string $path); + public function getVersion(string $path): string; /** * Applies version to the supplied path. * * @return string The versionized path */ - public function applyVersion(string $path); + public function applyVersion(string $path): string; } diff --git a/src/Symfony/Component/CssSelector/CssSelectorConverter.php b/src/Symfony/Component/CssSelector/CssSelectorConverter.php index faeee7a5905b6..a322e93fbb18c 100644 --- a/src/Symfony/Component/CssSelector/CssSelectorConverter.php +++ b/src/Symfony/Component/CssSelector/CssSelectorConverter.php @@ -59,10 +59,8 @@ public function __construct(bool $html = true) * * Optionally, a prefix can be added to the resulting XPath * expression with the $prefix parameter. - * - * @return string */ - public function toXPath(string $cssExpr, string $prefix = 'descendant-or-self::') + public function toXPath(string $cssExpr, string $prefix = 'descendant-or-self::'): string { return $this->cache[$prefix][$cssExpr] ?? $this->cache[$prefix][$cssExpr] = $this->translator->cssToXPath($cssExpr, $prefix); } diff --git a/src/Symfony/Component/CssSelector/Exception/SyntaxErrorException.php b/src/Symfony/Component/CssSelector/Exception/SyntaxErrorException.php index 7deacf9c5ee19..f73860cef5689 100644 --- a/src/Symfony/Component/CssSelector/Exception/SyntaxErrorException.php +++ b/src/Symfony/Component/CssSelector/Exception/SyntaxErrorException.php @@ -23,42 +23,27 @@ */ class SyntaxErrorException extends ParseException { - /** - * @return self - */ - public static function unexpectedToken(string $expectedValue, Token $foundToken) + public static function unexpectedToken(string $expectedValue, Token $foundToken): self { return new self(sprintf('Expected %s, but %s found.', $expectedValue, $foundToken)); } - /** - * @return self - */ - public static function pseudoElementFound(string $pseudoElement, string $unexpectedLocation) + public static function pseudoElementFound(string $pseudoElement, string $unexpectedLocation): self { return new self(sprintf('Unexpected pseudo-element "::%s" found %s.', $pseudoElement, $unexpectedLocation)); } - /** - * @return self - */ - public static function unclosedString(int $position) + public static function unclosedString(int $position): self { return new self(sprintf('Unclosed/invalid string at %s.', $position)); } - /** - * @return self - */ - public static function nestedNot() + public static function nestedNot(): self { return new self('Got nested ::not().'); } - /** - * @return self - */ - public static function stringAsFunctionArgument() + public static function stringAsFunctionArgument(): self { return new self('String not allowed as function argument.'); } diff --git a/src/Symfony/Component/CssSelector/Parser/Reader.php b/src/Symfony/Component/CssSelector/Parser/Reader.php index 34e5af2d92196..f926e605c59fa 100644 --- a/src/Symfony/Component/CssSelector/Parser/Reader.php +++ b/src/Symfony/Component/CssSelector/Parser/Reader.php @@ -63,7 +63,7 @@ public function getOffset(string $string) /** * @return array|false */ - public function findPattern(string $pattern) + public function findPattern(string $pattern): array|false { $source = substr($this->source, $this->position); diff --git a/src/Symfony/Component/CssSelector/Parser/TokenStream.php b/src/Symfony/Component/CssSelector/Parser/TokenStream.php index e5ce48b684541..d1daa75f28c89 100644 --- a/src/Symfony/Component/CssSelector/Parser/TokenStream.php +++ b/src/Symfony/Component/CssSelector/Parser/TokenStream.php @@ -45,7 +45,7 @@ class TokenStream * * @return $this */ - public function push(Token $token): self + public function push(Token $token): static { $this->tokens[] = $token; @@ -57,7 +57,7 @@ public function push(Token $token): self * * @return $this */ - public function freeze(): self + public function freeze(): static { return $this; } diff --git a/src/Symfony/Component/CssSelector/XPath/Extension/NodeExtension.php b/src/Symfony/Component/CssSelector/XPath/Extension/NodeExtension.php index 824851f6b9fcd..642702bbb89fb 100644 --- a/src/Symfony/Component/CssSelector/XPath/Extension/NodeExtension.php +++ b/src/Symfony/Component/CssSelector/XPath/Extension/NodeExtension.php @@ -41,7 +41,7 @@ public function __construct(int $flags = 0) /** * @return $this */ - public function setFlag(int $flag, bool $on): self + public function setFlag(int $flag, bool $on): static { if ($on && !$this->hasFlag($flag)) { $this->flags += $flag; diff --git a/src/Symfony/Component/CssSelector/XPath/Translator.php b/src/Symfony/Component/CssSelector/XPath/Translator.php index b671ad56e4bb5..128a4a9397ac3 100644 --- a/src/Symfony/Component/CssSelector/XPath/Translator.php +++ b/src/Symfony/Component/CssSelector/XPath/Translator.php @@ -117,7 +117,7 @@ public function selectorToXPath(SelectorNode $selector, string $prefix = 'descen /** * @return $this */ - public function registerExtension(Extension\ExtensionInterface $extension): self + public function registerExtension(Extension\ExtensionInterface $extension): static { $this->extensions[$extension->getName()] = $extension; @@ -145,7 +145,7 @@ public function getExtension(string $name): Extension\ExtensionInterface /** * @return $this */ - public function registerParserShortcut(ParserInterface $shortcut): self + public function registerParserShortcut(ParserInterface $shortcut): static { $this->shortcutParsers[] = $shortcut; diff --git a/src/Symfony/Component/CssSelector/XPath/XPathExpr.php b/src/Symfony/Component/CssSelector/XPath/XPathExpr.php index f3304a6e74bdc..61f8034a760af 100644 --- a/src/Symfony/Component/CssSelector/XPath/XPathExpr.php +++ b/src/Symfony/Component/CssSelector/XPath/XPathExpr.php @@ -77,7 +77,7 @@ public function addStarPrefix(): self * * @return $this */ - public function join(string $combiner, self $expr): self + public function join(string $combiner, self $expr): static { $path = $this->__toString().$combiner; diff --git a/src/Symfony/Component/DomCrawler/AbstractUriElement.php b/src/Symfony/Component/DomCrawler/AbstractUriElement.php index c284bcc5eebc3..5f3c4092c330f 100644 --- a/src/Symfony/Component/DomCrawler/AbstractUriElement.php +++ b/src/Symfony/Component/DomCrawler/AbstractUriElement.php @@ -55,10 +55,8 @@ public function __construct(\DOMElement $node, string $currentUri = null, ?strin /** * Gets the node associated with this link. - * - * @return \DOMElement */ - public function getNode() + public function getNode(): \DOMElement { return $this->node; } @@ -68,7 +66,7 @@ public function getNode() * * @return string The method */ - public function getMethod() + public function getMethod(): string { return $this->method ?? 'GET'; } @@ -78,26 +76,22 @@ public function getMethod() * * @return string The URI */ - public function getUri() + public function getUri(): string { return UriResolver::resolve($this->getRawUri(), $this->currentUri); } /** * Returns raw URI data. - * - * @return string */ - abstract protected function getRawUri(); + abstract protected function getRawUri(): string; /** * Returns the canonicalized URI path (see RFC 3986, section 5.2.4). * * @param string $path URI path - * - * @return string */ - protected function canonicalizePath(string $path) + protected function canonicalizePath(string $path): string { if ('' === $path || '/' === $path) { return $path; diff --git a/src/Symfony/Component/DomCrawler/Crawler.php b/src/Symfony/Component/DomCrawler/Crawler.php index 80befd9b1580a..fdc7e54afd59c 100644 --- a/src/Symfony/Component/DomCrawler/Crawler.php +++ b/src/Symfony/Component/DomCrawler/Crawler.php @@ -73,20 +73,16 @@ public function __construct(\DOMNodeList|\DOMNode|array|string $node = null, str /** * Returns the current URI. - * - * @return string|null */ - public function getUri() + public function getUri(): ?string { return $this->uri; } /** * Returns base href. - * - * @return string|null */ - public function getBaseHref() + public function getBaseHref(): ?string { return $this->baseHref; } @@ -304,10 +300,8 @@ public function addNode(\DOMNode $node) /** * Returns a node given its position in the node list. - * - * @return static */ - public function eq(int $position) + public function eq(int $position): static { if (isset($this->nodes[$position])) { return $this->createSubCrawler($this->nodes[$position]); @@ -332,7 +326,7 @@ public function eq(int $position) * * @return array An array of values returned by the anonymous function */ - public function each(\Closure $closure) + public function each(\Closure $closure): array { $data = []; foreach ($this->nodes as $i => $node) { @@ -344,10 +338,8 @@ public function each(\Closure $closure) /** * Slices the list of nodes by $offset and $length. - * - * @return static */ - public function slice(int $offset = 0, int $length = null) + public function slice(int $offset = 0, int $length = null): static { return $this->createSubCrawler(\array_slice($this->nodes, $offset, $length)); } @@ -358,10 +350,8 @@ public function slice(int $offset = 0, int $length = null) * To remove a node from the list, the anonymous function must return false. * * @param \Closure $closure An anonymous function - * - * @return static */ - public function reduce(\Closure $closure) + public function reduce(\Closure $closure): static { $nodes = []; foreach ($this->nodes as $i => $node) { @@ -375,20 +365,16 @@ public function reduce(\Closure $closure) /** * Returns the first node of the current selection. - * - * @return static */ - public function first() + public function first(): static { return $this->eq(0); } /** * Returns the last node of the current selection. - * - * @return static */ - public function last() + public function last(): static { return $this->eq(\count($this->nodes) - 1); } @@ -396,11 +382,9 @@ public function last() /** * Returns the siblings nodes of the current selection. * - * @return static - * * @throws \InvalidArgumentException When current node is empty */ - public function siblings() + public function siblings(): static { if (!$this->nodes) { throw new \InvalidArgumentException('The current node list is empty.'); @@ -451,11 +435,9 @@ public function closest(string $selector): ?self /** * Returns the next siblings nodes of the current selection. * - * @return static - * * @throws \InvalidArgumentException When current node is empty */ - public function nextAll() + public function nextAll(): static { if (!$this->nodes) { throw new \InvalidArgumentException('The current node list is empty.'); @@ -467,11 +449,9 @@ public function nextAll() /** * Returns the previous sibling nodes of the current selection. * - * @return static - * * @throws \InvalidArgumentException */ - public function previousAll() + public function previousAll(): static { if (!$this->nodes) { throw new \InvalidArgumentException('The current node list is empty.'); @@ -483,11 +463,9 @@ public function previousAll() /** * Returns the ancestors of the current selection. * - * @return static - * * @throws \InvalidArgumentException When the current node is empty */ - public function ancestors() + public function ancestors(): static { if (!$this->nodes) { throw new \InvalidArgumentException('The current node list is empty.'); @@ -508,12 +486,10 @@ public function ancestors() /** * Returns the children nodes of the current selection. * - * @return static - * * @throws \InvalidArgumentException When current node is empty * @throws \RuntimeException If the CssSelector Component is not available and $selector is provided */ - public function children(string $selector = null) + public function children(string $selector = null): static { if (!$this->nodes) { throw new \InvalidArgumentException('The current node list is empty.'); @@ -538,7 +514,7 @@ public function children(string $selector = null) * * @throws \InvalidArgumentException When current node is empty */ - public function attr(string $attribute) + public function attr(string $attribute): ?string { if (!$this->nodes) { throw new \InvalidArgumentException('The current node list is empty.'); @@ -556,7 +532,7 @@ public function attr(string $attribute) * * @throws \InvalidArgumentException When current node is empty */ - public function nodeName() + public function nodeName(): string { if (!$this->nodes) { throw new \InvalidArgumentException('The current node list is empty.'); @@ -577,7 +553,7 @@ public function nodeName() * * @throws \InvalidArgumentException When current node is empty */ - public function text(string $default = null, bool $normalizeWhitespace = true) + public function text(string $default = null, bool $normalizeWhitespace = true): string { if (!$this->nodes) { if (null !== $default) { @@ -605,7 +581,7 @@ public function text(string $default = null, bool $normalizeWhitespace = true) * * @throws \InvalidArgumentException When current node is empty */ - public function html(string $default = null) + public function html(string $default = null): string { if (!$this->nodes) { if (null !== $default) { @@ -654,7 +630,7 @@ public function outerHtml(): string * * @return array|Crawler */ - public function evaluate(string $xpath) + public function evaluate(string $xpath): array|Crawler { if (null === $this->document) { throw new \LogicException('Cannot evaluate the expression on an uninitialized crawler.'); @@ -685,7 +661,7 @@ public function evaluate(string $xpath) * * @return array An array of extracted values */ - public function extract(array $attributes) + public function extract(array $attributes): array { $count = \count($attributes); @@ -715,10 +691,8 @@ public function extract(array $attributes) * is considered as a fake parent of the elements inside it. * This means that a child selector "div" or "./div" will match only * the div elements of the current crawler, not their children. - * - * @return static */ - public function filterXPath(string $xpath) + public function filterXPath(string $xpath): static { $xpath = $this->relativize($xpath); @@ -735,11 +709,9 @@ public function filterXPath(string $xpath) * * This method only works if you have installed the CssSelector Symfony Component. * - * @return static - * * @throws \RuntimeException if the CssSelector Component is not available */ - public function filter(string $selector) + public function filter(string $selector): static { $converter = $this->createCssSelectorConverter(); @@ -749,10 +721,8 @@ public function filter(string $selector) /** * Selects links by name or alt value for clickable images. - * - * @return static */ - public function selectLink(string $value) + public function selectLink(string $value): static { return $this->filterRelativeXPath( sprintf('descendant-or-self::a[contains(concat(\' \', normalize-space(string(.)), \' \'), %1$s) or ./img[contains(concat(\' \', normalize-space(string(@alt)), \' \'), %1$s)]]', static::xpathLiteral(' '.$value.' ')) @@ -761,10 +731,8 @@ public function selectLink(string $value) /** * Selects images by alt value. - * - * @return static */ - public function selectImage(string $value) + public function selectImage(string $value): static { $xpath = sprintf('descendant-or-self::img[contains(normalize-space(string(@alt)), %s)]', static::xpathLiteral($value)); @@ -773,10 +741,8 @@ public function selectImage(string $value) /** * Selects a button by name or alt value for images. - * - * @return static */ - public function selectButton(string $value) + public function selectButton(string $value): static { return $this->filterRelativeXPath( sprintf('descendant-or-self::input[((contains(%1$s, "submit") or contains(%1$s, "button")) and contains(concat(\' \', normalize-space(string(@value)), \' \'), %2$s)) or (contains(%1$s, "image") and contains(concat(\' \', normalize-space(string(@alt)), \' \'), %2$s)) or @id=%3$s or @name=%3$s] | descendant-or-self::button[contains(concat(\' \', normalize-space(string(.)), \' \'), %2$s) or @id=%3$s or @name=%3$s]', 'translate(@type, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "abcdefghijklmnopqrstuvwxyz")', static::xpathLiteral(' '.$value.' '), static::xpathLiteral($value)) @@ -786,11 +752,9 @@ public function selectButton(string $value) /** * Returns a Link object for the first node in the list. * - * @return Link - * * @throws \InvalidArgumentException If the current node list is empty or the selected node is not instance of DOMElement */ - public function link(string $method = 'get') + public function link(string $method = 'get'): Link { if (!$this->nodes) { throw new \InvalidArgumentException('The current node list is empty.'); @@ -812,7 +776,7 @@ public function link(string $method = 'get') * * @throws \InvalidArgumentException If the current node list contains non-DOMElement instances */ - public function links() + public function links(): array { $links = []; foreach ($this->nodes as $node) { @@ -829,11 +793,9 @@ public function links() /** * Returns an Image object for the first node in the list. * - * @return Image - * * @throws \InvalidArgumentException If the current node list is empty */ - public function image() + public function image(): Image { if (!\count($this)) { throw new \InvalidArgumentException('The current node list is empty.'); @@ -853,7 +815,7 @@ public function image() * * @return Image[] */ - public function images() + public function images(): array { $images = []; foreach ($this as $node) { @@ -870,11 +832,9 @@ public function images() /** * Returns a Form object for the first node in the list. * - * @return Form - * * @throws \InvalidArgumentException If the current node list is empty or the selected node is not instance of DOMElement */ - public function form(array $values = null, string $method = null) + public function form(array $values = null, string $method = null): Form { if (!$this->nodes) { throw new \InvalidArgumentException('The current node list is empty.'); @@ -926,7 +886,7 @@ public function registerNamespace(string $prefix, string $namespace) * * @return string Converted string */ - public static function xpathLiteral(string $s) + public static function xpathLiteral(string $s): string { if (!str_contains($s, "'")) { return sprintf("'%s'", $s); @@ -1063,10 +1023,7 @@ private function relativize(string $xpath): string return $xpath; // The XPath expression is invalid } - /** - * @return \DOMNode|null - */ - public function getNode(int $position) + public function getNode(int $position): ?\DOMNode { return $this->nodes[$position] ?? null; } @@ -1084,10 +1041,7 @@ public function getIterator(): \ArrayIterator return new \ArrayIterator($this->nodes); } - /** - * @return array - */ - protected function sibling(\DOMNode $node, string $siblingDir = 'nextSibling') + protected function sibling(\DOMNode $node, string $siblingDir = 'nextSibling'): array { $nodes = []; diff --git a/src/Symfony/Component/DomCrawler/Field/ChoiceFormField.php b/src/Symfony/Component/DomCrawler/Field/ChoiceFormField.php index 680be84f7ac6f..b80e9f7358c71 100644 --- a/src/Symfony/Component/DomCrawler/Field/ChoiceFormField.php +++ b/src/Symfony/Component/DomCrawler/Field/ChoiceFormField.php @@ -30,7 +30,7 @@ class ChoiceFormField extends FormField * * @return bool true if the field should be included in the submitted values, false otherwise */ - public function hasValue() + public function hasValue(): bool { // don't send a value for unchecked checkboxes if (\in_array($this->type, ['checkbox', 'radio']) && null === $this->value) { @@ -42,10 +42,8 @@ public function hasValue() /** * Check if the current selected option is disabled. - * - * @return bool */ - public function isDisabled() + public function isDisabled(): bool { if (parent::isDisabled() && 'select' === $this->type) { return true; @@ -162,7 +160,7 @@ public function addChoice(\DOMElement $node) * * @return string The type */ - public function getType() + public function getType(): string { return $this->type; } @@ -172,7 +170,7 @@ public function getType() * * @return bool true if the field accepts multiple values, false otherwise */ - public function isMultiple() + public function isMultiple(): bool { return $this->multiple; } diff --git a/src/Symfony/Component/DomCrawler/Field/FormField.php b/src/Symfony/Component/DomCrawler/Field/FormField.php index 00cea429b31af..b05ace5226c2d 100644 --- a/src/Symfony/Component/DomCrawler/Field/FormField.php +++ b/src/Symfony/Component/DomCrawler/Field/FormField.php @@ -57,10 +57,8 @@ public function __construct(\DOMElement $node) /** * Returns the label tag associated to the field or null if none. - * - * @return \DOMElement|null */ - public function getLabel() + public function getLabel(): ?\DOMElement { $xpath = new \DOMXPath($this->node->ownerDocument); @@ -81,17 +79,15 @@ public function getLabel() * * @return string The name of the field */ - public function getName() + public function getName(): string { return $this->name; } /** * Gets the value of the field. - * - * @return string|array|null */ - public function getValue() + public function getValue(): string|array|null { return $this->value; } @@ -109,17 +105,15 @@ public function setValue(?string $value) * * @return bool true if the field should be included in the submitted values, false otherwise */ - public function hasValue() + public function hasValue(): bool { return true; } /** * Check if the current field is disabled. - * - * @return bool */ - public function isDisabled() + public function isDisabled(): bool { return $this->node->hasAttribute('disabled'); } diff --git a/src/Symfony/Component/DomCrawler/Form.php b/src/Symfony/Component/DomCrawler/Form.php index 00a53f67459b9..18e3211768c3b 100644 --- a/src/Symfony/Component/DomCrawler/Form.php +++ b/src/Symfony/Component/DomCrawler/Form.php @@ -43,10 +43,8 @@ public function __construct(\DOMElement $node, string $currentUri = null, string /** * Gets the form node associated with this form. - * - * @return \DOMElement */ - public function getFormNode() + public function getFormNode(): \DOMElement { return $this->node; } @@ -58,7 +56,7 @@ public function getFormNode() * * @return $this */ - public function setValues(array $values) + public function setValues(array $values): static { foreach ($values as $name => $value) { $this->fields->set($name, $value); @@ -74,7 +72,7 @@ public function setValues(array $values) * * @return array An array of field values */ - public function getValues() + public function getValues(): array { $values = []; foreach ($this->fields->all() as $name => $field) { @@ -95,7 +93,7 @@ public function getValues() * * @return array An array of file field values */ - public function getFiles() + public function getFiles(): array { if (!\in_array($this->getMethod(), ['POST', 'PUT', 'DELETE', 'PATCH'])) { return []; @@ -124,7 +122,7 @@ public function getFiles() * * @return array An array of field values */ - public function getPhpValues() + public function getPhpValues(): array { $values = []; foreach ($this->getValues() as $name => $value) { @@ -151,7 +149,7 @@ public function getPhpValues() * * @return array An array of file field values */ - public function getPhpFiles() + public function getPhpFiles(): array { $values = []; foreach ($this->getFiles() as $name => $value) { @@ -187,7 +185,7 @@ function (&$value, $key) { * * @return string The URI */ - public function getUri() + public function getUri(): string { $uri = parent::getUri(); @@ -208,7 +206,7 @@ public function getUri() return $uri; } - protected function getRawUri() + protected function getRawUri(): string { // If the form was created from a button rather than the form node, check for HTML5 action overrides if ($this->button !== $this->node && $this->button->getAttribute('formaction')) { @@ -225,7 +223,7 @@ protected function getRawUri() * * @return string The method */ - public function getMethod() + public function getMethod(): string { if (null !== $this->method) { return $this->method; @@ -254,7 +252,7 @@ public function getName(): string * * @return bool true if the field exists, false otherwise */ - public function has(string $name) + public function has(string $name): bool { return $this->fields->has($name); } @@ -274,7 +272,7 @@ public function remove(string $name) * * @throws \InvalidArgumentException When field is not present in this form */ - public function get(string $name) + public function get(string $name): FormField|array { return $this->fields->get($name); } @@ -292,7 +290,7 @@ public function set(FormField $field) * * @return FormField[] */ - public function all() + public function all(): array { return $this->fields->all(); } @@ -346,10 +344,8 @@ public function offsetUnset(mixed $name): void /** * Disables validation. - * - * @return self */ - public function disableValidation() + public function disableValidation(): self { foreach ($this->fields->all() as $field) { if ($field instanceof Field\ChoiceFormField) { diff --git a/src/Symfony/Component/DomCrawler/FormFieldRegistry.php b/src/Symfony/Component/DomCrawler/FormFieldRegistry.php index 9fd4a0b9034bc..40c4d1a7f0b55 100644 --- a/src/Symfony/Component/DomCrawler/FormFieldRegistry.php +++ b/src/Symfony/Component/DomCrawler/FormFieldRegistry.php @@ -69,7 +69,7 @@ public function remove(string $name) * * @throws \InvalidArgumentException if the field does not exist */ - public function &get(string $name) + public function &get(string $name): FormField|array { $segments = $this->getSegments($name); $target = &$this->fields; diff --git a/src/Symfony/Component/DomCrawler/Image.php b/src/Symfony/Component/DomCrawler/Image.php index b1ac5ca2ccb42..e57364151626e 100644 --- a/src/Symfony/Component/DomCrawler/Image.php +++ b/src/Symfony/Component/DomCrawler/Image.php @@ -21,7 +21,7 @@ public function __construct(\DOMElement $node, string $currentUri = null) parent::__construct($node, $currentUri, 'GET'); } - protected function getRawUri() + protected function getRawUri(): string { return $this->node->getAttribute('src'); } diff --git a/src/Symfony/Component/DomCrawler/Link.php b/src/Symfony/Component/DomCrawler/Link.php index 80a356e468480..658b4fd8ae779 100644 --- a/src/Symfony/Component/DomCrawler/Link.php +++ b/src/Symfony/Component/DomCrawler/Link.php @@ -18,7 +18,7 @@ */ class Link extends AbstractUriElement { - protected function getRawUri() + protected function getRawUri(): string { return $this->node->getAttribute('href'); } diff --git a/src/Symfony/Component/Finder/Comparator/Comparator.php b/src/Symfony/Component/Finder/Comparator/Comparator.php index d292bb40894e8..4ffe95275bfa7 100644 --- a/src/Symfony/Component/Finder/Comparator/Comparator.php +++ b/src/Symfony/Component/Finder/Comparator/Comparator.php @@ -34,7 +34,7 @@ public function __construct(string $target, string $operator = '==') * * @return string The target value */ - public function getTarget() + public function getTarget(): string { return $this->target; } @@ -44,17 +44,15 @@ public function getTarget() * * @return string The operator */ - public function getOperator() + public function getOperator(): string { return $this->operator; } /** * Tests against the target. - * - * @return bool */ - public function test(mixed $test) + public function test(mixed $test): bool { switch ($this->operator) { case '>': diff --git a/src/Symfony/Component/Finder/Finder.php b/src/Symfony/Component/Finder/Finder.php index cd494594634b7..1da942cedf3fd 100644 --- a/src/Symfony/Component/Finder/Finder.php +++ b/src/Symfony/Component/Finder/Finder.php @@ -74,10 +74,8 @@ public function __construct() /** * Creates a new Finder. - * - * @return static */ - public static function create() + public static function create(): static { return new static(); } @@ -87,7 +85,7 @@ public static function create() * * @return $this */ - public function directories() + public function directories(): static { $this->mode = Iterator\FileTypeFilterIterator::ONLY_DIRECTORIES; @@ -99,7 +97,7 @@ public function directories() * * @return $this */ - public function files() + public function files(): static { $this->mode = Iterator\FileTypeFilterIterator::ONLY_FILES; @@ -122,7 +120,7 @@ public function files() * @see DepthRangeFilterIterator * @see NumberComparator */ - public function depth(string|int|array $levels) + public function depth(string|int|array $levels): static { foreach ((array) $levels as $level) { $this->depths[] = new Comparator\NumberComparator($level); @@ -150,7 +148,7 @@ public function depth(string|int|array $levels) * @see DateRangeFilterIterator * @see DateComparator */ - public function date(string|array $dates) + public function date(string|array $dates): static { foreach ((array) $dates as $date) { $this->dates[] = new Comparator\DateComparator($date); @@ -175,7 +173,7 @@ public function date(string|array $dates) * * @see FilenameFilterIterator */ - public function name(string|array $patterns) + public function name(string|array $patterns): static { $this->names = array_merge($this->names, (array) $patterns); @@ -191,7 +189,7 @@ public function name(string|array $patterns) * * @see FilenameFilterIterator */ - public function notName(string|array $patterns) + public function notName(string|array $patterns): static { $this->notNames = array_merge($this->notNames, (array) $patterns); @@ -213,7 +211,7 @@ public function notName(string|array $patterns) * * @see FilecontentFilterIterator */ - public function contains(string|array $patterns) + public function contains(string|array $patterns): static { $this->contains = array_merge($this->contains, (array) $patterns); @@ -235,7 +233,7 @@ public function contains(string|array $patterns) * * @see FilecontentFilterIterator */ - public function notContains(string|array $patterns) + public function notContains(string|array $patterns): static { $this->notContains = array_merge($this->notContains, (array) $patterns); @@ -259,7 +257,7 @@ public function notContains(string|array $patterns) * * @see FilenameFilterIterator */ - public function path(string|array $patterns) + public function path(string|array $patterns): static { $this->paths = array_merge($this->paths, (array) $patterns); @@ -283,7 +281,7 @@ public function path(string|array $patterns) * * @see FilenameFilterIterator */ - public function notPath(string|array $patterns) + public function notPath(string|array $patterns): static { $this->notPaths = array_merge($this->notPaths, (array) $patterns); @@ -305,7 +303,7 @@ public function notPath(string|array $patterns) * @see SizeRangeFilterIterator * @see NumberComparator */ - public function size(string|int|array $sizes) + public function size(string|int|array $sizes): static { foreach ((array) $sizes as $size) { $this->sizes[] = new Comparator\NumberComparator($size); @@ -327,7 +325,7 @@ public function size(string|int|array $sizes) * * @see ExcludeDirectoryFilterIterator */ - public function exclude(string|array $dirs) + public function exclude(string|array $dirs): static { $this->exclude = array_merge($this->exclude, (array) $dirs); @@ -343,7 +341,7 @@ public function exclude(string|array $dirs) * * @see ExcludeDirectoryFilterIterator */ - public function ignoreDotFiles(bool $ignoreDotFiles) + public function ignoreDotFiles(bool $ignoreDotFiles): static { if ($ignoreDotFiles) { $this->ignore |= static::IGNORE_DOT_FILES; @@ -363,7 +361,7 @@ public function ignoreDotFiles(bool $ignoreDotFiles) * * @see ExcludeDirectoryFilterIterator */ - public function ignoreVCS(bool $ignoreVCS) + public function ignoreVCS(bool $ignoreVCS): static { if ($ignoreVCS) { $this->ignore |= static::IGNORE_VCS_FILES; @@ -381,7 +379,7 @@ public function ignoreVCS(bool $ignoreVCS) * * @return $this */ - public function ignoreVCSIgnored(bool $ignoreVCSIgnored) + public function ignoreVCSIgnored(bool $ignoreVCSIgnored): static { if ($ignoreVCSIgnored) { $this->ignore |= static::IGNORE_VCS_IGNORED_FILES; @@ -419,7 +417,7 @@ public static function addVCSPattern(string|array $pattern) * * @see SortableIterator */ - public function sort(\Closure $closure) + public function sort(\Closure $closure): static { $this->sort = $closure; @@ -435,7 +433,7 @@ public function sort(\Closure $closure) * * @see SortableIterator */ - public function sortByName(bool $useNaturalSort = false) + public function sortByName(bool $useNaturalSort = false): static { $this->sort = $useNaturalSort ? Iterator\SortableIterator::SORT_BY_NAME_NATURAL : Iterator\SortableIterator::SORT_BY_NAME; @@ -451,7 +449,7 @@ public function sortByName(bool $useNaturalSort = false) * * @see SortableIterator */ - public function sortByType() + public function sortByType(): static { $this->sort = Iterator\SortableIterator::SORT_BY_TYPE; @@ -469,7 +467,7 @@ public function sortByType() * * @see SortableIterator */ - public function sortByAccessedTime() + public function sortByAccessedTime(): static { $this->sort = Iterator\SortableIterator::SORT_BY_ACCESSED_TIME; @@ -481,7 +479,7 @@ public function sortByAccessedTime() * * @return $this */ - public function reverseSorting() + public function reverseSorting(): static { $this->reverseSorting = true; @@ -501,7 +499,7 @@ public function reverseSorting() * * @see SortableIterator */ - public function sortByChangedTime() + public function sortByChangedTime(): static { $this->sort = Iterator\SortableIterator::SORT_BY_CHANGED_TIME; @@ -519,7 +517,7 @@ public function sortByChangedTime() * * @see SortableIterator */ - public function sortByModifiedTime() + public function sortByModifiedTime(): static { $this->sort = Iterator\SortableIterator::SORT_BY_MODIFIED_TIME; @@ -536,7 +534,7 @@ public function sortByModifiedTime() * * @see CustomFilterIterator */ - public function filter(\Closure $closure) + public function filter(\Closure $closure): static { $this->filters[] = $closure; @@ -548,7 +546,7 @@ public function filter(\Closure $closure) * * @return $this */ - public function followLinks() + public function followLinks(): static { $this->followLinks = true; @@ -562,7 +560,7 @@ public function followLinks() * * @return $this */ - public function ignoreUnreadableDirs(bool $ignore = true) + public function ignoreUnreadableDirs(bool $ignore = true): static { $this->ignoreUnreadableDirs = $ignore; @@ -578,7 +576,7 @@ public function ignoreUnreadableDirs(bool $ignore = true) * * @throws DirectoryNotFoundException if one of the directories does not exist */ - public function in(string|array $dirs) + public function in(string|array $dirs): static { $resolvedDirs = []; @@ -650,7 +648,7 @@ public function getIterator(): \Iterator * * @throws \InvalidArgumentException when the given argument is not iterable */ - public function append(iterable $iterator) + public function append(iterable $iterator): static { if ($iterator instanceof \IteratorAggregate) { $this->iterators[] = $iterator->getIterator(); @@ -672,10 +670,8 @@ public function append(iterable $iterator) /** * Check if any results were found. - * - * @return bool */ - public function hasResults() + public function hasResults(): bool { foreach ($this->getIterator() as $_) { return true; diff --git a/src/Symfony/Component/Finder/Glob.php b/src/Symfony/Component/Finder/Glob.php index 8447932e57a72..7fe8b1a86ce22 100644 --- a/src/Symfony/Component/Finder/Glob.php +++ b/src/Symfony/Component/Finder/Glob.php @@ -37,10 +37,8 @@ class Glob { /** * Returns a regexp which is the equivalent of the glob pattern. - * - * @return string */ - public static function toRegex(string $glob, bool $strictLeadingDot = true, bool $strictWildcardSlash = true, string $delimiter = '#') + public static function toRegex(string $glob, bool $strictLeadingDot = true, bool $strictWildcardSlash = true, string $delimiter = '#'): string { $firstByte = true; $escaping = false; diff --git a/src/Symfony/Component/Finder/Iterator/FilecontentFilterIterator.php b/src/Symfony/Component/Finder/Iterator/FilecontentFilterIterator.php index 045c69f662d71..aec2d13e26072 100644 --- a/src/Symfony/Component/Finder/Iterator/FilecontentFilterIterator.php +++ b/src/Symfony/Component/Finder/Iterator/FilecontentFilterIterator.php @@ -51,7 +51,7 @@ public function accept(): bool * * @return string regexp corresponding to a given string or regexp */ - protected function toRegex(string $str) + protected function toRegex(string $str): string { return $this->isRegex($str) ? $str : '/'.preg_quote($str, '/').'/'; } diff --git a/src/Symfony/Component/Finder/Iterator/FilenameFilterIterator.php b/src/Symfony/Component/Finder/Iterator/FilenameFilterIterator.php index 62875c069db9f..fbfec86e606dc 100644 --- a/src/Symfony/Component/Finder/Iterator/FilenameFilterIterator.php +++ b/src/Symfony/Component/Finder/Iterator/FilenameFilterIterator.php @@ -40,7 +40,7 @@ public function accept(): bool * * @return string regexp corresponding to a given glob or regexp */ - protected function toRegex(string $str) + protected function toRegex(string $str): string { return $this->isRegex($str) ? $str : Glob::toRegex($str); } diff --git a/src/Symfony/Component/Finder/Iterator/MultiplePcreFilterIterator.php b/src/Symfony/Component/Finder/Iterator/MultiplePcreFilterIterator.php index 78a34abef8877..c36913729836e 100644 --- a/src/Symfony/Component/Finder/Iterator/MultiplePcreFilterIterator.php +++ b/src/Symfony/Component/Finder/Iterator/MultiplePcreFilterIterator.php @@ -48,7 +48,7 @@ public function __construct(\Iterator $iterator, array $matchPatterns, array $no * * @return bool */ - protected function isAccepted(string $string) + protected function isAccepted(string $string): bool { // should at least not match one rule to exclude foreach ($this->noMatchRegexps as $regex) { @@ -77,7 +77,7 @@ protected function isAccepted(string $string) * * @return bool */ - protected function isRegex(string $str) + protected function isRegex(string $str): bool { if (preg_match('/^(.{3,}?)[imsxuADU]*$/', $str, $m)) { $start = substr($m[1], 0, 1); @@ -102,5 +102,5 @@ protected function isRegex(string $str) * * @return string */ - abstract protected function toRegex(string $str); + abstract protected function toRegex(string $str): string; } diff --git a/src/Symfony/Component/Finder/Iterator/PathFilterIterator.php b/src/Symfony/Component/Finder/Iterator/PathFilterIterator.php index ab0ab31c3db7f..4c4dabda4b030 100644 --- a/src/Symfony/Component/Finder/Iterator/PathFilterIterator.php +++ b/src/Symfony/Component/Finder/Iterator/PathFilterIterator.php @@ -49,7 +49,7 @@ public function accept(): bool * * @return string regexp corresponding to a given string or regexp */ - protected function toRegex(string $str) + protected function toRegex(string $str): string { return $this->isRegex($str) ? $str : '/'.preg_quote($str, '/').'/'; } diff --git a/src/Symfony/Component/Finder/Iterator/RecursiveDirectoryIterator.php b/src/Symfony/Component/Finder/Iterator/RecursiveDirectoryIterator.php index a25631bb21f01..8a3c195ed7a66 100644 --- a/src/Symfony/Component/Finder/Iterator/RecursiveDirectoryIterator.php +++ b/src/Symfony/Component/Finder/Iterator/RecursiveDirectoryIterator.php @@ -117,7 +117,7 @@ public function rewind(): void * * @return bool true when the stream is rewindable, false otherwise */ - public function isRewindable() + public function isRewindable(): bool { if (null !== $this->rewindable) { return $this->rewindable; diff --git a/src/Symfony/Component/Finder/SplFileInfo.php b/src/Symfony/Component/Finder/SplFileInfo.php index af604e343f47e..635116d811d2c 100644 --- a/src/Symfony/Component/Finder/SplFileInfo.php +++ b/src/Symfony/Component/Finder/SplFileInfo.php @@ -40,7 +40,7 @@ public function __construct(string $file, string $relativePath, string $relative * * @return string the relative path */ - public function getRelativePath() + public function getRelativePath(): string { return $this->relativePath; } @@ -52,7 +52,7 @@ public function getRelativePath() * * @return string the relative path name */ - public function getRelativePathname() + public function getRelativePathname(): string { return $this->relativePathname; } @@ -71,7 +71,7 @@ public function getFilenameWithoutExtension(): string * * @throws \RuntimeException */ - public function getContents() + public function getContents(): string { set_error_handler(function ($type, $msg) use (&$error) { $error = $msg; }); $content = file_get_contents($this->getPathname()); diff --git a/src/Symfony/Component/Ldap/Adapter/AdapterInterface.php b/src/Symfony/Component/Ldap/Adapter/AdapterInterface.php index 01e39d13d867b..fa3210f09f690 100644 --- a/src/Symfony/Component/Ldap/Adapter/AdapterInterface.php +++ b/src/Symfony/Component/Ldap/Adapter/AdapterInterface.php @@ -21,26 +21,26 @@ interface AdapterInterface * * @return ConnectionInterface */ - public function getConnection(); + public function getConnection(): ConnectionInterface; /** * Creates a new Query. * * @return QueryInterface */ - public function createQuery(string $dn, string $query, array $options = []); + public function createQuery(string $dn, string $query, array $options = []): QueryInterface; /** * Fetches the entry manager instance. * * @return EntryManagerInterface */ - public function getEntryManager(); + public function getEntryManager(): EntryManagerInterface; /** * Escape a string for use in an LDAP filter or DN. * * @return string */ - public function escape(string $subject, string $ignore = '', int $flags = 0); + public function escape(string $subject, string $ignore = '', int $flags = 0): string; } diff --git a/src/Symfony/Component/Ldap/Adapter/CollectionInterface.php b/src/Symfony/Component/Ldap/Adapter/CollectionInterface.php index 2db4d2bd4a297..49aa68d5bf1b4 100644 --- a/src/Symfony/Component/Ldap/Adapter/CollectionInterface.php +++ b/src/Symfony/Component/Ldap/Adapter/CollectionInterface.php @@ -21,5 +21,5 @@ interface CollectionInterface extends \Countable, \IteratorAggregate, \ArrayAcce /** * @return Entry[] */ - public function toArray(); + public function toArray(): array; } diff --git a/src/Symfony/Component/Ldap/Adapter/ConnectionInterface.php b/src/Symfony/Component/Ldap/Adapter/ConnectionInterface.php index 56829dc4ead06..a414c9d48125a 100644 --- a/src/Symfony/Component/Ldap/Adapter/ConnectionInterface.php +++ b/src/Symfony/Component/Ldap/Adapter/ConnectionInterface.php @@ -25,7 +25,7 @@ interface ConnectionInterface * * @return bool */ - public function isBound(); + public function isBound(): bool; /** * Binds the connection against a user's DN and password. diff --git a/src/Symfony/Component/Ldap/Adapter/ExtLdap/Adapter.php b/src/Symfony/Component/Ldap/Adapter/ExtLdap/Adapter.php index 3106ba3ce4aa0..9f66d4c495f69 100644 --- a/src/Symfony/Component/Ldap/Adapter/ExtLdap/Adapter.php +++ b/src/Symfony/Component/Ldap/Adapter/ExtLdap/Adapter.php @@ -11,6 +11,9 @@ namespace Symfony\Component\Ldap\Adapter\ExtLdap; +use Symfony\Component\Ldap\Adapter\QueryInterface; +use Symfony\Component\Ldap\Adapter\EntryManagerInterface; +use Symfony\Component\Ldap\Adapter\ConnectionInterface; use Symfony\Component\Ldap\Adapter\AdapterInterface; use Symfony\Component\Ldap\Exception\LdapException; @@ -35,7 +38,7 @@ public function __construct(array $config = []) /** * {@inheritdoc} */ - public function getConnection() + public function getConnection(): ConnectionInterface { if (null === $this->connection) { $this->connection = new Connection($this->config); @@ -47,7 +50,7 @@ public function getConnection() /** * {@inheritdoc} */ - public function getEntryManager() + public function getEntryManager(): EntryManagerInterface { if (null === $this->entryManager) { $this->entryManager = new EntryManager($this->getConnection()); @@ -59,7 +62,7 @@ public function getEntryManager() /** * {@inheritdoc} */ - public function createQuery(string $dn, string $query, array $options = []) + public function createQuery(string $dn, string $query, array $options = []): QueryInterface { return new Query($this->getConnection(), $dn, $query, $options); } @@ -67,7 +70,7 @@ public function createQuery(string $dn, string $query, array $options = []) /** * {@inheritdoc} */ - public function escape(string $subject, string $ignore = '', int $flags = 0) + public function escape(string $subject, string $ignore = '', int $flags = 0): string { $value = ldap_escape($subject, $ignore, $flags); diff --git a/src/Symfony/Component/Ldap/Adapter/ExtLdap/Collection.php b/src/Symfony/Component/Ldap/Adapter/ExtLdap/Collection.php index dbb30285c9f95..123d7f8516416 100644 --- a/src/Symfony/Component/Ldap/Adapter/ExtLdap/Collection.php +++ b/src/Symfony/Component/Ldap/Adapter/ExtLdap/Collection.php @@ -33,7 +33,7 @@ public function __construct(Connection $connection, Query $search) /** * {@inheritdoc} */ - public function toArray() + public function toArray(): array { if (null === $this->entries) { $this->entries = iterator_to_array($this->getIterator(), false); diff --git a/src/Symfony/Component/Ldap/Adapter/ExtLdap/Connection.php b/src/Symfony/Component/Ldap/Adapter/ExtLdap/Connection.php index 4f0f276043b91..13f49caab7e42 100644 --- a/src/Symfony/Component/Ldap/Adapter/ExtLdap/Connection.php +++ b/src/Symfony/Component/Ldap/Adapter/ExtLdap/Connection.php @@ -38,7 +38,7 @@ class Connection extends AbstractConnection /** * @return array */ - public function __sleep() + public function __sleep(): array { throw new \BadMethodCallException('Cannot serialize '.__CLASS__); } @@ -56,7 +56,7 @@ public function __destruct() /** * {@inheritdoc} */ - public function isBound() + public function isBound(): bool { return $this->bound; } diff --git a/src/Symfony/Component/Ldap/Adapter/ExtLdap/Query.php b/src/Symfony/Component/Ldap/Adapter/ExtLdap/Query.php index e3b2bc12a1114..945c28a13d1e5 100644 --- a/src/Symfony/Component/Ldap/Adapter/ExtLdap/Query.php +++ b/src/Symfony/Component/Ldap/Adapter/ExtLdap/Query.php @@ -11,6 +11,8 @@ namespace Symfony\Component\Ldap\Adapter\ExtLdap; +use Symfony\Component\Ldap\Entry; +use Symfony\Component\Ldap\Adapter\CollectionInterface; use Symfony\Component\Ldap\Adapter\AbstractQuery; use Symfony\Component\Ldap\Exception\LdapException; use Symfony\Component\Ldap\Exception\NotBoundException; @@ -41,7 +43,7 @@ public function __construct(Connection $connection, string $dn, string $query, a /** * @return array */ - public function __sleep() + public function __sleep(): array { throw new \BadMethodCallException('Cannot serialize '.__CLASS__); } @@ -74,7 +76,7 @@ public function __destruct() /** * {@inheritdoc} */ - public function execute() + public function execute(): CollectionInterface { if (null === $this->results) { // If the connection is not bound, throw an exception. Users should use an explicit bind call first. diff --git a/src/Symfony/Component/Ldap/Adapter/QueryInterface.php b/src/Symfony/Component/Ldap/Adapter/QueryInterface.php index 23cf3e7b631e7..0246ced365298 100644 --- a/src/Symfony/Component/Ldap/Adapter/QueryInterface.php +++ b/src/Symfony/Component/Ldap/Adapter/QueryInterface.php @@ -38,5 +38,5 @@ interface QueryInterface * @throws NotBoundException * @throws LdapException */ - public function execute(); + public function execute(): CollectionInterface; } diff --git a/src/Symfony/Component/Ldap/Entry.php b/src/Symfony/Component/Ldap/Entry.php index 8493208a9e862..822aaa85c6607 100644 --- a/src/Symfony/Component/Ldap/Entry.php +++ b/src/Symfony/Component/Ldap/Entry.php @@ -37,7 +37,7 @@ public function __construct(string $dn, array $attributes = []) * * @return string */ - public function getDn() + public function getDn(): string { return $this->dn; } @@ -50,7 +50,7 @@ public function getDn() * * @return bool */ - public function hasAttribute(string $name, bool $caseSensitive = true) + public function hasAttribute(string $name, bool $caseSensitive = true): bool { $attributeKey = $this->getAttributeKey($name, $caseSensitive); @@ -72,7 +72,7 @@ public function hasAttribute(string $name, bool $caseSensitive = true) * * @return array|null */ - public function getAttribute(string $name, bool $caseSensitive = true) + public function getAttribute(string $name, bool $caseSensitive = true): ?array { $attributeKey = $this->getAttributeKey($name, $caseSensitive); @@ -88,7 +88,7 @@ public function getAttribute(string $name, bool $caseSensitive = true) * * @return array */ - public function getAttributes() + public function getAttributes(): array { return $this->attributes; } diff --git a/src/Symfony/Component/Ldap/LdapInterface.php b/src/Symfony/Component/Ldap/LdapInterface.php index 16c8a68594123..83f63c887e2a7 100644 --- a/src/Symfony/Component/Ldap/LdapInterface.php +++ b/src/Symfony/Component/Ldap/LdapInterface.php @@ -37,17 +37,17 @@ public function bind(string $dn = null, string $password = null); * * @return QueryInterface */ - public function query(string $dn, string $query, array $options = []); + public function query(string $dn, string $query, array $options = []): QueryInterface; /** * @return EntryManagerInterface */ - public function getEntryManager(); + public function getEntryManager(): EntryManagerInterface; /** * Escape a string for use in an LDAP filter or DN. * * @return string */ - public function escape(string $subject, string $ignore = '', int $flags = 0); + public function escape(string $subject, string $ignore = '', int $flags = 0): string; } diff --git a/src/Symfony/Component/Ldap/Security/LdapUserProvider.php b/src/Symfony/Component/Ldap/Security/LdapUserProvider.php index ac9ed288f4768..b179906fe9a46 100644 --- a/src/Symfony/Component/Ldap/Security/LdapUserProvider.php +++ b/src/Symfony/Component/Ldap/Security/LdapUserProvider.php @@ -66,7 +66,7 @@ public function __construct(LdapInterface $ldap, string $baseDn, string $searchD /** * {@inheritdoc} */ - public function loadUserByUsername(string $username) + public function loadUserByUsername(string $username): UserInterface { trigger_deprecation('symfony/security-core', '5.3', 'Method "%s()" is deprecated, use loadUserByIdentifier() instead.', __METHOD__); @@ -119,7 +119,7 @@ public function loadUserByIdentifier(string $identifier): UserInterface /** * {@inheritdoc} */ - public function refreshUser(UserInterface $user) + public function refreshUser(UserInterface $user): UserInterface { if (!$user instanceof LdapUser) { throw new UnsupportedUserException(sprintf('Instances of "%s" are not supported.', get_debug_type($user))); @@ -155,7 +155,7 @@ public function upgradePassword(PasswordAuthenticatedUserInterface $user, string /** * {@inheritdoc} */ - public function supportsClass(string $class) + public function supportsClass(string $class): bool { return LdapUser::class === $class; } @@ -165,7 +165,7 @@ public function supportsClass(string $class) * * @return UserInterface */ - protected function loadUser(string $identifier, Entry $entry) + protected function loadUser(string $identifier, Entry $entry): UserInterface { $password = null; $extraFields = []; diff --git a/src/Symfony/Component/Process/ExecutableFinder.php b/src/Symfony/Component/Process/ExecutableFinder.php index feee4ad49b733..849a7241aed3c 100644 --- a/src/Symfony/Component/Process/ExecutableFinder.php +++ b/src/Symfony/Component/Process/ExecutableFinder.php @@ -46,7 +46,7 @@ public function addSuffix(string $suffix) * * @return string|null The executable path or default value */ - public function find(string $name, string $default = null, array $extraDirs = []) + public function find(string $name, string $default = null, array $extraDirs = []): ?string { if (ini_get('open_basedir')) { $searchPath = array_merge(explode(\PATH_SEPARATOR, ini_get('open_basedir')), $extraDirs); diff --git a/src/Symfony/Component/Process/PhpExecutableFinder.php b/src/Symfony/Component/Process/PhpExecutableFinder.php index e4f03f76f1c99..a32f948b72eaf 100644 --- a/src/Symfony/Component/Process/PhpExecutableFinder.php +++ b/src/Symfony/Component/Process/PhpExecutableFinder.php @@ -31,7 +31,7 @@ public function __construct() * * @return string|false The PHP executable path or false if it cannot be found */ - public function find(bool $includeArgs = true) + public function find(bool $includeArgs = true): string|false { if ($php = getenv('PHP_BINARY')) { if (!is_executable($php)) { @@ -87,7 +87,7 @@ public function find(bool $includeArgs = true) * * @return array The PHP executable arguments */ - public function findArguments() + public function findArguments(): array { $arguments = []; if ('phpdbg' === \PHP_SAPI) { diff --git a/src/Symfony/Component/Process/PhpProcess.php b/src/Symfony/Component/Process/PhpProcess.php index d5d0884508936..cb749f9bbbe71 100644 --- a/src/Symfony/Component/Process/PhpProcess.php +++ b/src/Symfony/Component/Process/PhpProcess.php @@ -53,7 +53,7 @@ public function __construct(string $script, string $cwd = null, array $env = nul /** * {@inheritdoc} */ - public static function fromShellCommandline(string $command, string $cwd = null, array $env = null, mixed $input = null, ?float $timeout = 60) + public static function fromShellCommandline(string $command, string $cwd = null, array $env = null, mixed $input = null, ?float $timeout = 60): static { throw new LogicException(sprintf('The "%s()" method cannot be called when using "%s".', __METHOD__, self::class)); } diff --git a/src/Symfony/Component/Process/Process.php b/src/Symfony/Component/Process/Process.php index aa64e050fd05d..cf40fc89a188a 100644 --- a/src/Symfony/Component/Process/Process.php +++ b/src/Symfony/Component/Process/Process.php @@ -187,7 +187,7 @@ public function __construct(array $command, string $cwd = null, array $env = nul * * @throws LogicException When proc_open is not installed */ - public static function fromShellCommandline(string $command, string $cwd = null, array $env = null, mixed $input = null, ?float $timeout = 60) + public static function fromShellCommandline(string $command, string $cwd = null, array $env = null, mixed $input = null, ?float $timeout = 60): static { $process = new static([], $cwd, $env, $input, $timeout); $process->commandline = $command; @@ -198,7 +198,7 @@ public static function fromShellCommandline(string $command, string $cwd = null, /** * @return array */ - public function __sleep() + public function __sleep(): array { throw new \BadMethodCallException('Cannot serialize '.__CLASS__); } @@ -406,7 +406,7 @@ public function restart(callable $callback = null, array $env = []): static * @throws ProcessSignaledException When process stopped after receiving signal * @throws LogicException When process is not yet started */ - public function wait(callable $callback = null) + public function wait(callable $callback = null): int { $this->requireProcessIsStarted(__FUNCTION__); @@ -489,7 +489,7 @@ public function waitUntil(callable $callback): bool * * @return int|null The process id if running, null otherwise */ - public function getPid() + public function getPid(): ?int { return $this->isRunning() ? $this->processInformation['pid'] : null; } @@ -505,7 +505,7 @@ public function getPid() * @throws RuntimeException In case --enable-sigchild is activated and the process can't be killed * @throws RuntimeException In case of failure */ - public function signal(int $signal) + public function signal(int $signal): static { $this->doSignal($signal, true); @@ -520,7 +520,7 @@ public function signal(int $signal) * @throws RuntimeException In case the process is already running * @throws LogicException if an idle timeout is set */ - public function disableOutput() + public function disableOutput(): static { if ($this->isRunning()) { throw new RuntimeException('Disabling output while the process is running is not possible.'); @@ -541,7 +541,7 @@ public function disableOutput() * * @throws RuntimeException In case the process is already running */ - public function enableOutput() + public function enableOutput(): static { if ($this->isRunning()) { throw new RuntimeException('Enabling output while the process is running is not possible.'); @@ -557,7 +557,7 @@ public function enableOutput() * * @return bool */ - public function isOutputDisabled() + public function isOutputDisabled(): bool { return $this->outputDisabled; } @@ -570,7 +570,7 @@ public function isOutputDisabled() * @throws LogicException in case the output has been disabled * @throws LogicException In case the process is not started */ - public function getOutput() + public function getOutput(): string { $this->readPipesForOutput(__FUNCTION__); @@ -592,7 +592,7 @@ public function getOutput() * @throws LogicException in case the output has been disabled * @throws LogicException In case the process is not started */ - public function getIncrementalOutput() + public function getIncrementalOutput(): string { $this->readPipesForOutput(__FUNCTION__); @@ -666,7 +666,7 @@ public function getIterator(int $flags = 0): \Generator * * @return $this */ - public function clearOutput() + public function clearOutput(): static { ftruncate($this->stdout, 0); fseek($this->stdout, 0); @@ -683,7 +683,7 @@ public function clearOutput() * @throws LogicException in case the output has been disabled * @throws LogicException In case the process is not started */ - public function getErrorOutput() + public function getErrorOutput(): string { $this->readPipesForOutput(__FUNCTION__); @@ -706,7 +706,7 @@ public function getErrorOutput() * @throws LogicException in case the output has been disabled * @throws LogicException In case the process is not started */ - public function getIncrementalErrorOutput() + public function getIncrementalErrorOutput(): string { $this->readPipesForOutput(__FUNCTION__); @@ -725,7 +725,7 @@ public function getIncrementalErrorOutput() * * @return $this */ - public function clearErrorOutput() + public function clearErrorOutput(): static { ftruncate($this->stderr, 0); fseek($this->stderr, 0); @@ -739,7 +739,7 @@ public function clearErrorOutput() * * @return int|null The exit status code, null if the Process is not terminated */ - public function getExitCode() + public function getExitCode(): ?int { $this->updateStatus(false); @@ -757,7 +757,7 @@ public function getExitCode() * @see http://tldp.org/LDP/abs/html/exitcodes.html * @see http://en.wikipedia.org/wiki/Unix_signal */ - public function getExitCodeText() + public function getExitCodeText(): ?string { if (null === $exitcode = $this->getExitCode()) { return null; @@ -771,7 +771,7 @@ public function getExitCodeText() * * @return bool true if the process ended successfully, false otherwise */ - public function isSuccessful() + public function isSuccessful(): bool { return 0 === $this->getExitCode(); } @@ -785,7 +785,7 @@ public function isSuccessful() * * @throws LogicException In case the process is not terminated */ - public function hasBeenSignaled() + public function hasBeenSignaled(): bool { $this->requireProcessIsTerminated(__FUNCTION__); @@ -802,7 +802,7 @@ public function hasBeenSignaled() * @throws RuntimeException In case --enable-sigchild is activated * @throws LogicException In case the process is not terminated */ - public function getTermSignal() + public function getTermSignal(): int { $this->requireProcessIsTerminated(__FUNCTION__); @@ -822,7 +822,7 @@ public function getTermSignal() * * @throws LogicException In case the process is not terminated */ - public function hasBeenStopped() + public function hasBeenStopped(): bool { $this->requireProcessIsTerminated(__FUNCTION__); @@ -838,7 +838,7 @@ public function hasBeenStopped() * * @throws LogicException In case the process is not terminated */ - public function getStopSignal() + public function getStopSignal(): int { $this->requireProcessIsTerminated(__FUNCTION__); @@ -850,7 +850,7 @@ public function getStopSignal() * * @return bool true if the process is currently running, false otherwise */ - public function isRunning() + public function isRunning(): bool { if (self::STATUS_STARTED !== $this->status) { return false; @@ -866,7 +866,7 @@ public function isRunning() * * @return bool true if status is ready, false otherwise */ - public function isStarted() + public function isStarted(): bool { return self::STATUS_READY != $this->status; } @@ -876,7 +876,7 @@ public function isStarted() * * @return bool true if process is terminated, false otherwise */ - public function isTerminated() + public function isTerminated(): bool { $this->updateStatus(false); @@ -890,7 +890,7 @@ public function isTerminated() * * @return string The current process status */ - public function getStatus() + public function getStatus(): string { $this->updateStatus(false); @@ -905,7 +905,7 @@ public function getStatus() * * @return int|null The exit-code of the process or null if it's not running */ - public function stop(float $timeout = 10, int $signal = null) + public function stop(float $timeout = 10, int $signal = null): ?int { $timeoutMicro = microtime(true) + $timeout; if ($this->isRunning()) { @@ -977,7 +977,7 @@ public function getLastOutputTime(): ?float * * @return string The command to execute */ - public function getCommandLine() + public function getCommandLine(): string { return \is_array($this->commandline) ? implode(' ', array_map([$this, 'escapeArgument'], $this->commandline)) : $this->commandline; } @@ -987,7 +987,7 @@ public function getCommandLine() * * @return float|null The timeout in seconds or null if it's disabled */ - public function getTimeout() + public function getTimeout(): ?float { return $this->timeout; } @@ -997,7 +997,7 @@ public function getTimeout() * * @return float|null The timeout in seconds or null if it's disabled */ - public function getIdleTimeout() + public function getIdleTimeout(): ?float { return $this->idleTimeout; } @@ -1011,7 +1011,7 @@ public function getIdleTimeout() * * @throws InvalidArgumentException if the timeout is negative */ - public function setTimeout(?float $timeout) + public function setTimeout(?float $timeout): static { $this->timeout = $this->validateTimeout($timeout); @@ -1028,7 +1028,7 @@ public function setTimeout(?float $timeout) * @throws LogicException if the output is disabled * @throws InvalidArgumentException if the timeout is negative */ - public function setIdleTimeout(?float $timeout) + public function setIdleTimeout(?float $timeout): static { if (null !== $timeout && $this->outputDisabled) { throw new LogicException('Idle timeout can not be set while the output is disabled.'); @@ -1046,7 +1046,7 @@ public function setIdleTimeout(?float $timeout) * * @throws RuntimeException In case the TTY mode is not supported */ - public function setTty(bool $tty) + public function setTty(bool $tty): static { if ('\\' === \DIRECTORY_SEPARATOR && $tty) { throw new RuntimeException('TTY mode is not supported on Windows platform.'); @@ -1066,7 +1066,7 @@ public function setTty(bool $tty) * * @return bool true if the TTY mode is enabled, false otherwise */ - public function isTty() + public function isTty(): bool { return $this->tty; } @@ -1076,7 +1076,7 @@ public function isTty() * * @return $this */ - public function setPty(bool $bool) + public function setPty(bool $bool): static { $this->pty = $bool; @@ -1088,7 +1088,7 @@ public function setPty(bool $bool) * * @return bool */ - public function isPty() + public function isPty(): bool { return $this->pty; } @@ -1098,7 +1098,7 @@ public function isPty() * * @return string|null The current working directory or null on failure */ - public function getWorkingDirectory() + public function getWorkingDirectory(): ?string { if (null === $this->cwd) { // getcwd() will return false if any one of the parent directories does not have @@ -1114,7 +1114,7 @@ public function getWorkingDirectory() * * @return $this */ - public function setWorkingDirectory(string $cwd) + public function setWorkingDirectory(string $cwd): static { $this->cwd = $cwd; @@ -1126,7 +1126,7 @@ public function setWorkingDirectory(string $cwd) * * @return array The current environment variables */ - public function getEnv() + public function getEnv(): array { return $this->env; } @@ -1146,7 +1146,7 @@ public function getEnv() * * @return $this */ - public function setEnv(array $env) + public function setEnv(array $env): static { // Process can not handle env values that are arrays $env = array_filter($env, function ($value) { @@ -1179,7 +1179,7 @@ public function getInput() * * @throws LogicException In case the process is running */ - public function setInput(mixed $input) + public function setInput(mixed $input): static { if ($this->isRunning()) { throw new LogicException('Input can not be set while the process is running.'); @@ -1274,7 +1274,7 @@ public static function isTtySupported(): bool * * @return bool */ - public static function isPtySupported() + public static function isPtySupported(): bool { static $result; @@ -1316,7 +1316,7 @@ private function getDescriptors(): array * * @return \Closure A PHP closure */ - protected function buildCallback(callable $callback = null) + protected function buildCallback(callable $callback = null): \Closure { if ($this->outputDisabled) { return function ($type, $data) use ($callback): bool { @@ -1367,7 +1367,7 @@ protected function updateStatus(bool $blocking) * * @return bool */ - protected function isSigchildEnabled() + protected function isSigchildEnabled(): bool { if (null !== self::$sigchild) { return self::$sigchild; diff --git a/src/Symfony/Component/Process/ProcessUtils.php b/src/Symfony/Component/Process/ProcessUtils.php index d5bc447850642..1d86ad0023eb9 100644 --- a/src/Symfony/Component/Process/ProcessUtils.php +++ b/src/Symfony/Component/Process/ProcessUtils.php @@ -39,7 +39,7 @@ private function __construct() * * @throws InvalidArgumentException In case the input is not valid */ - public static function validateInput(string $caller, mixed $input) + public static function validateInput(string $caller, mixed $input): mixed { if (null !== $input) { if (\is_resource($input)) {