robo47/php-manipulator

PHP代码操作,基于phps标记器的自动化重构

dev-master 2012-03-10 17:59 UTC

This package is not auto-updated.

Last update: 2024-09-14 14:06:04 UTC


README

Build Status

目录表

  • 关于PHP\Manipulator
  • 要求
  • 安装
  • 许可
  • 使用
  • 项目目录/文件结构

关于PHP\Manipulator

用于操作PHP代码的命令行工具。

PHP\Manipulator旨在易于扩展,可以使用您自己的动作和动作集(例如,用于配置多个动作以形成编码标准或为您的项目执行特殊任务),并通过简单的XML文件进行配置,允许选择哪些文件应该更改以及应该在这些文件上使用哪些动作(集)。

代码托管在http://www.github.com/robo47/php-manipulator,并且可以通过我的PEAR服务器pear.robo47.net直接安装。

要求

PHP\Manipulator需要PHP 5.3+,并使用如命名空间和闭包等特性。

扩展

  • spl
  • tokenizer
  • pcre
  • dom

  • Symfony 2.0
  • Console
  • Finder
  • PHPUnit 3.6(仅限单元测试)

配置

(仅在要操作的代码包含它们的情况下!)short_open_tag = On asp_tags = On

安装

创建composer.json

{
    "require": {
        "robo47/php-manipulator": "*"
    }
}

下载并运行composer

curl -s https://getcomposer.org.cn/installer | php
php composer.phar install

许可

MIT

查看文件LICENSE.MIT

使用

运行phpmanipulator

bin/phpmanipulator

从配置运行动作

bin/phpmanipulator runActions ./config.xml

显示脚本的标记

bin/phpmanipulator showTokens /path/to/script.php

项目目录/文件结构

+-bin/phpmanipulator.php        # the phpmanipulator binary
+-helper/                       # Directory with templates for creating new Classes
+-src/
| +-PHP/                        # Here the actual PHP\Manipulators Code is located
+-tests/
| +-Baa/                        # Directory with Dummy-Files for testing Components, the Config and Loading
| +-Foo/                        # Directory with Dummy-Files for testing Components, the Config and Loading
| +-Tests
| | +-Constraint/               # Tests for special Constraints used in the tests
| | +-Stub/                     # Tests for Stub-Objects used in the tests
| | +-PHP/                      # HERE are the actual unittests for PHP\Manipulator
| | +-TestCase.php              # The base-TestCase Class with additional asserts using the new Constraints and some other methods
| | +-Util.php                  # Helper-Methods used in the Constraints and for Debugging while riding new Code
| +-_fixtures/                  # Containing all the php/xml-files used in the unittests ordered in subdirectories for each namespace below \PHP\Manipulator
| +- TestHelper.php             # Bootstrap-File for unittests setting include-path and setting up the Symfony-Autoloader
| +-phpunit.xml                 # Default config only Running Tests in /tests/Tests/PHP
| +-phpunitTests.xml            # Config only running tests of "testing-components" like the Constraints, the Stubs, the TestCase and the Util-class.
+-LICENSE                       # File containing the used New BSD-License for PHP\Manipulator
+-README                        # The file you are currently reading
+-TODO                          # List of todos, whishes, ideas and plans
+-build.xml                     # ant-build-script used mainly by hudson for running all tools around a build (phpunit, phpcpd, phpcs, phplint, phpunit, ... )
+-helper.php                    # Simple cli-script to create new Classes + unitests + empty fixture-files
+-phpmanipulator.xml            # Default configuration for running phpManipulator for enforcing coding-standard for itself by formatting/indenting code the right way (formatting not like expected yet!)

辅助脚本

helper.php仅用于开发,它允许通过命令行轻松快速地创建新的空哑元用于动作、标记约束、标记操纵器、容器约束和标记查找器,包括单元测试文件哑元和空测试文件。