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

Added phpstan level 0 and fixed various import issues #2510

Merged
merged 16 commits into from
Feb 5, 2024

Conversation

Shadow-Devil
Copy link
Contributor

Part of #2509.
Adds phpstan with level 0, but there were some issues:

aschempp and others added 8 commits February 5, 2024 11:32
# Conflicts:
#	system/modules/isotope/library/Isotope/Model/Attribute/Downloads.php
#	system/modules/isotope/library/Isotope/Model/Attribute/Price.php
#	system/modules/isotope/library/Isotope/Model/Attribute/PriceTiers.php
#	system/modules/isotope/library/Isotope/Model/Attribute/ShippingPrice.php
#	system/modules/isotope/library/Isotope/Model/Attribute/Weight.php
#	system/modules/isotope/library/Isotope/Model/Payment.php
#	system/modules/isotope/library/Isotope/Model/ProductCollection.php
@aschempp aschempp changed the title Feature/phpstan Added phpstan level 0 and fixed various import issues Feb 5, 2024
@aschempp aschempp merged commit 906ceac into isotope:2.9 Feb 5, 2024
@aschempp
Copy link
Member

aschempp commented Feb 5, 2024

Thank you @Shadow-Devil !

@Shadow-Devil
Copy link
Contributor Author

I am a bit confused, since when I now run:
vendor/terminal42/contao-build-tools/tools/phpstan/vendor/bin/phpstan analyze system

There is no #Function file_exists is unsafe to use# matched, which you explicitly ignored. Can you please tell me why you added it?

@aschempp
Copy link
Member

There are two file_exists calls in system/modules/isotope/library/Isotope/Template.php. If I remove the ignoreError, I get that reported.

------ ------------------------------------------------------------------ 
  Line   isotope/library/Isotope/Template.php                              
 ------ ------------------------------------------------------------------ 
  50     Function file_exists is unsafe to use, rely on Symfony component  
         Filesystem::exists instead.                                       
  54     Function file_exists is unsafe to use, rely on Symfony component  
         Filesystem::exists instead.                                       
 ------ ------------------------------------------------------------------ 

@aschempp
Copy link
Member

btw, you can simply run composer run phpstan 😎

@fritzmg
Copy link
Contributor

fritzmg commented Feb 15, 2024

Filesystem::exists is not safer than file_exists. It only introduces a check for \PHP_MAXPATHLEN - which file_exists does itself anyway. It looks like Symfony introduced the check in Symfony 2.3.38 (and later updated it in Symfony 2.7.35 to use \PHP_MAXPATHLEN) due to this PHP bug, which has since been fixed in PHP 7.1. The only advantage is that it will throw a nice IOException for you to catch in such a case.

@aschempp
Copy link
Member

Idk, I get the error when I run phpstan, I never asked for why it is there 😉

@aschempp aschempp added this to the 2.9.0 milestone Jul 26, 2024
@Shadow-Devil Shadow-Devil deleted the feature/phpstan branch November 3, 2024 18:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants