uuf6429/expression-language-arrowfunc 问题修复 & 功能扩展

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

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

uuf6429/expression-language-arrowfunc

Composer 安装命令:

composer require uuf6429/expression-language-arrowfunc

包简介

Arrow function support in Symfony Expression Language

README 文档

README

Build Status Minimum PHP Version License Coverage Scrutinizer Code Quality Packagist

Arrow function (aka "Lambda Expression" or "Anonymous Function") support in Symfony Expression Language component.

Syntax

 (a) -> { a * 2 }
  ^  ^      ^
  |  |      '----- Function body is a single expression that can make use of passed parameters or global variables.
  |  '------------ The lambda operator - input parameters are to the left and the output expression to the right.
  '--------------- Comma-separated list of parameters passed to arrow function.

Safety

Returning callbacks can be dangerous in PHP. If the returned value is not checked, PHP may end up executing arbitrary global functions, static class methods or object methods.

Problem Example

$language = new ExpressionLanguage();
$expression = '(value) -> { value > 20 }';
$filter = $language->evaluate($expression);
$values = array_filter([18, 23, 40], $filter);

If $expression returns a string or array, array_filter() will arbitrarily call whatever was returned.

Solution

There are two solutions:

  • Set the type declaration of methods using the callback to Closure (not Callable!) - prone to mistakes and quite risky.
  • The engine returns the callback wrapped in an object that cannot be invoked by default - this is the safest option (and default one).

统计信息

  • 总下载量: 12
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 3
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 3
  • Watchers: 1
  • Forks: 3
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-11-01

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固