X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=Civi%2FCore%2FCiviEventInspector.php;h=34514f9bf750dffa23203502a5133a5a22e6d0ed;hb=7c7cc622fb9ecae222bfa161850ffb41598ddbb9;hp=4f74cc54a8d9ef24407c57bc3b2df31c29e63e8d;hpb=43a6933288a9d6d27f5746b00618d6c751e90263;p=civicrm-core.git diff --git a/Civi/Core/CiviEventInspector.php b/Civi/Core/CiviEventInspector.php index 4f74cc54a8..34514f9bf7 100644 --- a/Civi/Core/CiviEventInspector.php +++ b/Civi/Core/CiviEventInspector.php @@ -7,10 +7,10 @@ namespace Civi\Core; * The event inspector is a development tool which provides metadata about events. * It can be used for code-generators and documentation-generators. * - * @code + * ``` * $i = new CiviEventInspector(); * print_r(CRM_Utils_Array::collect('name', $i->getAll())); - * @endCode + * ``` * * An event definition includes these fields: * - type: string, required. Ex: 'hook' or 'object' @@ -33,7 +33,7 @@ class CiviEventInspector { * @see \CRM_Utils_Hook::eventDefs() */ public static function findBuiltInEvents(\Civi\Core\Event\GenericHookEvent $e) { - $skipList = array('singleton'); + $skipList = ['singleton']; $e->inspector->addStaticStubs('CRM_Utils_Hook', 'hook_civicrm_', function ($eventDef, $method) use ($skipList) { return in_array($method->name, $skipList) ? NULL : $eventDef; @@ -56,7 +56,7 @@ class CiviEventInspector { */ public function build($force = FALSE) { if ($force || $this->eventDefs === NULL) { - $this->eventDefs = array(); + $this->eventDefs = []; \CRM_Utils_Hook::eventDefs($this); ksort($this->eventDefs); } @@ -113,7 +113,7 @@ class CiviEventInspector { return FALSE; } - if (!in_array($eventDef['type'], array('hook', 'object'))) { + if (!in_array($eventDef['type'], ['hook', 'object'])) { return FALSE; } @@ -133,7 +133,7 @@ class CiviEventInspector { * @return CiviEventInspector */ public function add($eventDef) { - $name = isset($eventDef['name']) ? $eventDef['name'] : NULL; + $name = $eventDef['name'] ?? NULL; if (!isset($eventDef['type'])) { $eventDef['type'] = preg_match('/^hook_/', $eventDef['name']) ? 'hook' : 'object'; @@ -167,10 +167,10 @@ class CiviEventInspector { * @return CiviEventInspector */ public function addEventClass($event, $className) { - $this->add(array( + $this->add([ 'name' => $event, 'class' => $className, - )); + ]); return $this; } @@ -195,20 +195,20 @@ class CiviEventInspector { continue; } - $eventDef = array( + $eventDef = [ 'name' => $prefix . $method->name, 'description_html' => $method->getDocComment() ? \CRM_Admin_Page_APIExplorer::formatDocBlock($method->getDocComment()) : '', - 'fields' => array(), + 'fields' => [], 'class' => 'Civi\Core\Event\GenericHookEvent', 'stub' => $method, - ); + ]; foreach ($method->getParameters() as $parameter) { - $eventDef['fields'][$parameter->getName()] = array( + $eventDef['fields'][$parameter->getName()] = [ 'name' => $parameter->getName(), 'ref' => (bool) $parameter->isPassedByReference(), // WISHLIST: 'type' => 'mixed', - ); + ]; } if ($filter !== NULL) {