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

Fixes #7560 manually look for DOMDocument #7563

Closed
wants to merge 1 commit into from

Conversation

tm1000
Copy link
Contributor

@tm1000 tm1000 commented Feb 2, 2022

Manually look for DOMDocument. See #7560

@AndrolGenhald
Copy link
Collaborator

AndrolGenhald commented Feb 2, 2022

I was thinking a better solution might be to do extension_loaded checks when Psalm is started. It would also be good to ensure the other required extensions are loaded and give a better error message for those too.

@tm1000
Copy link
Contributor Author

tm1000 commented Feb 2, 2022

I was thinking a better solution might be to do extension_loaded checks when Psalm is started. It would also be good to ensure the other required extensions are loaded and give a better error message for those too.

Yes but if you look at the original issue we have to assume Psalm was installed and the extension WAS loaded as they stated that it worked fine from the other CLI entry point, just not language server entry point.

I'm up to checking both but I still think DOMDocument has to be checked through class_exists as a fallback

Note: I also forgot to run phpcs :(

@AndrolGenhald
Copy link
Collaborator

AndrolGenhald commented Feb 2, 2022

Yes but if you look at the original issue we have to assume Psalm was installed and the extension WAS loaded as they stated that it worked fine from the other CLI entry point, just not language server entry point.

If the extension was loaded wouldn't the class have to exist though? I was under the impression that somehow the extension was loaded when running from CLI but not when running the language server from vscode.

@PythooonUser do you have any idea why it worked when running from CLI if you didn't have the XML extension installed?

@KevinVanSonsbeek
Copy link
Contributor

KevinVanSonsbeek commented Feb 3, 2022

I was thinking a better solution might be to do extension_loaded checks when Psalm is started. It would also be good to ensure the other required extensions are loaded and give a better error message for those too.

This is probably the more elegant and reliant solution. Also means it would be easier to find the checks if they're at a consistent check location.

@AndrolGenhald
Copy link
Collaborator

@tm1000 Mystery solved, they were actually different environments. I think the extension_loaded check should catch the problem and ensure that DOMDocument exists without the class_exists check.

@tm1000
Copy link
Contributor Author

tm1000 commented Feb 3, 2022

Yup you are right

So is the location I'm looking the best place to check the extension loaded or is there a better place to check for all extensions

@tm1000
Copy link
Contributor Author

tm1000 commented Feb 3, 2022

It looks like composer 2.0 already does this on startup through autoload.php unless I'm mistaken

https://getcomposer.org/doc/07-runtime.md#platform-check

@AndrolGenhald
Copy link
Collaborator

AndrolGenhald commented Feb 3, 2022

So is the location I'm looking the best place to check the extension loaded or is there a better place to check for all extensions

@orklah?

I would say as early as possible, maybe somewhere in Psalm\Internal\Cli::run()? We definitely want to make sure the check is there for all the ways Psalm can be launched, CLI, language server, Psalter, etc.

It looks like composer 2.0 already does this on startup through autoload.php unless I'm mistaken

Oh, I wasn't aware that was done at runtime, I've only used that through the CLI interface.
"The default value is php-only which only checks the PHP version."
Maybe we can change that to check extensions at runtime too? Then we wouldn't need our own check at all. I think maybe we just need to set "platform-check": true in composer.json.

@tm1000
Copy link
Contributor Author

tm1000 commented Feb 3, 2022

The issue with relying on composer (and yes there is a setting we can put into composer.json to check the extensions) is that it looks to be a 2.0 feature only

@AndrolGenhald
Copy link
Collaborator

AndrolGenhald commented Feb 3, 2022

I think we could require "composer-runtime-api": "^2.0" without causing any problems. I believe it's required anyway due to dependencies, but I could be wrong about that. Is it still possible to use Psalm with composer 1.* without something breaking? Even if it is, it probably won't remain possible for long: https://blog.packagist.com/deprecating-composer-1-support/

@tm1000
Copy link
Contributor Author

tm1000 commented Feb 3, 2022

@AndrolGenhald

That was actually added about a month ago and then removed by @weirdan in a revert (see: weirdan@a4878ac)

I don't think we can require that at this time. Best check might just to be to do it ourselves.

@weirdan
Copy link
Collaborator

weirdan commented Feb 3, 2022

Maybe we can change that to check extensions at runtime too?

That option goes into config entry that works for root packages only, so whatever we set it to would get ignored when people install psalm with "require" : { "vimeo/psalm": "..." }

@tm1000
Copy link
Contributor Author

tm1000 commented Feb 3, 2022

@weirdan good point.

@orklah orklah added PR: Need review release:internal The PR will be included in 'Internal changes' section of the release notes labels Feb 7, 2022
@weirdan
Copy link
Collaborator

weirdan commented Nov 27, 2022

4.x branch is closed now as we prepare for the 5.0 release. Please target the master branch instead.

@weirdan
Copy link
Collaborator

weirdan commented Nov 28, 2022

Superseded by #8782

@weirdan weirdan closed this Nov 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR: Need review release:internal The PR will be included in 'Internal changes' section of the release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants