Skip to content

Commit fbcb705

Browse files
committed
Update Readme & Todo list
1 parent fd53d3f commit fbcb705

File tree

2 files changed

+53
-5
lines changed

2 files changed

+53
-5
lines changed

CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,19 @@ Intended to follow [«Keep a Changelog»](https://keepachangelog.com/en/)
55

66
----
77

8+
## Upcomming
9+
10+
- Remove support for the interface
11+
- Deprecate (abandon) the interface package
12+
- create conflict with interface for version 2
13+
```json
14+
{
15+
"conflict": {
16+
"ebln/ebln/phpstan-factory-mark": "*"
17+
}
18+
}
19+
```
20+
821
----
922

1023
## [1.0.0]

README.md

Lines changed: 40 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,44 @@ ebln/phpstan-factory-rule
33

44
Enforce that your classes get only instantiated by the factories you define!
55

6-
## Usage
6+
## Usage with support for attributes
7+
Require this package: `composer require --dev ebln/phpstan-factory-rule`
78

8-
Install this package and the marking package alongside with PHPStan.
9+
Add the `ForceFactory` attribute to your class, and supply all class names as arguments,
10+
which shall be allowed to instanciate your object.
11+
```php
12+
<?php
13+
// […]
14+
15+
#[\Ebln\Attrib\ForceFactory(GoodFactory::class, BetterFactory::class)]
16+
class OnlyViaFactory
17+
{
18+
}
19+
```
20+
21+
Now lean back and rely on PHPStan in CI pipelines, git hooks or IDE integrations;
22+
If somebody introduces a rogue factory:
23+
```php
24+
<?php
25+
// […]
26+
27+
class FailingFactory
28+
{
29+
public function create(): OnlyViaFactory
30+
{
31+
return new OnlyViaFactory();
32+
}
33+
}
34+
```
35+
…that is supposed to fail, when you run PHPStan.
36+
37+
## Deprecated usage with `ebln/phpstan-factory-mark`
38+
39+
Require this extention and [the package containing the marking interface](https://github.com/ebln/phpstan-factory-mark) via [Composer](https://getcomposer.org/) alongside with PHPStan:
40+
```shell
41+
composer require ebln/phpstan-factory-mark
42+
composer require --dev ebln/phpstan-factory-rule
43+
```
944

1045
Implement `\Ebln\PHPStan\EnforceFactory\ForceFactoryInterface` with the DTO you want to protect.
1146
```php
@@ -42,10 +77,10 @@ class FailingFactory
4277

4378
## Installation
4479

45-
Require this extention and [the package containing the interface](https://github.com/ebln/phpstan-factory-mark) via [Composer](https://getcomposer.org/):
80+
Require this extention via [Composer](https://getcomposer.org/):
4681

47-
```
48-
composer require ebln/phpstan-factory-mark && composer require --dev ebln/phpstan-factory-rule
82+
```php
83+
composer require --dev ebln/phpstan-factory-rule
4984
```
5085

5186
If you also install [phpstan/extension-installer](https://github.com/phpstan/extension-installer) then you're all set!

0 commit comments

Comments
 (0)