diff --git a/composer/Plugin/Scaffold/Plugin.php b/composer/Plugin/Scaffold/Plugin.php index 8fe6961424c..3de043a36ef 100644 --- a/composer/Plugin/Scaffold/Plugin.php +++ b/composer/Plugin/Scaffold/Plugin.php @@ -47,7 +47,7 @@ class Plugin implements PluginInterface, EventSubscriberInterface, Capable { /** * Record whether the 'require' command was called. * - * @param bool + * @var bool */ protected $requireWasCalled; diff --git a/core/includes/bootstrap.inc b/core/includes/bootstrap.inc index 881d695b4ae..3554cd4cc1e 100644 --- a/core/includes/bootstrap.inc +++ b/core/includes/bootstrap.inc @@ -441,7 +441,7 @@ function drupal_static_reset($name = NULL) { * * @param callable $callback * The shutdown function to register. - * @param ... + * @param ...$args * Additional arguments to pass to the shutdown function. * * @return array @@ -450,7 +450,7 @@ function drupal_static_reset($name = NULL) { * @see register_shutdown_function() * @ingroup php_wrappers */ -function &drupal_register_shutdown_function($callback = NULL) { +function &drupal_register_shutdown_function($callback = NULL, ...$args) { // We cannot use drupal_static() here because the static cache is reset during // batch processing, which breaks batch handling. static $callbacks = []; @@ -460,9 +460,6 @@ function &drupal_register_shutdown_function($callback = NULL) { if (empty($callbacks)) { register_shutdown_function('_drupal_shutdown_function'); } - $args = func_get_args(); - // Remove $callback from the arguments. - unset($args[0]); // Save callback and arguments $callbacks[] = ['callback' => $callback, 'arguments' => $args]; } diff --git a/core/lib/Drupal/Component/Assertion/Inspector.php b/core/lib/Drupal/Component/Assertion/Inspector.php index 25402077dab..945272f9de7 100644 --- a/core/lib/Drupal/Component/Assertion/Inspector.php +++ b/core/lib/Drupal/Component/Assertion/Inspector.php @@ -184,7 +184,7 @@ class Inspector { * * @param mixed $traversable * Variable to be examined. - * @param string ... + * @param ...$keys * Keys to be searched for. * * @return bool @@ -370,7 +370,7 @@ class Inspector { * * @param mixed $traversable * Variable to be examined. - * @param string ... + * @param ...$classes * Classes and interfaces to test objects against. * * @return bool diff --git a/core/lib/Drupal/Component/Utility/NestedArray.php b/core/lib/Drupal/Component/Utility/NestedArray.php index ba74210b7aa..80f3822cf42 100644 --- a/core/lib/Drupal/Component/Utility/NestedArray.php +++ b/core/lib/Drupal/Component/Utility/NestedArray.php @@ -286,7 +286,7 @@ class NestedArray { * $correct = NestedArray::mergeDeep($link_options_1, $link_options_2); * @endcode * - * @param array ... + * @param array ...$arrays * Arrays to merge. * * @return array @@ -294,8 +294,8 @@ class NestedArray { * * @see NestedArray::mergeDeepArray() */ - public static function mergeDeep() { - return self::mergeDeepArray(func_get_args()); + public static function mergeDeep(...$arrays) { + return self::mergeDeepArray($arrays); } /** diff --git a/core/lib/Drupal/Core/Cache/Cache.php b/core/lib/Drupal/Core/Cache/Cache.php index 693e2cd9189..bd0b4508357 100644 --- a/core/lib/Drupal/Core/Cache/Cache.php +++ b/core/lib/Drupal/Core/Cache/Cache.php @@ -19,7 +19,7 @@ class Cache { /** * Merges lists of cache contexts and removes duplicates. * - * @param list ... + * @param list ...$cache_contexts * Cache contexts to merge. * * @return list @@ -42,7 +42,7 @@ class Cache { * allows items to be invalidated based on all tags attached to the content * they're constituted from. * - * @param list ... + * @param list ...$cache_tags * Cache tags to merge. * * @return list @@ -59,7 +59,7 @@ class Cache { * * Ensures infinite max-age (Cache::PERMANENT) is taken into account. * - * @param int ... + * @param int ...$max_ages * Max age values to merge. * * @return int diff --git a/core/lib/Drupal/Core/ImageToolkit/ImageToolkitOperationBase.php b/core/lib/Drupal/Core/ImageToolkit/ImageToolkitOperationBase.php index c1cbceead49..d7a6f70c54a 100644 --- a/core/lib/Drupal/Core/ImageToolkit/ImageToolkitOperationBase.php +++ b/core/lib/Drupal/Core/ImageToolkit/ImageToolkitOperationBase.php @@ -97,8 +97,8 @@ abstract class ImageToolkitOperationBase extends PluginBase implements ImageTool * @return array * The prepared arguments array. * - * @throws \InvalidArgumentException. - * @throws \Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException. + * @throws \InvalidArgumentException + * @throws \Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException */ protected function prepareArguments(array $arguments) { foreach ($this->arguments() as $id => $argument) { diff --git a/core/lib/Drupal/Core/Template/Attribute.php b/core/lib/Drupal/Core/Template/Attribute.php index 7422e26f463..52485e6a538 100644 --- a/core/lib/Drupal/Core/Template/Attribute.php +++ b/core/lib/Drupal/Core/Template/Attribute.php @@ -174,13 +174,12 @@ class Attribute implements \ArrayAccess, \IteratorAggregate, MarkupInterface { /** * Adds classes or merges them on to array of existing CSS classes. * - * @param string|array ... + * @param string|array ...$args * CSS classes to add to the class attribute array. * * @return $this */ - public function addClass() { - $args = func_get_args(); + public function addClass(...$args) { if ($args) { $classes = []; foreach ($args as $arg) { @@ -237,13 +236,12 @@ class Attribute implements \ArrayAccess, \IteratorAggregate, MarkupInterface { /** * Removes an attribute from an Attribute object. * - * @param string|array ... + * @param string|array ...$args * Attributes to remove from the attribute array. * * @return $this */ - public function removeAttribute() { - $args = func_get_args(); + public function removeAttribute(...$args) { foreach ($args as $arg) { // Support arrays or multiple arguments. if (is_array($arg)) { @@ -262,15 +260,14 @@ class Attribute implements \ArrayAccess, \IteratorAggregate, MarkupInterface { /** * Removes argument values from array of existing CSS classes. * - * @param string|array ... + * @param string|array ...$args * CSS classes to remove from the class attribute array. * * @return $this */ - public function removeClass() { + public function removeClass(...$args) { // With no class attribute, there is no need to remove. if (isset($this->storage['class']) && $this->storage['class'] instanceof AttributeArray) { - $args = func_get_args(); $classes = []; foreach ($args as $arg) { // Merge the values passed in from the classes array. diff --git a/core/lib/Drupal/Core/Template/TwigExtension.php b/core/lib/Drupal/Core/Template/TwigExtension.php index 7ed77162080..cd34aec4497 100644 --- a/core/lib/Drupal/Core/Template/TwigExtension.php +++ b/core/lib/Drupal/Core/Template/TwigExtension.php @@ -631,22 +631,20 @@ class TwigExtension extends AbstractExtension { * * @param array|object $element * The parent renderable array to exclude the child items. - * @param string[]|string ... + * @param string[]|string ...$args * The string keys of $element to prevent printing. Arguments can include * string keys directly, or arrays of string keys to hide. * * @return array * The filtered renderable array. */ - public function withoutFilter($element) { + public function withoutFilter($element, ...$args) { if ($element instanceof \ArrayAccess) { $filtered_element = clone $element; } else { $filtered_element = $element; } - $args = func_get_args(); - unset($args[0]); // Since the remaining arguments can be a mix of arrays and strings, we use // some native PHP iterator classes to allow us to recursively iterate over // everything in a single pass. diff --git a/core/lib/Drupal/Core/Url.php b/core/lib/Drupal/Core/Url.php index 1857ba09048..d16ef550651 100644 --- a/core/lib/Drupal/Core/Url.php +++ b/core/lib/Drupal/Core/Url.php @@ -563,7 +563,7 @@ class Url implements TrustedCallbackInterface { * * @return string * - * @throws \UnexpectedValueException. + * @throws \UnexpectedValueException * If this is a URI with no corresponding route. */ public function getRouteName() { @@ -579,7 +579,7 @@ class Url implements TrustedCallbackInterface { * * @return array * - * @throws \UnexpectedValueException. + * @throws \UnexpectedValueException * If this is a URI with no corresponding route. */ public function getRouteParameters() { @@ -598,7 +598,7 @@ class Url implements TrustedCallbackInterface { * * @return $this * - * @throws \UnexpectedValueException. + * @throws \UnexpectedValueException * If this is a URI with no corresponding route. */ public function setRouteParameters($parameters) { @@ -619,7 +619,7 @@ class Url implements TrustedCallbackInterface { * * @return $this * - * @throws \UnexpectedValueException. + * @throws \UnexpectedValueException * If this is a URI with no corresponding route. */ public function setRouteParameter($key, $value) { @@ -777,7 +777,7 @@ class Url implements TrustedCallbackInterface { * @return string * The internal path for this route. * - * @throws \UnexpectedValueException. + * @throws \UnexpectedValueException * If this is a URI with no corresponding system path. */ public function getInternalPath() { diff --git a/core/modules/update/tests/src/Unit/UpdateFetcherTest.php b/core/modules/update/tests/src/Unit/UpdateFetcherTest.php index 57642519cf5..2345a65fe92 100644 --- a/core/modules/update/tests/src/Unit/UpdateFetcherTest.php +++ b/core/modules/update/tests/src/Unit/UpdateFetcherTest.php @@ -160,7 +160,7 @@ class UpdateFetcherTest extends UnitTestCase { /** * Mocks the HTTP client. * - * @param \GuzzleHttp\Psr7\Response ... + * @param \GuzzleHttp\Psr7\Response ...$responses * Variable number of Response objects that the mocked client should return. */ protected function mockClient(Response ...$responses): void { diff --git a/core/modules/views/views.module b/core/modules/views/views.module index 84bec7df7a1..c5cc438a7d5 100644 --- a/core/modules/views/views.module +++ b/core/modules/views/views.module @@ -726,18 +726,14 @@ function _views_query_tag_alter_condition(AlterableInterface $query, &$condition * @param $display_id * The display id to embed. If unsure, use 'default', as it will always be * valid. But things like 'page' or 'block' should work here. - * @param ... + * @param ...$args * Any additional parameters will be passed as arguments. * * @return array|null * A renderable array containing the view output or NULL if the display ID * of the view to be executed doesn't exist. */ -function views_embed_view($name, $display_id = 'default') { - $args = func_get_args(); - // Remove $name and $display_id from the arguments. - unset($args[0], $args[1]); - +function views_embed_view($name, $display_id = 'default', ...$args) { $view = Views::getView($name); if (!$view || !$view->access($display_id)) { return; @@ -763,17 +759,13 @@ function views_embed_view($name, $display_id = 'default') { * want to use. A URL will appear in the status bar of your browser. This is * usually at the bottom of the window, in the chrome. Everything after * #views-tab- is the display ID, e.g. page_1. - * @param ... + * @param ...$args * Any additional parameters will be passed as arguments. * * @return array * An array containing an object for each view item. */ -function views_get_view_result($name, $display_id = NULL) { - $args = func_get_args(); - // Remove $name and $display_id from the arguments. - unset($args[0], $args[1]); - +function views_get_view_result($name, $display_id = NULL, ...$args) { $view = Views::getView($name); if (is_object($view)) { if (is_array($args)) { diff --git a/core/modules/workflows/src/StateInterface.php b/core/modules/workflows/src/StateInterface.php index 3335ea7452a..d4fe9871c46 100644 --- a/core/modules/workflows/src/StateInterface.php +++ b/core/modules/workflows/src/StateInterface.php @@ -60,7 +60,7 @@ interface StateInterface { * @return \Drupal\workflows\TransitionInterface * The Transition object for the provided state ID. * - * @throws \InvalidArgumentException() + * @throws \InvalidArgumentException * Exception thrown when the provided state ID can not be transitioned to. */ public function getTransitionTo($to_state_id); diff --git a/core/scripts/password-hash.sh b/core/scripts/password-hash.sh index 70d701d0fb0..fd799f0a6ec 100755 --- a/core/scripts/password-hash.sh +++ b/core/scripts/password-hash.sh @@ -5,7 +5,7 @@ * @file * Drupal hash script - to generate a hash from a plaintext password * - * @param password1 [password2 [password3 ...]] + * @param string[] ...$password * Plain-text passwords in quotes (or with spaces backslash escaped). * * @todo Port to a console command. https://www.drupal.org/node/2289409 diff --git a/core/tests/Drupal/Tests/Core/Asset/LibraryDiscoveryParserTest.php b/core/tests/Drupal/Tests/Core/Asset/LibraryDiscoveryParserTest.php index e5348e1a4b0..830772284eb 100644 --- a/core/tests/Drupal/Tests/Core/Asset/LibraryDiscoveryParserTest.php +++ b/core/tests/Drupal/Tests/Core/Asset/LibraryDiscoveryParserTest.php @@ -68,14 +68,14 @@ class LibraryDiscoveryParserTest extends UnitTestCase { /** * The mocked stream wrapper manager. * - * @var \Drupal\Core\StreamWrapper\StreamWrapperManagerInterface||\PHPUnit\Framework\MockObject\MockObject + * @var \Drupal\Core\StreamWrapper\StreamWrapperManagerInterface|\PHPUnit\Framework\MockObject\MockObject */ protected $streamWrapperManager; /** * The mocked libraries directory file finder. * - * @var \Drupal\Core\Asset\LibrariesDirectoryFileFinder||\PHPUnit\Framework\MockObject\MockObject + * @var \Drupal\Core\Asset\LibrariesDirectoryFileFinder|\PHPUnit\Framework\MockObject\MockObject */ protected $librariesDirectoryFileFinder; diff --git a/core/tests/Drupal/Tests/Core/Routing/AccessAwareRouterTest.php b/core/tests/Drupal/Tests/Core/Routing/AccessAwareRouterTest.php index 8587efbf478..09b42d393ca 100644 --- a/core/tests/Drupal/Tests/Core/Routing/AccessAwareRouterTest.php +++ b/core/tests/Drupal/Tests/Core/Routing/AccessAwareRouterTest.php @@ -42,7 +42,7 @@ class AccessAwareRouterTest extends UnitTestCase { protected $accessManager; /** - * @var \Drupal\Core\Session\AccountInterface||\PHPUnit\Framework\MockObject\MockObject + * @var \Drupal\Core\Session\AccountInterface|\PHPUnit\Framework\MockObject\MockObject */ protected $currentUser;