zendtech / IbmiToolkit

PHP frontend to XMLSERVICE for IBM i development.
BSD 3-Clause "New" or "Revised" License
46 stars 34 forks source link

Docbloc return type for ToolkitService::getInstance() incorrect #152

Closed csears123 closed 3 years ago

csears123 commented 3 years ago

With IDE's like Visual Studio Code there are PHP language server plugins like "PHP Intelephense" that offer IntelliSense and error checking for type hinting. The @return type in the getInstance() docblock indicates "bool|null" and all variables assigned to this return type will assume a 'bool' value.

Instantiating the variable: $conn = \ToolkitService::getInstance($db, $userOrI5NamingFlag='0', $password='', $transportType='pdo');

Using the variable will highlight an error detected with varaible "$conn": $conn->setOptions(['stateless'=>true]);

Error message: Expected type 'object'. Found 'bool|null'.

Changing the @return type to "Toolkit" removes the error syntax highlighting from the IDE, and correctly interprets/inspects the functions that the variable uses.