forked from tomaszdurka/codegenerator
-
Notifications
You must be signed in to change notification settings - Fork 3
/
sandbox.php
43 lines (31 loc) · 1.11 KB
/
sandbox.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php
namespace CodeGenerator;
require 'vendor/autoload.php';
$file = new FileBlock();
$closureFunction = new FunctionBlock(function ($bar = null) {
return 'foo';
});
$file->addBlock($closureFunction);
$function = new FunctionBlock('return true;');
$file->addBlock($function);
$method = new MethodBlock('_bar');
$method->setVisibility('private');
$method->addParameter(new ParameterBlock('foo'));
$method->addParameter(new ParameterBlock('bar'));
$method->addParameter(new ParameterBlock('zoo'));
$method->setReturnType('string');
$property = new PropertyBlock('foo');
$property->setDocBlock(new PropertyDocBlock('string'));
$property->setDefaultValue('foo');
$constant = new ConstantBlock('FOO', 1);
$class = new ClassBlock('Foo');
$class->addMethod($method);
$class->addProperty($property);
$class->addConstant($constant);
$file->addBlock($class);
$childClass = new ClassBlock('Bar', 'Foo');
$file->addBlock($childClass);
$reflectionClass = new \ReflectionClass('\\CodeGenerator\\FunctionBlock');
$reflectedClass = ClassBlock::buildFromReflection($reflectionClass);
$file->addBlock($reflectedClass);
echo $file->dump();