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

[String] add $lastGlue argument to join() methods #33914

Merged
merged 1 commit into from Oct 11, 2019

Conversation

@nicolas-grekas
Copy link
Member

commented Oct 8, 2019

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

An idea that came when reviewing symfony/symfony-docs#12440

@ro0NL

This comment has been minimized.

Copy link
Contributor

commented Oct 8, 2019

unicode defines a start/middle/end part: https://github.com/unicode-org/icu/blob/fd123bf023882f07bfacf51c39111be2f946d8f8/icu4c/source/data/locales/en.txt#L2008-L2019

this was on my list to investigate :) not sure it fits String component, as i was already skeptical about $glue->join($strings) for an API.

ultimately i want to format list values in ICU translation files, but the spec format is missing still :( https://github.com/tc39/proposal-intl-list-format

@yceruto
yceruto approved these changes Oct 8, 2019
@nicolas-grekas

This comment has been minimized.

Copy link
Member Author

commented Oct 8, 2019

@ro0NL I'm not trying to solve 100% of the problem but the most common that we've all been solving again and again. TC39 is another level of complexity (same reasoning about title(true): it's not linguistically universal, yet it's common enough to deserve being supported out of the box.)

@ro0NL
ro0NL approved these changes Oct 8, 2019
Copy link
Contributor

left a comment

anyway, i think this feature is fine for non-localized stuff either way 👍

@gharlan
gharlan approved these changes Oct 9, 2019
@gharlan

This comment has been minimized.

Copy link
Contributor

commented Oct 9, 2019

What do you think about making the method static, like in Java: https://docs.oracle.com/javase/8/docs/api/java/lang/String.html#join-java.lang.CharSequence-java.lang.CharSequence...-

For me, it is a kind of named special constructor for a string (and not a method for doing something with the glue string).
$str = UnicodeString::join($array, $glue, $lastGlue);

@nicolas-grekas

This comment has been minimized.

Copy link
Member Author

commented Oct 9, 2019

I think it would make the method harder to discover.

@stof

This comment has been minimized.

Copy link
Member

commented Oct 11, 2019

I'm not even sure this should belong to a String component, as it is more about dealing with arrays...

@nicolas-grekas

This comment has been minimized.

Copy link
Member Author

commented Oct 11, 2019

@stof Python has it. That's a serious enough precedent to me.

nicolas-grekas added a commit that referenced this pull request Oct 11, 2019
…as-grekas)

This PR was merged into the 5.0-dev branch.

Discussion
----------

[String] add $lastGlue argument to join() methods

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

An idea that came when reviewing symfony/symfony-docs#12440

Commits
-------

714d629 [String] add $lastGlue argument to join() methods
@nicolas-grekas nicolas-grekas merged commit 714d629 into symfony:master Oct 11, 2019
3 checks passed
3 checks passed
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
fabbot.io Your code looks good.
Details
@nicolas-grekas nicolas-grekas deleted the nicolas-grekas:s-join branch Oct 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
8 participants
You can’t perform that action at this time.