msgraph-sdk-php icon indicating copy to clipboard operation
msgraph-sdk-php copied to clipboard

Deprecated nullable type causes a warning on PHP 8.4

Open Marian-Kechlibar opened this issue 10 months ago • 7 comments

Describe the bug

This is a mostly self-explaining problem whose fix is, fortunately, very simple - literally one extra letter.

Deprecated: Microsoft\Graph\Core\Requests\BaseBatchRequestBuilder::__construct(): Implicitly marking parameter $errorMappings as nullable is deprecated, the explicit nullable type must be used instead in /var/www/html/vendor/microsoft/microsoft-graph-core/src/Requests/BaseBatchRequestBuilder.php on line 49

Looking at the signature of the constructor

public function __construct(RequestAdapter $requestAdapter, array $errorMappings = null)

should be

public function __construct(RequestAdapter $requestAdapter, ?array $errorMappings = null)

Maybe the whole codebase should be scanned for this deprecation... these will become errors in PHP 9.

Expected behavior

No deprecation warning.

How to reproduce

Run anything with this class under PHP 8.4

SDK Version

2.25.0

Latest version known to work for scenario above?

No response

Known Workarounds

No response

Debug output

Click to expand log ```
</details>


### Configuration

_No response_

### Other information

_No response_

Marian-Kechlibar avatar Feb 05 '25 19:02 Marian-Kechlibar

So, here is more of them:

Deprecated: Microsoft\Graph\GraphRequestAdapter::__construct(): Implicitly marking parameter $httpClient as nullable is deprecated, the explicit nullable type must be used instead in /var/www/html/vendor/microsoft/microsoft-graph/src/GraphRequestAdapter.php on line 32

Deprecated: Microsoft\Graph\Core\GraphClientFactory::getDefaultHandlerStack(): Implicitly marking parameter $handler as nullable is deprecated, the explicit nullable type must be used instead in /var/www/html/vendor/microsoft/microsoft-graph-core/src/GraphClientFactory.php on line 146

Deprecated: Microsoft\Graph\Core\Requests\BaseBatchRequestBuilder::__construct(): Implicitly marking parameter $errorMappings as nullable is deprecated, the explicit nullable type must be used instead in /var/www/html/vendor/microsoft/microsoft-graph-core/src/Requests/BaseBatchRequestBuilder.php on line 49

Deprecated: Http\Promise\FulfilledPromise::then(): Implicitly marking parameter $onFulfilled as nullable is deprecated, the explicit nullable type must be used instead in /var/www/html/vendor/php-http/promise/src/FulfilledPromise.php on line 32

Deprecated: Http\Promise\FulfilledPromise::then(): Implicitly marking parameter $onRejected as nullable is deprecated, the explicit nullable type must be used instead in /var/www/html/vendor/php-http/promise/src/FulfilledPromise.php on line 32

Deprecated: Http\Promise\Promise::then(): Implicitly marking parameter $onFulfilled as nullable is deprecated, the explicit nullable type must be used instead in /var/www/html/vendor/php-http/promise/src/Promise.php on line 48

Deprecated: Http\Promise\Promise::then(): Implicitly marking parameter $onRejected as nullable is deprecated, the explicit nullable type must be used instead in /var/www/html/vendor/php-http/promise/src/Promise.php on line 48

Marian-Kechlibar avatar Feb 07 '25 11:02 Marian-Kechlibar

This will require updates in the various core libraries,

musale avatar Feb 20 '25 11:02 musale

This will require updates in the various core libraries,

Is it something in the pipeline?

azgooon avatar Mar 05 '25 18:03 azgooon

This will require updates in the various core libraries,

Is it something in the pipeline?

Not at the moment. We've moved the core libraries into a Mono repo so we can discuss internally and prioritize. Alternatively, if you put up a pr for this, we shall definitely have a look and merge it in.

musale avatar Mar 12 '25 14:03 musale

The code's been updated in GitHub. Any chance of tagging a release and getting it into Packagist?

mralston avatar Apr 03 '25 21:04 mralston

@mralston this release is currently blocked by https://github.com/microsoft/kiota-php/pull/53

rkodev avatar Apr 04 '25 09:04 rkodev

Ah, gotcha. Thanks for the info.

mralston avatar Apr 04 '25 14:04 mralston