https://github.com/tomnomnom/flatclass
Flatten deep inheritance trees in PHP to aid debugging
https://github.com/tomnomnom/flatclass
Last synced: about 2 months ago
JSON representation
Flatten deep inheritance trees in PHP to aid debugging
- Host: GitHub
- URL: https://github.com/tomnomnom/flatclass
- Owner: tomnomnom
- License: mit
- Created: 2015-11-02T22:51:29.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2015-11-08T13:40:39.000Z (over 9 years ago)
- Last Synced: 2025-01-24T09:08:22.126Z (3 months ago)
- Language: PHP
- Homepage:
- Size: 133 KB
- Stars: 2
- Watchers: 4
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.mkd
- License: LICENSE
Awesome Lists containing this project
README
# Flatclass
Given an object or class name, the `Flatterer` returns a 'flattened' version of a class;
i.e. with non-overridden methods and properties from parent classes copied into it.For example, the following code:
```php
name = $name;
}
public function getName(){
return $this->name;
}
}class Dog extends Animal {
public function bark(){
return "Woof!";
}
}$f = new \Flatclass\Flatterer('Dog');
echo $f->flatten('FlatDog');
```Would produce a `FlatDog` class that looked like this:
```php
name = $name;
}// From class Animal
public function getName(){
return $this->name;
}}
```## Why?
This is meant as a debugging tool. With very deep inheritance hierarchies it can be difficult to
mentally follow code execution paths that jump back and forth between several files.While the generated class is not guaranteed to function in the same way as the original, some efforts
are made to make it more likely; e.g. the resulting class has the same parent as the original to
allow `parent::method()` calls to work.