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

NativeFunctionTypeDeclarationCasingFixer - Introduction #4126

Open
wants to merge 7 commits into
base: master
from

Conversation

Projects
None yet
4 participants
@SpacePossum
Member

SpacePossum commented Nov 29, 2018

closes #3553

$ php php-cs-fixer describe native_function_type_declaration_casing
Description of native_function_type_hint_casing rule.
Type hints (of functions) defined by PHP should be called using the correct casing.

Fixing examples:
 * Example #1.
   ---------- begin diff ----------
   --- Original
   +++ New
   @@ -1,4 +1,4 @@
    <?php
   -function Foo(CALLABLE $bar) {
   +function Foo(callable $bar) {
        return 1;
    }
   
   ----------- end diff -----------

 * Example #2.
   ---------- begin diff ----------
   --- Original
   +++ New
   @@ -1,5 +1,5 @@
    <?php
   -function Foo(INT $a): Bool
   +function Foo(int $a): bool
    {
        return true;
    }
   
   ----------- end diff -----------

 * Example #3.
   ---------- begin diff ----------
   --- Original
   +++ New
   @@ -1,5 +1,5 @@
    <?php
   -function Foo(Iterable $a): VOID
   +function Foo(iterable $a): void
    {
        echo 'Hello world';
    }
   
   ----------- end diff -----------

 * Example #4.
   ---------- begin diff ----------
   --- Original
   +++ New
   @@ -1,5 +1,5 @@
    <?php
   -function Foo(Object $a)
   +function Foo(object $a)
    {
        return 'hi!';
    }
   
   ----------- end diff -----------

@SpacePossum SpacePossum added the feature label Nov 29, 2018

@ntzm

This comment has been minimized.

Contributor

ntzm commented Nov 29, 2018

Is this to work with class methods as well? Tests and description should be updated to reflect that if so.

@SpacePossum

This comment has been minimized.

Member

SpacePossum commented Nov 29, 2018

Is this to work with class methods as well? Tests and description should be updated to reflect that if so.

I've updated some tests, I don't think the doc is off as methods are function (not always true the otherway around)

@SpacePossum SpacePossum changed the title from NativeFunctionTypeHintCasingFixer. - Introduction to NativeFunctionTypeHintCasingFixer - Introduction Nov 29, 2018

ntzm and others added some commits Nov 29, 2018

Update src/Fixer/Casing/NativeFunctionTypeHintCasingFixer.php
Co-Authored-By: SpacePossum <possumfromspace@gmail.com>
@ntzm

ntzm approved these changes Nov 29, 2018

@ntzm

This comment has been minimized.

Contributor

ntzm commented Nov 29, 2018

Oh one last thing from me, could you add a test for interface as well?

@ntzm

This comment has been minimized.

Contributor

ntzm commented Nov 29, 2018

LGTM 👍

SpacePossum added some commits Dec 3, 2018

@SpacePossum SpacePossum changed the title from NativeFunctionTypeHintCasingFixer - Introduction to NativeFunctionTypeDeclarationCasingFixer - Introduction Dec 3, 2018

@SpacePossum

This comment has been minimized.

Member

SpacePossum commented Dec 4, 2018

Suggestions for adding this fixer to a set? (maybe a PHP migration one, SF, projects one?)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment