Skip to content

Commit

Permalink
Initial commit of this phpstan extension to analyse wrong route gener…
Browse files Browse the repository at this point in the history
…ation
  • Loading branch information
DaDeather committed Mar 8, 2022
0 parents commit f342b18
Show file tree
Hide file tree
Showing 26 changed files with 5,931 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.php-cs-fixer.cache
.phpunit.result.cache

vendor/
23 changes: 23 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

$finder = PhpCsFixer\Finder::create()
->exclude(['var', 'vendor'])
->in(__DIR__);

$config = new PhpCsFixer\Config();

return $config->setRules([
'@Symfony' => true,
'@PSR12' => true,
'no_useless_return' => true,
'array_syntax' => ['syntax' => 'short'],
'concat_space' => ['spacing' => 'one'],
'function_typehint_space' => true,
'no_empty_statement' => true,
'no_leading_namespace_whitespace' => true,
'single_trait_insert_per_statement' => true,
'yoda_style' => false,
'array_indentation' => true,
'single_quote' => true,
'ordered_imports' => ['sort_algorithm' => 'alpha'],
])->setFinder($finder);
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2022 Ismail Özgün Turan

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
49 changes: 49 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# PHPStan Symfony Framework extensions and rules

[![Latest Stable Version](https://poser.pugx.org/dadadev/phpstan-symfony-routing/v/stable)](https://packagist.org/packages/dadadev/phpstan-symfony-routing)
[![License](https://poser.pugx.org/dadadev/phpstan-symfony-routing/license)](https://packagist.org/packages/dadadev/phpstan-symfony-routing)

* [PHPStan](https://phpstan.org/)

This extension provides following features:

* Notifies you when you try to generate a URL for a non-existing route name.


## Installation

To use this extension, require it in [Composer](https://getcomposer.org/):

```
composer require --dev dadadev/phpstan-symfony-routing
```

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

<details>
<summary>Manual installation</summary>

If you don't want to use `phpstan/extension-installer`, include extension.neon in your project's PHPStan config:

```
includes:
- vendor/dadadev/phpstan-symfony-routing/extension.neon
```

To perform framework-specific checks, include also this file:

```
includes:
- vendor/dadadev/phpstan-symfony-routing/rules.neon
```
</details>

# Analysis of generating URLs

You have to provide a path to `url_generating_routes.php` for the url generating analysis to work.

```yaml
parameters:
symfony:
urlGeneratingRulesFile: var/cache/dev/url_generating_routes.xml
```
63 changes: 63 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
{
"name": "dadadev/phpstan-symfony-routing",
"description": "A phpstan plugin to analyze generating of routes from symfony routing",
"type": "phpstan-extension",
"keywords": ["php", "phpstan", "symfony", "routing", "bundle"],
"homepage": "https://dadadev.com",
"license": "MIT",
"authors": [
{
"name": "Ismail Özgün Turan",
"email": "[email protected]",
"homepage": "https://dadadev.com"
}
],
"require": {
"php": "^7.1 || ^8.0",
"phpstan/phpstan": "^1.4"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.0",
"php-parallel-lint/php-parallel-lint": "^1.2",
"phpstan/phpstan-phpunit": "^1.0",
"phpstan/phpstan-strict-rules": "^1.0",
"phpunit/phpunit": "^9.5",
"symfony/framework-bundle": "^4.4 || ^5.0 || ^6.0",
"symfony/polyfill-php80": "^1.24",
"symfony/routing": "^4.4 || ^5.0 || ^6.0"
},
"scripts": {
"php-cs-fix": "vendor/bin/php-cs-fixer fix -v --config=.php-cs-fixer.dist.php",
"php-cs-check": "vendor/bin/php-cs-fixer fix -v --config=.php-cs-fixer.dist.php --dry-run",
"phpstan": "vendor/bin/phpstan analyse",
"phpunit": "vendor/bin/phpunit"
},
"config": {
"sort-packages": true
},
"extra": {
"phpstan": {
"includes": [
"extension.neon",
"rules.neon"
]
},
"branch-alias": {
"dev-master": "1.0-dev"
}
},
"conflict": {
"symfony/framework-bundle": "<3.0"
},
"autoload": {
"psr-4": {
"DaDaDev\\": "src/"
}
},
"autoload-dev": {
"classmap": [
"tests/"
]
},
"prefer-stable": true
}
Loading

0 comments on commit f342b18

Please sign in to comment.