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 extension documentation. #7577

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

AndrolGenhald
Copy link
Collaborator

Fixes #7513.

Psalm's stub generator had enough issues that I decided to fork https://github.com/sasezaki/php-extension-stub-generator and get it working again.

I added documentation on how to add/improve support for extensions, and some generated stubs for the extensions I have installed.

- [Templates](../annotating_code/templated_annotations.md)

To use the extension stub generator, download the latest phar at
https://github.com/AndrolGenhald/php-extension-stub-generator/releases and run `php-extension-stub-generator.phar dump
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Does someone want to create psalm/php-extension-stub-generator and move this there?

Copy link
Collaborator

Choose a reason for hiding this comment

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

We'd have to ask Matt I think. Let's do that when it's finished

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Well, I think it is finished, more or less 😛
I was thinking this would be merged as mostly a documentation/process update.

@AndrolGenhald
Copy link
Collaborator Author

To add a bit more clarity here, the intention is that after this is merged, I'll open an issue for each of the extensions here to update the actual stubfile that Psalm uses. I figured it'd be best to do a separate PR for each extension. See adding_an_extension.md for how I expect this process to work, if I don't explain it satisfactorily there I'd rather update the documentation than explain in the PR comments.

@@ -0,0 +1,1019 @@
<?php
// Generated with PHP version 8.1.2 dom version 20031129
Copy link
Collaborator Author

@AndrolGenhald AndrolGenhald Feb 4, 2022

Choose a reason for hiding this comment

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

I named the file dom-8.1.2 because I'm pretty sure this dom version is misleading and the dom extension has actually changed along with php. I'm not sure why it doesn't show the php version like the other php-bundled extensions, but I'm guessing that's a bug on their end.

Edit: Opened php/php-src#8038

@orklah orklah added PR: Need review release:feature The PR will be included in 'Features' section of the release notes labels Feb 7, 2022
@AndrolGenhald
Copy link
Collaborator Author

AndrolGenhald commented Feb 9, 2022

@orklah I'm wondering if we should keep the reflection-generated stubs in a separate repo, there are getting to be quite a number of them and they're not directly needed by Psalm anyway. Do you have any preference there? Maybe I should stick them in the stub generator repo?

I've been working through the extension stubs and updating them to include everything defined by the extensions instead of just stuff to override, do you want me to put that here or open a separate pull request?

@orklah
Copy link
Collaborator

orklah commented Feb 9, 2022

well, you'll end up requiring them anyway and always in the latest version. Also I'm not sure I want to know what will happen the day someone will try using Psalm 5 with stubs made for Psalm 7 :p

But I'm undecided, I don't have much experience on advantages or drawbacks of making separate repos

@AndrolGenhald
Copy link
Collaborator Author

Well the generated stubs aren't used directly, I'm just using them to simplify seeing what's changed between versions. Some of the extensions I'm taking one of the generated stubs as a base and applying stuff from the CallMap/PropertyMap/existing stub on top of that, and I'm using @since to support multiple versions so there's only going to be one stub that's actually used. The reflection-generated stubs I'm just keeping around for historical/diffing purposes, so Psalm doesn't really need them at all.

I tried to explain this as best I could in adding_an_extension.md.

@orklah
Copy link
Collaborator

orklah commented Feb 9, 2022

Yeah, I need to start the review first :p

@AndrolGenhald AndrolGenhald force-pushed the add-extension-documentation branch from 1b2ac47 to edfe00e Compare February 10, 2022 21:55
@AndrolGenhald
Copy link
Collaborator Author

I went ahead and removed them. Should be ready for review.

@AndrolGenhald AndrolGenhald changed the title Add extension documentation and some generated stubs. Add extension documentation. Feb 12, 2022
@orklah
Copy link
Collaborator

orklah commented Feb 22, 2022

Mind rebasing? There seems to be a few build errors that I would not expect.

Otherwise this seems good

@weirdan we might want to create a new repo on psalm org for the stub generator. Is this something you can do?

@weirdan
Copy link
Collaborator

weirdan commented Feb 22, 2022

@orklah I can, but I'll need the name for the repo.

@orklah
Copy link
Collaborator

orklah commented Feb 23, 2022

I think we can keep the current name php-extension-stub-generator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR: Need review release:feature The PR will be included in 'Features' section of the release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants