Summary
In Smarty\Cacheresource\File::retrieveCachedContent(), the docblock indicates that the method returns a string, but the implementation may return false when the cache file does not exist.
/**
* Read cached template from cache
*
* @param Template $_template template object
*
* @return string content
*/
public function retrieveCachedContent(Template $_template)
{
if (is_file($_template->getCached()->filepath)) {
return file_get_contents($_template->getCached()->filepath);
}
return false;
}
This creates a mismatch between the documented return type and the actual return value.
Question
Is the intended contract of this method:
- string|false (return cached content or false if not found), or
- always string, where missing cache should be handled differently (e.g. exception or empty string)?
Before opening a PR, I would like to confirm the expected behavior.
Possible solutions
Depending on the intended contract:
-
Option A — adjust documentation
Update the docblock to reflect the actual return type, e.g.
@return string|false
-
Option B — enforce a string return type
Ensure the method always returns a string and handle missing cache differently.
Next step
Once the expected behavior is clarified, I’d be happy to open a PR to align either the implementation or the documentation.
Summary
In
Smarty\Cacheresource\File::retrieveCachedContent(), the docblock indicates that the method returns astring, but the implementation may returnfalsewhen the cache file does not exist.This creates a mismatch between the documented return type and the actual return value.
Question
Is the intended contract of this method:
Before opening a PR, I would like to confirm the expected behavior.
Possible solutions
Depending on the intended contract:
Option A — adjust documentation
Update the docblock to reflect the actual return type, e.g.
@return string|falseOption B — enforce a string return type
Ensure the method always returns a string and handle missing cache differently.
Next step
Once the expected behavior is clarified, I’d be happy to open a PR to align either the implementation or the documentation.