class - PHP Strict warning: Declaration of Child::set() should be compatible with Parent::set()? -


i have

class {...} class b extends {...}  class parent {     public function setobj(a $obj)  { .... } } class child extends parent {     public function setobj(b $obj) { .... } } 

whit message :

strict warning: declaration of child::setobj() should compatible parent::setobj(a $obj) in require_once()

why warning ?

php 5.5.12 (in drupal 7.38)

your code should like

class {...} class b extends {...}  class parent {     public function setobj(a $obj)  { .... } } class child extends parent {     public function setobj(a $obj) { .... } } 

because overwrite parent::setobj(a) method has same name, other signature.

see also: https://softwareengineering.stackexchange.com/questions/227766/changing-method-signature-for-implementing-classes-in-php


Comments