Skip to content

YamlEncoder handle yml format #28815

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
Oct 11, 2018

Conversation

mcsky
Copy link

@mcsky mcsky commented Oct 11, 2018

Q A
Branch? ?
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #28768
License MIT

Symfony\Component\Serializer\Encoder\YamlEncoder now handle the yml format too

use Symfony\Component\Serializer\Serializer;
use Symfony\Component\Serializer\Encoder\YamlEncoder;

$serializer = new Serializer([], [new YamlEncoder()]);
$content = file_get_contents(__DIR__ . '/test.yml');
$data = $serializer->decode($content, YamlEncoder::ALTERNATIVE_FORMAT);

Let me know if something is wrong for you

@stof
Copy link
Member

stof commented Oct 11, 2018

yml is not a format. It is an alternative extension for the YAML format. I would find it bad to see some constants calling it a format.

@mcsky mcsky force-pushed the enhancement/serializer-handle-yml branch from 4271939 to 261e5f8 Compare October 11, 2018 12:58
@Nek-
Copy link
Contributor

Nek- commented Oct 11, 2018

Well, it's related to #28768 and was somehow validated by @nicolas-grekas

@mcsky mcsky force-pushed the enhancement/serializer-handle-yml branch from 491825b to d8640f9 Compare October 11, 2018 13:09
@fabpot
Copy link
Member

fabpot commented Oct 11, 2018

Thank you @mcsky.

@fabpot fabpot merged commit d8640f9 into symfony:master Oct 11, 2018
fabpot added a commit that referenced this pull request Oct 11, 2018
This PR was merged into the 4.2-dev branch.

Discussion
----------

YamlEncoder handle yml format

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

`Symfony\Component\Serializer\Encoder\YamlEncoder` now handle the `yml` format too

```
use Symfony\Component\Serializer\Serializer;
use Symfony\Component\Serializer\Encoder\YamlEncoder;

$serializer = new Serializer([], [new YamlEncoder()]);
$content = file_get_contents(__DIR__ . '/test.yml');
$data = $serializer->decode($content, YamlEncoder::ALTERNATIVE_FORMAT);
```

Let me know if something is wrong for you

Commits
-------

d8640f9 YamlEncoder handle yml extension
fabpot added a commit that referenced this pull request Oct 12, 2018
…nt from 'YamlEncoder' (kevin-biig)

This PR was merged into the 4.2-dev branch.

Discussion
----------

'yml' is not a format and shouldn't be visible as constant from 'YamlEncoder'

A little fix of my [previous PR](#28815)

This PR changes the constant visibility of the `yml` format as private.

Because as @stof [mentionned](#28815 (comment)) `yml` isn't a format, so the constant  shoudn't be public.

Otherwise, this will be confusing while using autocomplete, you see two formats. The user can ask himself if there is a difference between `yaml` / `yml`.

No need of that :)

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Fixed tickets | -
| License       | MIT
| Doc PR        |

Commits
-------

674b359 'yml' is not a format and shouldn't be visible as constant from 'YamlEncoder' class
This was referenced Nov 3, 2018
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.

6 participants