An open API service indexing awesome lists of open source software.

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

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.