forked from phpowermove/php-code-generator
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPhpInterface.php
More file actions
59 lines (51 loc) · 1.37 KB
/
PhpInterface.php
File metadata and controls
59 lines (51 loc) · 1.37 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php
namespace gossi\codegen\model;
use gossi\codegen\model\parts\ConstantsPart;
use gossi\codegen\model\parts\InterfacesPart;
use gossi\codegen\parser\FileParser;
use gossi\codegen\parser\visitor\ConstantParserVisitor;
use gossi\codegen\parser\visitor\InterfaceParserVisitor;
use gossi\codegen\parser\visitor\MethodParserVisitor;
/**
* Represents a PHP interface.
*
* @author Thomas Gossmann
*/
class PhpInterface extends AbstractPhpStruct implements GenerateableInterface, ConstantsInterface {
use ConstantsPart;
use InterfacesPart;
/**
* Creates a PHP interface from file
*
* @param string $filename
* @return PhpInterface
*/
public static function fromFile($filename) {
$interface = new PhpInterface();
$parser = new FileParser($filename);
$parser->addVisitor(new InterfaceParserVisitor($interface));
$parser->addVisitor(new MethodParserVisitor($interface));
$parser->addVisitor(new ConstantParserVisitor($interface));
$parser->parse();
return $interface;
}
/**
* Create a new PHP interface
*
* @param string $name qualified name
*/
public function __construct($name = null) {
parent::__construct($name);
$this->initConstants();
$this->initInterfaces();
}
/**
* @inheritDoc
*/
public function generateDocblock() {
parent::generateDocblock();
foreach ($this->constants as $constant) {
$constant->generateDocblock();
}
}
}