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

PHP 8.1 : Undefined index scope_closer with Enum #3763

Closed
dimitriBouteille opened this issue Feb 17, 2023 · 4 comments
Closed

PHP 8.1 : Undefined index scope_closer with Enum #3763

dimitriBouteille opened this issue Feb 17, 2023 · 4 comments

Comments

@dimitriBouteille
Copy link

Describe the bug

When I want to analyze the following code, I have the following error: An error occurred during processing; checking has been aborted. The error message was: Undefined index: scope_closer in /vendor/squizlabs/php_codesniffer/src/Tokenizers/PHP.php on line 2836.

Code sample

<?php
/**
 * 2001-2023 Reflet Communication
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Open Software License (OSL 3.0) that is available
 * through the world-wide-web at this URL: http://www.opensource.org/licenses/OSL-3.0
 * If you are unable to obtain it through the world-wide-web, please send an email
 * to [email protected] so we can send you a copy immediately.
 *
 * @author Reflet Communication
 * @copyright 2001-2023 Reflet Communication
 * @license http://www.opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
 */
declare(strict_types=1);

namespace Reflet\EInvoice\Model\Config\Source;

/**
 * Class ModeProvider
 *
 * @package Reflet\EInvoice\Model\Config\Source
 */
enum ModeProvider: string
{

    case Donation = 'donation';
    case Default = 'default';

    /**
     * @return \Magento\Framework\Phrase
     * @throws \Exception
     */
    public function label(): \Magento\Framework\Phrase
    {
        return match($this) {
            self::Donation => __('Donation'),
            self::Default => __('E-Invoice'),
        };
    }
}

Expected behavior

There should normally be no error with the code mentioned just before.

Versions (please complete the following information):

  • OS: Linux
  • PHP: 8.1
  • PHPCS: 3.7.1 (stable)
@jrfnl
Copy link
Contributor

jrfnl commented Feb 18, 2023

I have a suspicion this may be related to/the same underlying issue as #3750... (untested/unconfirmed, but probably a good idea to look at both code samples when addressing either these)

@jrfnl
Copy link
Contributor

jrfnl commented Aug 14, 2023

@dimitriBouteille I've just tested your code sample on PHP 8.1 with both PHPCS 3.7.1 as well as master and I cannot reproduce the issue.

Please provide additional information with which the issue can be reproduced if you still see the issue. If not, please close the issue.

@jrfnl
Copy link
Contributor

jrfnl commented Aug 14, 2023

Note: the scope_closer index is also not referenced in or around line 2836, I'd have to go back to v 3.6.0 to find a reference to scope_closer on that line. As enums weren't supported until v 3.7.0, that would explain it, but would also mean that the version which the OP claims to use is incorrect.

@dimitriBouteille
Copy link
Author

Hye @jrfnl

I do not reproduce the bug also:)

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

2 participants