Required __construct call in SplFileObject
| From: | Christoph Rosse | Date: | Wed, 05 Dec 2012 14:38:46 +0000 |
| Subject: | Required __construct call in SplFileObject | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-64156@lists.php.net to get a copy of this message | ||
Hi,
I'm just curious is there a reason why SplFileObject requires a call to parent::__construct()
if I override the class? Someone on my twitter feed mentioned it because he tried to create a Mock-Object.
The following code gives me:
PHP Fatal error: Uncaught exception 'LogicException' with message 'The parent constructor was not called: the object is in an invalid state
<?php
class cls1 extends \SplFileObject
{
public function __construct()
{
}
public function fpassthru()
{
}
}
$cl = new cls1();
$cl->fpassthru();