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

Source stubber based on jetbrains/phpstorm-stubs #373

Merged
merged 11 commits into from
Apr 20, 2019

Conversation

kukulich
Copy link
Collaborator

@kukulich kukulich commented Sep 22, 2017

Proof of concept to have something to discuss.

Copy link
Member

@Ocramius Ocramius left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Partial review for now - will get back to this :-)

composer.json Outdated Show resolved Hide resolved
phpstan.neon Show resolved Hide resolved
src/SourceLocator/SourceStubber/AggregateSourceStubber.php Outdated Show resolved Hide resolved
src/SourceLocator/SourceStubber/AggregateSourceStubber.php Outdated Show resolved Hide resolved
src/SourceLocator/SourceStubber/AggregateSourceStubber.php Outdated Show resolved Hide resolved
src/SourceLocator/SourceStubber/AggregateSourceStubber.php Outdated Show resolved Hide resolved
@kukulich
Copy link
Collaborator Author

@Ocramius just for your info: a lot of tests are missing here currently, I will write them later when I know you are ok with the interface etc :)

@kukulich kukulich force-pushed the source-stubber branch 2 times, most recently from c99097d to 0e54523 Compare September 25, 2017 21:16
@theofidry
Copy link
Contributor

The repo is now tagged https://github.com/JetBrains/phpstorm-stubs/releases/tag/2018.1.2 :)

@asgrim
Copy link
Member

asgrim commented Apr 25, 2018

that's one hell of a high major version 😀

@kukulich kukulich force-pushed the source-stubber branch 3 times, most recently from 93096e7 to 9149d75 Compare May 23, 2018 06:31
Copy link
Member

@asgrim asgrim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The title says WIP, but this seems reasonable addition now - is there anything stopping a rebase to fix conflicts and getting this merged @kukulich ? Thanks

@kukulich
Copy link
Collaborator Author

@asgrim If there are no objections about the way how I've implemented it I can rebase it, add tests and prepare for final review :)

@asgrim
Copy link
Member

asgrim commented Jan 26, 2019

@kukulich no objections here; seems fine to me 👍

@jcsilkey
Copy link

Hello!

I just started working on a similar effort (https://github.com/jcsilkey/BetterReflection/tree/stubber) for my own personal usage before I looked and saw this PR existed. I wasn't aiming to replace the internal stubs with the JetBrains stubs but rather a different set and therefore needed to refactor the SourceLocator to be able to pass in a custom Stubber instance. Anyhow, I see that this PR hasn't been updated in a quite a while and I'd be willing to consolidate the two and update it if there are no objections (particularly from @kukulich since this is his work).

Thanks!

@asgrim
Copy link
Member

asgrim commented Feb 26, 2019

@jcsilkey interesting: what is the use case you're trying to solve? BR can already load classes from files (e.g. SingleFileSourceLocator for single files, DirectoriesSourceLocator for anything in a folder), so I'm wondering if they can't just be used. I'm assuming you have a directory of PHP files for the stubs, otherwise, in what form would you be supplying the stubs? Is it just because the JB stubs aren't sufficient?

General side note for @Ocramius / @kukulich - I wonder if it makes sense to replace the mechanism of PhpInternalSourceLocator with just a wrapper around DirectoriesSourceLocator that points to the JB stubs...?

@Ocramius
Copy link
Member

Ocramius commented Feb 26, 2019 via email

@kukulich
Copy link
Collaborator Author

I plan to rebase this PR in March.

@sebastianbergmann
Copy link

@kukulich Can you foresee when you'll be able to rebase this PR? Thanks! I am asking because of sebastianbergmann/phpunit#3577 (comment).

@kukulich
Copy link
Collaborator Author

@sebastianbergmann It’s in progress. Both chilldren were ill in March so less free time than expected :( I hope I will finish it in 14 days

@sebastianbergmann
Copy link

@kukulich Thanks for the update. Familiy first! Hope your children are no longer ill.

composer.json Outdated Show resolved Hide resolved
@kukulich
Copy link
Collaborator Author

The PR is rebased and build is green (Travis is green, AppVeyor is 💩 )

I have to still write new tests.

@Ocramius
Copy link
Member

@kukulich btw, sorry for not noticing this patch before!

@Ocramius
Copy link
Member

AppVeyor failures are coming from "standard Windows PHP environment weirdness", so they can be ignored.

@Ocramius Ocramius changed the title WIP Source stubber based on jetbrains/phpstorm-stubs Source stubber based on jetbrains/phpstorm-stubs Apr 20, 2019
@Ocramius Ocramius merged commit df78b55 into Roave:master Apr 20, 2019
@Ocramius
Copy link
Member

Thanks @kukulich!

@Ocramius Ocramius modified the milestones: 4.0.0, 3.3.0 Apr 20, 2019
/**
* Determine if a stub exists for specified class name
*/
public function hasStub(string $className) : bool
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For future readers: this is indeed a BC break, but since this is an internal component (which is erroneously not marked as @internal), we can ignore it.

@kukulich
Copy link
Collaborator Author

@Ocramius You are really fast :) As I mentioned in previous comment, tests are missing. I’ll send PR with them ASAP (next week)

@Ocramius
Copy link
Member

Urghh, I'll need a coverage threshold plugin to be added to the build to prevent this. I expect to finish up another patch today, so we'll likely also have 3.4.0.

@kukulich kukulich deleted the source-stubber branch April 21, 2019 07:20
{
parent::__construct($astLocator);

$this->stubber = new SourceStubber();
$this->stubber = $stubber ?? new ReflectionSourceStubber();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't this include the phpstorm stubber as well?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@theofidry No, because it would be BC break.

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.

9 participants