| layout | default |
|---|---|
| title | PHP |
| parent | Language Guides |
| nav_order | 13 |
English | 한국어 | 日本語 | हिन्दी | Deutsch
.php
| Element | Kind | Example |
|---|---|---|
| Function | function |
function greet($name) |
| Method | method |
public function getName() |
| Class | class |
class User |
| Interface | interface |
interface Repository |
| Trait | type |
trait Loggable |
| Enum | enum |
enum Status |
| Constant | variable |
const MAX_SIZE = 100; |
| Property | variable |
public $name; |
| PHPDoc Comment | doc |
/** Description */ |
| Line Comment | doc |
// Description |
| use Statement | import |
use App\Services\UserService; |
| require/include | import |
require 'vendor/autoload.php'; |
<?php
namespace App\Services;
use App\Models\User;
/**
* UserService handles user-related operations.
*/
class UserService {
private $repository;
public function __construct($repo) {
$this->repository = $repo;
}
public function findUser($id): ?User {
return $this->repository->find($id);
}
}
interface RepositoryInterface {
public function find($id);
public function save($entity);
}
trait Loggable {
public function log($message) {
echo $message;
}
}
function helper($data) {
return $data;
}
const MAX_ITEMS = 100;
const APP_NAME = "Brf.it";<file path="example.php" language="php">
<type kind="class" line="10">
<name>UserService</name>
<text>class UserService</text>
<doc>UserService handles user-related operations.</doc>
</type>
<function kind="method" line="15">
<name>__construct</name>
<text>public function __construct($repo)</text>
</function>
<function kind="method" line="19">
<name>findUser</name>
<text>public function findUser($id): ?User</text>
</function>
<type kind="interface" line="25">
<name>RepositoryInterface</name>
<text>interface RepositoryInterface</text>
</type>
<function kind="method" line="26">
<name>find</name>
<text>public function find($id)</text>
</function>
<function kind="method" line="27">
<name>save</name>
<text>public function save($entity)</text>
</function>
<type kind="type" line="30">
<name>Loggable</name>
<text>trait Loggable</text>
</type>
<function kind="method" line="31">
<name>log</name>
<text>public function log($message)</text>
</function>
<function kind="function" line="36">
<name>helper</name>
<text>function helper($data)</text>
</function>
<variable kind="variable" line="40">
<name>MAX_ITEMS</name>
<text>const MAX_ITEMS = 100;</text>
</variable>
<variable kind="variable" line="41">
<name>APP_NAME</name>
<text>const APP_NAME = "Brf.it";</text>
</variable>
</file>- All declarations are extracted regardless of visibility (public, private, protected)
- Use
--include-privateflag to filter (future feature)
When --include-body flag is not used:
- Functions/Methods: body removed after opening brace
{ - Classes/Interfaces/Traits: body removed after class name
- Constants/Properties: preserved as-is
With --include-imports flag:
usestatements:use App\Services\UserService;requirestatements:require 'vendor/autoload.php';require_oncestatements:require_once 'config.php';includestatements:include 'file.php';include_oncestatements:include_once 'helpers.php';
- PHPDoc comments (
/** ... */) are extracted - Regular multi-line comments (
/* ... */) and line comments (//,#) are also supported