@@ -58,7 +58,7 @@ class MigrationService {
5858 /**
5959 * @throws \Exception
6060 */
61- public function __construct ($ appName , Connection $ connection , ?IOutput $ output = null , ?AppLocator $ appLocator = null ) {
61+ public function __construct (string $ appName , Connection $ connection , ?IOutput $ output = null , ?AppLocator $ appLocator = null ) {
6262 $ this ->appName = $ appName ;
6363 $ this ->connection = $ connection ;
6464 if ($ output === null ) {
@@ -100,18 +100,15 @@ public function __construct($appName, Connection $connection, ?IOutput $output =
100100
101101 /**
102102 * Returns the name of the app for which this migration is executed
103- *
104- * @return string
105103 */
106- public function getApp () {
104+ public function getApp (): string {
107105 return $ this ->appName ;
108106 }
109107
110108 /**
111- * @return bool
112109 * @codeCoverageIgnore - this will implicitly tested on installation
113110 */
114- private function createMigrationTable () {
111+ private function createMigrationTable (): bool {
115112 if ($ this ->migrationTableCreated ) {
116113 return false ;
117114 }
@@ -188,7 +185,7 @@ public function getMigratedVersions() {
188185 ->where ($ qb ->expr ()->eq ('app ' , $ qb ->createNamedParameter ($ this ->getApp ())))
189186 ->orderBy ('version ' );
190187
191- $ result = $ qb ->execute ();
188+ $ result = $ qb ->executeQuery ();
192189 $ rows = $ result ->fetchAll (\PDO ::FETCH_COLUMN );
193190 $ result ->closeCursor ();
194191
@@ -197,15 +194,17 @@ public function getMigratedVersions() {
197194
198195 /**
199196 * Returns all versions which are available in the migration folder
200- *
201- * @return array
197+ * @return list<string>
202198 */
203- public function getAvailableVersions () {
199+ public function getAvailableVersions (): array {
204200 $ this ->ensureMigrationsAreLoaded ();
205201 return array_map ('strval ' , array_keys ($ this ->migrations ));
206202 }
207203
208- protected function findMigrations () {
204+ /**
205+ * @return array<string, string>
206+ */
207+ protected function findMigrations (): array {
209208 $ directory = realpath ($ this ->migrationsPath );
210209 if ($ directory === false || !file_exists ($ directory ) || !is_dir ($ directory )) {
211210 return [];
@@ -322,10 +321,9 @@ public function getMigrationsDirectory() {
322321 /**
323322 * Return the explicit version for the aliases; current, next, prev, latest
324323 *
325- * @param string $alias
326324 * @return mixed|null|string
327325 */
328- public function getMigration ($ alias ) {
326+ public function getMigration (string $ alias ) {
329327 switch ($ alias ) {
330328 case 'current ' :
331329 return $ this ->getCurrentVersion ();
@@ -342,29 +340,22 @@ public function getMigration($alias) {
342340 return '0 ' ;
343341 }
344342
345- /**
346- * @param string $version
347- * @param int $delta
348- * @return null|string
349- */
350- private function getRelativeVersion ($ version , $ delta ) {
343+ private function getRelativeVersion (string $ version , int $ delta ): ?string {
351344 $ this ->ensureMigrationsAreLoaded ();
352345
353346 $ versions = $ this ->getAvailableVersions ();
354- array_unshift ($ versions , 0 );
347+ array_unshift ($ versions , '0 ' );
348+ /** @var int $offset */
355349 $ offset = array_search ($ version , $ versions , true );
356350 if ($ offset === false || !isset ($ versions [$ offset + $ delta ])) {
357351 // Unknown version or delta out of bounds.
358352 return null ;
359353 }
360354
361- return (string ) $ versions [$ offset + $ delta ];
355+ return (string )$ versions [$ offset + $ delta ];
362356 }
363357
364- /**
365- * @return string
366- */
367- private function getCurrentVersion () {
358+ private function getCurrentVersion (): string {
368359 $ m = $ this ->getMigratedVersions ();
369360 if (count ($ m ) === 0 ) {
370361 return '0 ' ;
@@ -374,11 +365,9 @@ private function getCurrentVersion() {
374365 }
375366
376367 /**
377- * @param string $version
378- * @return string
379368 * @throws \InvalidArgumentException
380369 */
381- private function getClass ($ version ) {
370+ private function getClass (string $ version ): string {
382371 $ this ->ensureMigrationsAreLoaded ();
383372
384373 if (isset ($ this ->migrations [$ version ])) {
@@ -390,21 +379,16 @@ private function getClass($version) {
390379
391380 /**
392381 * Allows to set an IOutput implementation which is used for logging progress and messages
393- *
394- * @param IOutput $output
395382 */
396- public function setOutput (IOutput $ output ) {
383+ public function setOutput (IOutput $ output ): void {
397384 $ this ->output = $ output ;
398385 }
399386
400387 /**
401388 * Applies all not yet applied versions up to $to
402- *
403- * @param string $to
404- * @param bool $schemaOnly
405389 * @throws \InvalidArgumentException
406390 */
407- public function migrate ($ to = 'latest ' , $ schemaOnly = false ) {
391+ public function migrate (string $ to = 'latest ' , bool $ schemaOnly = false ): void {
408392 if ($ schemaOnly ) {
409393 $ this ->migrateSchemaOnly ($ to );
410394 return ;
@@ -425,11 +409,9 @@ public function migrate($to = 'latest', $schemaOnly = false) {
425409
426410 /**
427411 * Applies all not yet applied versions up to $to
428- *
429- * @param string $to
430412 * @throws \InvalidArgumentException
431413 */
432- public function migrateSchemaOnly ($ to = 'latest ' ) {
414+ public function migrateSchemaOnly (string $ to = 'latest ' ): void {
433415 // read known migrations
434416 $ toBeExecuted = $ this ->getMigrationsToExecute ($ to );
435417
0 commit comments