1 | <?php |
||
44 | trait ConfigFileProcessingTrait |
||
45 | { |
||
46 | use SafeFileHandlingTrait; |
||
47 | /** |
||
48 | * Looks for and replaces any {Yapeal.*} it finds in values with the corresponding other setting value. |
||
49 | * |
||
50 | * This will replace full value or part of the value. Examples: |
||
51 | * |
||
52 | * $settings = [ |
||
53 | * 'Yapeal.baseDir' => '/my/junk/path/Yapeal/', |
||
54 | * 'Yapeal.libDir' => '{Yapeal.baseDir}lib/' |
||
55 | * 'Yapeal.Sql.dir' => '{Yapeal.libDir}Sql/' |
||
56 | * ]; |
||
57 | * |
||
58 | * After doSubstitutions would be: |
||
59 | * |
||
60 | * $settings = [ |
||
61 | * 'Yapeal.baseDir' => '/my/junk/path/Yapeal/', |
||
62 | * 'Yapeal.libDir' => '/my/junk/path/Yapeal/lib/' |
||
63 | * 'Yapeal.Sql.dir' => '/my/junk/path/Yapeal/lib/Sql/' |
||
64 | * ]; |
||
65 | * |
||
66 | * Note that order in which subs are done is undefined so it could have |
||
67 | * done libDir first and then baseDir into both or done baseDir into libDir |
||
68 | * then libDir into Sql.dir. |
||
69 | * |
||
70 | * Subs from within $settings itself are used first with $dic used to |
||
71 | * fill-in as needed for any unknown ones. |
||
72 | * |
||
73 | * Subs are tried up to 10 times as long as any {Yapeal.*} are found before |
||
74 | * giving up to prevent infinite loop. |
||
75 | * |
||
76 | * @param array $settings |
||
77 | * @param ContainerInterface $dic |
||
78 | * |
||
79 | * @return array |
||
80 | * @throws \DomainException |
||
81 | */ |
||
82 | protected function doSubstitutions(array $settings, ContainerInterface $dic): array |
||
118 | /** |
||
119 | * Converts any depth Yaml config file into a flattened array with '.' separators and values. |
||
120 | * |
||
121 | * @param string $configFile |
||
122 | * @param array $existing |
||
123 | * |
||
124 | * @return array |
||
125 | * @throws \LogicException |
||
126 | * @throws \DomainException |
||
127 | */ |
||
128 | protected function parserConfigFile(string $configFile, array $existing = []): array |
||
140 | } |
||
141 |
This check looks for methods that are used by a trait but not required by it.
To illustrate, let’s look at the following code example
The trait
Idable
provides a methodequalsId
that in turn relies on the methodgetId()
. If this method does not exist on a class mixing in this trait, the method will fail.Adding the
getId()
as an abstract method to the trait will make sure it is available.