Skip to content

Commit

Permalink
Update usage to show diff of changed form
Browse files Browse the repository at this point in the history
  • Loading branch information
matt committed Feb 26, 2024
1 parent 20d2574 commit 1863bc7
Showing 1 changed file with 19 additions and 13 deletions.
32 changes: 19 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@

Generate [Psalm] types for [Laminas forms]

**This is a work in progress**. Until we hit a `1.x` release, the examples below are more to illustrate what _can_ be
done, not how it _will_ work once stable.

## Installation

Install this package as a development dependency using [Composer]:
Expand All @@ -18,18 +15,27 @@ composer require --dev kynx/laminas-form-shape
## Usage

```commandline
vendor/bin/laminas form:psalm-type src/Forms/MyForm.php
vendor/bin/laminas form:psalm-type src/Forms/Artist.php
```

...outputs an [array shape] something like:

```text
array{
name: non-empty-string,
age: numeric-string,
gender?: null|string,
can_code: '0'|'1',
}
...will add an [array shape] to your `Artist` form something like:

```diff
use Laminas\Form\Element\Text;
use Laminas\Form\Form;

+/**
+ * @psalm-import-type TAlbumData from Album
+ * @psalm-type TArtistData = array{
+ * id: int|null,
+ * name: non-empty-string,
+ * albums: array<array-key, TAlbumData>,
+ * }
+ * @extends Form<TArtistData>
+ */
final class Artist extends Form
{
/**
```

To see a full list of options:
Expand Down

0 comments on commit 1863bc7

Please sign in to comment.