phinx: No More migration possible : error creating AbstractMigration because of type int for the second parameter

Hello,

Since upgrade to 0.13.0, we can’t anymore run migration scripte cause of the following error : TypeError: Argument 2 passed to Phinx\Migration\AbstractMigration::__construct() must be of the type int, string given,

Error throwed by line 824 into Phinx\Migration\Manager.php // instantiate it $migration = new $class($environment, $version, $this->getInput(), $this->getOutput());

$version is initialised at line 779 by the method Util::getVersionFromFileName which return a string value

src/Phinx/Migration/AbstractMigration.php image

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 18 (11 by maintainers)

Most upvoted comments

Do you need me to retest and put the errors here?

This should have been fixed in 0.13.3 from #2150. There were no changes in 0.13.4 related to this codepath, so I’d expect the same error on 0.x-dev as 0.13.3.

The two paths would be:

  1. Make it so that $version can be a string everywhere
  2. Make it so that $version is an integer everywhere (what we’re currently doing)

For case (2), it would just be modifying Util::getVersionFromFileName so that it casts its regex match to an integer and update the type appropriately.

The root cause of the bug is that while we added typing everywhere, we didn’t add declare(strict_types=1); everywhere as well so there’s some amount of implicit conversion happening that need to track down and eliminate (such as here, as well as in casting $version in the CLI commands appropriately).