Git Product home page Git Product logo

php-class-parser's Introduction

README

The ClassParser gets information about the classes (and their methods) defined in a file. Basic usage (taken from sample.php):

$cp = new ClassParser();
$cp->parse('sample.classes.php');
var_dump($cp->getClasses());

The following info is parsed (using the example from sample.php):

array(2) {
  ["Our"]=>
  array(5) {
    ["name"]=>
    string(3) "Our"
    ["modifiers"]=>
    array(1) {
      [0]=>
      string(8) "abstract"
    }
    ["line"]=>
    int(2) 11
    ["doc"]=>
    NULL
    ["functions"]=>
    array(1) {
      ["cd"]=>
      array(2) {
        ["modifiers"]=>
        array(2) {
          [0]=>
          string(6) "public"
          [1]=>
          string(8) "abstract"
        }
        ["line"]=>
        int(2) 12
        ["doc"]=>
        NULL
      }
    }
    ["file"]=>
    string(59) "/Users/hugowett/Desktop/php-class-parser/sample.classes.php"
  }
  ["Abc"]=>
  array(7) {
    ["name"]=>
    string(3) "Abc"
    ["modifiers"]=>
    array(0) {
    }
    ["line"]=>
    int(2) 21
    ["doc"]=>
    string(79) "/**
 * undocumented class
 *
 * @package default
 * @author Hugo Wetterberg
 */"
    ["extends"]=>
    array(1) {
      [0]=>
      string(3) "Our"
    }
    ["implements"]=>
    array(2) {
      [0]=>
      string(5) "iSome"
      [1]=>
      string(6) "iOther"
    }
    ["functions"]=>
    array(4) {
      ["ab"]=>
      array(2) {
        ["modifiers"]=>
        array(1) {
          [0]=>
          string(7) "private"
        }
        ["line"]=>
        int(2) 22
        ["doc"]=>
        NULL
      }
      ["cd"]=>
      array(2) {
        ["modifiers"]=>
        array(1) {
          [0]=>
          string(6) "public"
        }
        ["line"]=>
        int(2) 26
        ["doc"]=>
        NULL
      }
      ["q"]=>
      array(2) {
        ["modifiers"]=>
        array(1) {
          [0]=>
          string(6) "public"
        }
        ["line"]=>
        int(2) 37
        ["doc"]=>
        string(114) "/**
   * undocumented function
   *
   * @param string $name 
   * @return void
   * @author Hugo Wetterberg
   */"
      }
      ["r"]=>
      array(2) {
        ["modifiers"]=>
        array(1) {
          [0]=>
          string(6) "public"
        }
        ["line"]=>
        int(2) 41
        ["doc"]=>
        NULL
      }
      ["randomStaticMethod"]=>
      array(2) {
        ["modifiers"]=>
        array(1) {
          [0]=>
          string(6) "public"
          [1]=>
          string(6) "static"
        }
        ["line"]=>
        int(2) 52
        ["doc"]=>
        string(114) "/**
   * randomStaticMethod
   *
   * @param string $checkdata 
   * @return boolean
   * @author Dean Huczok
   */"
      }
    }
    ["file"]=>
    string(59) "/Users/deanhucz/Desktop/php-class-parser/sample.classes.php"
  }
}

Was parsed from the following:

<?php

interface iOther {
  public function q($name);
}

interface iSome {
  public function r($gio);
}

abstract class Our {
  public abstract function cd();
}

/**
 * undocumented class
 *
 * @package default
 * @author Hugo Wetterberg
 */
class Abc extends Our implements iSome, iOther {
  private function ab() {

  }

  public function cd() {

  }

  /**
   * undocumented function
   *
   * @param string $name
   * @return void
   * @author Hugo Wetterberg
   */
  public function q($name) {
    return $name;
  }

  public function r($gio) {
    return $gio;
  }

  /**
   * randomStaticMethod
   *
   * @param string $checkdata
   * @return boolean
   * @author Dean Huczok
   */
  public static function randomStaticMethod($checkdata)
  {
      return true;
  }
}

public function asasd() {

}

php-class-parser's People

Contributors

dean-huczok avatar hugowetterberg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

php-class-parser's Issues

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.