php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #76585 Assign operator overload are not triggerred correctly
Submitted: 2018-07-06 10:11 UTC Modified: 2018-07-06 11:57 UTC
From: syforce at hotmail dot fr Assigned:
Status: Suspended Package: operator (PECL)
PHP Version: 7.2.7 OS: Linux (Debian 9)
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: syforce at hotmail dot fr
New email:
PHP Version: OS:

 

 [2018-07-06 10:11 UTC] syforce at hotmail dot fr
Description:
------------
Sometimes, assign operators overloads are not called correctly.
Seems to affect all affect overloads ( = += -= *= /= %= **= ) and increment/decrement overloads (++ --)

Working cases :
 - Assigning value directly AND returning/assigning the result. (case 0/1)

Non-working cases :
 - Assigning value indirectly. (case 2/3 = overloads not called)
 - Assigning value indirectly AND returning/assigning the result. (case 4)
 - Assigning value directly without returning/assigning the result. (case 5/6)

Test script:
---------------
/* Pathfinder\Ability extends Pathfinder\Stat, which has overloaded operators */
/* Pathfinder\Character have an `abilities` array attribute, containing Pathfinder\Ability */

$to_add    = 20;
$abid      = Pathfinder\Ability::STR; // int 0
$character = Pathfinder\Character::getByName( $charname, $user );  // return Pathfinder\Character;
$ability   = $character->getAbility( $abid );                      // return $character->abilities[0]; ( Pathfinder\Ability )

var_dump($ability += $to_add);                          // Case 0 | Works        : $ability->value = $ability->value + 20;
$tmp     = $ability += $to_add;                         // Case 1 | Works        : $ability->value = $ability->value + 20;
$character->abilities[$abid] += $to_add;                // Case 2 | Doesn't work : $character->abilities[0] = 21 (int)
$tmp     = $character->abilities[$abid] += $to_add;     // Case 3 | Doesn't work : $character->abilities[0] = 21 (int)  
$tmp     = $character->getAbility( $abid ) += $to_add;  // Case 4 | Doesn't work : PHP Error `Can't use method return value in write context`  
$character->getAbility( $abid ) += $to_add;             // Case 5 | Doesn't work : PHP Error `Can't use method return value in write context`
$ability += $to_add;                                    // Case 6 | Doesn't work : Crash the page without error (ERR_EMPTY_RESPONSE)


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-07-06 11:57 UTC] cmb@php.net
-Status: Open +Status: Suspended
 [2018-07-06 11:57 UTC] cmb@php.net
The operator PECL package has not had a release for more than 5
years and development activity seems to have ceased.  If a new
maintainer picks up this package, then this report should be
re-opened.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Dec 26 10:01:29 2024 UTC