1 | <?php declare(strict_types=1); |
||
18 | use phootwork\file\exception\FileNotFoundException; |
||
19 | |||
20 | /** |
||
21 | * Represents a PHP interface. |
||
22 | * |
||
23 | * @author Thomas Gossmann |
||
24 | */ |
||
25 | class PhpInterface extends AbstractPhpStruct implements GenerateableInterface, ConstantsInterface { |
||
26 | use ConstantsPart; |
||
27 | use InterfacesPart; |
||
28 | |||
29 | 2 | /** |
|
30 | 2 | * Creates a PHP interface from file |
|
31 | 2 | * |
|
32 | 2 | * @param string $filename |
|
33 | 2 | * |
|
34 | 2 | * @throws FileNotFoundException |
|
35 | 2 | * |
|
36 | * @return PhpInterface |
||
37 | 2 | * |
|
38 | */ |
||
39 | public static function fromFile(string $filename): self { |
||
40 | $interface = new self(); |
||
41 | $parser = new FileParser($filename); |
||
42 | $parser->addVisitor(new InterfaceParserVisitor($interface)); |
||
43 | $parser->addVisitor(new MethodParserVisitor($interface)); |
||
44 | $parser->addVisitor(new ConstantParserVisitor($interface)); |
||
45 | 8 | $parser->parse(); |
|
46 | 8 | ||
47 | 8 | return $interface; |
|
48 | 8 | } |
|
49 | 8 | ||
50 | /** |
||
51 | * Create a new PHP interface |
||
52 | * |
||
53 | * @param string $name qualified name |
||
54 | 3 | */ |
|
55 | 3 | public function __construct(string $name = '') { |
|
56 | parent::__construct($name); |
||
57 | 3 | $this->initConstants(); |
|
58 | 1 | $this->initInterfaces(); |
|
59 | } |
||
60 | 3 | ||
61 | /** |
||
62 | * @inheritDoc |
||
69 |