seotils / has-parent
该特性允许设置和获取实例的父类。
0.0.3
2016-09-06 20:30 UTC
Requires
- php: >=5.6.0
- seotils/deferred-exceptions: >=0.2
This package is not auto-updated.
Last update: 2024-09-14 18:37:01 UTC
README
描述
此特性将父类分配给一个类。
许可证
HasParent 是开源软件,采用 [GPL-3.0] 许可 (https://gnu.ac.cn/licenses/gpl-3.0.en.html)。
要求
该软件包依赖于 deferred-exceptions 软件包。
-
GitHub
- [seotils/deferred-exceptions] (https://github.com/seotils/deferred-exceptions)
-
Composer (packagist.org)
- [seotils/deferred-exceptions] (https://packagist.org.cn/packages/seotils/deferred-exceptions)
-
PHPClasses
- [Deferred Exceptions] (http://www.phpclasses.org/package/9854-PHP-Queue-exceptions-and-throws-them-afterwards.html)
安装
composer require seotils/has-parent
用法
<?php namespace My; use Seotils\Traits\HasParent; /** * Parent class */ class A { public function time(){ return date('Y-m-d H:i:s'); } } /** * Class with HasParent trait */ class B { use HasParent; } // Usage $a = new A(); $b = new B(); // Assign and use parent class echo $b->parentClass( $a )->time(); // Or step by step // Assign parent class $b->parentClass( $a ); // Use parent class echo $b->parentClass()->time();
这就结束了!