From 3c30e721de6924ecd6548c0c1b863f029e622167 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Fri, 25 Aug 2023 17:41:58 -0700 Subject: [PATCH] PhpStormMetadata - Define registerArgumentsSet() and addExpectedArguments() --- .../Civi/PhpStorm/PhpStormMetadata.php | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tools/extensions/phpstorm/Civi/PhpStorm/PhpStormMetadata.php b/tools/extensions/phpstorm/Civi/PhpStorm/PhpStormMetadata.php index 854e8643ef..260f0ebd2e 100644 --- a/tools/extensions/phpstorm/Civi/PhpStorm/PhpStormMetadata.php +++ b/tools/extensions/phpstorm/Civi/PhpStorm/PhpStormMetadata.php @@ -44,6 +44,30 @@ class PhpStormMetadata { $this->buffer = ''; } + public function registerArgumentsSet(string $name, ...$args) { + $escapedName = var_export($name, 1); + $escapedArgs = implode(', ', array_map(function($arg) { + return var_export($arg, 1); + }, $args)); + $this->buffer .= "registerArgumentsSet($escapedName, $escapedArgs);\n"; + return $this; + } + + /** + * @param string $for + * Ex: '\Civi\Core\SettingsBag::get()' + * @param int $index + * The positional offset among the arguments + * @param string $argumentSet + * Name of the argument set. (This should already be defined by `registerArgumentsSet()`.) + * @return $this + */ + public function addExpectedArguments(string $for, int $index, string $argumentSet) { + $escapedSet = var_export($argumentSet, 1); + $this->buffer .= "expectedArguments($for, $index, argumentsSet($escapedSet));\n"; + return $this; + } + /** * @param string $for * @param array $map -- 2.25.1