sourcegraph/srclib-php — pull request #1 by mcuadros (2014-11-18 23:52:52+00:00)
Title: Grapher: defs from constants, functions and basic classes

This are the first steps to build the `scrlib-php`, this PR contains:

* Grapher scaffolding
* Test suite
* DefExtractor: working with constants, functions and basic classes.

**Example:**
Input:
```php
foo = $foo;
}

protected function protectedMethod() {}
private function privateMethod() {}
}

function baz() {}
```

Output:
```json
{
"defs": [
{
"Kind": "constant",
"Name": "QUX",
"TreePath": "Foo/QUX",
"File": "/tests/fixtures/010.complex.php",
"Test": false,
"DefStart": 23,
"DefEnd": 42,
"Exported": true
},
{
"Kind": "class",
"Name": "Bar",
"TreePath": "Foo/Bar",
"File": "/tests/fixtures/010.complex.php",
"Test": false,
"DefStart": 44,
"DefEnd": 215,
"Exported": true
},
{
"Kind": "method",
"Name": "__construct",
"TreePath": "Foo/Bar/__construct",
"Exported": true,
"File": "/tests/fixtures/010.complex.php",
"Test": false,
"DefStart": 60,
"DefEnd": 128
},
{
"Kind": "method",
"Name": "protectedMethod",
"TreePath": "Foo/Bar/protectedMethod",
"Exported": false,
"File": "/tests/fixtures/010.complex.php",
"Test": false,
"DefStart": 134,
"DefEnd": 173
},
{
"Kind": "method",
"Name": "privateMethod",
"TreePath": "Foo/Bar/privateMethod",
"Exported": false,
"File": "/tests/fixtures/010.complex.php",
"Test": false,
"DefStart": 178,
"DefEnd": 213
},
{
"Kind": "function",
"Name": "baz",
"TreePath": "Foo/baz",
"File": "/tests/fixtures/010.complex.php",
"Test": false,
"DefStart": 217,
"DefEnd": 234,
"Exported": true
}
]
}
```

https://gist.github.com/mcuadros/559ecadcd8072102cafe