Injection
Sometimes you need to add some text content to an already existing file.
It is possible using injections.
Let's say we have a PHP class named CartRenderer like the following:
<?php
class CartRenderer
{
}After
In the following example we insert the interface implementation after the class name.
---
to: CartRenderer.php
inject: true
after: /^class .*/mi
---
{{ ' ' }}implements SingletonInterfaceBefore
This injection can also be done using the before setting.
This example inserts the final keyword before the class declaration.
Replace
This injection mode replace the actual match of the regex.
Conditional injection
And last, we can skip any injections using the skip_if setting:
Last updated