Comments (4)
@cnanney hi! It's still possible, but the approach has changed. It's now preferred to use composition instead of inheritance.
Meaning, you'd have to create your own grammar (akin to this) and construct your own container using said grammar like this.
Rule.php is extendable so you should be able to override the constructor.
from php-rule-parser.
If that's any help, I just tried the same test case but with an underscore and it does pass the test.
public function testArrayWithUnderscoreInKeyDoesParseCorrectly()
{
$this->assertTrue($this->evaluate(
'foo_bar === [
"foo", // This is foo
"bar" // And this is bar
]',
['foo_bar' => ['foo', 'bar']]
));
}
from php-rule-parser.
Hi @Fuitad!
Thanks for your submission. This is actually by design. I tried to keep it as close to Javascript syntax as possible. Plus, if I plan on adding math equations in the future, the dash would be interpreted as minus (foo minus bar). I'm not sure if I'll ever implement this, but it crossed my mind.
However, if you're using the latest version (0.4.0 as of writing this), you can actually redefine tokens in user-land. This would allow you to do what you want.
Eg:
$rule->registerToken(Tokenizer::TOKEN_VARIABLE, '[a-zA-Z_][\w-]*');
I hope this helps!
from php-rule-parser.
@nicoSWD Is this no longer possible? Using 0.6.1
and there is no longer public access to the tokenizer, and all properties are private so I can't extend Rule
and add a method to access from the container.
from php-rule-parser.
Related Issues (15)
- CVE-2018-14040 (Medium) detected in bootstrap-3.3.7-3.3.13.min.js
- CVE-2018-14042 (Medium) detected in bootstrap-3.3.7-3.3.13.min.js
- CVE-2018-20677 (Medium) detected in bootstrap-3.3.7-3.3.13.min.js
- CVE-2019-11358 (Medium) detected in jquery-3.1.1.min.js
- Negative Containment check possible? HOT 2
- CVE-2020-11022 (Medium) detected in phpunit/php-code-coverage-7.0.10, jquery-3.4.1.min.js
- CVE-2020-11023 (Medium) detected in phpunit/php-code-coverage-7.0.10, jquery-3.4.1.min.js
- CVE-2019-8331 (Medium) detected in bootstrap-4.1.3.min.js
- Being worked on? HOT 3
- Fatal error with Bool variables and ||
- Multiple tests cause parser error HOT 2
- How to can I register a new function? HOT 3
- ReadMe Mis-type? HOT 2
- This is a test issue from WhiteSource, it will be closed shortly
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from php-rule-parser.