matthiasnoback/php-parser-instantiation-printer 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

matthiasnoback/php-parser-instantiation-printer

最新稳定版本:v0.3.0

Composer 安装命令:

composer require matthiasnoback/php-parser-instantiation-printer

包简介

README 文档

README

This project provides a so-called InstantiationPrinter. I'm not the only one who has attempted to build such a thing: nikic/PHP-Parser#566

Example: $instance = new self(); In PHP-Parser nodes this will be:

array(
    0: Stmt_Expression(
        expr: Expr_Assign(
            var: Expr_Variable(
                name: instance
            )
            expr: Expr_New(
                class: Name(
                    parts: array(
                        0: self
                    )
                )
                args: array(
                )
            )
        )
    )
)

When printed by the InstantiationPrinter this becomes:

new PhpParser\Node\Stmt\Expression(
    new PhpParser\Node\Expr\Assign(
        new PhpParser\Node\Expr\Variable('instance'),
        new PhpParser\Node\Expr\New_(
            new PhpParser\Node\Name('self')
        )
    )
);

Usage

Install this library in your project:

composer require --dev matthiasnoback/php-parser-instantiation-printer

You'll have command-line tool now, that generates the nodes based on the provided PHP script:

bin/print-node-instantiation-code temp.php

(if you don't have a bin/ directory in your project, try vendor/bin)

You can also instantiate your own InstantiationPrinter service. Take a look at the code in the print-node-instantiation-code script to find out how to accomplish this.

统计信息

  • 总下载量: 117.37k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 14
  • 点击次数: 1
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 14
  • Watchers: 1
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-10-16