phpstorm - Convert "Generator" to "PhpStormCompilePass"
authorTim Otten <totten@civicrm.org>
Fri, 25 Aug 2023 22:03:12 +0000 (15:03 -0700)
committerTim Otten <totten@civicrm.org>
Fri, 25 Aug 2023 22:03:12 +0000 (15:03 -0700)
tools/extensions/phpstorm/Civi/PhpStorm/PhpStormCompilePass.php [moved from tools/extensions/phpstorm/Civi/PhpStorm/Generator.php with 90% similarity]
tools/extensions/phpstorm/info.xml
tools/extensions/phpstorm/mixin/phpstorm@1.0.0.mixin.php [deleted file]
tools/extensions/phpstorm/phpstorm.php

similarity index 90%
rename from tools/extensions/phpstorm/Civi/PhpStorm/Generator.php
rename to tools/extensions/phpstorm/Civi/PhpStorm/PhpStormCompilePass.php
index d555b4850db90cbd0f7968925e52a5c03a2cf2c4..8d108c150d6dfe0291d13be8170d8e0ef8065ee5 100644 (file)
@@ -2,6 +2,7 @@
 
 namespace Civi\PhpStorm;
 
+use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
 use Symfony\Component\DependencyInjection\ContainerBuilder;
 
 /**
@@ -9,13 +10,13 @@ use Symfony\Component\DependencyInjection\ContainerBuilder;
  *
  * @link https://www.jetbrains.com/help/phpstorm/2021.3/ide-advanced-metadata.html
  */
-class Generator {
+class PhpStormCompilePass implements CompilerPassInterface {
 
   /**
    * @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
    * @return void
    */
-  public static function generate(ContainerBuilder $container): void {
+  public function process(ContainerBuilder $container): void {
     if (defined('CIVICRM_TEST')) {
       return;
     }
index 8f4f17f9684e6f639048e3998e51ca0030884351..6ae54c75c0df63da71737f3117727aaccbb30f6c 100644 (file)
@@ -31,7 +31,6 @@
     <angularModule>crmPhpstorm</angularModule>
   </civix>
   <mixins>
-    <mixin>phpstorm@1.0.0</mixin>
     <!--
     <mixin>mgd-php@1.0.0</mixin>
     <mixin>setting-php@1.0.0</mixin>
diff --git a/tools/extensions/phpstorm/mixin/phpstorm@1.0.0.mixin.php b/tools/extensions/phpstorm/mixin/phpstorm@1.0.0.mixin.php
deleted file mode 100644 (file)
index c70b85b..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-<?php
-
-/**
- * @mixinName phpstorm
- * @mixinVersion 1.0.0
- *
- * @param CRM_Extension_MixInfo $mixInfo
- *   On newer deployments, this will be an instance of MixInfo. On older deployments, Civix may polyfill with a work-a-like.
- * @param \CRM_Extension_BootCache $bootCache
- *   On newer deployments, this will be an instance of MixInfo. On older deployments, Civix may polyfill with a work-a-like.
- */
-return function ($mixInfo, $bootCache) {
-
-  // We want to register a late-stage listener for hook_civicrm_container, but... it's a special hook.
-  // Therefore, we apply the Shenanigan technique.
-  Civi::dispatcher()->addListener('&hook_civicrm_container', function($container) use ($mixInfo) {
-    if ($mixInfo->isActive()) {
-      \Civi\PhpStorm\Generator::generate($container);
-    }
-  }, -2000);
-
-};
index b7d7483201a10ca2d8a953d2a3c30003a9b385b1..71a5085f44898d23e0af1090d7a795c4117c58b7 100644 (file)
@@ -4,6 +4,7 @@
 // phpcs:disable
 // use CRM_Phpstorm_ExtensionUtil as E;
 // phpcs:enable
+use Symfony\Component\DependencyInjection\Compiler\PassConfig;
 
 /**
  * Implements hook_civicrm_config().
@@ -13,3 +14,7 @@
 // function phpstorm_civicrm_config(&$config): void {
 //  _phpstorm_civix_civicrm_config($config);
 // }
+
+function phpstorm_civicrm_container(\Symfony\Component\DependencyInjection\ContainerBuilder $container) {
+  $container->addCompilerPass(new \Civi\PhpStorm\PhpStormCompilePass(), PassConfig::TYPE_AFTER_REMOVING, 2000);
+}