Giter Club home page Giter Club logo

Comments (10)

dunglas avatar dunglas commented on May 25, 2024 1

@TomasVotruba do you think we can deprecate this package in favor of Rector?

from phpdoc-to-typehint.

dunglas avatar dunglas commented on May 25, 2024 1

Ok, let me know when you think that there is a feature parity and that the project is stable enough. I'll then archive this repo and redirect to Rector.

from phpdoc-to-typehint.

dunglas avatar dunglas commented on May 25, 2024 1

You're very welcome, I've not the time to actively work on this project anymore, and Rector looks very promising.

from phpdoc-to-typehint.

TomasVotruba avatar TomasVotruba commented on May 25, 2024

This error is very common among other tags as well, due to https://github.com/phpDocumentor/ReflectionDocBlock
You'd have to create own tags with fixes: https://github.com/Symplify/Symplify/blob/f80fada524b7a198782a07836ce20ee13b457900/packages/BetterReflectionDocBlock/src/CleanDocBlockFactory.php#L28

or use more advanced phpdoc-parser: https://github.com/phpstan/phpdoc-parser, that is used also by PHPStan

I tried them both and I must say the later wins 🍾

from phpdoc-to-typehint.

TomasVotruba avatar TomasVotruba commented on May 25, 2024

Few months in the future... :) there is PR in Rector that supports and a solves that:
rectorphp/rector#795

from phpdoc-to-typehint.

TomasVotruba avatar TomasVotruba commented on May 25, 2024

I think so 👍 I've already ported tests from here, from nikic/TypeUtil and from php-cs-fixer today

I plan to add few more tests, than try it on Symfony code and see what happens :) that should be "battle-tested"

from phpdoc-to-typehint.

TomasVotruba avatar TomasVotruba commented on May 25, 2024

Will do, thanks for being open to this 👍

from phpdoc-to-typehint.

TomasVotruba avatar TomasVotruba commented on May 25, 2024

I've tested it on Symfony and released after many bugfixes in Rector v0.3.22.

Apart classic docblock → typehint it includes:

  • skip for override of vendor method without typehint
  • propagation of added typehint on all children - classes and interfaces
  • propagation of added typehint on class that implements interface and that required a method, that is used from a trait
  • PHP 7.1 and nullables by default
  • PHP 7.2 and object typehint enabled by parameter

Install

composer require rector/rector --dev

Setup

# rector.yml
services:
    Rector\Php\Rector\FunctionLike\ParamScalarTypehintRector: ~
    Rector\Php\Rector\FunctionLike\ReturnScalarTypehintRector: ~

Run

vendor/bin/rector process src --dry-run
vendor/bin/rector process src

from phpdoc-to-typehint.

TomasVotruba avatar TomasVotruba commented on May 25, 2024

It's out: https://www.tomasvotruba.cz/blog/2018/12/10/rocket-science-behind-migration-of-docblock-types-to-php-typehints/

from phpdoc-to-typehint.

TomasVotruba avatar TomasVotruba commented on May 25, 2024

Ok, let me know when you think that there is a feature parity and that the project is stable enough. I'll then archive this repo and redirect to Rector.

Btw, this si done since my last comment. Already tagged and used by people, so you you can archive and recommend Rector 🙇‍♂️

from phpdoc-to-typehint.

Related Issues (15)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.