PHPStan Issues - from methods docs vars "typos" - Parameter x of method y has invalid type - Drupal\ai\Operation\zzzz.

Created on 10 February 2025, 12 days ago

Problem/Motivation

It seems there are several "typos" for the methods params definition - wrong namespaces
And they are not accurate as really defined and used in the methods.

Which leads to some errors on running PHPStan - starting with level 2
And it affect all AI "extensions" - using this AI API

Ex. for OpenAI provider

  Line   src/Plugin/AiProvider/OpenAiProvider.php                                                                                
 ------ ------------------------------------------------------------------------------------------------------------------------ 
  265    Parameter $input of method Drupal\ai_provider_openai\Plugin\AiProvider\OpenAiProvider::chat() has invalid type          
         Drupal\ai\Operation\Chat\ChatInput.                                                                                     
  365    Parameter $input of method Drupal\ai_provider_openai\Plugin\AiProvider\OpenAiProvider::textToImage() has invalid type   
         Drupal\ai\Operation\TextToImage\TextToImageInput.                                                                       
  407    Parameter #1 $normalized of class Drupal\ai\OperationType\TextToImage\TextToImageOutput constructor expects             
         array<Drupal\ai\OperationType\GenericType\ImageType>, array<int, Drupal\ai\OperationType\GenericType\ImageFile> given.  
  413    Parameter $input of method Drupal\ai_provider_openai\Plugin\AiProvider\OpenAiProvider::textToSpeech() has invalid type  
         Drupal\ai\Operation\TextToSpeech\TextToSpeechInput.                                                                     
  451    Parameter $input of method Drupal\ai_provider_openai\Plugin\AiProvider\OpenAiProvider::speechToText() has invalid type  
         Drupal\ai\Operation\SpeechToText\SpeechToTextInput.   

Steps to reproduce

- Run PHPStan with level 2 for OpenAI provider module - quicker than AI package.

Proposed resolution

- Correct the namespaces.
- Increase (at least temporary for the MR) the PHPStan level 2

Remaining tasks

--

User interface changes

--

API changes

--

Data model changes

--

🐛 Bug report
Status

Active

Version

1.0

Component

Code

Created by

🇷🇴Romania vasike Ramnicu Valcea

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024