|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #60593 Please support binary and set in spl types
Submitted: 2011-12-22 15:24 UTC Modified: 2017-01-10 08:15 UTC
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: jueljust at gmail dot com Assigned:
Status: Suspended Package: SPL_Types (PECL)
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.
Block user comment
Status: Assign to:
Bug Type:
From: jueljust at gmail dot com
New email:
PHP Version: OS:


 [2011-12-22 15:24 UTC] jueljust at gmail dot com
From manual page:

$binary = (binary) 'abcde12345';

Class PermissionSet extends SplSet{
    const __default = 0;

    const OwnerRead = pow(2,0);
    const OwnerWrite = pow(2,1);
    const OwnerExcute = pow(2,2);


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2012-03-01 19:06 UTC] clicky at erebot dot net
Not really sure what the example is supposed to do: you can't use expressions (like pow(x,y)) with the const keyword. You may only use constant values in that context.

Aside from that remark, pease note that PHP 5.4 introduced support for binary numbers notation.
So your example could be rewritten as:

class PermissionSet extends SplSet
    class __default = 0;

    const OwnerRead = 0b100;
    const OwnerWrite = 0b10;
    const OwnerExecute = 0b1;

Then again, I suppose you'd want to be able to do something like:
$ownerPerm = PermissionSet(PermissionSet::OwnerRead | PermissionSet::OwnerWrite);

Unfortunately, this is not possible due to the way the SPL_Types extension works. SplSet only works with the constants defined in the class, so you'd have to define all possible combinations as constants:

class PermissionSet extends SplSet
    class __default = 0;

    const OwnerRead = 0b100;
    const OwnerWrite = 0b010;
    const OwnerExecute = 0b001;

    const NoRights = 0b000;
    const __RW = 0b110;
    const __RX = 0b101;
    const __WX = 0b011;
    const __RWX = 0b111;

Then you can combine the values together provided the result matches the value of a constant of the class.

$ownerPerm = PermissionSet(PermissionSet::OwnerRead | PermissionSet::OwnerWrite);
// same as:
$ownerPerm = PermissionSet(PermissionSet::__RW);
 [2017-01-10 08:15 UTC]
-Status: Open +Status: Suspended
 [2017-01-10 08:15 UTC]
Suspending this report as the extension have not had a release for almost 5 years.  Please revive this if the extension once again shows life
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 01 04:01:34 2024 UTC