php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #59562 extend Spl-class and override a methode
Submitted: 2011-01-06 05:28 UTC Modified: 2017-01-10 08:15 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: coola at arcor dot de Assigned:
Status: Suspended Package: SPL_Types (PECL)
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: coola at arcor dot de
New email:
PHP Version: OS:

 

 [2011-01-06 05:28 UTC] coola at arcor dot de
Description:
------------
Hi,

i would like to do something like that:

<?php
   class A extends SplInt // extends SplInt
   {
      protected $x;
      protected $y;
      public function __construct($x, $y)
      {
         $this->x = $x;
         $this->y = $y;
      }
      public function splIntMethode($other, $operator) // override SplInt-Methode
      {
         if($operator != '+')
            throw new Exception();
         if(!($other instanceof A))
            throw new Exception();

         return new A($this->x + $other->x, $this->y + $other->y);
      }
   }
   $a0 = new A(1,2);
   $a1 = new A(3,4); // $a1 is the '$other'-Objekt at methode splIntMethode
   $a2 = $a0 + $a1;  // $operator +
?>


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2014-07-02 21:10 UTC] tobihille at gmail dot com
Crashed on my System (PHP 5.5 fpm on OpenSuse) when extending SplType.

At least Extension of SplType should be possible.

My Code:

<?php

class ConvChar extends SplType
{
    private $__default = 0;

    public function __construct($initial_value, $strict = true)
    {
        $this->__default = $initial_value;
    }
}
 [2017-01-10 08:15 UTC] kalle@php.net
-Status: Open +Status: Suspended
 [2017-01-10 08:15 UTC] kalle@php.net
Suspending this report as the extension have not had a release for almost 5 years.  Please revive this if the extension once again shows life
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Nov 04 11:01:29 2024 UTC