Merge "Return null from EditPage::importContentFormData"
[lhc/web/wiklou.git] / maintenance / convertExtensionToRegistration.php
index 4ae9558..3db0511 100644 (file)
@@ -13,13 +13,13 @@ class ConvertExtensionToRegistration extends Maintenance {
                'ResourceModuleSkinStyles' => 'handleResourceModules',
                'Hooks' => 'handleHooks',
                'ExtensionFunctions' => 'handleExtensionFunctions',
-               'ParserTestFiles' => 'removeAbsolutePath',
+               'ParserTestFiles' => 'removeAutodiscoveredParserTestFiles',
        ];
 
        /**
         * Things that were formerly globals and should still be converted
         *
-        * @var array
+        * @var string[]
         */
        protected $formerGlobals = [
                'TrackingCategories',
@@ -28,7 +28,7 @@ class ConvertExtensionToRegistration extends Maintenance {
        /**
         * No longer supported globals (with reason) should not be converted and emit a warning
         *
-        * @var array
+        * @var string[]
         */
        protected $noLongerSupportedGlobals = [
                'SpecialPageGroups' => 'deprecated', // Deprecated 1.21, removed in 1.26
@@ -37,7 +37,7 @@ class ConvertExtensionToRegistration extends Maintenance {
        /**
         * Keys that should be put at the top of the generated JSON file (T86608)
         *
-        * @var array
+        * @var string[]
         */
        protected $promote = [
                'name',
@@ -171,6 +171,7 @@ class ConvertExtensionToRegistration extends Maintenance {
                        }
                        // check if $func exists in the global scope
                        if ( function_exists( $func ) ) {
+                               // @phan-suppress-next-next-line PhanTypeSuspiciousStringExpression
                                $this->fatalError( "Error: Global functions cannot be converted to JSON. " .
                                        "Please move your extension function ($func) into a class."
                                );
@@ -222,6 +223,22 @@ class ConvertExtensionToRegistration extends Maintenance {
                $this->json[$realName] = $out;
        }
 
+       protected function removeAutodiscoveredParserTestFiles( $realName, $value ) {
+               $out = [];
+               foreach ( $value as $key => $val ) {
+                       $path = $this->stripPath( $val, $this->dir );
+                       // When path starts with tests/parser/ the file would be autodiscovered with
+                       // extension registry, so no need to add it to extension.json
+                       if ( substr( $path, 0, 13 ) !== 'tests/parser/' || substr( $path, -4 ) !== '.txt' ) {
+                               $out[$key] = $path;
+                       }
+               }
+               // in the best case all entries are filtered out
+               if ( $out ) {
+                       $this->json[$realName] = $out;
+               }
+       }
+
        protected function handleCredits( $realName, $value ) {
                $keys = array_keys( $value );
                $this->json['type'] = $keys[0];