定制 funivan/php-tokenizer 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

funivan/php-tokenizer

最新稳定版本:0.3.0

Composer 安装命令:

composer require funivan/php-tokenizer

包简介

Wrapper around token_get_all. Easy to extract and modify php code.

关键字:

README 文档

README

GitHub tag Software License Total Downloads

Wrapper around token_get_all. Easy to extract and modify tokens

Install

Via Composer

composer require funivan/php-tokenizer

Usage

Reformat our code like PhpStorm. Lets create rule: place single spaces after while

  use Funivan\PhpTokenizer\Collection;
  use Funivan\PhpTokenizer\Pattern\PatternMatcher;
  use Funivan\PhpTokenizer\QuerySequence\QuerySequence;


  $source = "<?php while(){}"; // while (){}
  
  $collection = Collection::createFromString($source);
  
  (new PatternMatcher($collection))->apply(function (QuerySequence $checker) {

    $while = $checker->strict('while');
    $space = $checker->possible(T_WHITESPACE);

    if ($checker->isValid()) {
      $space->remove();
      $while->appendToValue(" ");
    }

  });

  echo (string) $collection;
   

Documentation

Documentation

Testing

./vendor/bin/phpunit

Contributing

Please see CONTRIBUTING for details.

Credits

License

The MIT License (MIT). Please see License File for more information.

统计信息

  • 总下载量: 38.46k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 12
  • 点击次数: 0
  • 依赖项目数: 4
  • 推荐数: 0

GitHub 信息

  • Stars: 12
  • Watchers: 5
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-05-18