paragonie/stern
Composer 安装命令:
composer require paragonie/stern
包简介
Stern lets you built type-safe PHP projects, even if your project's users aren't writing type-safe code
README 文档
README
Stern lets you built type-safe PHP projects, even if your project's users aren't writing type-safe code.
Requires PHP 7+
Usage
Using Stern is simply:
- Make your class use the
SternTrait. - Rename your methods from
whateverNametostrictWhateverName. - Enjoy strict-typing whether your users like it or not.
Example
<?php
declare(strict_types=1);
namespace YourVendor\YourNamespace;
class YourClassThatUsesStrictTypes
{
+ use \ParagonIE\Stern\SternTrait;
/* ... */
- public function foo(string $param = ''): bool
+ public function strictFoo(string $param = ''): bool
{
}
}
Docblock Usability
For better usability (especially with type-aware IDEs like PHPStorm), make sure
you use @method
docblocks.
<?php declare(strict_types=1); namespace YourVendor\YourNamespace; + /** + * @method bool foo(string $param = '') + */ class YourClassThatUsesStrictTypes { + use \ParagonIE\Stern\SternTrait; /* ... */ - public function foo(string $param = ''): bool + public function strictFoo(string $param = ''): bool { } }
统计信息
- 总下载量: 1.48k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 20
- 点击次数: 2
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-05-02