Magento 2: Captcha overwrite fatal error on PHP 7
-
06-10-2020 - |
Question
Magento 2: How to override Zend library files function only?
I overwrite Captcha module on my WAMP PHP 5.X & it works fine.
On linux server which has PHP 7 gives below error
Fatal error: Declaration of Custom\Captcha\Model\CustomCaptcha::render(Custom\Captcha\Model\Zend_View_Interface $view = NULL, $element = NULL) must be compatible with Zend_Captcha_Adapter::render(Zend_View_Interface $view = NULL, $element = NULL) in /var/www/html/magento/app/code/Custom/Captcha/Model/CustomCaptcha.php on line 156 Segmentation fault (core dumped)
Solution
Looks like Zend_View_Interface
class does not imported in your scope.
You can use import in top of you file:
use Zend_Captcha_Image;
Or use full class name
public function render(\Zend_View_Interface $view = NULL, $element = NULL)
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange