lesstif / php-jira-rest-client

PHP classes interact Jira with the REST API.
Other
510 stars 263 forks source link

Typed property must not be accessed before initialization #439

Closed LordSimal closed 2 years ago

LordSimal commented 2 years ago

Updated from 4.0.0 to 4.0.1 and now I am getting:

Typed property JiraRestApi\Configuration\AbstractConfiguration::$timeout must not be accessed before initialization
In [<my-path>/vendor/lesstif/php-jira-rest-client/src/Configuration/AbstractConfiguration.php, line 221]

Problem

Since PHP 7.4 typed properties are possible but those don't have a default value of null.

Solution

Therefore it would be nice if AbstractConfiguration would have some reasonable default values for those properties.

This is is needed for all properties because e.g. protected ?string $proxyServer; doesn't have a null default value as well as you see here after manually setting the timeout in my config:

Typed property JiraRestApi\Configuration\AbstractConfiguration::$proxyServer must not be accessed before initialization in
<my-path>/vendor/lesstif/php-jira-rest-client/src/Configuration/AbstractConfiguration.php on line 196
knallcharge commented 2 years ago

Same here. I fixed the above error by initializing the service with

                'timeout'      => 60,
                'proxyServer'  => null,

in the ArrayConfiguration, but when calling getAllProjects() on the service, I'm now getting "Typed property JiraRestApi\Project\Project::$description must not be accessed before initialization" when trying to access the description.

Using v4.0.1 with PHP 8.1.2 and symfony 6.1.1

lesstif commented 2 years ago

I'm so sorry for the late reply. Could you check if this commit resolved your problem?

LordSimal commented 2 years ago

Looks good for me 👍🏻

knallcharge commented 2 years ago

$description still fails without default, I have created a pull request, see #447