This repository has been archived by the owner on Jun 26, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
29 changed files
with
437 additions
and
305 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
service_name: travis-ci | ||
coverage_clover: coverage.xml | ||
json_path: coverage.json | ||
coverage_clover: tests/tmp/clover.xml | ||
json_path: tests/tmp/coveralls.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,15 @@ | ||
language: php | ||
|
||
sudo: false | ||
|
||
cache: | ||
directories: | ||
- $HOME/.composer/cache | ||
|
||
env: # intentionally blank | ||
|
||
php: | ||
- 7.1 | ||
- 7.2 | ||
|
||
matrix: | ||
fast_finish: true | ||
include: | ||
- php: 7.2 | ||
env: COVERAGE="1" | ||
allow_failures: | ||
- php: 7.2 | ||
env: COVERAGE="1" | ||
|
||
install: | ||
- travis_retry composer install --no-interaction --prefer-dist | ||
before_script: | ||
- composer self-update | ||
- composer install | ||
|
||
script: | ||
- > | ||
if [ "$COVERAGE" != "1" ]; then | ||
phpenv config-rm xdebug.ini | ||
&& composer check; fi | ||
- if [ "$COVERAGE" == "1" ]; then ./vendor/bin/phpunit --coverage-clover=./coverage.xml; fi | ||
- vendor/bin/phing | ||
|
||
after_success: | ||
- > | ||
if [ $COVERAGE == "1" ]; then | ||
wget https://github.com/satooshi/php-coveralls/releases/download/v1.0.1/coveralls.phar | ||
&& php ./coveralls.phar --verbose | ||
|| true; fi | ||
after_script: | ||
- php vendor/bin/coveralls -v |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,39 @@ | ||
# Symfony extension for PHPStan | ||
# PHPStan Symfony Framework extensions and rules | ||
|
||
## What does it do? | ||
[![Build Status](https://travis-ci.org/phpstan/phpstan-symfony.svg)](https://travis-ci.org/phpstan/phpstan-symfony) | ||
[![Latest Stable Version](https://poser.pugx.org/phpstan/phpstan-symfony/v/stable)](https://packagist.org/packages/phpstan/phpstan-symfony) | ||
[![License](https://poser.pugx.org/phpstan/phpstan-symfony/license)](https://packagist.org/packages/phpstan/phpstan-symfony) | ||
|
||
* Provides correct return type for `ContainerInterface::get()` method, | ||
* provides correct return type for `Controller::get()` method, | ||
* notifies you when you try to get an unregistered service from the container, | ||
* notifies you when you try to get a private service from the container. | ||
* [PHPStan](https://github.com/phpstan/phpstan) | ||
|
||
## Installation | ||
This extension provides following features: | ||
|
||
```sh | ||
composer require --dev lookyman/phpstan-symfony | ||
``` | ||
* Provides correct return type for `ContainerInterface::get()` method. | ||
* Provides correct return type for `Controller::get()` method. | ||
* Notifies you when you try to get an unregistered service from the container. | ||
* Notifies you when you try to get a private service from the container. | ||
|
||
## Usage | ||
|
||
## Configuration | ||
To use this extension, require it in [Composer](https://getcomposer.org/): | ||
|
||
```bash | ||
composer require --dev phpstan/phpstan-symfony | ||
``` | ||
|
||
Put this into your `phpstan.neon` config: | ||
And include extension.neon in your project's PHPStan config: | ||
|
||
```neon | ||
``` | ||
includes: | ||
- vendor/lookyman/phpstan-symfony/extension.neon | ||
- vendor/phpstan/phpstan-symfony/extension.neon | ||
parameters: | ||
symfony: | ||
container_xml_path: %rootDir%/../../../var/cache/dev/srcDevDebugProjectContainer.xml | ||
``` | ||
|
||
## Limitations | ||
|
||
It can only recognize pure strings or `::class` constants passed into `get()` method. This follows from the nature of static code analysis. | ||
|
||
You have to provide a path to `srcDevDebugProjectContainer.xml` or similar xml file describing your container. | ||
|
||
## Need something? | ||
|
||
I don't use Symfony that often. So it might be entirely possible that something doesn't work here or that it lacks some functionality. If that's the case, **PLEASE DO NOT HESITATE** to open an issue or send a pull request. I will have a look at it and together we'll get you what you need. Thanks. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<project name="PHPStan Symfony Framework extensions and rules" default="check"> | ||
|
||
<target name="check" depends=" | ||
composer, | ||
lint, | ||
cs, | ||
tests, | ||
phpstan | ||
"/> | ||
|
||
<target name="composer"> | ||
<exec | ||
executable="composer" | ||
logoutput="true" | ||
passthru="true" | ||
checkreturn="true" | ||
> | ||
<arg value="install"/> | ||
</exec> | ||
</target> | ||
|
||
<target name="lint"> | ||
<exec | ||
executable="vendor/bin/parallel-lint" | ||
logoutput="true" | ||
passthru="true" | ||
checkreturn="true" | ||
> | ||
<arg path="src"/> | ||
<arg path="tests"/> | ||
</exec> | ||
</target> | ||
|
||
<target name="cs"> | ||
<exec | ||
executable="vendor/bin/phpcs" | ||
logoutput="true" | ||
passthru="true" | ||
checkreturn="true" | ||
> | ||
<arg value="--extensions=php"/> | ||
<arg value="--encoding=utf-8"/> | ||
<arg value="--tab-width=4"/> | ||
<arg value="-sp"/> | ||
<arg path="src"/> | ||
<arg path="tests"/> | ||
</exec> | ||
</target> | ||
|
||
<target name="cs-fix"> | ||
<exec | ||
executable="vendor/bin/phpcbf" | ||
logoutput="true" | ||
passthru="true" | ||
checkreturn="true" | ||
> | ||
<arg value="--extensions=php"/> | ||
<arg value="--encoding=utf-8"/> | ||
<arg value="--tab-width=4"/> | ||
<arg value="-sp"/> | ||
<arg path="src"/> | ||
<arg path="tests"/> | ||
</exec> | ||
</target> | ||
|
||
<target name="tests"> | ||
<exec | ||
executable="vendor/bin/phpunit" | ||
logoutput="true" | ||
passthru="true" | ||
checkreturn="true" | ||
> | ||
<arg value="-c"/> | ||
<arg value="tests/phpunit.xml"/> | ||
<arg path="tests"/> | ||
</exec> | ||
</target> | ||
|
||
<target name="phpstan"> | ||
<exec | ||
executable="vendor/bin/phpstan" | ||
logoutput="true" | ||
passthru="true" | ||
checkreturn="true" | ||
> | ||
<arg value="analyse"/> | ||
<arg value="-l"/> | ||
<arg value="7"/> | ||
<arg value="-c"/> | ||
<arg path="phpstan.neon"/> | ||
<arg path="src"/> | ||
<arg path="tests"/> | ||
</exec> | ||
</target> | ||
|
||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,42 @@ | ||
{ | ||
"name": "lookyman/phpstan-symfony", | ||
"license": "MIT", | ||
"description": "Symfony extension for PHPStan", | ||
"keywords": ["PHPStan", "Symfony"], | ||
"name": "phpstan/phpstan-symfony", | ||
"description": "Symfony Framework extensions and rules for PHPStan", | ||
"license": ["MIT"], | ||
"authors": [ | ||
{ | ||
"name": "Lukáš Unger", | ||
"email": "looky.msc@gmail.com", | ||
"homepage": "https://lookyman.net" | ||
} | ||
], | ||
"minimum-stability": "dev", | ||
"prefer-stable": true, | ||
"extra": { | ||
"branch-alias": { | ||
"dev-master": "0.10-dev" | ||
} | ||
}, | ||
"require": { | ||
"php": "^7.1" | ||
"php": "~7.1", | ||
"phpstan/phpstan": "^0.9.1" | ||
}, | ||
"require-dev": { | ||
"consistence/coding-standard": "^2.0", | ||
"jakub-onderka/php-parallel-lint": "^0.9.2", | ||
"phpstan/phpstan": "^0.9.0", | ||
"phing/phing": "^2.16.0", | ||
"phpstan/phpstan-strict-rules": "^0.9", | ||
"satooshi/php-coveralls": "^1.0", | ||
"slevomat/coding-standard": "^3.3.0", | ||
"phpunit/phpunit": "^6.4", | ||
"phpstan/phpstan-phpunit": "^0.9.0", | ||
"symfony/framework-bundle": "^4.0", | ||
"phpstan/phpstan-strict-rules": "^0.9.0", | ||
"lookyman/coding-standard": "0.1.0" | ||
"symfony/framework-bundle": "^4.0" | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"Lookyman\\PHPStan\\Symfony\\": "src/" | ||
"PHPStan\\": "src/" | ||
} | ||
}, | ||
"autoload-dev": { | ||
"psr-4": { | ||
"Lookyman\\PHPStan\\Symfony\\": "tests/" | ||
} | ||
}, | ||
"scripts": { | ||
"lint": "parallel-lint ./src ./tests", | ||
"cs": "phpcs --colors --extensions=php --encoding=utf-8 -sp ./src ./tests", | ||
"tests": "phpunit --coverage-text", | ||
"stan": "phpstan analyse -l max -c ./phpstan.neon ./src ./tests", | ||
"check": [ | ||
"@lint", | ||
"@cs", | ||
"@tests", | ||
"@stan" | ||
] | ||
"classmap": ["tests/"] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,18 @@ | ||
services: | ||
- | ||
class: Lookyman\PHPStan\Symfony\Type\ContainerInterfaceDynamicReturnTypeExtension | ||
tags: [phpstan.broker.dynamicMethodReturnTypeExtension] | ||
class: PHPStan\Type\Symfony\ContainerInterfaceDynamicReturnTypeExtension | ||
tags: | ||
- phpstan.broker.dynamicMethodReturnTypeExtension | ||
- | ||
class: Lookyman\PHPStan\Symfony\Type\ControllerDynamicReturnTypeExtension | ||
tags: [phpstan.broker.dynamicMethodReturnTypeExtension] | ||
class: PHPStan\Type\Symfony\ControllerDynamicReturnTypeExtension | ||
tags: | ||
- phpstan.broker.dynamicMethodReturnTypeExtension | ||
- | ||
class: Lookyman\PHPStan\Symfony\Rules\ContainerInterfacePrivateServiceRule | ||
tags: [phpstan.rules.rule] | ||
class: PHPStan\Rules\Symfony\ContainerInterfacePrivateServiceRule | ||
tags: | ||
- phpstan.rules.rule | ||
- | ||
class: Lookyman\PHPStan\Symfony\Rules\ContainerInterfaceUnknownServiceRule | ||
tags: [phpstan.rules.rule] | ||
- Lookyman\PHPStan\Symfony\ServiceMap(%symfony.container_xml_path%) | ||
class: PHPStan\Rules\Symfony\ContainerInterfaceUnknownServiceRule | ||
tags: | ||
- phpstan.rules.rule | ||
- PHPStan\Symfony\ServiceMap(%symfony.container_xml_path%) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?xml version="1.0"?> | ||
<ruleset name="PHPStan PHPUnit extensions and rules"> | ||
<rule ref="vendor/consistence/coding-standard/Consistence/ruleset.xml"> | ||
<exclude name="Squiz.Functions.GlobalFunction.Found"/> | ||
</rule> | ||
<rule ref="vendor/slevomat/coding-standard/SlevomatCodingStandard/ruleset.xml"> | ||
<exclude name="SlevomatCodingStandard.Files.TypeNameMatchesFileName"/> | ||
<exclude name="SlevomatCodingStandard.Namespaces.FullyQualifiedClassNameAfterKeyword"/> | ||
<exclude name="SlevomatCodingStandard.Namespaces.UseOnlyWhitelistedNamespaces"/> | ||
<exclude name="SlevomatCodingStandard.Namespaces.ReferenceUsedNamesOnly"/> | ||
<exclude name="SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingTraversableParameterTypeHintSpecification"/> | ||
<exclude name="SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingTraversableReturnTypeHintSpecification"/> | ||
<exclude name="SlevomatCodingStandard.Namespaces.FullyQualifiedClassNameInAnnotation.NonFullyQualifiedClassName"/> | ||
<exclude name="SlevomatCodingStandard.Namespaces.FullyQualifiedGlobalConstants"/> | ||
<exclude name="SlevomatCodingStandard.Namespaces.FullyQualifiedGlobalFunctions"/> | ||
</rule> | ||
<rule ref="SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses"> | ||
<properties> | ||
<property name="caseSensitive" value="false"/> | ||
</properties> | ||
</rule> | ||
<rule ref="SlevomatCodingStandard.TypeHints.DeclareStrictTypes"> | ||
<properties> | ||
<property name="newlinesCountBetweenOpenTagAndDeclare" value="0"/> | ||
</properties> | ||
</rule> | ||
<rule ref="SlevomatCodingStandard.TypeHints.TypeHintDeclaration"> | ||
<properties> | ||
<property name="usefulAnnotations" type="array" value=" | ||
@dataProvider, | ||
@requires | ||
"/> | ||
</properties> | ||
</rule> | ||
<exclude-pattern>tests/*/data</exclude-pattern> | ||
</ruleset> |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
includes: | ||
- vendor/phpstan/phpstan-phpunit/extension.neon | ||
- vendor/phpstan/phpstan-phpunit/rules.neon | ||
- vendor/phpstan/phpstan-phpunit/strictRules.neon | ||
- vendor/phpstan/phpstan-strict-rules/rules.neon | ||
|
||
parameters: | ||
excludes_analyse: | ||
- %rootDir%/../../../tests/*/data/* | ||
- */tests/*/data/* |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.