Skip to content

Add types to private and internal properties #51068

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
Jul 25, 2023

Conversation

nicolas-grekas
Copy link
Member

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

@xabbuh
Copy link
Member

xabbuh commented Jul 21, 2023

The failures look related.

@nicolas-grekas nicolas-grekas force-pushed the typed-private-props branch 7 times, most recently from d382bd0 to 64a6035 Compare July 25, 2023 14:47
@nicolas-grekas nicolas-grekas changed the title Add types to private properties Add types to private and internal properties Jul 25, 2023
@nicolas-grekas
Copy link
Member Author

PR green, comments addressed.

@nicolas-grekas nicolas-grekas merged commit 0bac246 into symfony:6.4 Jul 25, 2023
@nicolas-grekas nicolas-grekas deleted the typed-private-props branch July 25, 2023 15:45
@PhilETaylor
Copy link
Contributor

PhilETaylor commented Jul 25, 2023

I did a composer update and now I get white screen of death (the actual error below) AMA

Fatal error: Uncaught Error: Typed property Symfony\Component\Runtime\SymfonyRuntime::$input must not be accessed before initialization in /var/www/current/vendor/symfony/runtime/SymfonyRuntime.php:109 Stack trace: #0 /var/www/current/vendor/autoload_runtime.php(16): Symfony\Component\Runtime\SymfonyRuntime->__construct() #1 /var/www/current/public/index.php(13): require_once('...') #2 {main} thrown in /var/www/current/vendor/symfony/runtime/SymfonyRuntime.php on line 109

installed version
symfony/runtime: '6.4.x-dev#58f074a10fed1094ca7a2bb753c36983790fdb29'

@PhilETaylor
Copy link
Contributor

Moving the $this->getInput(); out of the elseif statement in the constructor of SymfonyRuntime seems to fix the issue for me but Im unsure of any knock on affects.

from this:

if (isset($options['env'])) {
            $_SERVER[$envKey] = $options['env'];
        } elseif (isset($_SERVER['argv']) && class_exists(ArgvInput::class)) {
            $this->options = $options;
            $this->getInput();
        }

to this

if (isset($options['env'])) {
            $_SERVER[$envKey] = $options['env'];
        } elseif (isset($_SERVER['argv']) && class_exists(ArgvInput::class)) {
            $this->options = $options;
        }
        $this->getInput();

nicolas-grekas added a commit that referenced this pull request Jul 26, 2023
…alization on SymfonyRuntime (l-vo)

This PR was merged into the 6.4 branch.

Discussion
----------

[Runtime] Fix property must not be accessed before initialization on SymfonyRuntime

| Q             | A
| ------------- | ---
| Branch?       | 6.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       |
| License       | MIT
| Doc PR        | symfony/symfony-docs#... <!-- required for new features -->

Introduced by #51068, see #51068 (comment)

Commits
-------

dd3c406 Fix property must not be accessed before initialization on SymfonyRuntime::$input
nicolas-grekas added a commit that referenced this pull request Jul 28, 2023
…grekas)

This PR was merged into the 7.0 branch.

Discussion
----------

Add types to public and protected properties

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

:hot_face:

Allowed by #45360

Follows #51068 and #51067

Commits
-------

7ea2461 Add types to public and protected properties
fabpot added a commit that referenced this pull request Oct 16, 2023
…ulting in bad argument (weaverryan)

This PR was squashed before being merged into the 6.4 branch.

Discussion
----------

[Process] Fix bug where $this->callback is never null, resulting in bad argument

| Q             | A
| ------------- | ---
| Branch?       | 6.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | None
| License       | MIT
| Doc PR        | Not needed

Hi!

Caused by #51068 - by the time `$this->getDescriptors()` is called, `$this->callback` is ALWAYS a callable thanks to `$this->callback = $this->buildCallback($callback)`.

Previously, there was a separate `hasCallback` property that handled this logic. I chose to NOT re-add that because it was only needed in `getDescriptors()` and that is only called from this one place: easier to pass `$hasCallback` as an argument.

Caught by the symfony/ux test suite ❤️

Cheers!

Commits
-------

95aa236 [Process] Fix bug where $this->callback is never null, resulting in bad argument
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