Method Flux_Template::itemTypeText() has invalid return type Item
1088 * @return Item type or false.
1089 * @access public
1090 */
1091 public function itemTypeText($id)1092 {
1093 return Flux::getItemType($id);
1094 }
Parameter $options of method Flux_Authorization::config() has invalid type arary
153 * @param arary $options
154 * @access public
155 */
156 public function config($key, $value = null, $options = array())157 {
158 if (!is_null($value)) {
159 return $this->config->set($key, $value, $options);
Method Flux::getItemType() has invalid return type Item
701 * @return Item Type or false.
702 * @access public
703 */
704 public static function getItemType($id1) 705 {
706 if (is_null($id1))
707 return false;
Description
The typehint provided for the function is not a valid class type. This may happen because of a typo, or the class specified in typehint is not present in the current namespace. You can also face this issue on using native union types if your PHP version is < 8.0. Native union types are only available in PHP 8.0 and later.
Bad Practice
// invalid: User class used as return type doesn't exists
function getUser(): User
{
return new User('John');
}
class User
{
public function update(array $data) {}
}
// invalid: Parameter type contains typo
function updateUser(Usr $user, array $data): void
{
$user->update(['name' => $data['name']]);
}
Recommended
Make sure class used in return typehint exists:
class User
{
private string $name;
public function __construct(string $name)
{
$this->name = $name;
}
}
function getUser(): User
{
return new User('John');
}
Make sure there are no typos:
class User
{
public function update(array $data) {}
}
// invalid: Parameter type contains typo
function updateUser(User $user, array $data): void
{
$user->update(['name' => $data['name']]);
}