algolia / algolia/algoliasearch-client-php

Regression: missing @return annotation on Psr7\Stream::getMetadata() causes symfony/error-handler deprecation again (was fixed in #703 for #701)

Open Beginner friendly
#763 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
PHP
Stars
697
Forks
112
PR merge metrics
No merged PRs in 30d

Description

### Description

`Algolia\AlgoliaSearch\Http\Psr7\Stream::getMetadata()` no longer has an explicit `@return` PHPDoc annotation, which causes `symfony/error-handler`'s `DebugClassLoader` to emit a deprecation notice when the class is loaded:

```
User Deprecated: Method "Psr\Http\Message\StreamInterface::getMetadata()" might add "mixed" as a native return type declaration in the future. Do the same in implementation "Algolia\AlgoliaSearch\Http\Psr7\Stream" now to avoid errors or add an explicit @return annotation to suppress this message.
```

This is a regression: the same issue was already reported in #701 and fixed in #703 (merged 2022), which added `@return array|mixed|null` above `getMetadata()` in `src/Http/Psr7/Stream.php` (along with annotations on `Request.php`, `Uri.php`, and a few `Response` classes).

On the current release, the annotation is missing again on `lib/Http/Psr7/Stream.php`:

```php
public function getMetadata($key = null)
{
if (!isset($this->stream)) {
```

My guess is this got dropped by a regeneration of the SDK from its codegen spec, since the fix was a manual addition to a generated file rather than something enforced by the generator/templates.

### Steps To Reproduce

Load `Algolia\AlgoliaSearch\Http\Psr7\Stream` in an app using `symfony/error-handler`'s `DebugClassLoader` (e.g. any Symfony app in `dev`/`test` env), and call `getMetadata()` (it's called internally from the constructor via `$this->uri = $this->getMetadata('uri');`).

### Expected behavior

No deprecation notice, consistent with the fix in #703.

### Versions

- Algolia Client Version: 4.47.0
- PHP: 8.4

cc @jeromevieilledent-qobuz

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with lib/Http/Psr7/Stream.php and inspect getMetadata(), then compare the earlier fix in #703 and the corresponding src/Http/Psr7/Stream.php change. Check whether the annotation is generated from a codegen spec or template. Done means loading the class with Symfony DebugClassLoader no longer emits the deprecation and the annotation is preserved by regeneration.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
api, backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
76/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.