laminas-code icon indicating copy to clipboard operation
laminas-code copied to clipboard

Examples for Trait generator

Open weierophinney opened this issue 6 years ago • 4 comments

I had requested traits back in zendframework/zendframework#4876 which is now closed. It appears this support was added via TraitGenerator. Would be great to see some examples included in the docs.


Originally posted by @RSully at https://github.com/zendframework/zend-code/issues/73

weierophinney avatar Dec 31 '19 21:12 weierophinney

$traitclass = new TraitGenerator();
$traitclass->addMethod('MethodOne');
$traitclass->addConstant('VERSION','1.0.0');
echo $traitclass->generate();
trait 
{
    public const VERSION = '1.0.0';

    public function MethodOne()
    {
    }
}

@weierophinney You can close this issue as I am sharing code for the user. Ping :- @RSully

vrkansagara avatar Apr 14 '21 14:04 vrkansagara

You can close this issue as I am sharing code for the user.

Is it part of the docs though? The original issue is indeed about expanding in the RST docs...

Ocramius avatar Apr 14 '21 14:04 Ocramius

@Ocramius I am thinking to contribute into doc but it was not original into doc so I am not sure about this.

vrkansagara avatar Apr 14 '21 14:04 vrkansagara

Perhaps adding a section to https://github.com/laminas/laminas-code/blob/ab0d54d8cb8b9ca1f6a8c3287e83724fbc61edbf/docs/book/generator/examples.md ?

Ocramius avatar Apr 14 '21 14:04 Ocramius