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

make:entity fails: In DoctrineHelper.php line 314: Warning: Invalid argument supplied for foreach() #989

Closed
SieGeL2k16 opened this issue Oct 7, 2021 · 6 comments · Fixed by #993

Comments

@SieGeL2k16
Copy link

I've tried to create a new entity in an existing project.
Called the command make:entity, entered the name of the new Entity and right after this got the following warning:

bin/console make:entity

 Class name of the entity to create or update (e.g. TinyChef):
> EsserFiles


In DoctrineHelper.php line 314:
                                                    
  Warning: Invalid argument supplied for foreach()  
                                                    

make:entity [-a|--api-resource] [-b|--broadcast] [--regenerate] [--overwrite] [--] [<name>]

I've checked the DoctrineHelper.php @ line 314 and the foreach() Parameter $this->mappingDriversByPrefix is NULL.

As a workaround I've added a check if $this->mappingDriversByPrefix is not null and the make:entity is working.

However I'm not sure if this is the desired behavour.

@weaverryan
Copy link
Member

Hmm. Can you post your versions of doctrine/doctrine-bundle, doctrine/orm and doctrine/dbal? This behavior is related to those versions... so it could be some problem specific to a version mix you have. Regardless, it certainly looks like a bug.

@SieGeL2k16
Copy link
Author

@weaverryan Here it goes:

doctrine/doctrine-bundle 2.1.2
doctrine/orm 2.10.1
doctrine/dbal 2.13.4

Just tried this with PHP 8.0.11 (my original post was tested with PHP 7.4.24), and got almost the same error:

bin/console make:entity

 Class name of the entity to create or update (e.g. DeliciousPuppy):
 > TestSascha


In DoctrineHelper.php line 314:

  Warning: foreach() argument must be of type array|object, null given

@weaverryan
Copy link
Member

weaverryan commented Oct 13, 2021

Hmm, ok my guess is that we have a bug in DoctrineBundle LESS than 2.3 & MakerBundle 1.34.0, because we modified this behavior in that release: 9ecc684#diff-ac3a9e6886ce5b8d1d6a3742fa169ee859a8a140d1bbf8a03f1a56335607ade6

@weaverryan
Copy link
Member

fixed in #993

@SieGeL2k16
Copy link
Author

Just checked again after doing a composer update and make:entity is now working, thanks for fixing!

@amonkonanBYF
Copy link

Hi! I use symfony 4.3.11 version and i have a same problem.
composer -version 2.1.9.

i was update Maker-Bundle 1.34 and Doctrine-Bundle 2.3. But its'nt work.

my composer.json

{
    "type": "project",
    "license": "proprietary",
    "require": {
        "php": "^7.1.3",
        "ext-ctype": "*",
        "ext-iconv": "*",
        "ext-json": "*",
        "api-platform/core": "^2.5",
        "aws/aws-sdk-php": "^3.89",
        "cocur/slugify": "^4.0",
        "csa/guzzle-bundle": "^3.1",
        "doctrine/annotations": "^1.0",
        "doctrine/doctrine-bundle": "1.11",
        "doctrine/doctrine-migrations-bundle": "^2.0",
        "doctrine/orm": "^2.7",
        "hidehalo/nanoid-php": "^1.1",
        "jms/serializer-bundle": "^3.6",
        "knplabs/knp-gaufrette-bundle": "^0.5.3",
        "league/flysystem-bundle": "^1.5",
        "lexik/jwt-authentication-bundle": "^2.6",
        "liip/imagine-bundle": "^2.2",
        "mikehaertl/php-pdftk": "^0.9.1",
        "nelmio/cors-bundle": "^2.1",
        "phpdocumentor/reflection-docblock": "^5.3",
        "phpoffice/phpspreadsheet": "^1.15",
        "phpoffice/phpword": "^0.17.0",
        "sensio/framework-extra-bundle": "^5.2",
        "spatie/dropbox-api": "^1.17",
        "spatie/flysystem-dropbox": "^1.2",
        "symfony/apache-pack": "^1.0",
        "symfony/asset": "4.3.*",
        "symfony/console": "4.3.*",
        "symfony/dotenv": "4.3.*",
        "symfony/event-dispatcher": "4.3.*",
        "symfony/expression-language": "4.3.*",
        "symfony/flex": "^1.1",
        "symfony/form": "4.3.*",
        "symfony/framework-bundle": "4.3.*",
        "symfony/http-client": "4.3.*",
        "symfony/ldap": "4.3.*",
        "symfony/monolog-bundle": "^3.5",
        "symfony/property-access": "4.3.*",
        "symfony/property-info": "4.3.*",
        "symfony/security-bundle": "4.3.*",
        "symfony/serializer": "4.3.*",
        "symfony/swiftmailer-bundle": "^3.2",
        "symfony/translation": "4.3.*",
        "symfony/twig-bundle": "4.3.*",
        "symfony/validator": "4.3.*",
        "symfony/yaml": "4.3.*",
        "vich/uploader-bundle": "^1.9",
        "webonyx/graphql-php": "^0.13.0"
    },
    "config": {
        "preferred-install": {
            "*": "dist"
        },
        "sort-packages": true
    },
    "autoload": {
        "psr-4": {
            "App\\": "src/"
        }
    },
    "autoload-dev": {
        "psr-4": {
            "App\\Tests\\": "tests/"
        }
    },
    "replace": {
        "paragonie/random_compat": "2.*",
        "symfony/polyfill-ctype": "*",
        "symfony/polyfill-iconv": "*",
        "symfony/polyfill-php71": "*",
        "symfony/polyfill-php70": "*",
        "symfony/polyfill-php56": "*"
    },
    "scripts": {
        "auto-scripts": {
            "cache:clear": "symfony-cmd",
            "assets:install %PUBLIC_DIR%": "symfony-cmd"
        },
        "post-install-cmd": [
            "@auto-scripts"
        ],
        "post-update-cmd": [
            "@auto-scripts"
        ]
    },
    "conflict": {
        "symfony/symfony": "*"
    },
    "extra": {
        "symfony": {
            "allow-contrib": false,
            "require": "4.3.*"
        }
    },
    "require-dev": {
        "dama/doctrine-test-bundle": "^6.3",
        "doctrine/doctrine-fixtures-bundle": "^3.3",
        "guzzlehttp/guzzle": "^6.5",
        "symfony/browser-kit": "4.3.*",
        "symfony/css-selector": "4.3.*",
        "symfony/maker-bundle": "^1.15",
        "symfony/phpunit-bridge": "^5.0",
        "symfony/stopwatch": "4.3.*",
        "symfony/web-profiler-bundle": "4.3.*",
        "symfony/web-server-bundle": "4.3.*"
    }
}

Sorry for my english.

weaverryan added a commit that referenced this issue Nov 16, 2021
…averryan)

This PR was merged into the 1.0-dev branch.

Discussion
----------

Avoid iterating on null for DoctrineBundle 2.2 and lower

Fixes #989

Commits
-------

53dec5c Avoid iterating on null for DoctrineBundle 2.2 and lower
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants