Skip to content

Conversation

@h-marumoto
Copy link
Contributor

This PR fixes #1143

This PR resolves static analysis errors when using method chaining.

The Smarty class extends the Data class, but the PHPDoc return types for methods in the Data class (assign(), append(), etc.) were documented as returning Data.

As a result, when using method chaining like the following, static analysis tools would interpret that a Data instance is returned instead of a Smarty instance, and would report errors that Smarty-specific methods (e.g., display()) do not exist.

(new Smarty())->assign("x", "x")->display('template.tpl');
// Undefined method 'display'.

I changed the PHPDoc return type from Data to $this. By using $this, static analysis tools can correctly recognize that an instance of the actually invoked class (in this case, Smarty) is returned.

This change only modifies PHPDoc comments and has no effect on runtime behavior.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Error chaining assign and display

1 participant