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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
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

Add a Patch

Pull Requests

Add a Pull Request

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-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 18 14:01:31 2024 UTC