GithubHelp home page GithubHelp logo

php-parser's Introduction

PHP-Parser

Parses your php file and extract class, method/function and property informations.

Basic usage: php parse.php --file=<filename>

Example #1

Command: php parse.php --file=test-001.php -o=parse.json --pretty

Input

<?php

class Bar
{
    public $var_abc = null;
    public $var_xyz = null;
    public $var_foo = null;

    public function foourz()
    {

    }
}

class Foo
{
    private $_foobar = null;

    public function foobar($a)
    {

    }

    public function test()
    {

    }
}

Output (in parse.json):

{
    "class Bar": {
        "properties": [
            "public $var_abc",
            "public $var_xyz",
            "public $var_foo"
        ],
        "functions": [
            "public foourz()"
        ]
    },
    "class Foo": {
        "properties": [
            "private $_foobar"
        ],
        "functions": [
            "public foobar($a)",
            "public test()"
        ]
    }
}

#Example #2

Command: php parse.php --file=test-001.php -o=parse.json (without --pretty)

Same Input

Output (in parse.json)

[
    {
        "class": "Bar",
        "text": "$var_abc",
        "snippet": "var_abc",
        "type": "property",
        "typehint": null,
        "protection": "public",
        "state": null
    },
    {
        "class": "Bar",
        "text": "$var_xyz",
        "snippet": "var_xyz",
        "type": "property",
        "typehint": null,
        "protection": "public",
        "state": null
    },
    {
        "class": "Bar",
        "text": "$var_foo",
        "snippet": "var_foo",
        "type": "property",
        "typehint": null,
        "protection": "public",
        "state": null
    },
    {
        "class": "Bar",
        "text": "foourz",
        "snippet": "foourz()",
        "type": "function",
        "protection": "public",
        "state": null
    },
    {
        "class": "Foo",
        "text": "$_foobar",
        "snippet": "_foobar",
        "type": "property",
        "typehint": null,
        "protection": "private",
        "state": null
    },
    {
        "class": "Foo",
        "text": "foobar",
        "snippet": "foobar($a)",
        "type": "function",
        "protection": "public",
        "state": null
    },
    {
        "class": "Foo",
        "text": "test",
        "snippet": "test($a,$b)",
        "type": "function",
        "protection": "public",
        "state": null
    }
]

Without -o=<output> the result will be printed to stdin.

You can furthermore configurate the output by using these options:

  • no-static
  • no-abstract
  • no-trait
  • no-interface
  • no-private
  • no-protected

php-parser's People

Contributors

dgame avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.