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: 2018-10-18 12:25 UTC
From: bolkunovdu at mail dot ru Assigned:
Status: Open Package: SPL_Types (PECL)
PHP Version: 7.2.11 OS: ubuntu
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [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

Add a Patch

Pull Requests

Add a Pull Request

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?
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Thu Apr 22 18:01:24 2021 UTC