2017 © Pedro Peláez
 

library code_generate

image

linzhen/code_generate

  • Thursday, October 12, 2017
  • by Smiler94
  • Repository
  • 1 Watchers
  • 0 Stars
  • 7 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

codeGenerate

a simple demo to generate php code, (*1)

usage

install

clone the resposity, (*2)

$ git clone https://github.com/Smiler94/code_generate.git, (*3)

install the dependencies, (*4)

$ composer install, (*5)

use

``` php require_once DIR.'/vendor/autoload.php';, (*6)

use generator\Property; use generator\Method; use generator\Classes; $property = (new Property('test')) ->addComment('a test property') ->setStatic(true) ->indent(0) ->setPrivilege(Property::PRIVILEGE_PROTECTED) ->setValue('dddd'); // ->generate();, (*7)

echo $property; // // $method = (new Method('test')) ->addComment('a test method') ->addComment(' ') ->addComment('@author linzhen 2017-07-03 16:17:02') ->setStatic(true) ->indent(1) ->addBody('return true');, (*8)

echo $method;, (*9)

$class = (new Classes('Test')) ->addComment('a test class') ->setNameSpace('generate') ->addTrait('\generate\Method') ->addExtend('extend') ->addImplement('implement') ->addImplement('implement2');, (*10)

$prop = $class->addProperty('prop1', '') ->addComment('prop1') ->setPrivilege('private');, (*11)

$method = $class->addMethod('method1') ->addComment('a test method') ->addComment(' ') ->addComment('@author linzhen 2017-07-04 09:55:57') ->setPrivilege('public') ->addParam('arg1') ->addBody('return true');, (*12)

$method2 = $class->addMethod('method2') ->addComment('a test method2') ->addComment(' ') ->addComment('@author linzhen 2017-07-04 09:55:57') ->setPrivilege('private') ->addParam('arg1') ->addBody(''); echo $class;, (*13)

```, (*14)

The Versions

12/10 2017

dev-master

9999999-dev

  Sources   Download

by linzhen