yaroslavche / bitmask Goto Github PK
View Code? Open in Web Editor NEWPHP library for working with bitmask
License: MIT License
PHP library for working with bitmask
License: MIT License
Hi,
I like what you've been working on here. Not sure how active the project is for you still but I had an issue to discuss. Hopefully I've missed something here, so before I investigate too much further I thought I would ask you first.
The following test results in an unexpected Exception.
$bitmask = new AssociativeBitMask(['readable', 'writable', 'executable'], 1);
$bitmask->isReadable(); // True
$bitmask->isWritable(); // Exception thrown "Undefined offset: 1" from line 68 (AssociativeBitMask class).
It looks like the constructor (set()
method) is not correctly initialising the internal map
property for the AssociativeBitMask.
The above example, yields
map = [
0 => true
]
But I'd expect,
map = [
0 => true,
1 => false,
2 => false
]
Am I missing something, or does the set()
method need to initialise all map values?
A similar issue occurs if the mask value is initially set with all bits on, and then altered.
$bitmask = new AssociativeBitMask(['readable', 'writable', 'executable'], 7);
Correctly generates the following map,
map = [
0 => true,
1 => true,
2 => true
]
Then updating the mask,
$bitmask->set(1);
Yields an unexpected map array,
map = [
0 => true,
1 => true,
2 => true
]
Thanks.
Hi @yaroslavche,
thanks for this package! We saw, that you had removed the old releases. We have a project depending on version 0.2.0. It cannot be upgraded to version 1.0.0, because the minimum php-version changed. Is there a specific reason that you removed the old releases (like a bug, a security-concern, ...)?
Thanks in advance!
$this->map = array_fill(0, count($keys), false);
Should be
$this->map = array_fill(0, count($keys) - 1, false);
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.