Merge pull request #16731 from eileenmcnaughton/regress
[civicrm-core.git] / Civi / Core / Resolver.php
index 6bb47fab6143d3e47538913f6c92b9f45d32ffe7..b1e54684a627629d4004068b9e83330177c76f38 100644 (file)
@@ -53,7 +53,7 @@ class Resolver {
    * @param string|array $id
    *   A callback expression; any of the following.
    *
-   * @return array
+   * @return array|callable
    *   A PHP callback. Do not serialize (b/c it may include an object).
    * @throws \RuntimeException
    */
@@ -77,7 +77,7 @@ class Resolver {
         case 'call':
           // Callback: Object/method in container.
           $obj = \Civi::service($url['host']);
-          return array($obj, ltrim($url['path'], '/'));
+          return [$obj, ltrim($url['path'], '/')];
 
         case 'api3':
           // Callback: API.
@@ -91,7 +91,7 @@ class Resolver {
           throw new \RuntimeException("Unsupported callback scheme: " . $url['scheme']);
       }
     }
-    elseif (in_array($id, array('0', '1'))) {
+    elseif (in_array($id, ['0', '1'])) {
       // Callback: Constant value.
       return new ResolverConstantCallback((int) $id);
     }
@@ -184,7 +184,7 @@ class ResolverApi {
    * Fire an API call.
    */
   public function __invoke() {
-    $apiParams = array();
+    $apiParams = [];
     if (isset($this->url['query'])) {
       parse_str($this->url['query'], $apiParams);
     }
@@ -212,7 +212,7 @@ class ResolverApi {
    *   (e.g. "@1" => "firstValue").
    */
   protected function createPlaceholders($prefix, $args) {
-    $result = array();
+    $result = [];
     foreach ($args as $offset => $arg) {
       $result[$prefix . (1 + $offset)] = $arg;
     }
@@ -250,7 +250,8 @@ class ResolverApi {
 }
 
 class ResolverGlobalCallback {
-  private $mode, $path;
+  private $mode;
+  private $path;
 
   /**
    * Class constructor.
@@ -267,6 +268,8 @@ class ResolverGlobalCallback {
   /**
    * Invoke function.
    *
+   * @param mixed $arg1
+   *
    * @return mixed
    */
   public function __invoke($arg1 = NULL) {
@@ -275,6 +278,7 @@ class ResolverGlobalCallback {
     }
     elseif ($this->mode === 'setter') {
       \CRM_Utils_Array::pathSet($GLOBALS, explode('/', $this->path), $arg1);
+      return NULL;
     }
     else {
       throw new \RuntimeException("Resolver failed: global:// must specify getter or setter mode.");