PHP-TYPEHINT-OVERRIDE-001
public function display($tpl = null)
Child class missing Joomla 4 typehints
Joomla 4 added scalar/return types on MVC parents. A J3 subclass that omits them fatals: Declaration must be compatible.
public function display($tpl = null) → Match parent signatures (including types and return)
What you will see
- Declaration of ... must be compatible with
- Fatal error: Declaration
Symptoms people search
incompatible declaration · typehint override · PHP fatal on view display
Replace this code
Swap public function display($tpl = null) for Match parent signatures (including types and return).
Joomla 3
Remove or stop calling this
public function display($tpl = null) { parent::display($tpl); }Joomla 4 / 6
Use this instead
public function display($tpl = null): void { parent::display($tpl); }How to fix it
- 1Copy the parent method signature from HtmlView / BaseController / ListModel.
- 2Do not guess — open the Joomla 6 class.
Also known as
must be compatible · Return type · typed properties
Related issues
- Joomla 3 → 4PHP
jimport() autoloader calls
jimport('joomla.filesystem.file') → use Joomla\CMS\Filesystem\File;
- Joomla 3 → 4PHP
DS path constant
DS → DIRECTORY_SEPARATOR or /
- Joomla 3 → 4PHP
JPATH_PLATFORM
JPATH_PLATFORM → Do not use — autoload instead
- Joomla 3 → 4PHP
mysql_* PHP functions
mysql_query() → Joomla DatabaseInterface / mysqli / PDO
- Joomla 3 → 4PHP
each() / create_function() / ereg / split
each($array) → foreach / closures / preg_*
- Joomla 4 → 5PHP
Dynamic PHP properties (PHP 8.2+)
$this->foo = 1 on an untyped class → Declare the property or use AllowDynamicProperties