11<?php
2+
23declare (strict_types=1 );
34
45namespace PhpList \Core \Composer ;
56
7+ use InvalidArgumentException ;
68use Symfony \Component \Yaml \Yaml ;
79
810/**
@@ -20,14 +22,14 @@ class ModuleFinder
2022 /**
2123 * @var PackageRepository
2224 */
23- private $ packageRepository = null ;
25+ private ? PackageRepository $ packageRepository = null ;
2426
2527 /**
2628 * @param PackageRepository $repository
2729 *
2830 * @return void
2931 */
30- public function injectPackageRepository (PackageRepository $ repository )
32+ public function injectPackageRepository (PackageRepository $ repository ): void
3133 {
3234 $ this ->packageRepository = $ repository ;
3335 }
@@ -38,7 +40,7 @@ public function injectPackageRepository(PackageRepository $repository)
3840 * @return string[][] class names of the bundles of all installed phpList modules:
3941 * ['module package name' => ['bundle class name 1', 'bundle class name 2']]
4042 *
41- * @throws \ InvalidArgumentException
43+ * @throws InvalidArgumentException
4244 */
4345 public function findBundleClasses (): array
4446 {
@@ -66,9 +68,9 @@ public function findBundleClasses(): array
6668 *
6769 * @return void
6870 *
69- * @throws \ InvalidArgumentException if $extra has an invalid bundles configuration
71+ * @throws InvalidArgumentException if $extra has an invalid bundles configuration
7072 */
71- private function validateBundlesSectionInExtra (array $ extra )
73+ private function validateBundlesSectionInExtra (array $ extra ): void
7274 {
7375 if (!isset ($ extra ['phplist/core ' ])) {
7476 return ;
@@ -79,7 +81,7 @@ private function validateBundlesSectionInExtra(array $extra)
7981 return ;
8082 }
8183 if (!is_array ($ extra ['phplist/core ' ]['bundles ' ])) {
82- throw new \ InvalidArgumentException (
84+ throw new InvalidArgumentException (
8385 'The extras.phplist/core.bundles section in the composer.json must be an array. ' ,
8486 1505411665
8587 );
@@ -89,7 +91,7 @@ private function validateBundlesSectionInExtra(array $extra)
8991 $ bundleExtras = $ extra ['phplist/core ' ]['bundles ' ];
9092 foreach ($ bundleExtras as $ key => $ bundleName ) {
9193 if (!is_string ($ bundleName )) {
92- throw new \ InvalidArgumentException (
94+ throw new InvalidArgumentException (
9395 'The extras.phplist/core.bundles. ' . $ key . '" section in the composer.json must be a string. ' ,
9496 1505412184
9597 );
@@ -104,12 +106,12 @@ private function validateBundlesSectionInExtra(array $extra)
104106 *
105107 * @return void
106108 *
107- * @throws \ InvalidArgumentException
109+ * @throws InvalidArgumentException
108110 */
109- private function validatePhpListSectionInExtra (array $ extra )
111+ private function validatePhpListSectionInExtra (array $ extra ): void
110112 {
111113 if (!is_array ($ extra ['phplist/core ' ])) {
112- throw new \ InvalidArgumentException (
114+ throw new InvalidArgumentException (
113115 'The extras.phplist/core" section in the composer.json must be an array. ' ,
114116 1505411436
115117 );
@@ -125,7 +127,7 @@ private function validatePhpListSectionInExtra(array $extra)
125127 */
126128 public function createBundleConfigurationYaml (): string
127129 {
128- return static ::YAML_COMMENT . "\n" . Yaml::dump ($ this ->findBundleClasses ());
130+ return static ::YAML_COMMENT . PHP_EOL . Yaml::dump ($ this ->findBundleClasses ());
129131 }
130132
131133 /**
@@ -134,7 +136,7 @@ public function createBundleConfigurationYaml(): string
134136 * @return array[] class names of the routes of all installed phpList modules:
135137 * ['route name' => [route configuration]
136138 *
137- * @throws \ InvalidArgumentException
139+ * @throws InvalidArgumentException
138140 */
139141 public function findRoutes (): array
140142 {
@@ -167,9 +169,9 @@ public function findRoutes(): array
167169 *
168170 * @return void
169171 *
170- * @throws \ InvalidArgumentException if $extra has an invalid routes configuration
172+ * @throws InvalidArgumentException if $extra has an invalid routes configuration
171173 */
172- private function validateRoutesSectionInExtra (array $ extra )
174+ private function validateRoutesSectionInExtra (array $ extra ): void
173175 {
174176 if (!isset ($ extra ['phplist/core ' ])) {
175177 return ;
@@ -180,7 +182,7 @@ private function validateRoutesSectionInExtra(array $extra)
180182 return ;
181183 }
182184 if (!is_array ($ extra ['phplist/core ' ]['routes ' ])) {
183- throw new \ InvalidArgumentException (
185+ throw new InvalidArgumentException (
184186 'The extras.phplist/core.routes section in the composer.json must be an array. ' ,
185187 1506429004
186188 );
@@ -190,7 +192,7 @@ private function validateRoutesSectionInExtra(array $extra)
190192 $ bundleExtras = $ extra ['phplist/core ' ]['routes ' ];
191193 foreach ($ bundleExtras as $ routeName => $ routeConfiguration ) {
192194 if (!is_array ($ routeConfiguration )) {
193- throw new \ InvalidArgumentException (
195+ throw new InvalidArgumentException (
194196 'The extras.phplist/core.routes. ' . $ routeName .
195197 '" section in the composer.json must be an array. ' ,
196198 1506429860
@@ -208,15 +210,15 @@ private function validateRoutesSectionInExtra(array $extra)
208210 */
209211 public function createRouteConfigurationYaml (): string
210212 {
211- return static ::YAML_COMMENT . "\n" . Yaml::dump ($ this ->findRoutes ());
213+ return static ::YAML_COMMENT . PHP_EOL . Yaml::dump ($ this ->findRoutes ());
212214 }
213215
214216 /**
215217 * Finds and merges the configuration in all installed modules.
216218 *
217219 * @return array configuration which can be dumped in a config_modules.yml file
218220 *
219- * @throws \ InvalidArgumentException
221+ * @throws InvalidArgumentException
220222 */
221223 public function findGeneralConfiguration (): array
222224 {
@@ -244,9 +246,9 @@ public function findGeneralConfiguration(): array
244246 *
245247 * @return void
246248 *
247- * @throws \ InvalidArgumentException if $extra has an invalid routes configuration
249+ * @throws InvalidArgumentException if $extra has an invalid routes configuration
248250 */
249- private function validateGeneralConfigurationSectionInExtra (array $ extra )
251+ private function validateGeneralConfigurationSectionInExtra (array $ extra ): void
250252 {
251253 if (!isset ($ extra ['phplist/core ' ])) {
252254 return ;
@@ -257,7 +259,7 @@ private function validateGeneralConfigurationSectionInExtra(array $extra)
257259 return ;
258260 }
259261 if (!is_array ($ extra ['phplist/core ' ]['configuration ' ])) {
260- throw new \ InvalidArgumentException (
262+ throw new InvalidArgumentException (
261263 'The extras.phplist/core.configuration section in the composer.json must be an array. ' ,
262264 1508165934
263265 );
@@ -273,6 +275,6 @@ private function validateGeneralConfigurationSectionInExtra(array $extra)
273275 */
274276 public function createGeneralConfigurationYaml (): string
275277 {
276- return static ::YAML_COMMENT . "\n" . Yaml::dump ($ this ->findGeneralConfiguration ());
278+ return static ::YAML_COMMENT . PHP_EOL . Yaml::dump ($ this ->findGeneralConfiguration ());
277279 }
278280}
0 commit comments