Skip to content

Commit

Permalink
Document better usability
Browse files Browse the repository at this point in the history
  • Loading branch information
paragonie-security committed Dec 23, 2019
1 parent 113cde8 commit e9ced50
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
27 changes: 27 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,30 @@ Using Stern is simply:
}
}
```

## Docblock Usability

For better usability (especially with type-aware IDEs like PHPStorm), make sure
you use [`@method`](https://docs.phpdoc.org/references/phpdoc/tags/method.html)
docblocks.

```diff
<?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
{
}
}
```
9 changes: 7 additions & 2 deletions tests/test-classes/Weak.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
/**
* Class Weak
* @package ParagonIE\SternTests
*
* @method bool weakBool(bool $isWeak = false)
* @method string weakString(string $str = '')
* @method float weakFloat(float $f)
* @method int weakInt(int $int)
*/
class Weak
{
Expand Down Expand Up @@ -34,7 +39,7 @@ protected function strictWeakString(string $str = ''): string
* @param float $f
* @return float
*/
protected function strictWeakFloat(float $f)
protected function strictWeakFloat(float $f): float
{
return $f;
}
Expand All @@ -43,7 +48,7 @@ protected function strictWeakFloat(float $f)
* @param int $int
* @return int
*/
protected function strictWeakInt(int $int)
protected function strictWeakInt(int $int): int
{
return $int + 1;
}
Expand Down

0 comments on commit e9ced50

Please sign in to comment.