domaincoder/code-metamodel-php

CodeMetamodel-PHP provides metamodel classes of PHP code and a parser which parses PHP codes and build metamodel objects.

dev-master 2015-03-26 09:29 UTC

This package is not auto-updated.

Last update: 2024-03-16 14:14:31 UTC


README

Code Metamodel for PHP

Build Status SensioLabsInsight Total Downloads Latest Stable Version Latest Unstable Version Dependency Status

Features

  • Parser\Parser parses PHP sources under a project to generate metamodel objects (via CLI command).
  • Element\* are metamodel classes. Currently supports
    • namespace
    • use
    • class
    • class annotation
    • class inheritance
    • property
    • property annotation
    • property type resolving (only declared by use)
    • method
    • method annotation
  • Dumper\SimpleDumper dumps metamodel objects to simple text.

Installation

CodeMetamodel-PHP can be installed using Composer.

CAUTION: dev package is only available.

// composer.json
{
    "minimum-stability": "dev"
}

$ composer require domaincoder/code-metamodel-php

Commands

Some features of CodeMetamodel-PHP are provided via CLI commands. CLI commands can be ran as follows:

$ php bin/domaincoder-parser.php COMMAND_NAME TARGET_DIR (OPTIONS)

parse

This command parses codes under the TARGET_DIR and create model cache.

$ php bin/domaincoder-parser.php parse /path/to/project/root

dump

This command dumps meta-model objects of a specified location.

$ php bin/domaincoder-parser.php dump /path/to/project/root

filter-class

With this command you can search classes in a meta-model objects of a specified location. Options are:

  • annotation: Annotation name (ex. ORM\Entity, author)
  • comment: keyword (ex. related to tax)
$ php bin/domaincoder-parser.php filter-class /path/to/project/root --annotation=Route --comment=Test

filter-property

With this command you can search properties in a meta-model objects of a specified location. Options are:

  • annotation: Annotation name (ex. ORM\Entity, author)
  • comment: keyword (ex. related to tax)
$ php bin/domaincoder-parser.php filter-property /path/to/project/root --annotation=Route --comment=Test

filter-method

With this command you can search methods in a meta-model objects of a specified location. Options are:

  • annotation: Annotation name (ex. ORM\Entity, author)
  • comment: keyword (ex. related to tax)
$ php bin/domaincoder-parser.php filter-method /path/to/project/root --annotation=Route --comment=Test

Roadmap

  • v 0.0.1 implements parser which parses codes to build metamodel objects. saving model objects to a cache (APC) or json format.
  • v 0.0.2 adds filter commands.
  • v 0.0.3 adds modifying existing AST to add fields, change annotations, etc.

Support

If you find a bug or have a question, or want to request a feature, create an issue or pull request for it on Issues.

Copyright

Copyright (c) 2015 GOTO Hidenori, All rights reserved.

License

The BSD 2-Clause License