Skip to content

[DependencyInjection] Add support for key-type in XmlFileLoader #58035

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
Aug 27, 2024

Conversation

alexandre-daubois
Copy link
Member

@alexandre-daubois alexandre-daubois commented Aug 19, 2024

Q A
Branch? 7.2
Bug fix? no
New feature? yes
Deprecations? no
Issues Fix #45708
License MIT

Quoting the tests to show how this works:

<?xml version="1.0" encoding="utf-8"?>
<container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/services https://symfony.com/schema/dic/services/services-1.0.xsd">
  <services>
    <service id="foo" class="Symfony\Component\DependencyInjection\Tests\Fixtures\Bar">
      <argument type="collection">
        <argument key-type="constant" key="PHP_INT_MAX">Value 1</argument>
        <argument key="PHP_INT_MAX">Value 2</argument>
        <argument key-type="binary" key="AQID">Value 3</argument>
      </argument>
    </service>
  </services>
</container>

Makes the following pass:

    public function testArgumentKeyType()
    {
        // ...

        $definition = $container->getDefinition('foo');
        $this->assertSame([
            \PHP_INT_MAX => 'Value 1',
            'PHP_INT_MAX' => 'Value 2',
            "\x01\x02\x03" => 'Value 3',
        ], $definition->getArgument(0));
    }

@alexandre-daubois alexandre-daubois force-pushed the xml-keytype branch 3 times, most recently from d3f0395 to fe4500c Compare August 19, 2024 14:31
@fabpot
Copy link
Member

fabpot commented Aug 27, 2024

Thank you @alexandre-daubois.

@fabpot fabpot merged commit 20bda2b into symfony:7.2 Aug 27, 2024
8 of 10 checks passed
@fabpot fabpot mentioned this pull request Oct 27, 2024
javiereguiluz added a commit to symfony/symfony-docs that referenced this pull request Nov 27, 2024
This PR was merged into the 6.4 branch.

Discussion
----------

[Routing] Add example of Requirement enum

[Requirement Enum](https://github.com/symfony/symfony/blob/6.4/src/Symfony/Component/Routing/Requirement/Requirement.php) values are not cases but constants.

So in YAML routing format we must use `!php/const` instead of `!php/enum`.

This PR add examples to how to use the "Requirement enum"

Can you confirm constants are not supported in XML format for routing ? (if not, maybe we can make PR like symfony/symfony#58035 cc `@alexandre`-daubois)

Commits
-------

ebfa5e2 [Routing] Add example of Requirement enum
javiereguiluz added a commit to symfony/symfony-docs that referenced this pull request Jan 13, 2025
…e (phansys)

This PR was merged into the 7.2 branch.

Discussion
----------

[Doctrine] Use PDO constants in XML configuration example

Follows #20557, in this case for XML.

See symfony/symfony#58035.

I guess this PR should be merged after merging the 7.1 branch.

Commits
-------

c880a88 [Doctrine] Use PDO constants in XML configuration example
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.

Support for constants in collection keys in XML config
4 participants