2017 © Pedro Peláez
 

library stern

Stern lets you built type-safe PHP projects, even if your project's users aren't writing type-safe code

image

paragonie/stern

Stern lets you built type-safe PHP projects, even if your project's users aren't writing type-safe code

  • Wednesday, May 3, 2017
  • by paragonie-scott
  • Repository
  • 3 Watchers
  • 13 Stars
  • 40 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Stern

Build Status Latest Stable Version Latest Unstable Version License, (*1)

Stern lets you built type-safe PHP projects, even if your project's users aren't writing type-safe code., (*2)

Requires PHP 7+, (*3)

Usage

Using Stern is simply:, (*4)

  1. Make your class use the SternTrait.
  2. Rename your methods from whateverName to strictWhateverName.
  3. 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., (*5)

  <?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
      {
      }
  }

The Versions

03/05 2017

dev-master

9999999-dev

Stern lets you built type-safe PHP projects, even if your project's users aren't writing type-safe code

  Sources   Download

MIT

The Requires

  • php ^7

 

The Development Requires