eastoriented/php-block

一个用于模拟Smalltalk块的PHP库

安装: 297

依赖: 3

建议者: 0

安全性: 0

星星: 0

关注者: 2

分支: 0

开放问题: 0

语言:Makefile

dev-master 2021-05-28 07:51 UTC

This package is auto-updated.

Last update: 2024-08-28 15:02:00 UTC


README

eastoriented/php-block是一个面向东方的PHP库,用于执行带参数的代码块。所有类的所有公共方法都返回void

如何使用它?

文件src/block.php定义了接口eastoriented\php\block
文件src/block/functor.php包含一个类,该类通过使用PHP可调用实现了eastoriented\php\block

use eastoriented\php\block;

(new block\functor(function() { echo 'Hello world!'; }))->blockArgumentsAre(); // display 'Hello world!'
(new block\functor(function($message) { echo $message; }))->blockArgumentsAre('Hello world!'); // display 'Hello world!'
(new block\functor(function($hello, $world) { echo $hello . ' ' . $world . '!'; }))->blockArgumentsAre('Hello', 'world'); // display 'Hello world!'

文件src/block/exception.php包含一个类,该类实现了eastoriented\php\block以抛出异常。

use eastoriented\php\block;

(new block\exception(new \exception))->blockArgumentsAre(); // throw $exception

贡献

关于工作流程

我们使用拉取请求来引入新功能和错误修复。
请尽量在提交信息中明确

  1. 解释为何做出更改;
  2. 解释技术实现(您可以提供任何相关票据、文章或其他资源的链接)。

您可以使用以下模板

# If applied, this commit will...

# Explain why this change is being made

# Provide links to any relevant tickets, articles or other resources

要使用它,只需将其放在一个文本文件中(例如,您的家中)并定义为一个模板

# git config --global commit.template ~/.git_commit_template.txt

关于测试

要运行单元测试,只需执行make unit-tests
此外,您可以使用./bin/php tests/units/src/path/to/file.php执行特定的测试文件。

语言和工具