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

Classmap autoload for backed enum not working in all cases #10498

Closed
marc-mabe opened this issue Jan 31, 2022 · 0 comments
Closed

Classmap autoload for backed enum not working in all cases #10498

marc-mabe opened this issue Jan 31, 2022 · 0 comments
Labels
Milestone

Comments

@marc-mabe
Copy link
Contributor

I have defined an enum in my code as follows:

<?php

declare(strict_types=1);

namespace App\Value;

enum ReportExecutionStatus:string
{
    // cases
}

But composer fails to extract the class name and extracts ReportExecutionStatus:string instead of ReportExecutionStatus.
If I change the enum definition to enum ReportExecutionStatus: string it works as expected.

My composer.json:

{
    "type": "project",
    "license": "proprietary",
    "minimum-stability": "stable",
    "prefer-stable": true,
    "require": {
        "php": ">=8.1",
        "ext-ctype": "*",
        "ext-iconv": "*",
        "ext-intl": "*",
        "ext-mbstring": "*",
        "ext-pdo": "*",
        "aws/aws-sdk-php": "^3.209.14",
        "doctrine/annotations": "^1.13.2",
        "doctrine/doctrine-bundle": "^2.5.5",
        "doctrine/orm": "^2.11.0",
        "phpdocumentor/reflection-docblock": "^5.3.0",
        "sensio/framework-extra-bundle": "^6.2.6",
        "symfony/asset": "6.0.*",
        "symfony/console": "6.0.*",
        "symfony/dotenv": "6.0.*",
        "symfony/expression-language": "6.0.*",
        "symfony/flex": "^2.1.4",
        "symfony/form": "6.0.*",
        "symfony/framework-bundle": "6.0.*",
        "symfony/http-client": "6.0.*",
        "symfony/intl": "6.0.*",
        "symfony/mailer": "6.0.*",
        "symfony/messenger": "6.0.*",
        "symfony/mime": "6.0.*",
        "symfony/monolog-bundle": "^3.7.1",
        "symfony/notifier": "6.0.*",
        "symfony/process": "6.0.*",
        "symfony/property-access": "6.0.*",
        "symfony/property-info": "6.0.*",
        "symfony/proxy-manager-bridge": "6.0.*",
        "symfony/runtime": "6.0.*",
        "symfony/security-bundle": "6.0.*",
        "symfony/serializer": "6.0.*",
        "symfony/string": "6.0.*",
        "symfony/translation": "6.0.*",
        "symfony/twig-bundle": "6.0.*",
        "symfony/validator": "6.0.*",
        "symfony/web-link": "6.0.*",
        "symfony/webpack-encore-bundle": "^1.13.2",
        "symfony/yaml": "6.0.*",
        "twig/extra-bundle": "^3.3.7",
        "twig/twig": "^3.3.7"
    },
    "require-dev": {
        "friendsofphp/php-cs-fixer": "^3.4.0",
        "jetbrains/phpstorm-attributes": "^1.0",
        "phpstan/phpstan": "^1.4.2",
        "phpstan/phpstan-doctrine": "^1.2.7",
        "phpunit/phpunit": "^9.5.13",
        "symfony/browser-kit": "6.0.*",
        "symfony/css-selector": "6.0.*",
        "symfony/debug-bundle": "6.0.*",
        "symfony/maker-bundle": "^1.36.4",
        "symfony/phpunit-bridge": "^6.0",
        "symfony/stopwatch": "6.0.*",
        "symfony/web-profiler-bundle": "6.0.*"
    },
    "config": {
        "optimize-autoloader": true,
        "preferred-install": {
            "*": "dist"
        },
        "sort-packages": true,
        "allow-plugins": {
            "composer/package-versions-deprecated": true,
            "symfony/flex": true,
            "symfony/runtime": true
        }
    },
    "autoload": {
        "psr-4": {
            "App\\": "src/"
        }
    },
    "autoload-dev": {
        "psr-4": {
            "App\\Tests\\": "tests/"
        }
    },
    "replace": {
        "symfony/polyfill-ctype": "*",
        "symfony/polyfill-iconv": "*",
        "symfony/polyfill-intl-grapheme": "*",
        "symfony/polyfill-intl-icu": "*",
        "symfony/polyfill-intl-idn": "*",
        "symfony/polyfill-intl-messageformatter": "*",
        "symfony/polyfill-intl-normalizer": "*",
        "symfony/polyfill-mbstring": "*",
        "symfony/polyfill-php72": "*",
        "symfony/polyfill-php73": "*",
        "symfony/polyfill-php74": "*",
        "symfony/polyfill-php80": "*",
        "symfony/polyfill-php81": "*"
    },
    "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": "6.0.*"
        }
    }
}

Output of composer diagnose:

$ composer diagnose
Checking composer.json: OK
Checking platform settings: OK
Checking git settings: OK
Checking http connectivity to packagist: OK
Checking https connectivity to packagist: OK
Checking github.com rate limit: OK
Checking disk free space: OK
Checking pubkeys: FAIL
Missing pubkey for tags verification
Missing pubkey for dev verification
Run composer self-update --update-keys to set them up
Checking composer version: OK
Composer version: 2.2.5
PHP version: 8.1.2
PHP binary path: /usr/local/bin/php
OpenSSL version: OpenSSL 1.1.1l  24 Aug 2021
cURL version: 7.80.0 libz 1.2.11 ssl OpenSSL/1.1.1l
zip: extension present, unzip present, 7-Zip not available

When I run this command: composer -vvv dumpautoload I get the following output:

$ composer -vvv dumpautoload
Running 2.2.5 (2022-01-21 17:25:52) with PHP 8.1.2 on Linux / 5.11.0-34-generic
Reading ./composer.json (/app/composer.json)
Loading config file ./composer.json (/app/composer.json)
Checked CA file /etc/pki/tls/certs/ca-bundle.crt does not exist or it is not a file.
Checked directory /etc/pki/tls/certs/ca-bundle.crt does not exist or it is not a directory.
Checked CA file /etc/ssl/certs/ca-certificates.crt: valid
Executing command (/app): git branch -a --no-color --no-abbrev -v
Executing command (/app): git describe --exact-match --tags
Executing command (CWD): git --version
Executing command (/app): git log --pretty="%H" -n1 HEAD
Executing command (/app): hg branch
Executing command (/app): fossil branch list
Executing command (/app): fossil tag list
Executing command (/app): svn info --xml
Failed to initialize global composer: Composer could not find the config file: /.composer/composer.json

Reading /app/vendor/composer/installed.json
Loading plugin Symfony\Flex\Flex (from symfony/flex)
Loading plugin Symfony\Component\Runtime\Internal\ComposerPlugin (from symfony/runtime)
Generating optimized autoload files
Class App\Value\ReportExecutionStatus:string located in ./src/Value/ReportExecutionStatus.php does not comply with psr-4 autoloading standard. Skipping.
> post-autoload-dump: Symfony\Component\Runtime\Internal\ComposerPlugin->updateAutoloadFile
Generated optimized autoload files containing 7212 classes

And I expected this to happen:

No warning, ReportExecutionStatus should be detected as valid PSR-4 and written to autoload_classmap.php.

@Seldaek Seldaek added this to the 2.2 milestone Feb 2, 2022
@Seldaek Seldaek added the Bug label Feb 2, 2022
@Seldaek Seldaek closed this as completed in db8ea45 Feb 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants