php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #53656 extend Spl-class and override a methode
Submitted: 2011-01-05 18:59 UTC Modified: 2011-01-06 02:49 UTC
Votes:1
Avg. Score:1.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: coola at arcor dot de Assigned:
Status: Not a bug Package: *General Issues
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-05 18:59 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($x + $other->x, $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
 [2011-01-06 02:49 UTC] aharvey@php.net
-Status: Open +Status: Bogus
 [2011-01-06 02:49 UTC] aharvey@php.net
Bugs in PECL packages, such as SPL_Types, should be reported on the
PECL bug tracker instead of this one. In this case, you can request
the feature at http://pecl.php.net/bugs/report.php?package=SPL_Types
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Jul 03 08:01:34 2025 UTC