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

Skip to content

[Config] Use better typehint in PHP Configuration #44166

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 24, 2022

Conversation

jderusse
Copy link
Member

@jderusse jderusse commented Nov 20, 2021

Q A
Branch? 6.2
Bug fix? no
New feature? yes
Deprecations? no
Tickets -
License MIT
Doc PR -

This PR now followup #46328 to replace the generic mixed type-hint by type inferred from normalizations (ie, if a config use ifString, when now that the normalization works only for string, these mixed can safely be replaced by string)

@carsonbot carsonbot added this to the 6.0 milestone Nov 20, 2021
@carsonbot carsonbot changed the title Allow scalar configuration in PHP Configuration [Config] Allow scalar configuration in PHP Configuration Nov 20, 2021
@jderusse jderusse modified the milestones: 6.0, 6.1 Nov 20, 2021
@jderusse jderusse force-pushed the config-scalar branch 2 times, most recently from e4fe334 to 5b38780 Compare November 20, 2021 23:57
@ro0NL

This comment was marked as outdated.

@jderusse

This comment was marked as outdated.

@jderusse jderusse changed the base branch from 6.0 to 6.1 December 2, 2021 17:22
nicolas-grekas added a commit that referenced this pull request May 17, 2022
…jderusse, HypeMC)

This PR was merged into the 5.4 branch.

Discussion
----------

[Config] Allow scalar configuration in PHP Configuration

| Q             | A
| ------------- | ---
| Branch?       | 5.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | Fix symfony/monolog-bundle#417 (comment)
| License       | MIT
| Doc PR        | -

Fixes passing scalar values to array nodes that have a `beforeNormalization` hook, eg:

```php
return static function (MonologConfig $config): void {
    $config->handler('console')
        // ...
        ->processPsr3Messages()
            ->enabled(true)
    ;
};
```

can be shortened thanks to a [`beforeNormalization` hook](https://github.com/symfony/monolog-bundle/blob/a41bbcdc1105603b6d73a7d9a43a3788f8e0fb7d/DependencyInjection/Configuration.php#L453):

```php
return static function (MonologConfig $config): void {
    $config->handler('console')
        // ...
        ->processPsr3Messages(true)
    ;
};
```

I've used some of the code from #44166 by `@jderusse`. Since his PR is a feature it can't go on 5.4, but it still helped a lot.

Commits
-------

2d81a3a [Config] Allow scalar configuration in PHP Configuration
1c176e1 [Config] Allow scalar configuration in PHP Configuration
@nicolas-grekas
Copy link
Member

Rebase needed, in case there is anything left after #46328

@fabpot fabpot modified the milestones: 6.1, 6.2 May 20, 2022
@nicolas-grekas
Copy link
Member

Friendly ping @jderusse
/cc @HypeMC

Is this PR still needed after #46328?

@HypeMC
Copy link
Contributor

HypeMC commented Jul 28, 2022

@nicolas-grekas This PR provides some additional features that #46328 doesn't have, eg allowed type hints on generated methods:

Currently mixed is used in these situations:

My PR only covers using scalars with the beforeNormalization hook.

@nicolas-grekas
Copy link
Member

Would you be able to take over the PR @HypeMC? I feel like @jderusse would appreciate :)

@jderusse

This comment was marked as outdated.

@HypeMC

This comment was marked as outdated.

@jderusse

This comment was marked as outdated.

@jderusse jderusse changed the title [Config] Allow scalar configuration in PHP Configuration [Config] Use better typehint in PHP Configuration Oct 23, 2022
@jderusse
Copy link
Member Author

PR rebased and duplicated logic with #46328 removed

Copy link
Member

@chalasr chalasr left a comment

Choose a reason for hiding this comment

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

Missing CHANGELOG entry. 👍 to ship this in 6.2

@nicolas-grekas
Copy link
Member

Thank you @jderusse.

@nicolas-grekas nicolas-grekas merged commit 8321162 into symfony:6.2 Oct 24, 2022
@jderusse jderusse deleted the config-scalar branch October 24, 2022 07:26
@fabpot fabpot mentioned this pull request Oct 24, 2022
@alexndlm
Copy link
Contributor

@jderusse

Before in \Symfony\Config\Framework\HttpClient\ScopedClientConfig\RetryFailedConfig::httpCode was:

public function httpCode(string $code, mixed $value = []): \Symfony\Config\Framework\HttpClient\ScopedClientConfig\RetryFailed\HttpCodeConfig|static

Now it generates:

public function httpCode(string $code, array $value = []): \Symfony\Config\Framework\HttpClient\ScopedClientConfig\RetryFailed\HttpCodeConfig|static

Is this a bug in the config generator or in the HttpClient?

alexndlm pushed a commit to alexndlm/symfony that referenced this pull request Sep 4, 2023
alexndlm pushed a commit to alexndlm/symfony that referenced this pull request Sep 4, 2023
alexndlm pushed a commit to alexndlm/symfony that referenced this pull request Nov 11, 2023
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.

8 participants