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

ConstantSpacingSniff warning #1620

Closed
enumag opened this issue Sep 11, 2023 · 3 comments
Closed

ConstantSpacingSniff warning #1620

enumag opened this issue Sep 11, 2023 · 3 comments
Labels

Comments

@enumag
Copy link
Contributor

enumag commented Sep 11, 2023

I got this warning:

Warning: Undefined array key "" in /app/vendor/slevomat/coding-standard/SlevomatCodingStandard/Sniffs/Classes/ConstantSpacingSniff.php on line 61

Warning: Trying to access array offset on value of type null in /app/vendor/slevomat/coding-standard/SlevomatCodingStandard/Sniffs/Classes/ConstantSpacingSniff.php on line 61

It seems to be triggered by an enum class with a const. In my case it was something like this:

enum A: string
{
    public const X = [
        self::A,
        self::B,
    ];

    case A = 'a';

    case B = 'b';
}
@kukulich kukulich added the Bug label Sep 11, 2023
@kukulich
Copy link
Contributor

Thank you for your report.

Fixed in a3c437f

@alies-dev
Copy link

Hey @kukulich
I have the same problem for the following code:

<?php

namespace App;

enum EventCategory: string
{
    public const CATEGORY_SECURITY = 1;

    case FOO = 'BAR';
}
1 | ERROR | [ ] An error occurred during processing; checking has been aborted. The error message was: Undefined array
   |       |     key "" in
   |       |     /Users/alies/code/IxDF/IxDF-web/vendor/slevomat/coding-standard/SlevomatCodingStandard/Sniffs/Classes/ConstantSpacingSniff.php
   |       |     on line 62 (Internal.Exception)

Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 12, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants