1 | <?php |
||
10 | class TemplateHelper |
||
11 | { |
||
12 | /** @var array */ |
||
13 | private $variableList = []; |
||
14 | /** @var string[] */ |
||
15 | private $variableNameList = []; |
||
16 | /** @var string */ |
||
17 | private $filenameResolverRegexp; |
||
18 | /** @var Filesystem */ |
||
19 | private $fs; |
||
20 | |||
21 | /** |
||
22 | * @param array $variableList |
||
23 | * @param array $extraTemplatePath |
||
24 | */ |
||
25 | public function __construct(array $variableList, array $extraTemplatePath = []) |
||
59 | |||
60 | /** |
||
61 | * @param string $templateFilePath |
||
62 | * @param string $outputFilePath |
||
63 | * @param bool $overwrite overwrite even if present |
||
64 | * |
||
65 | * @throws TargetFileExistsException |
||
66 | */ |
||
67 | public function dumpTemplate($templateFilePath, $outputFilePath, $overwrite = false) |
||
71 | |||
72 | /** |
||
73 | * @param string $templateFilePath |
||
74 | * |
||
75 | * @return string |
||
76 | */ |
||
77 | public function resolveOutputFilePath($templateFilePath, $outputDir) |
||
85 | |||
86 | /** |
||
87 | * @param string $templateFilePath |
||
88 | * |
||
89 | * @return string |
||
90 | */ |
||
91 | public function resolveOutputFilename($templateFilePath) |
||
95 | |||
96 | /** |
||
97 | * @param string $templateFilePath |
||
98 | * |
||
99 | * @return string file content |
||
100 | */ |
||
101 | public function loadTemplate($templateFilePath) |
||
105 | } |
||
106 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: