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

Add PHPStan extension for macros #1916

Merged
merged 19 commits into from
Jun 22, 2020
Merged

Add PHPStan extension for macros #1916

merged 19 commits into from
Jun 22, 2020

Conversation

spawnia
Copy link
Contributor

@spawnia spawnia commented Oct 22, 2019

Resolves #1846

Just threw together a WIP (nothing works atm), taking parts from larastan/larastan#301 and Larastan.

@kylekatarnls is this the direction you want this to go?

@kylekatarnls
Copy link
Collaborator

Yep, that's the idea. Thanks a lot. 🥇

@spawnia
Copy link
Contributor Author

spawnia commented Oct 27, 2019

@kylekatarnls i am not too familiar with the inner workings of PHPStan, this is taking me longer than i thought.

There is a whole bunch of abstractions in Larastan that seem unnecessary for us, i tried to strip them away to keep the code as simple as it can be.

Can you take a look and see if you can work with what i have so far? I got the test to a point where it produces usable output, at least.

@kylekatarnls
Copy link
Collaborator

I had some tries but's it's indeed a bit more difficult than I expected. I postpone this for version 2.27.

@kylekatarnls kylekatarnls modified the milestones: 2.26, 2.27 Nov 5, 2019
@kylekatarnls kylekatarnls modified the milestones: 2.27, 2.28 Nov 14, 2019
@kylekatarnls kylekatarnls modified the milestones: 2.28, 2.29 Dec 12, 2019
@kylekatarnls kylekatarnls removed this from the 2.29 milestone Jan 12, 2020
@kylekatarnls kylekatarnls added the postponed Not yet possible but candidate for a next major release label Jan 12, 2020
@kylekatarnls kylekatarnls removed their assignment Jan 14, 2020
@kylekatarnls kylekatarnls marked this pull request as draft April 8, 2020 21:58
@kylekatarnls kylekatarnls changed the title WIP: Add PHPStan extension for macros Add PHPStan extension for macros Apr 8, 2020
@codecov-commenter
Copy link

codecov-commenter commented Jun 20, 2020

Codecov Report

Merging #1916 into master will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@             Coverage Diff             @@
##              master     #1916   +/-   ##
===========================================
  Coverage     100.00%   100.00%           
- Complexity      1994      2027   +33     
===========================================
  Files            883       885    +2     
  Lines           8836      8899   +63     
===========================================
+ Hits            8836      8899   +63     
Impacted Files Coverage Δ Complexity Δ
src/Carbon/CarbonInterval.php 100.00% <ø> (ø) 385.00 <0.00> (ø)
src/Carbon/Traits/Creator.php 100.00% <ø> (ø) 118.00 <0.00> (ø)
src/Carbon/Traits/Localization.php 100.00% <ø> (ø) 128.00 <0.00> (ø)
src/Carbon/Traits/Macro.php 100.00% <ø> (ø) 10.00 <0.00> (ø)
src/Carbon/Traits/Mixin.php 100.00% <ø> (ø) 17.00 <0.00> (ø)
src/Carbon/Traits/Modifiers.php 100.00% <ø> (ø) 47.00 <0.00> (ø)
src/Carbon/Traits/Serialization.php 100.00% <ø> (ø) 20.00 <0.00> (ø)
src/Carbon/Traits/Week.php 100.00% <ø> (ø) 20.00 <0.00> (ø)
src/Carbon/CarbonPeriod.php 100.00% <100.00%> (ø) 317.00 <0.00> (ø)
src/Carbon/PHPStan/Macro.php 100.00% <100.00%> (ø) 30.00 <30.00> (?)
... and 3 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f9996ce...1ae2a00. Read the comment docs.

@kylekatarnls kylekatarnls assigned kylekatarnls and unassigned spawnia Jun 20, 2020
@kylekatarnls kylekatarnls marked this pull request as ready for review June 21, 2020 20:41
@kylekatarnls
Copy link
Collaborator

This extension is ready to be tested:

Require this branch in an app using:

composer require nesbot/carbon:dev-phpstan

Require phpstan + extension-installer:

composer require --dev phpstan/phpstan phpstan/extension-installer

And finally, add the file loading your macros and mixins in the bootstrapFiles list of phpstan.neon:

parameters:
    bootstrapFiles:
        - config/bootstrap.php

@kylekatarnls kylekatarnls added this to the 2.36.0 milestone Jun 21, 2020
@kylekatarnls kylekatarnls merged commit c1a1ab3 into briannesbitt:master Jun 22, 2020
@spawnia spawnia deleted the phpstan branch June 22, 2020 10:26
@spawnia
Copy link
Contributor Author

spawnia commented Jun 22, 2020

Awesome work @kylekatarnls, i tested according to your suggestion. Works perfectly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement postponed Not yet possible but candidate for a next major release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add PHPStan extension for macros
3 participants