Skip to content

PHP 8, #[Attribute] in front of class_alias #149

@rotdrop

Description

@rotdrop

Hi,

I'm using https://github.com/humbug/php-scoper to decouple some composer package requirements from an ambient cloud-software (Nextcloud). ATM this results also in wrapping some Symfony polyfill stuff.

The error message is as follows

ac-php: An error occurred during to re-index: 
PHPParser: Syntax error, unexpected T_NAME_FULLY_QUALIFIED on line 24 - /var/www/localhost/htdocs/nextcloud-git/apps/cafevdb/vendor-wrapped/symfony/polyfill-php80/Resources/stubs/Attribute.php

The offending lines are:

#[Attribute(Attribute::TARGET_CLASS)]
\class_alias('OCA\\CAFEVDB\\Wrapped\\Attribute', 'Attribute', \false);

And finally the complete source:

<?php

namespace OCA\CAFEVDB\Wrapped;

#[Attribute(Attribute::TARGET_CLASS)]
final class Attribute
{
    public const TARGET_CLASS = 1;
    public const TARGET_FUNCTION = 2;
    public const TARGET_METHOD = 4;
    public const TARGET_PROPERTY = 8;
    public const TARGET_CLASS_CONSTANT = 16;
    public const TARGET_PARAMETER = 32;
    public const TARGET_ALL = 63;
    public const IS_REPEATABLE = 64;
    /** @var int */
    public $flags;
    public function __construct(int $flags = self::TARGET_ALL)
    {
        $this->flags = $flags;
    }
}
#[Attribute(Attribute::TARGET_CLASS)]
\class_alias('OCA\\CAFEVDB\\Wrapped\\Attribute', 'Attribute', \false);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions