laravel-ide-helper icon indicating copy to clipboard operation
laravel-ide-helper copied to clipboard

Improve formatting, readability and size of generated files.

Open S-K-Tiger opened this issue 2 years ago • 0 comments

Versions:

  • ide-helper Version: v2.12.3
  • Laravel Version: v9.34.0
  • PHP Version: 8.1.11

Summary:

The generated _ide_helper.php file has inconsistent indentation among other things that both reduce readability and increase filesize. I would like to recommend enabling the rendering of whitespaces when working on this enhancement.

Examples from the generated _ide_helper.php file:

line 15 t/m 32

    namespace Illuminate\Support\Facades { 
            /**
     * 
     *
     * @see \Illuminate\Contracts\Foundation\Application
     */ 
        class App {
                    /**
         * Get the version number of the application.
         *
         * @return string 
         * @static 
         */ 
        public static function version()
        {
                        /** @var \Illuminate\Foundation\Application $instance */
                        return $instance->version();
        }

Line 15031 t/m 15033

        public static function prepend($path, $data, $separator = '
')
        {

Line 17217 t/m 17240

    namespace Illuminate\Support { 
            /**
     * 
     *
     */ 
        class Arr {
         
    }
            /**
     * 
     *
     */ 
        class Js {
         
    }
            /**
     * 
     *
     */ 
        class Str {
         
    }
     
}

Potential improvements:

  • Ensure proper indentation
  • Render special characters in parameters as an escaped character (' ' -> "\t") or their predefined constant. (PHP_EOL)
  • Remove empty docblocks
  • Prune trailing whitespaces
  • Convert spaces to tabs
  • Remove the @static tag as the functions themselves are already marked in their definition as a public static function
  • Remove double spaces in, and spaces that can interfere with, definitions (@param \Illuminate\Foundation\(callable(string, string, ?array, ?array): array)|array $attributes is incorrectly proccessed as type \Illuminate\Foundation\ (callable(string, with comment string, ?array, ?array): array)|array $attributes)

S-K-Tiger avatar Dec 19 '22 10:12 S-K-Tiger