yii2 icon indicating copy to clipboard operation
yii2 copied to clipboard

Adopt Psalm

Open samdark opened this issue 3 years ago • 8 comments

See #19174

samdark avatar Jan 19 '22 12:01 samdark

need

  1. generate stubs
  2. require dev package Yii2 extension for PHPStan

WinterSilence avatar Jan 28 '22 15:01 WinterSilence

@samdark I have been working on a Yii2 plugin for psalm . It mainly resolves types for getters and setters, but things like database fields can also support in the future.

I don't think there is a need for generating stubs, only updating some doc blocks to support psalm types. We have some examples of supporting one and all methods on ActiveQuery in our stubs I would be nice to get them upstream somehow, then we can remove the stubs.

Feel free to have a poke around, sorry the docs are not there yet if you want any info then let me know, and I will do what I can to help.

AdeAttwood avatar Jan 31 '22 10:01 AdeAttwood

would be nice to get them upstream somehow

@AdeAttwood well, a pull request would do.

samdark avatar Jan 31 '22 11:01 samdark

@AdeAttwood do you see latest manual? Stub files

  1. stubs using to specify special/custom PHPDoc tags when it's need
  2. with stubs analyze work faster
  3. practically/psalm-plugin-yii2 doesn't cover code well enough(behaviors, application, AR attributes and etc.) + require >=PHP 7.1

WinterSilence avatar Jan 31 '22 11:01 WinterSilence

@AdeAttwood well, a pull request would do.

Yea, we can do that. There will need to be some discussion on the types. It is quite opinionated about the doc blocks, for example you will get an error about missing template parameters, but this can be discussed more on the upcoming PR :+1:.

@WinterSilence this not the purpose of the stubs. From the psalm docs you linked to.

Stub files provide a way to override third-party type information when you cannot add Psalm's extended docblocks to the upstream source files directly.

For most of it Yii2 type definitions are really good, we have created stubs to override the types defined by Yii2

AdeAttwood avatar Jan 31 '22 12:01 AdeAttwood

@AdeAttwood

Stub files provide a way to override third-party type information when you cannot add Psalm's extended docblocks to the upstream source files directly.

is

stubs using to specify special/custom PHPDoc tags when it's need

but this is not only purpose of stubs

For most of it Yii2 type definitions are really good, we have created stubs to override the types defined by Yii2

I'm know how work this plugin - as you remember, I also contribute it. But plugin doesn't cover Yii2 features(behaviors, application/modules, DI, AR attributes) well enough and in some cases it does more harm than useful - we can't easy analyze methods/properties of Yii2 classes extending BaseObject only by code, but that's plugin trying do it and fail.

WinterSilence avatar Jan 31 '22 13:01 WinterSilence

@AdeAttwood https://github.com/yiisoft/yii2/pull/19174#issuecomment-1024346343

WinterSilence avatar Jan 31 '22 13:01 WinterSilence

I do not see this happening, given the conversations. Is there any new information since last time? Is anyone interested in making this happen?

mtangoo avatar Jan 28 '24 19:01 mtangoo

Since Yii2 is in feature freeze mode, I will close this one

mtangoo avatar Apr 02 '24 12:04 mtangoo