代码之家  ›  专栏  ›  技术社区  ›  ajthinking

带PHP解析器的PSR-2 pretyprinter

  •  1
  • ajthinking  · 技术社区  · 7 年前

    nikic/PHP-Parser 解析/操作/打印PHP代码。但是,没有提供特定的pretyprinter,默认设置会损坏某些点的结果。例子:

    <?php
    
    namespace App;
    
    use Illuminate\Notifications\Notifiable;
    use Illuminate\Contracts\Auth\MustVerifyEmail;
    use Illuminate\Foundation\Auth\User as Authenticatable;
    
    class User extends Authenticatable
    {
        use Notifiable;
    
        /**
         * The attributes that are mass assignable.
         *
         * @var array
         */
        protected $fillable = [
            'name', 'email', 'password',
        ];
    
        /**
         * The attributes that should be hidden for arrays.
         *
         * @var array
         */
        protected $hidden = [
            'password', 'remember_token',
        ];
    }
    

    实际

    <?php
    
    namespace App;
    
    use Illuminate\Notifications\Notifiable;
    use Illuminate\Contracts\Auth\MustVerifyEmail;
    use Illuminate\Foundation\Auth\User as Authenticatable;
    class User extends Authenticatable
    {
        use Notifiable;
        /**
         * The attributes that are mass assignable.
         *
         * @var array
         */
        protected $fillable = ['name', 'email', 'password'];
        /**
         * The attributes that should be hidden for arrays.
         *
         * @var array
         */
        protected $hidden = ['password', 'remember_token'];
    }
    

    我的问题:在哪里可以找到标准PrettyPrinter类的基本PSR-2扩展来修复这些(和其他)问题?

    https://github.com/FriendsOfPHP/PHP-CS-Fixer .

    我确实找到了 this one

    0 回复  |  直到 7 年前
    推荐文章