Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type error on database manager when running migrations with doctrine enabled #49084

Closed
esteban-serfe opened this issue Nov 22, 2023 · 4 comments

Comments

@esteban-serfe
Copy link

esteban-serfe commented Nov 22, 2023

Laravel Version

10.32.1

PHP Version

8.2.12

Database Driver & Version

PostgreSQL 15.4 on Linux

Description

The following error appears when trying to run the artisan migrate command:


  Illuminate\Database\DatabaseManager::registerConfiguredDoctrineTypes(): Return value must be of type Illuminate\Database\DatabaseManager, none returned

  at vendor/laravel/framework/src/Illuminate/Database/DatabaseManager.php:245
    241▕ 
    242▕         foreach ($this->doctrineTypes as $name => [$type, $class]) {
    243▕             $connection->registerDoctrineType($class, $name, $type);
    244▕         }
  ➜ 245▕     }
    246▕ 
    247▕     /**
    248▕      * Register a custom Doctrine type.
    249▕      *

  1   vendor/laravel/framework/src/Illuminate/Database/DatabaseManager.php:207
      Illuminate\Database\DatabaseManager::registerConfiguredDoctrineTypes(Object(Illuminate\Database\PostgresConnection))

  2   vendor/laravel/framework/src/Illuminate/Database/DatabaseManager.php:100
      Illuminate\Database\DatabaseManager::configure(Object(Illuminate\Database\PostgresConnection))

  3   vendor/laravel/framework/src/Illuminate/Database/Migrations/DatabaseMigrationRepository.php:226
      Illuminate\Database\DatabaseManager::connection("pgsql")

  4   vendor/laravel/framework/src/Illuminate/Database/Migrations/DatabaseMigrationRepository.php:182
      Illuminate\Database\Migrations\DatabaseMigrationRepository::getConnection()

  5   vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php:700
      Illuminate\Database\Migrations\DatabaseMigrationRepository::repositoryExists()

  6   vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/MigrateCommand.php:140
      Illuminate\Database\Migrations\Migrator::repositoryExists()

  7   vendor/laravel/framework/src/Illuminate/Support/helpers.php:248
      Illuminate\Database\Console\Migrations\MigrateCommand::Illuminate\Database\Console\Migrations\{closure}()
  8   vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/MigrateCommand.php:140

  9   vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/MigrateCommand.php:116
      Illuminate\Database\Console\Migrations\MigrateCommand::repositoryExists()

  10  vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/MigrateCommand.php:84
      Illuminate\Database\Console\Migrations\MigrateCommand::prepareDatabase()

  11  vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php:633
      Illuminate\Database\Console\Migrations\MigrateCommand::Illuminate\Database\Console\Migrations\{closure}()

  12  vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/MigrateCommand.php:83
      Illuminate\Database\Migrations\Migrator::usingConnection(Object(Closure))

  13  vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:36
      Illuminate\Database\Console\Migrations\MigrateCommand::handle()

  14  vendor/laravel/framework/src/Illuminate/Container/Util.php:41
      Illuminate\Container\BoundMethod::Illuminate\Container\{closure}()

  15  vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:93
      Illuminate\Container\Util::unwrapIfClosure(Object(Closure))

  16  vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:35
      Illuminate\Container\BoundMethod::callBoundMethod(Object(Illuminate\Foundation\Application), Object(Closure))

  17  vendor/laravel/framework/src/Illuminate/Container/Container.php:662
      Illuminate\Container\BoundMethod::call(Object(Illuminate\Foundation\Application), [])

  18  vendor/laravel/framework/src/Illuminate/Console/Command.php:211
      Illuminate\Container\Container::call()

  19  vendor/symfony/console/Command/Command.php:326
      Illuminate\Console\Command::execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))

  20  vendor/laravel/framework/src/Illuminate/Console/Command.php:180
      Symfony\Component\Console\Command\Command::run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))

  21  vendor/symfony/console/Application.php:1081
      Illuminate\Console\Command::run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

  22  vendor/symfony/console/Application.php:320
      Symfony\Component\Console\Application::doRunCommand(Object(Illuminate\Database\Console\Migrations\MigrateCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

  23  vendor/symfony/console/Application.php:174
      Symfony\Component\Console\Application::doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

  24  vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:201
      Symfony\Component\Console\Application::run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

  25  artisan:35
      Illuminate\Foundation\Console\Kernel::handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

This is solvable by adding return $this on line 245 of src/Illuminate/Database/DatabaseManager.php

Steps To Reproduce

Install laravel
Install laravel-doctrine
Confiugre Postgresql
Run migrations with Eloquen Models & Doctrine entities.

@crynobone
Copy link
Member

Hey there, thanks for reporting this issue.

We'll need more info and/or code to debug this further. Can you please create a repository with the command below, commit the code that reproduces the issue as one separate commit on the main/master branch and share the repository here?

Please make sure that you have the latest version of the Laravel installer in order to run this command. Please also make sure you have both Git & the GitHub CLI tool properly set up.

laravel new bug-report --github="--public"

Do not amend and create a separate commit with your custom changes. After you've posted the repository, we'll try to reproduce the issue.

Thanks!

@driesvints
Copy link
Member

We don't provide direct support for laravel-doctrine sorry. Please open an issue on their repo.

@esteban-serfe
Copy link
Author

We don't provide direct support for laravel-doctrine sorry. Please open an issue on their repo.

The code is not on laravel-doctrine vendor folder. It's https://github.com/laravel/framework/blob/10.x/src/Illuminate/Database/DatabaseManager.php#L242

Will report the issue on laravel-doctrine anyway.

@crynobone
Copy link
Member

Illuminate\Database\DatabaseManager::registerConfiguredDoctrineTypes(): Return value must be of type Illuminate\Database\DatabaseManager, none returned

@esteban-serfe This error is incorrect and doesn't occur in vanilla Laravel installation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants