2

我正在使用nikic/PHP-Parser来解析/操作/打印 PHP 代码。但是没有提供特定的 PrettyPrinters,默认值会在某些点上破坏结果。例子:

预期的

<?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这样的 CLI 。

我确实找到了一个看起来不错的开始,但它有点旧,我不能轻易让那个运行。

4

0 回答 0