vanderlee/expression 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

vanderlee/expression

Composer 安装命令:

composer require vanderlee/expression

包简介

Safe, eval()-based simple and extendable expression parser

README 文档

README

Version 1.0.3

Simple and fast PHP expression parser, based on secure use of eval().

Compatible with PHP 7.1 and up.

Using eval() is evil()

This class tries to expose a subset of PHP functionality not by removing the bad features, but by explicitly allowing only the good features.

IF YOU FIND ANY (POTENTIAL) SECURITY ISSUE, PLEASE REPORT!

Since PHP-Expression uses eval(), it can also handle PHP syntax, including parenthesis, arithmetic, functions and more.

Things you are allowed to do

  • Use numbers, either floating-point or integer, including negative.
  • Use a number of different bases, such as decimal, octal, hexadecimal.
  • Use most basic math functions such as abs(), min(), max() and sqrt().
  • Use basic arithmetic operators +, -, *, / and %.
  • Use parenthesis.
  • Use comparisons (true/false returns 1/0 decimal).
  • Use boolean operators in comparisons.
  • Use bitwise operators.
  • Use textual boolean operators like and, xor and or

Things we've added

  • Binary numbers, using a 0b prefix. i.e. 0b1001110.
  • New functions/function aliases.
  • Support to use number "types" using prefixes.
  • Boolean operator ^^ for logical XOR (same as xor).
  • Textual boolean operator not (same as !).

Things you should NOT be able to do

  • Access functions not explicitly permitted.
  • Access static classs method not explicitly permitted.
  • Access class properties or functions.
  • Access system constants.
  • Access variables, local or global.
  • Access Expression class itself.
  • Access namespace functions.
  • Access arrays of any kind, using either brackets or accolades.
  • Use strings.
  • Return anything except numbers (integer or floating-point, 1/0 for boolean results).

Things you cannnot do

  • Ternary operator (x ? y : z) not supported.
  • Elvis operator (x ?: z) not supported.
  • Null-coalescing operator (x ?? z) not supported.
  • Spaceship operator (x <=> y) only supported on PHP 7 and up (it's a PHP 7 feature).

Available functions

TODO

Disclaimers

Though this class has been tested and independently reviewed by several people, I cannot make any absolute 100% guarantee that it cannot be hacked. If you find any potential security problem, please let us know.

Even though the Expression class itself is supposed to be secure, the return value may still be abused if your code does not check for validity. Only numbers can be returned, but if your code crashes on a number "666", the Expression class cannot and will not be able to protect you. Check for valid ranges.

vanderlee/expression 适用场景与选型建议

vanderlee/expression 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 10.97k 次下载、GitHub Stars 达 5, 最近一次更新时间为 2017 年 04 月 04 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「parser」 「math」 「expression」 「eval」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 vanderlee/expression 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 vanderlee/expression 我们能提供哪些服务?
定制开发 / 二次开发

基于 vanderlee/expression 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 10.97k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 5
  • 点击次数: 7
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 5
  • Watchers: 3
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-04-04