Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Yaml] Allow using _ in some numeric notations#18096

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed
Taluu wants to merge1 commit intosymfony:2.3fromTaluu:fix-yaml-integer-groups

Conversation

@Taluu
Copy link
Contributor

QA
Branch2.3
Bug fix?no ?
New feature?yes ?
BC breaks?no
Deprecations?no
Tests pass?yes
Fixed tickets#18094
LicenseMIT
Doc PR~

Allows to use the_ to group "big" ints, as suggested in the yaml integer type specification. As discussed in#18094, we should check if it is still part of the 1.2 specification, but I don't really see why not ? I can't see anywhere anything saying it is not valid anymore... as there are links to these types in some other specs.

@Taluu
Copy link
ContributorAuthor

It seems that binaries too should accept this, but as on 2.3 it is not handled (maybe on master though ? as the binary notation was introduced on php 5.4

@nicolas-grekas
Copy link
Member

Leading_ shouldn't parsed as numbers but this PR does, isn't it?

@Taluu
Copy link
ContributorAuthor

Indeed. I'll fix that then.

return -log(0);
case'-.inf' ===$scalarLower:
returnlog(0);
casepreg_match('/^(-|\+)?[0-9,]+(\.[0-9]+)?$/',$scalar):
Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

I don't think I saw anywhere that the, was authorized though ? I kept it, but nothing in the specs says it should be used as a separator (And as@nicolas-grekas noticed,_123_456_ should not be a valid number, so shouldn't,123,456, be also considered invalid or a string ?

Choose a reason for hiding this comment

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

You should check with a reference parser, e.g.http://yaml-online-parser.appspot.com/

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

That tool is awesome, and yes, the, is not allowed as a separator (it renders as string when one is used in a number). I'd rather not touch it, as it would introduce a bc break.

But123_ seems to be a valid integer too, so I need to keep that (it will simplify some regex)

@xabbuh
Copy link
Member

@fabpot@stof What is your opinion on this? I tend to treat it as a bug fix. Though what confuses me is that this only part of the 1.1 spec but is not included in 1.2 (see#18094). On the other hand it looks that mostly all widespread YAML parsers support the underscore as a separation character.

@fabpot
Copy link
Member

Some thoughts:

  • We explicitly don't support all YAML features, only the ones that makes sense when using YAML as a configuration file format.
  • If this is not supported in 1.2, we don't want to add support for this feature.
  • It looks like a new feature to me.

@stof
Copy link
Member

stof commentedApr 6, 2016

Given that this will change the way we treat the value, I'm against putting this in a patch release, as it might break existing project. This should go in master

@stof
Copy link
Member

stof commentedApr 6, 2016

and the dumper needs to be changed, to detect that a string123_456 requires to be quoted when being dumped (to avoid being parsed as an integer after that)

@Taluu
Copy link
ContributorAuthor

I will rebase this onmaster then, and fix the dumper

@Taluu
Copy link
ContributorAuthor

Closing in favor of#18486

@TaluuTaluu closed thisApr 9, 2016
@TaluuTaluu deleted the fix-yaml-integer-groups branchApril 9, 2016 11:05
xabbuh added a commit that referenced this pull requestMay 14, 2016
This PR was merged into the 3.2-dev branch.Discussion----------[Yaml] Allow using _ in some numeric notations| Q             | A| ------------- | ---| Branch        | master| Bug fix?      | no ?| New feature?  | yes ?| BC breaks?    | no| Deprecations? | no| Tests pass?   | yes| Fixed tickets |#18094| License       | MIT| Doc PR        | ~Allows to use the `_` to group "big" ints, as suggested in the yaml integer type specification. As discussed in#18094, we should check if it is still part of the 1.2 specification, but I don't really see why not ? I can't see anywhere anything saying it is not valid anymore... as there are links to these types in some other specs.This is#18096, but targetted on master as this is considered as a new feature. I also support the dump of such values as only strings. I think I should change how it is dumped thoug, and use the escape filter instead though (as I was misusing the data provider and it provided strange results at the time)Commits-------e6da11c [Yaml] Allow using _ in some numeric notations
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

7 participants

@Taluu@nicolas-grekas@xabbuh@fabpot@stof@javiereguiluz@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp