@@ -49,7 +49,7 @@ class Config implements ConfigInterface, NamespaceAwareInterface
49
49
* @param array $configArray Config array
50
50
* @param string|null $configFilePath Config file path
51
51
*/
52
- public function __construct (array $ configArray , $ configFilePath = null )
52
+ public function __construct (array $ configArray , ? string $ configFilePath = null )
53
53
{
54
54
$ this ->configFilePath = $ configFilePath ;
55
55
$ this ->values = $ this ->replaceTokens ($ configArray );
@@ -62,7 +62,7 @@ public function __construct(array $configArray, $configFilePath = null)
62
62
* @throws \RuntimeException
63
63
* @return \Phinx\Config\Config
64
64
*/
65
- public static function fromYaml ($ configFilePath )
65
+ public static function fromYaml (string $ configFilePath ): Config
66
66
{
67
67
if (!class_exists ('Symfony \\Component \\Yaml \\Yaml ' , true )) {
68
68
// @codeCoverageIgnoreStart
@@ -90,7 +90,7 @@ public static function fromYaml($configFilePath)
90
90
* @throws \RuntimeException
91
91
* @return \Phinx\Config\Config
92
92
*/
93
- public static function fromJson ($ configFilePath )
93
+ public static function fromJson (string $ configFilePath ): Config
94
94
{
95
95
if (!function_exists ('json_decode ' )) {
96
96
// @codeCoverageIgnoreStart
@@ -116,7 +116,7 @@ public static function fromJson($configFilePath)
116
116
* @throws \RuntimeException
117
117
* @return \Phinx\Config\Config
118
118
*/
119
- public static function fromPhp ($ configFilePath )
119
+ public static function fromPhp (string $ configFilePath ): Config
120
120
{
121
121
ob_start ();
122
122
/** @noinspection PhpIncludeInspection */
@@ -138,7 +138,7 @@ public static function fromPhp($configFilePath)
138
138
/**
139
139
* @inheritDoc
140
140
*/
141
- public function getEnvironments ()
141
+ public function getEnvironments (): ? array
142
142
{
143
143
if (isset ($ this ->values ) && isset ($ this ->values ['environments ' ])) {
144
144
$ environments = [];
@@ -157,7 +157,7 @@ public function getEnvironments()
157
157
/**
158
158
* @inheritDoc
159
159
*/
160
- public function getEnvironment ($ name )
160
+ public function getEnvironment (string $ name ): ? array
161
161
{
162
162
$ environments = $ this ->getEnvironments ();
163
163
@@ -187,15 +187,15 @@ public function getEnvironment($name)
187
187
/**
188
188
* @inheritDoc
189
189
*/
190
- public function hasEnvironment ($ name )
190
+ public function hasEnvironment (string $ name ): bool
191
191
{
192
192
return $ this ->getEnvironment ($ name ) !== null ;
193
193
}
194
194
195
195
/**
196
196
* @inheritDoc
197
197
*/
198
- public function getDefaultEnvironment ()
198
+ public function getDefaultEnvironment (): string
199
199
{
200
200
// The $PHINX_ENVIRONMENT variable overrides all other default settings
201
201
$ env = getenv ('PHINX_ENVIRONMENT ' );
@@ -242,23 +242,23 @@ public function getDefaultEnvironment()
242
242
/**
243
243
* @inheritDoc
244
244
*/
245
- public function getAlias ($ alias )
245
+ public function getAlias ($ alias ): ? string
246
246
{
247
247
return !empty ($ this ->values ['aliases ' ][$ alias ]) ? $ this ->values ['aliases ' ][$ alias ] : null ;
248
248
}
249
249
250
250
/**
251
251
* @inheritDoc
252
252
*/
253
- public function getAliases ()
253
+ public function getAliases (): array
254
254
{
255
255
return !empty ($ this ->values ['aliases ' ]) ? $ this ->values ['aliases ' ] : [];
256
256
}
257
257
258
258
/**
259
259
* @inheritDoc
260
260
*/
261
- public function getConfigFilePath ()
261
+ public function getConfigFilePath (): string
262
262
{
263
263
return $ this ->configFilePath ;
264
264
}
@@ -267,7 +267,7 @@ public function getConfigFilePath()
267
267
* @inheritDoc
268
268
* @throws \UnexpectedValueException
269
269
*/
270
- public function getMigrationPaths ()
270
+ public function getMigrationPaths (): array
271
271
{
272
272
if (!isset ($ this ->values ['paths ' ]['migrations ' ])) {
273
273
throw new UnexpectedValueException ('Migrations path missing from config file ' );
@@ -280,24 +280,11 @@ public function getMigrationPaths()
280
280
return $ this ->values ['paths ' ]['migrations ' ];
281
281
}
282
282
283
- /**
284
- * Gets the base class name for migrations.
285
- *
286
- * @param bool $dropNamespace Return the base migration class name without the namespace.
287
- * @return string
288
- */
289
- public function getMigrationBaseClassName ($ dropNamespace = true )
290
- {
291
- $ className = !isset ($ this ->values ['migration_base_class ' ]) ? 'Phinx\Migration\AbstractMigration ' : $ this ->values ['migration_base_class ' ];
292
-
293
- return $ dropNamespace ? (substr (strrchr ($ className , '\\' ), 1 ) ?: $ className ) : $ className ;
294
- }
295
-
296
283
/**
297
284
* @inheritDoc
298
285
* @throws \UnexpectedValueException
299
286
*/
300
- public function getSeedPaths ()
287
+ public function getSeedPaths (): array
301
288
{
302
289
if (!isset ($ this ->values ['paths ' ]['seeds ' ])) {
303
290
throw new UnexpectedValueException ('Seeds path missing from config file ' );
@@ -310,13 +297,26 @@ public function getSeedPaths()
310
297
return $ this ->values ['paths ' ]['seeds ' ];
311
298
}
312
299
300
+ /**
301
+ * Gets the base class name for migrations.
302
+ *
303
+ * @param bool $dropNamespace Return the base migration class name without the namespace.
304
+ * @return string
305
+ */
306
+ public function getMigrationBaseClassName (bool $ dropNamespace = true ): string
307
+ {
308
+ $ className = !isset ($ this ->values ['migration_base_class ' ]) ? 'Phinx\Migration\AbstractMigration ' : $ this ->values ['migration_base_class ' ];
309
+
310
+ return $ dropNamespace ? (substr (strrchr ($ className , '\\' ), 1 ) ?: $ className ) : $ className ;
311
+ }
312
+
313
313
/**
314
314
* Gets the base class name for seeders.
315
315
*
316
316
* @param bool $dropNamespace Return the base seeder class name without the namespace.
317
317
* @return string
318
318
*/
319
- public function getSeedBaseClassName ($ dropNamespace = true )
319
+ public function getSeedBaseClassName (bool $ dropNamespace = true ): string
320
320
{
321
321
$ className = !isset ($ this ->values ['seed_base_class ' ]) ? 'Phinx\Seed\AbstractSeed ' : $ this ->values ['seed_base_class ' ];
322
322
@@ -354,7 +354,7 @@ public function getTemplateClass()
354
354
/**
355
355
* {@inheritdoc}
356
356
*/
357
- public function getDataDomain ()
357
+ public function getDataDomain (): array
358
358
{
359
359
if (!isset ($ this ->values ['data_domain ' ])) {
360
360
return [];
@@ -366,7 +366,7 @@ public function getDataDomain()
366
366
/**
367
367
* @inheritDoc
368
368
*/
369
- public function getContainer ()
369
+ public function getContainer (): ? \ Psr \ Container \ ContainerInterface
370
370
{
371
371
if (!isset ($ this ->values ['container ' ])) {
372
372
return null ;
@@ -380,7 +380,7 @@ public function getContainer()
380
380
*
381
381
* @return string
382
382
*/
383
- public function getVersionOrder ()
383
+ public function getVersionOrder (): string
384
384
{
385
385
if (!isset ($ this ->values ['version_order ' ])) {
386
386
return self ::VERSION_ORDER_CREATION_TIME ;
@@ -394,7 +394,7 @@ public function getVersionOrder()
394
394
*
395
395
* @return bool
396
396
*/
397
- public function isVersionOrderCreationTime ()
397
+ public function isVersionOrderCreationTime (): bool
398
398
{
399
399
$ versionOrder = $ this ->getVersionOrder ();
400
400
@@ -421,7 +421,7 @@ public function getBootstrapFile()
421
421
* @param array $arr Array to replace
422
422
* @return array
423
423
*/
424
- protected function replaceTokens (array $ arr )
424
+ protected function replaceTokens (array $ arr ): array
425
425
{
426
426
// Get environment variables
427
427
// Depending on configuration of server / OS and variables_order directive,
@@ -449,7 +449,7 @@ protected function replaceTokens(array $arr)
449
449
* @param string[] $tokens Array of tokens to search for
450
450
* @return array
451
451
*/
452
- protected function recurseArrayForTokens ($ arr , $ tokens )
452
+ protected function recurseArrayForTokens (array $ arr , array $ tokens ): array
453
453
{
454
454
$ out = [];
455
455
foreach ($ arr as $ name => $ value ) {
@@ -476,7 +476,7 @@ protected function recurseArrayForTokens($arr, $tokens)
476
476
* @param array $options Options
477
477
* @return array
478
478
*/
479
- protected function parseAgnosticDsn (array $ options )
479
+ protected function parseAgnosticDsn (array $ options ): array
480
480
{
481
481
$ parsed = Util::parseDsn ($ options ['dsn ' ] ?? '' );
482
482
if ($ parsed ) {
@@ -495,7 +495,7 @@ protected function parseAgnosticDsn(array $options)
495
495
* @param mixed $value Value
496
496
* @return void
497
497
*/
498
- public function offsetSet ($ id , $ value )
498
+ public function offsetSet ($ id , $ value ): void
499
499
{
500
500
$ this ->values [$ id ] = $ value ;
501
501
}
@@ -522,7 +522,7 @@ public function offsetGet($id)
522
522
* @param mixed $id ID
523
523
* @return bool
524
524
*/
525
- public function offsetExists ($ id )
525
+ public function offsetExists ($ id ): bool
526
526
{
527
527
return isset ($ this ->values [$ id ]);
528
528
}
@@ -533,7 +533,7 @@ public function offsetExists($id)
533
533
* @param mixed $id ID
534
534
* @return void
535
535
*/
536
- public function offsetUnset ($ id )
536
+ public function offsetUnset ($ id ): void
537
537
{
538
538
unset($ this ->values [$ id ]);
539
539
}
0 commit comments