Skip to content

[Yaml] improve error message when detecting unquoted asterisks #11843

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

Merged
merged 1 commit into from
Sep 4, 2014

Conversation

xabbuh
Copy link
Member

@xabbuh xabbuh commented Sep 3, 2014

Q A
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #11835
License MIT
Doc PR

Asterisks in unquoted strings are used in YAML to reference variables. Before Symfony 2.3.19, Symfony 2.4.9 and Symfony 2.5.4, unquoted asterisks in inlined YAML code were treated as regular strings. This was fixed for the inline parser in #11677. However, an unquoted * character now led to an error message like this:

PHP Warning:  array_key_exists(): The first argument should be either a string or an integer in vendor/symfony/symfony/src/Symfony/Component/Yaml/Inline.php on line 409

  [Symfony\Component\Yaml\Exception\ParseException]
  Reference "" does not exist at line 171 (near "- { foo: * }").

@xabbuh xabbuh changed the title [Yaml] improve error when detecting unquoted asterisks [Yaml] improve error message when detecting unquoted asterisks Sep 3, 2014
// an unquoted *
if ('*' === $scalar) {
throw new ParseException('A reference must contain at least one character.');
}
Copy link
Member

Choose a reason for hiding this comment

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

this should actually be moved a few lines below so that a * followed by a comment will be parsed properly

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks.

Asterisks in unquoted strings are used in YAML to reference
variables. Before Symfony 2.3.19, Symfony 2.4.9 and Symfony 2.5.4,
unquoted asterisks in inlined YAML code were treated as regular
strings. This was fixed for the inline parser in symfony#11677. However, an
unquoted * character now led to an error message like this:

```
PHP Warning:  array_key_exists(): The first argument should be either a string or an integer in vendor/symfony/symfony/src/Symfony/Component/Yaml/Inline.php on line 409

  [Symfony\Component\Yaml\Exception\ParseException]
  Reference "" does not exist at line 171 (near "- { foo: * }").
```
@fabpot
Copy link
Member

fabpot commented Sep 4, 2014

👍

1 similar comment
@stof
Copy link
Member

stof commented Sep 4, 2014

👍

@fabpot
Copy link
Member

fabpot commented Sep 4, 2014

Thank you @xabbuh.

@fabpot fabpot merged commit 854e07b into symfony:2.3 Sep 4, 2014
fabpot added a commit that referenced this pull request Sep 4, 2014
…isks (xabbuh)

This PR was merged into the 2.3 branch.

Discussion
----------

[Yaml] improve error message when detecting unquoted asterisks

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #11835
| License       | MIT
| Doc PR        |

Asterisks in unquoted strings are used in YAML to reference variables. Before Symfony 2.3.19, Symfony 2.4.9 and Symfony 2.5.4, unquoted asterisks in inlined YAML code were treated as regular strings. This was fixed for the inline parser in #11677. However, an unquoted * character now led to an error message like this:

```
PHP Warning:  array_key_exists(): The first argument should be either a string or an integer in vendor/symfony/symfony/src/Symfony/Component/Yaml/Inline.php on line 409

  [Symfony\Component\Yaml\Exception\ParseException]
  Reference "" does not exist at line 171 (near "- { foo: * }").
```

Commits
-------

854e07b improve error when detecting unquoted asterisks
@xabbuh xabbuh deleted the issue-11835 branch September 4, 2014 10:04
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.

3 participants