-
Notifications
You must be signed in to change notification settings - Fork 660
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
Option to assume all files get included? #1154
Comments
Creating a fake entry point that includes everything solves the noted problem, I'd still be interested if there is a configuration option to assume this mode of operation.
Psalm dosn't seem to be aware of the CURL constants like CURLOPT_POSTFIELDS, or Imagick extension. It's also missing the mcrypt constants which are used by phpmailer. It's also getting confused by my template system which uses extract() I've just filtered out the templates as I don't see that much value in checking them. |
As far as I understand, Psalm expects you to include those files from your autoloader script, and specify that script in Psalm config file (see |
Hi weirdan, with the exception of some 3rd party code, this system doesn't use php's autoload system, everything is included manually, most of it optionally at runtime. I've discussed this with the author previously. Issues with curl was due to me not having curl installed locally, I usually edit this code remotely with sshfs, but an running psalm locally. I just attempted to ignore errors from the 3rd party code I use with:
Doing so throws an exception, it works without this line but generates a lot of errors from the 3rd party code:
|
You mentioned Wordpress in your earlier ticket, and the way I analysed that is instructive here. Psalm was only configured to analyse a couple of entrypoint PHP files (e.g. app/main.php in your example) and it then analysed the includes as they appeared in the files, recursively. |
Thanks, that was a misinterpretation on my part then. |
Do you have any idea what would cause the exception above? |
@robehickman running with |
@muglug It's crashing on PHPMailer get oauth token. PHPMailer optionally has support for oauth, I'm not using that feature.
If I remove the two files related to oauth from pmpmailer, the issue goes away. |
Awesome, thanks. I’ll have a look tonight. |
Tried reproducing with latest version of PHPMailer, no luck. Would you mind zipping your version of PHPMailer and sending? |
@muglug No problem, will do tomorrow. |
It is version 5.2.23. |
Here you go, this is a minimal example that crashes: http://files.robehickman.com/psalm_crash.zip I'm using PHP 7.0.32-0ubuntu0.16.04.1 (cli) ( NTS ) in case that matters. |
perfect - should have a fix tonight |
Hopefully it crashes for you. Relating to dead code detection, psalm detects both of the following vars as unused, when they are being used. They are passed as an array into a template.
|
Reproduced here: https://getpsalm.org/r/d8e47866e9 |
Thanks for your patience, and for helping to improve Psalm! |
No problem, It's already found a few problems with my code and I foresee it being a useful tool for me. If you have time, it would be good if the section of the documentation on checking templates was fleshed out a bit more, with an example of variables being passed to a template, a template which uses them, and the plasm plug-in which processes this. I can't currently follow the example template checker class as I'm unsure what the expected input is. |
Relating to the comment posted yesterday on my previous issue, this is a minimal case:
File app/a.php
b.php
main.php
What I had assumed is that 'directory' recursively includes all files into the global namespace, which does not appear to be the case.
In my actual code, the main entry point is './src/main.php', this includes a small number of always loaded files which define global helper functions like select_keys() above. From this point, the system calls a dispatcher which includes a 'controller' file depending on the URL (validated against a statically built array), represented here by b.php. As this is data driven, Psalm can't see it.
It is safe to assume that all files always get included, as this will not cause name collision, the lazy loading is done as an optimisation. Is there a configuration option to say 'assume that every file is included?', or do I need to create a 'fake' entry point file that includes everything?
The text was updated successfully, but these errors were encountered: