Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Use str_ends_with() and str_starts_with() #44482

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

Closed

Conversation

alexislefebvre
Copy link
Contributor

Q A
Branch? 4.4
Bug fix? no
New feature? no
Deprecations? no
Tickets no
License MIT
Doc PR no

Use str_ends_with() and str_starts_with() instead of substr().

(replaces #44476)

@@ -102,15 +102,15 @@ public function testEncodingAndDecodingSamples()
$dir = realpath(__DIR__.'/../Fixtures/samples/charsets');
$sampleFp = opendir($dir);
while (false !== $encoding = readdir($sampleFp)) {
if ('.' == substr($encoding, 0, 1)) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder why the equality test ignored the type of the variables (no ===).

Copy link
Member

@GromNaN GromNaN left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All updated packages require symfony/polyfill-php80, except symfony/framework: 4.4, can you add the dependency please.

@alexislefebvre
Copy link
Contributor Author

alexislefebvre commented Dec 6, 2021

Thanks for your review.

I'm sorry but symfony/framework doesn't exist. The composer.json of symfony/framework-bundle already requires symfony/polyfill-php80 though:

"symfony/polyfill-php80": "^1.16",

If this is not the right file, please tell me the path of the file, because this PR didn't changed any file in the Framework namespace and I don't know what is the relevant file.

@GromNaN
Copy link
Member

GromNaN commented Dec 7, 2021

My bad. That's the workflow component that needs this update. Sorry for the confusion.
https://github.com/symfony/symfony/blob/4.4/src/Symfony/Component/Workflow/composer.json

@fancyweb
Copy link
Contributor

fancyweb commented Dec 7, 2021

@alexislefebvre I am very sorry but @nicolas-grekas warned me that such changes are not made on the lowest maintained branch anymore (4.4) to avoid as many possible regressions as possible. The policy has changed recently and I did not know about it. It was not the case yet for #41576, that's why this one was made on 4.4.

However it does not mean your work is lost, you just have to rebase it on 6.1, I guess most occurrences should still be there :-) @nicolas-grekas Can you confirm it plz? :-)

@nicolas-grekas
Copy link
Member

I do confirm yes, we decided to be stricter now and merge only true bug fixes on lower branches.

@Nyholm Nyholm added this to the 6.1 milestone Dec 7, 2021
@alexislefebvre
Copy link
Contributor Author

Thanks for your feedbacks. Psalm is trying to merge this PR in 4.4 and it fails. I opened a new PR: #44499

@alexislefebvre alexislefebvre deleted the use-str-starts-end-with-4.4 branch December 7, 2021 21:25
GromNaN added a commit that referenced this pull request Dec 7, 2021
This PR was squashed before being merged into the 6.1 branch.

Discussion
----------

Use str_ends_with() and str_starts_with()

| Q             | A
| ------------- | ---
| Branch?       | 6.1
| Bug fix?      | no
| New feature?  | no
| Deprecations? | no
| Tickets       | no
| License       | MIT
| Doc PR        | no

Use `str_ends_with()` and `str_starts_with()` instead of `substr()`.

(replaces #44482 and #44476 🥲)

Commits
-------

28d4d6b Use str_ends_with() and str_starts_with()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants