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

Allow magic methods __serialize and __unserialize in CamelCapsFunctionNameSniff #3029

Closed
ludekbenedik opened this issue Jul 22, 2020 · 0 comments · Fixed by #3031
Closed

Comments

@ludekbenedik
Copy link

ludekbenedik commented Jul 22, 2020

Describe the bug
The sniff Generic.NamingConventions.CamelCapsFunctionName.MethodDoubleUnderscore does not known magic methods __serialize and __unserialize.

Code sample

<?php declare(strict_types = 1);

namespace App;

class Test
{
    public function __serialize(): array
    {
        return [];
    }

    public function __unserialize(array $data): void
    {
    }
}

To reproduce

  7 | ERROR | Method name "Test::__serialize" is invalid; only PHP
    |       | magic methods should be prefixed with a double
    |       | underscore
    |       | (Generic.NamingConventions.CamelCapsFunctionName.MethodDoubleUnderscore)
 12 | ERROR | Method name "Test::__unserialize" is invalid; only PHP
    |       | magic methods should be prefixed with a double
    |       | underscore
    |       | (Generic.NamingConventions.CamelCapsFunctionName.MethodDoubleUnderscore)

Expected behavior
None error

Versions (please complete the following information):

  • OS: [*]
  • PHP: [7.4]
  • PHPCS: [3.5.5 (stable)]
  • Standard: [Generic]
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.

1 participant