I can´t find the problem. This code works over years, but after reset the server this fatal-error was displayed. Maybe you can help me. Thank you
PHP Fatal error: Declaration of styBoxLoadEventArgs::__construct() must be compatible with EventArgs::__construct() in .../modules/sty/events/styBoxLoadEventArgs.php on line 4
the code is:
<?php
class styBoxLoadEventArgs extends EventArgs
{
public $hide = false;
public $box;
public function __construct($box)
{
$this->box = $box;
}
}
?>
here is the code of the EventArgs
?php
/**
* EventArgs
*/
abstract class EventArgs
{
public $sender, $senderClass, $senderObject, $event;
protected $items;
/**
* Creates new EventArgs object
*/
abstract public function __construct();
/**
* Returns specified item
*
* @param string item-name
* @return mixed
*/
public function __get($_name)
{
if(!array_key_exists($_name, $this->items))
{
throw new BasicException("Item '" . $_name . "' not found");
}
return $this->items[$_name];
}
/**
* Sets specified item
*
* @param string item-name
* @param mixed value
*/
public function __set($_name, $_value)
{
if(!array_key_exists($_name, $this->items))
{
throw new BasicException("Item '" . $_name . "' not found");
}
$this->items[$_name] = $_value;
}
public function &GetByRef($_key)
{
if(!array_key_exists($_key, $this->items))
{
throw new BasicException("Item '" . $_key . "' not found");
}
return $this->items[$_key];
}
}
When a child redeclares a function that a parent has defined, you have to keep the same hinting/data types for the function. So let's say EventArgs
asks for a specific data object in its constructor (or in PHP7 uses strict type hints). Your child must also specify that data type. Here's an example (made one up)
class EventArgs
{
public function __construct(Array $box)
{
$this->box = $box;
}
}
In this case, your child constructor must also ask for an Array
. There's some elaborate reasons for this
@schnittstelle, I think we are both working on the same software problem. My ..date software no longer go after the switch to PHP 5.6. Thanks to this page, I am now one step further but put again firmly. Did you come on and runs it with you? Unfortunately I am PHP layman, looking me through here, but would need but help. Have also been posted in the forum of ..date.de, but received no response. Howl. LG Angelika
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.