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

[Filesystem] Fix str_contains deprecation #54298

Merged

Conversation

NeilPeyssard
Copy link
Contributor

Q A
Branch? 5.4
Bug fix? yes
New feature? no
Deprecations? no
Issues Fix #54291
License MIT

In the Filesystem component, str_contains is potentially called with null as a first parameter. This is deprecated since PHP 8.1.

@@ -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)')) {
Copy link
Member

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))) {
Copy link
Member

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)

@NeilPeyssard NeilPeyssard force-pushed the fix/54291-str-contains-deprecation branch from 8003acc to d7519b7 Compare March 15, 2024 10:00
@derrabus
Copy link
Member

Thank you @NeilPeyssard.

@derrabus derrabus merged commit e05d922 into symfony:5.4 Mar 15, 2024
6 of 12 checks passed
This was referenced Apr 2, 2024
github-merge-queue bot pushed a commit to Lendable/composer-license-checker that referenced this pull request Apr 4, 2024
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](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`
|
[![age](https://developer.mend.io/api/mc/badges/age/packagist/symfony%2ffilesystem/6.4.6?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/packagist/symfony%2ffilesystem/6.4.6?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/packagist/symfony%2ffilesystem/6.4.3/6.4.6?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/packagist/symfony%2ffilesystem/6.4.3/6.4.6?slim=true)](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 ([@&#8203;xabbuh](https://togithub.com/xabbuh))
- bug
[symfony/symfony#54298](https://togithub.com/symfony/symfony/issues/54298)
\[Filesystem] Fix str_contains deprecation
([@&#8203;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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants