Skip to content

Commit f342b18

Browse files
committed
Initial commit of this phpstan extension to analyse wrong route generation
0 parents  commit f342b18

26 files changed

+5931
-0
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.php-cs-fixer.cache
2+
.phpunit.result.cache
3+
4+
vendor/

.php-cs-fixer.dist.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
$finder = PhpCsFixer\Finder::create()
4+
->exclude(['var', 'vendor'])
5+
->in(__DIR__);
6+
7+
$config = new PhpCsFixer\Config();
8+
9+
return $config->setRules([
10+
'@Symfony' => true,
11+
'@PSR12' => true,
12+
'no_useless_return' => true,
13+
'array_syntax' => ['syntax' => 'short'],
14+
'concat_space' => ['spacing' => 'one'],
15+
'function_typehint_space' => true,
16+
'no_empty_statement' => true,
17+
'no_leading_namespace_whitespace' => true,
18+
'single_trait_insert_per_statement' => true,
19+
'yoda_style' => false,
20+
'array_indentation' => true,
21+
'single_quote' => true,
22+
'ordered_imports' => ['sort_algorithm' => 'alpha'],
23+
])->setFinder($finder);

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2022 Ismail Özgün Turan
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# PHPStan Symfony Framework extensions and rules
2+
3+
[![Latest Stable Version](https://poser.pugx.org/dadadev/phpstan-symfony-routing/v/stable)](https://packagist.org/packages/dadadev/phpstan-symfony-routing)
4+
[![License](https://poser.pugx.org/dadadev/phpstan-symfony-routing/license)](https://packagist.org/packages/dadadev/phpstan-symfony-routing)
5+
6+
* [PHPStan](https://phpstan.org/)
7+
8+
This extension provides following features:
9+
10+
* Notifies you when you try to generate a URL for a non-existing route name.
11+
12+
13+
## Installation
14+
15+
To use this extension, require it in [Composer](https://getcomposer.org/):
16+
17+
```
18+
composer require --dev dadadev/phpstan-symfony-routing
19+
```
20+
21+
If you also install [phpstan/extension-installer](https://github.com/phpstan/extension-installer) then you're all set!
22+
23+
<details>
24+
<summary>Manual installation</summary>
25+
26+
If you don't want to use `phpstan/extension-installer`, include extension.neon in your project's PHPStan config:
27+
28+
```
29+
includes:
30+
- vendor/dadadev/phpstan-symfony-routing/extension.neon
31+
```
32+
33+
To perform framework-specific checks, include also this file:
34+
35+
```
36+
includes:
37+
- vendor/dadadev/phpstan-symfony-routing/rules.neon
38+
```
39+
</details>
40+
41+
# Analysis of generating URLs
42+
43+
You have to provide a path to `url_generating_routes.php` for the url generating analysis to work.
44+
45+
```yaml
46+
parameters:
47+
symfony:
48+
urlGeneratingRulesFile: var/cache/dev/url_generating_routes.xml
49+
```

composer.json

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
{
2+
"name": "dadadev/phpstan-symfony-routing",
3+
"description": "A phpstan plugin to analyze generating of routes from symfony routing",
4+
"type": "phpstan-extension",
5+
"keywords": ["php", "phpstan", "symfony", "routing", "bundle"],
6+
"homepage": "https://dadadev.com",
7+
"license": "MIT",
8+
"authors": [
9+
{
10+
"name": "Ismail Özgün Turan",
11+
"email": "[email protected]",
12+
"homepage": "https://dadadev.com"
13+
}
14+
],
15+
"require": {
16+
"php": "^7.1 || ^8.0",
17+
"phpstan/phpstan": "^1.4"
18+
},
19+
"require-dev": {
20+
"friendsofphp/php-cs-fixer": "^3.0",
21+
"php-parallel-lint/php-parallel-lint": "^1.2",
22+
"phpstan/phpstan-phpunit": "^1.0",
23+
"phpstan/phpstan-strict-rules": "^1.0",
24+
"phpunit/phpunit": "^9.5",
25+
"symfony/framework-bundle": "^4.4 || ^5.0 || ^6.0",
26+
"symfony/polyfill-php80": "^1.24",
27+
"symfony/routing": "^4.4 || ^5.0 || ^6.0"
28+
},
29+
"scripts": {
30+
"php-cs-fix": "vendor/bin/php-cs-fixer fix -v --config=.php-cs-fixer.dist.php",
31+
"php-cs-check": "vendor/bin/php-cs-fixer fix -v --config=.php-cs-fixer.dist.php --dry-run",
32+
"phpstan": "vendor/bin/phpstan analyse",
33+
"phpunit": "vendor/bin/phpunit"
34+
},
35+
"config": {
36+
"sort-packages": true
37+
},
38+
"extra": {
39+
"phpstan": {
40+
"includes": [
41+
"extension.neon",
42+
"rules.neon"
43+
]
44+
},
45+
"branch-alias": {
46+
"dev-master": "1.0-dev"
47+
}
48+
},
49+
"conflict": {
50+
"symfony/framework-bundle": "<3.0"
51+
},
52+
"autoload": {
53+
"psr-4": {
54+
"DaDaDev\\": "src/"
55+
}
56+
},
57+
"autoload-dev": {
58+
"classmap": [
59+
"tests/"
60+
]
61+
},
62+
"prefer-stable": true
63+
}

0 commit comments

Comments
 (0)