-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Filesystem] Fix str_contains deprecation #54298
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
[Filesystem] Fix str_contains deprecation #54298
Conversation
@@ -396,7 +396,7 @@ public function hardlink(string $originFile, $targetFiles) | |||
private function linkException(string $origin, string $target, string $linkType) | |||
{ | |||
if (self::$lastError) { | |||
if ('\\' === \DIRECTORY_SEPARATOR && str_contains(self::$lastError, 'error code(1314)')) { | |||
if ('\\' === \DIRECTORY_SEPARATOR && str_contains((string) self::$lastError, 'error code(1314)')) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this change is wrong. It cannot be null here due to the surrounding if (self::$lastError)
@@ -199,7 +199,7 @@ private static function doRemove(array $files, bool $isRecursive): void | |||
|
|||
throw new IOException(sprintf('Failed to remove directory "%s": ', $file).$lastError); | |||
} | |||
} elseif (!self::box('unlink', $file) && (str_contains(self::$lastError, 'Permission denied') || file_exists($file))) { | |||
} elseif (!self::box('unlink', $file) && (str_contains((string) self::$lastError, 'Permission denied') || file_exists($file))) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd rather use self::$lastError && str_contains(self::$lastError, 'Permission denied')
here to make the intent easier to understand here (handling the case where there is no last error)
8003acc
to
d7519b7
Compare
Thank you @NeilPeyssard. |
[](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [symfony/filesystem](https://symfony.com) ([source](https://togithub.com/symfony/filesystem)) | `6.4.3` -> `6.4.6` | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes <details> <summary>symfony/filesystem (symfony/filesystem)</summary> ### [`v6.4.6`](https://togithub.com/symfony/filesystem/releases/tag/v6.4.6) [Compare Source](https://togithub.com/symfony/filesystem/compare/v6.4.3...v6.4.6) **Changelog** (symfony/filesystem@v6.4.5...v6.4.6) - bug [symfony/symfony#54362](https://togithub.com/symfony/symfony/issues/54362) \[Filesystem] preserve the file modification time when mirroring directories ([@​xabbuh](https://togithub.com/xabbuh)) - bug [symfony/symfony#54298](https://togithub.com/symfony/symfony/issues/54298) \[Filesystem] Fix str_contains deprecation ([@​NeilPeyssard](https://togithub.com/NeilPeyssard)) </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Enabled. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/Lendable/composer-license-checker). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4yNjkuMiIsInVwZGF0ZWRJblZlciI6IjM3LjI2OS4yIiwidGFyZ2V0QnJhbmNoIjoibWFpbiJ9--> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
In the Filesystem component,
str_contains
is potentially called with null as a first parameter. This is deprecated since PHP 8.1.