Skip to content

Commit

Permalink
Migrate to new docs
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosas committed Aug 19, 2023
1 parent 493cd0a commit 513943d
Show file tree
Hide file tree
Showing 22 changed files with 29 additions and 524 deletions.
2 changes: 0 additions & 2 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
/.github export-ignore
/ci export-ignore
/doc export-ignore
/docs export-ignore
/tests export-ignore
.gitattributes export-ignore
.gitignore export-ignore
mkdocs.yaml export-ignore
CHANGELOG.md export-ignore
README.md export-ignore
32 changes: 0 additions & 32 deletions .github/CONTRIBUTING.md

This file was deleted.

Binary file removed .github/contributing.png
Binary file not shown.
204 changes: 0 additions & 204 deletions CHANGELOG.md

This file was deleted.

112 changes: 4 additions & 108 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@

<hr />

ℹ️ **PHPat** has been transformed into a [PHPStan](https://phpstan.org/) extension. Read the [UPGRADE notes](doc/UPGRADE-0.10.md).
<br />
The standalone version (v0.9) will remain available and will receive critical bugfixes if required.

<h2></h2>

### Introduction 📜
Expand All @@ -35,119 +31,19 @@ It provides a natural language abstraction that enables you to define your own a
<img width="500px" src="https://raw.githubusercontent.com/carlosas/phpat/master/doc/img/example.gif" alt="Example">
</p>

Check out the section [WHAT TO TEST](doc/WHAT_TO_TEST.md) to see some examples of typical use cases.

<h2></h2>

### Installation 💽

Require **PHPat** with [Composer](https://getcomposer.org/):
```bash
composer require --dev phpat/phpat
```

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

<details>
<summary>Manual installation</summary>
### Getting started 🚀

If you don't want to use `phpstan/extension-installer`, enable the extension in your PHPStan configuration:
```neon
# phpstan.neon
includes:
- vendor/phpat/phpat/extension.neon
```
</details>
For further information, check out the documentation at **[phpat.dev](https://phpat.dev)**
or just the [Examples](docs/examples.md) section to get some ideas and see some typical use cases.

<h2></h2>

### Configuration 🔧

You will need to register your test classes in your PHPStan configuration:
```neon
# phpstan.neon
services:
-
class: Tests\Architecture\MyFirstTest
tags:
- phpat.test
-
class: Tests\Architecture\MySecondTest
tags:
- phpat.test
```
⚠️ Your architecture tests folder should be included in the PHPStan analysed paths. See [PHPat's own PHPat configuration](ci/phpstan-phpat.neon) as an example.

You can configure some PHPat options as follows:
```neon
# phpstan.neon
parameters:
phpat:
ignore_built_in_classes: true
```

<details><summary>Complete list of options</summary>
<br />

| Name | Description | Default |
|---------------------------|---------------------------------------|:-------:|
| `ignore_doc_comments` | Ignore relations on Doc Comments | *false* |
| `ignore_built_in_classes` | Ignore relations with PHP+ext classes | *false* |
| `show_rule_names` | Show rule name to assertion message | *false* |

</details>

<h2></h2>

### Test definition 📓

There are different [Selectors](doc/SELECTORS.md) available to select the classes involved in a rule, and a wide set of [Assertions](doc/ASSERTIONS.md).

Here's an example test with a rule:

```php
<?php

use PHPat\Selector\Selector;
use PHPat\Test\Builder\Rule;
use PHPat\Test\PHPat;
use App\Domain\SuperForbiddenClass;

final class MyFirstTest
{
public function test_domain_does_not_depend_on_other_layers(): Rule
{
return PHPat::rule()
->classes(Selector::namespace('App\Domain'))
->shouldNotDependOn()
->classes(
Selector::namespace('App\Application'),
Selector::namespace('App\Infrastructure'),
Selector::classname(SuperForbiddenClass::class),
Selector::classname('/^SomeVendor\\\.*\\\ForbiddenSubfolder\\\.*/', true)
)
->because('this will break our architecture, implement it another way! see /docs/howto.md');
}
}
```

<h2></h2>

### Usage 🚀

Run **PHPStan** as usual:
```bash
php vendor/bin/phpstan analyse -c phpstan.neon
```

<h2></h2>
**PHP Architecture Tester** is open source, contributions are welcome!

> **Warning**<br />
> The launch of early-stage releases (0.x.x) could break the API according to [Semantic Versioning 2.0](https://semver.org/).
> We are using *minor* for breaking changes until the release of the stable `1.0.0` version.
**PHP Architecture Tester** is open source, contributions are welcome. Please have a look to the [Contribution docs](.github/CONTRIBUTING.md).

<br />

**Sponsors** (free license)
Expand Down
Loading

0 comments on commit 513943d

Please sign in to comment.