php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #77032 bug in enum
Submitted: 2018-10-18 10:08 UTC Modified: 2021-05-31 13:57 UTC
From: bolkunovdu at mail dot ru Assigned:
Status: Suspended Package: SPL_Types (PECL)
PHP Version: 7.2.11 OS: ubuntu
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: bolkunovdu at mail dot ru
New email:
PHP Version: OS:

 

 [2018-10-18 10:08 UTC] bolkunovdu at mail dot ru
Description:
------------
sorry for my bad English. i found bug in enum, just run code, and you`ll see, that on first var_dump variables has correct values

object(CardType)#1 (1) { 
["__default"]=> 
string(5) "table" 
} 
object(CardType)#2 (1) { 
["__default"]=> 
string(4) "list" 
} 

but after assignment operation variable $card_type is broken. Sometimes it return another enum, but i can`t emulate this in short version of code, so just attach small code, which broke variable

object(CardType)#1 (1) { 
["__default"]=> 
UNKNOWN:0 
} 
object(CardType)#2 (1) { 
["__default"]=> 
string(5) "table" 
}

think that happens because of some bugs in work with memory pointers on clone\copy operation

Test script:
---------------
class CardType extends SplEnum 
{ 
const __default = 'list';

const CARD_LIST = 'list'; 
const TABLE = 'table'; 
const TABLE2 = 'table2'; 
}

$card_type = new CardType('table'); 
$card_type2 = new CardType('list'); 
var_dump($card_type, $card_type2);

$card_type2=$card_type;

var_dump($card_type, $card_type2);


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-10-18 10:16 UTC] pmmaga@php.net
-Package: Class/Object related +Package: SPL_Types
 [2018-10-18 12:25 UTC] cmb@php.net
Hmm, SplTypes got no updates for five years (the latest release is
even more than six years old) – does it even compile with PHP
7.2.11?
 [2021-05-31 13:57 UTC] cmb@php.net
-Status: Open +Status: Suspended
 [2021-05-31 13:57 UTC] cmb@php.net
The spl_types package is unmaintained; I suspend this ticket,
until a new maintainer steps up.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 18:01:29 2024 UTC