-
-
Notifications
You must be signed in to change notification settings - Fork 709
Fix static analysis warnings for isDot() and remove deprecated APC support #1164
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
Conversation
|
good finds! And if the |
|
Thanks for the comment! The issue was only with the If my understanding is incorrect, please let me know! |
|
Consider the following code segment: $_compile = new RecursiveIteratorIterator($_compileDirs, RecursiveIteratorIterator::CHILD_FIRST);
foreach ($_compile as $_file) {
if (substr(basename($_file->getPathname()), 0, 1) === '.') {
continue;
}
$_filepath = (string)$_file;
if ($_file->isDir()) {
if (!$_compile->isDot()) {
// delete folder if empty
@rmdir($_file->getPathname());
}
} else {
// delete only php filesSince Moreover, it has done sone for over 10 years, because these lines are in the codebase since (at least) 2015. |
|
I apologize my understanding was incorrect. However, I believe the current fix is likely the correct approach for the following reasons:
was appearing in static analysis tools like VSCode, but the code actually runs without issues in practice. I initially thought I would prefer to keep the isDir() conditional branch, as removing it could result in unnecessary directories remaining in the target deletion directory. |
|
I just tested what you wrote ("the code actually runs without issues in practice") and wow, you are right. So RecursiveIteratorIterator passes any undefined method call on to the wrapped object? That means your changes are indeed correct. I will merge them! |
This PR fixes #1144
This issue likely refers to errors generated by static analysis.
I have addressed those issues.
Issue 1:
Investigation
While investigating this warning, I discovered that:
RecursiveIteratorIterator returns SplFileInfo objects in foreach loops
SplFileInfo does not have an isDot() method
isDot() only exists on DirectoryIterator and RecursiveDirectoryIterator classes
All entries starting with . are already filtered out earlier:
Since isDot() only matches . and .. (both start with .), they are already excluded
The isDot() check is unreachable code
Fix
Removed the unnecessary isDot() checks from:
Impact
No functional changes.
The removed checks were redundant and never executed.
Issue 2:
The old APC (Alternative PHP Cache) extension was deprecated in PHP 5.5 and is not available in PHP 7.0+.
Since Smarty now requires PHP 7.2+ (as defined in composer.json), all APC-related code has become dead code that will never execute.
Fix:
Impact:
No functional impact.
The removed code was never executed on supported PHP versions (7.2+).
I would appreciate it if you could review this.
Thank you!