Skip to content

[DI] Default undefined env to empty string during compile #28838

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 17, 2018
Merged

[DI] Default undefined env to empty string during compile #28838

merged 1 commit into from
Oct 17, 2018

Conversation

ro0NL
Copy link
Contributor

@ro0NL ro0NL commented Oct 12, 2018

Q A
Branch? 4.1
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #28827
License MIT
Doc PR symfony/symfony-docs#...

Instead of using null for undefined envs, use "" instead. We already default the type to string, so actually providing a string value makes sense. During runtime it will always be string also.

@ro0NL
Copy link
Contributor Author

ro0NL commented Oct 16, 2018

To further clarify, this makes the null value explicit. It can only come from a default parameter (env(SOME): ~). A real env can never be null, so without a default, passing "" is the better assumption.

@fabpot
Copy link
Member

fabpot commented Oct 17, 2018

Thank you @ro0NL.

@fabpot fabpot merged commit 38a8ab9 into symfony:4.1 Oct 17, 2018
fabpot added a commit that referenced this pull request Oct 17, 2018
…(ro0NL)

This PR was squashed before being merged into the 4.1 branch (closes #28838).

Discussion
----------

[DI] Default undefined env to empty string during compile

| Q             | A
| ------------- | ---
| Branch?       | 4.1
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no     <!-- see https://symfony.com/bc -->
| Deprecations? | no
| Tests pass?   | yes    <!-- please add some, will be required by reviewers -->
| Fixed tickets | #28827
| License       | MIT
| Doc PR        | symfony/symfony-docs#... <!-- required for new features -->

Instead of using `null` for undefined envs, use `""` instead. We already default the type to string, so actually providing a string value makes sense. During runtime it will always be string also.

Commits
-------

38a8ab9 [DI] Default undefined env to empty string during compile
@ro0NL ro0NL deleted the env branch October 17, 2018 07:50
@fabpot fabpot mentioned this pull request Nov 3, 2018
nicolas-grekas added a commit that referenced this pull request Dec 1, 2018
…o0NL)

This PR was squashed before being merged into the 4.3-dev branch (closes #28858).

Discussion
----------

[DI] Deprecated using env vars with cannotBeEmpty()

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | yes-ish
| New feature?  | yes
| BC breaks?    | no     <!-- see https://symfony.com/bc -->
| Deprecations? | yes
| Tests pass?   | yes    <!-- please add some, will be required by reviewers -->
| Fixed tickets | #28827
| License       | MIT
| Doc PR        | symfony/symfony-docs#... <!-- required for new features -->

Continuation of #28838 for 4.2

Using environment variables for nodes marked `cannotBeEmpty()` is semantically not possible, we'll never know the value is empty yes/no during compile time. Neither we should assume one or another.

Commits
-------

397c19e [DI] Deprecated using env vars with cannotBeEmpty()
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.

5 participants