timecop / scope-guard
使用 Scope Guard 模式实现的 php-timecop 辅助工具
1.0.1
2015-11-25 12:46 UTC
Requires
- ext-timecop: *
This package is not auto-updated.
Last update: 2024-09-12 00:02:31 UTC
README
描述
hnw/php-timecop 辅助工具,使用 Scope Guard 模式。
安装
需要 hnw/php-timecop 扩展。
cd /path/to/your-project
composer require --dev timecop/scope-guard
用法
<?php public function test_foo() { // Don't remove $t $t = new \TimeFreezeScopeGuard('2007-08-31 12:00:00'); echo date('Y-m-d H:i:s'); // 2007-08-31 12:00:00 }
即使警告 $t
是一个未使用的变量,请不要删除它。
当 test_foo()
方法完成时,$t
变量将被 GC 删除,timecop 关闭。
许可证
Copyright 2015 pixiv Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
https://apache.ac.cn/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.