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

Skip to content

[Yaml] Parse error when comment on another indent level #16065

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
PeterFour opened this issue Oct 2, 2015 · 4 comments
Closed

[Yaml] Parse error when comment on another indent level #16065

PeterFour opened this issue Oct 2, 2015 · 4 comments

Comments

@PeterFour
Copy link

New merge commit 2ff0f97
(from parent commit 150f52f and issue #15860 )
just cause an error on Yaml file with different comment level.

This file will throw an exception :

services:
# Session Handler (Inactivity Logout)
    app.handler.session_idle:
        class: AppBundle\Handler\SessionIdleHandler
        arguments: ["@session", "@security.token_storage", "@router", %session_max_idle_time%]
        tags:
            - { name: kernel.event_listener, event: kernel.request, method: onKernelRequest }

but this one is not (note the comment position):

services:
    # Session Handler (Inactivity Logout)
    app.handler.session_idle:
        class: AppBundle\Handler\SessionIdleHandler
        arguments: ["@session", "@security.token_storage", "@router", %session_max_idle_time%]
        tags:
            - { name: kernel.event_listener, event: kernel.request, method: onKernelRequest }

I think the error is caused especially if you put a comment between two entries, but you keep the comment on root level

Is it a changes in Yaml syntax ?

@fabpot
Copy link
Member

fabpot commented Oct 2, 2015

has been reverted

@fabpot fabpot closed this as completed Oct 2, 2015
@ogizanagi
Copy link
Contributor

I tried to reproduce it in a regression test along with the changes that were reverted, but it didn't failed :/

So I tried with the exact code you gave:

    public function testCommentAtTheRootIndent()
    {
        $this->assertSame(array(
            'services' => array(
                'app.handler.session_idle' => array(
                    'class' => 'AppBundle\\Handler\\SessionIdleHandler',
                    'arguments' => array(
                        0 => '@session',
                        1 => '@security.token_storage',
                        2 => '@router',
                        3 => '%session_max_idle_time%',
                    ),
                    'tags' => array(
                        0 => array(
                            'name' => 'kernel.event_listener',
                            'event' => 'kernel.request',
                            'method' => 'onKernelRequest',
                        ),
                    ),
                ),
            ),
        ), Yaml::parse(<<<EOF
services:
# Session Handler (Inactivity Logout)
    app.handler.session_idle:
        class: AppBundle\Handler\SessionIdleHandler
        arguments: ["@session", "@security.token_storage", "@router", %session_max_idle_time%]
        tags:
            - { name: kernel.event_listener, event: kernel.request, method: onKernelRequest }
EOF
        ));
    }

but doesn't fail either :/

Any hint ?

@PeterFour
Copy link
Author

Ok let me try with a more complete version, the thing is the problem is caused when you have several definition and a comment back on root level in between like so :

services:

# Custom Services
    app.service.client:
        class: AppBundle\Service\ClientService
        arguments:
            container: "@service_container"

# Validator
    app.validator.sort_code_validator:
        class: AppBundle\Validator\Constraints\SortCodeValidator
        arguments:
                bv: "@app.service.bankval"
        tags:
            - { name: validator.constraint_validator, alias: sort_validator }

@ogizanagi
Copy link
Contributor

Ok, I can confirm this regression. I'll submit a PR to introduce the regression test. Thanks !

fabpot added a commit that referenced this issue Oct 2, 2015
This PR was merged into the 2.3 branch.

Discussion
----------

[Yaml] Add regression test for comments indents

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

This is related to #16065, #15857 and #15860  (last one has been reverted due to this regression)

Commits
-------

7b9d519 [Yaml] Add regression test for comments indents
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants