tboothman / imdbphp

PHP library for retrieving film and tv information from IMDb
247 stars 84 forks source link

Missing phpdoc comment in alsoknow() method #297

Closed jcvignoli closed 1 year ago

jcvignoli commented 1 year ago

Just found out that method alsoknow() in title.php is missing in its phpdoc comment the "comment" (singular) variable in @return line 1175. This line * @return array<array{title: string, country: string, countryCode: string|null, language: string, languageCode: string|null, comments: string[]}> should be replaced by * @return array<array{title: string, country: string, countryCode: string|null, language: string, languageCode: string|null, comment: string, comments: string[]}> I added "comment: string, ". It is necessary for projects using imdbphp and phpstan.

tboothman commented 1 year ago

It was slightly deliberate. I didn't want it to be there, but left the comment in the actual return for backwards compatibility. The docbloc used to say

* Note: This may return an empty country or comments. The original title will have a country of '' and a comment of 'original title'
* comment, year and lang are there for backwards compatibility and should not be used
* @return array array[0..n] of array[title,country,comments[]]

alsoknow() was the first method I fixed for 8.0 so I was trying to keep backwards compatibility. As I went on so many things had to change I started removing depricated stuff. Explicitely talking about the field I'd wanted to remove in the comment was pretty stupid though.

It's actually impossible to have more than one 'comment'. The language used to get rolled into the comments array (["German title", "DVD title"]), but not any more. image

Arguably then comment is the good field and comments is the one that should be deprecated

tboothman commented 1 year ago

Probably could've just posted the conclusion rather than the conversation with myself :D