Navigation Menu

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

PhpdocToPropertyTypeFixer - introduction #4592

Merged

Conversation

julienfalque
Copy link
Member

@julienfalque julienfalque commented Oct 13, 2019

This PR includes #4591 and depends on #4593 which should both be merged first.

@SpacePossum
Copy link
Contributor

👍 looking very nice :)

some minors I found;
the fixer crashes on abstract function like;

abstract public function getFoo(): string;

which seems to be because;

            if ($tokens[$index]->isGivenKind(T_FUNCTION)) {
                $index = $tokens->getNextTokenOfKind($index, ['{']);

secondly, when there are a of candidate the fixer doesn't catch them all in the first run. Test sample;

<?php

class ActivityLog
{
    /**
     * @var int
     */
    private $id;

    /**
     * @var string
     */
    private $id1;

    /**
     * @var string
     */
    private $id2;

    /**
     * @var int
     */
    private $id3;

    /**
     * @var string
     */
    private $id4;

    /**
     * @var string
     */
    private $id5;

    /**
     * @var string
     */
    private $id6;

    /**
     * @var string
     */
    private $id7;

    /**
     * @var int
     */
    private $id8;

    /**
     * @var string
     */
    private $id9;

    /**
     * @var int|null
     */
    private $id410;
}

@julienfalque
Copy link
Member Author

Thanks for the test cases, I fixed them :)

@julienfalque julienfalque force-pushed the phpdoc-to-property-type-fixer branch 2 times, most recently from 7225aa6 to b3d57cc Compare March 21, 2020 17:20
src/AbstractFixer.php Outdated Show resolved Hide resolved
@duxthefux
Copy link

+1 on that. Any estimation on when this can be merged?

@kubawerlos
Copy link
Contributor

@julienfalque can you split this PR to one adding new fixers and 2nd (targeted to 2.15) with refactoring of DocBlock classes?

@julienfalque
Copy link
Member Author

@kubawerlos Is #4591 what you want (this PR depends on it)? It currently targets 2.16 though.

@kubawerlos
Copy link
Contributor

@julienfalque yes, it is. Shame on me.

@SpacePossum SpacePossum changed the title Add PhpdocToPropertyTypeFixer PhpdocToPropertyTypeFixer - introduction May 13, 2020
README.rst Outdated Show resolved Hide resolved
@julienfalque julienfalque force-pushed the phpdoc-to-property-type-fixer branch from b726858 to 7b00b95 Compare June 25, 2020 22:49
@kubawerlos
Copy link
Contributor

Sorry for the conflicts @julienfalque - can you solve them? I believe thee review would be quite straightforward here.

@julienfalque julienfalque force-pushed the phpdoc-to-property-type-fixer branch from 7b00b95 to 16be9fe Compare July 24, 2020 16:40
@julienfalque
Copy link
Member Author

Rebased #4591 and here, please review :)

@GrahamCampbell
Copy link
Contributor

I'd actually question if this belongs in php-cs-fixer. It's more a job for a refactoring tool like Rector, rather than a code style fixing tool.

@Slamdunk
Copy link
Contributor

I'd actually question if this belongs in php-cs-fixer. It's more a job for a refactoring tool like Rector, rather than a code style fixing tool.

We already to a lot of refactoring in PHP-CS-Fixer. Moreover, PHP_CodeSniffer already does it: https://github.com/slevomat/coding-standard/blob/master/SlevomatCodingStandard/Sniffs/TypeHints/PropertyTypeHintSniff.php#L260-L296

@GrahamCampbell
Copy link
Contributor

I don't think we need to add more. It only adds more upgrading work every time a new version of PHP comes out.

@Slamdunk
Copy link
Contributor

I understand your point: it would be good for maintenance to have a fixer tool decoupled from PHP version, and maybe other one (like Rector) for the upgrade path.

But we are a bit late for such approach, aren't we?

@SpacePossum
Copy link
Contributor

@julienfalque please rebase and after that RTM 👍

@julienfalque
Copy link
Member Author

@SpacePossum #4591 should be merged first.

@keradus keradus added this to the 2.19.0 milestone May 3, 2021
@coveralls
Copy link

coveralls commented May 3, 2021

Coverage Status

Coverage increased (+0.02%) to 91.596% when pulling 0382be5 on julienfalque:phpdoc-to-property-type-fixer into 24e9391 on FriendsOfPHP:master.

composer.json Outdated Show resolved Hide resolved
@keradus keradus force-pushed the phpdoc-to-property-type-fixer branch from 7f0cbc5 to 0382be5 Compare May 3, 2021 19:36
@keradus
Copy link
Member

keradus commented May 3, 2021

Thank you @julienfalque.

@keradus keradus merged commit 5698474 into PHP-CS-Fixer:master May 3, 2021
@julienfalque julienfalque deleted the phpdoc-to-property-type-fixer branch May 3, 2021 19:51
@julienfalque
Copy link
Member Author

Thank you @keradus!

@AJenbo
Copy link
Contributor

AJenbo commented Jun 4, 2023

thanks this will be useful

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

Successfully merging this pull request may close these issues.

None yet

9 participants