Skip to content

Commit 8bfae17

Browse files
committed
Make the extension official
1 parent c9f4635 commit 8bfae17

28 files changed

+470
-331
lines changed

.coveralls.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
service_name: travis-ci
2-
coverage_clover: coverage.xml
3-
json_path: coverage.json
1+
service_name: travis-ci
2+
coverage_clover: tests/tmp/clover.xml
3+
json_path: tests/tmp/coveralls.json

.gitattributes

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
tests export-ignore
2-
.coveralls.yml export-ignore
3-
.gitattributes export-ignore
4-
.gitignore export-ignore
5-
.travis.yml export-ignore
6-
phpstan.neon export-ignore
7-
phpunit.xml.dist export-ignore
8-
ruleset.xml export-ignore
1+
tests export-ignore
2+
.coveralls.yml export-ignore
3+
.gitattributes export-ignore
4+
.gitignore export-ignore
5+
.travis.yml export-ignore
6+
build.xml export-ignore
7+
phpcs.xml export-ignore
8+
phpstan.neon export-ignore

.travis.yml

Lines changed: 10 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,15 @@
11
language: php
2-
3-
sudo: false
4-
5-
cache:
6-
directories:
7-
- $HOME/.composer/cache
8-
9-
env:
10-
- DEPENDENCIES="--prefer-lowest"
11-
- DEPENDENCIES=""
12-
132
php:
143
- 7.1
154
- 7.2
16-
- master
17-
18-
matrix:
19-
fast_finish: true
20-
include:
21-
- php: 7.2
22-
env: COVERAGE="1"
23-
allow_failures:
24-
- php: 7.2
25-
env: COVERAGE="1"
26-
- php: master
27-
28-
install:
29-
- travis_retry composer update --no-interaction --prefer-dist $DEPENDENCIES
30-
5+
env:
6+
- dependencies=lowest
7+
- dependencies=highest
8+
before_script:
9+
- composer self-update
10+
- if [ "$dependencies" = "lowest" ]; then composer update --prefer-lowest --no-interaction; fi;
11+
- if [ "$dependencies" = "highest" ]; then composer update --no-interaction; fi;
3112
script:
32-
- >
33-
if [ "$COVERAGE" != "1" ]; then
34-
phpenv config-rm xdebug.ini
35-
&& composer check; fi
36-
- if [ "$COVERAGE" == "1" ]; then ./vendor/bin/phpunit --coverage-clover=./coverage.xml; fi
37-
38-
after_success:
39-
- >
40-
if [ $COVERAGE == "1" ]; then
41-
wget https://github.com/satooshi/php-coveralls/releases/download/v1.0.1/coveralls.phar
42-
&& php ./coveralls.phar --verbose
43-
|| true; fi
13+
- vendor/bin/phing
14+
after_script:
15+
- php vendor/bin/coveralls -v

README.md

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,31 @@
1-
# Symfony extension for PHPStan
1+
# PHPStan Symfony Framework extensions and rules
22

3-
## What does it do?
3+
[![Build Status](https://travis-ci.org/phpstan/phpstan-symfony.svg)](https://travis-ci.org/phpstan/phpstan-symfony)
4+
[![Latest Stable Version](https://poser.pugx.org/phpstan/phpstan-symfony/v/stable)](https://packagist.org/packages/phpstan/phpstan-symfony)
5+
[![License](https://poser.pugx.org/phpstan/phpstan-symfony/license)](https://packagist.org/packages/phpstan/phpstan-symfony)
46

5-
* Provides correct return type for `ContainerInterface::get()` method,
6-
* provides correct return type for `Controller::get()` method,
7-
* notifies you when you try to get an unregistered service from the container,
8-
* notifies you when you try to get a private service from the container.
7+
* [PHPStan](https://github.com/phpstan/phpstan)
98

10-
## Installation
9+
This extension provides following features:
1110

12-
```sh
13-
composer require --dev lookyman/phpstan-symfony
14-
```
11+
* Provides correct return type for `ContainerInterface::get()` method.
12+
* Provides correct return type for `Controller::get()` method.
13+
* Notifies you when you try to get an unregistered service from the container.
14+
* Notifies you when you try to get a private service from the container.
15+
16+
## Usage
1517

16-
## Configuration
18+
To use this extension, require it in [Composer](https://getcomposer.org/):
19+
20+
```bash
21+
composer require --dev phpstan/phpstan-symfony
22+
```
1723

18-
Put this into your `phpstan.neon` config:
24+
And include extension.neon in your project's PHPStan config:
1925

20-
```neon
26+
```
2127
includes:
22-
- vendor/lookyman/phpstan-symfony/extension.neon
28+
- vendor/phpstan/phpstan-symfony/extension.neon
2329
parameters:
2430
symfony:
2531
container_xml_path: %rootDir%/../../../var/cache/dev/appDevDebugProjectContainer.xml # or srcDevDebugProjectContainer.xml for Symfony 4+
@@ -30,7 +36,3 @@ parameters:
3036
It can only recognize pure strings or `::class` constants passed into `get()` method. This follows from the nature of static code analysis.
3137

3238
You have to provide a path to `appDevDebugProjectContainer.xml` or similar xml file describing your container.
33-
34-
## Need something?
35-
36-
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.

build.xml

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<project name="PHPStan Symfony Framework extensions and rules" default="check">
3+
4+
<target name="check" depends="
5+
composer,
6+
lint,
7+
cs,
8+
tests,
9+
phpstan
10+
"/>
11+
12+
<target name="composer">
13+
<exec
14+
executable="composer"
15+
logoutput="true"
16+
passthru="true"
17+
checkreturn="true"
18+
>
19+
<arg value="install"/>
20+
</exec>
21+
</target>
22+
23+
<target name="lint">
24+
<exec
25+
executable="vendor/bin/parallel-lint"
26+
logoutput="true"
27+
passthru="true"
28+
checkreturn="true"
29+
>
30+
<arg path="src"/>
31+
<arg path="tests"/>
32+
</exec>
33+
</target>
34+
35+
<target name="cs">
36+
<exec
37+
executable="vendor/bin/phpcs"
38+
logoutput="true"
39+
passthru="true"
40+
checkreturn="true"
41+
>
42+
<arg value="--extensions=php"/>
43+
<arg value="--encoding=utf-8"/>
44+
<arg value="--tab-width=4"/>
45+
<arg value="-sp"/>
46+
<arg path="src"/>
47+
<arg path="tests"/>
48+
</exec>
49+
</target>
50+
51+
<target name="cs-fix">
52+
<exec
53+
executable="vendor/bin/phpcbf"
54+
logoutput="true"
55+
passthru="true"
56+
checkreturn="true"
57+
>
58+
<arg value="--extensions=php"/>
59+
<arg value="--encoding=utf-8"/>
60+
<arg value="--tab-width=4"/>
61+
<arg value="-sp"/>
62+
<arg path="src"/>
63+
<arg path="tests"/>
64+
</exec>
65+
</target>
66+
67+
<target name="tests">
68+
<exec
69+
executable="vendor/bin/phpunit"
70+
logoutput="true"
71+
passthru="true"
72+
checkreturn="true"
73+
>
74+
<arg value="-c"/>
75+
<arg value="tests/phpunit.xml"/>
76+
<arg path="tests"/>
77+
</exec>
78+
</target>
79+
80+
<target name="phpstan">
81+
<exec
82+
executable="vendor/bin/phpstan"
83+
logoutput="true"
84+
passthru="true"
85+
checkreturn="true"
86+
>
87+
<arg value="analyse"/>
88+
<arg value="-l"/>
89+
<arg value="7"/>
90+
<arg value="-c"/>
91+
<arg path="phpstan.neon"/>
92+
<arg path="src"/>
93+
<arg path="tests"/>
94+
</exec>
95+
</target>
96+
97+
</project>

composer.json

Lines changed: 23 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,43 @@
11
{
2-
"name": "lookyman/phpstan-symfony",
3-
"license": "MIT",
4-
"description": "Symfony extension for PHPStan",
5-
"keywords": ["PHPStan", "Symfony"],
2+
"name": "phpstan/phpstan-symfony",
3+
"description": "Symfony Framework extensions and rules for PHPStan",
4+
"license": ["MIT"],
65
"authors": [
76
{
87
"name": "Lukáš Unger",
98
"email": "looky.msc@gmail.com",
109
"homepage": "https://lookyman.net"
1110
}
1211
],
12+
"minimum-stability": "dev",
13+
"prefer-stable": true,
14+
"extra": {
15+
"branch-alias": {
16+
"dev-master": "0.10-dev"
17+
}
18+
},
1319
"require": {
1420
"php": "^7.1",
15-
"phpstan/phpstan": "^0.9.2"
21+
"phpstan/phpstan": "^0.10"
1622
},
1723
"require-dev": {
18-
"jakub-onderka/php-parallel-lint": "^0.9.2",
19-
"phpunit/phpunit": "^6.4 || ^7.0",
20-
"phpstan/phpstan-phpunit": "^0.9.0",
21-
"symfony/framework-bundle": "^4.0",
22-
"phpstan/phpstan-strict-rules": "^0.9.0",
23-
"lookyman/coding-standard": "0.1.0"
24+
"consistence/coding-standard": "^3.0.1",
25+
"jakub-onderka/php-parallel-lint": "^1.0",
26+
"dealerdirect/phpcodesniffer-composer-installer": "^0.4.4",
27+
"phpunit/phpunit": "^7.0",
28+
"phing/phing": "^2.16.0",
29+
"phpstan/phpstan-strict-rules": "^0.10",
30+
"satooshi/php-coveralls": "^1.0",
31+
"slevomat/coding-standard": "^4.5.2",
32+
"phpstan/phpstan-phpunit": "^0.10",
33+
"symfony/framework-bundle": "^4.0"
2434
},
2535
"autoload": {
2636
"psr-4": {
27-
"Lookyman\\PHPStan\\Symfony\\": "src/"
37+
"PHPStan\\": "src/"
2838
}
2939
},
3040
"autoload-dev": {
31-
"psr-4": {
32-
"Lookyman\\PHPStan\\Symfony\\": "tests/"
33-
}
34-
},
35-
"scripts": {
36-
"lint": "parallel-lint ./src ./tests",
37-
"cs": "phpcs --colors --extensions=php --encoding=utf-8 -sp ./src ./tests",
38-
"tests": "phpunit --coverage-text",
39-
"stan": "phpstan analyse -l max -c ./phpstan.neon ./src ./tests",
40-
"check": [
41-
"@lint",
42-
"@cs",
43-
"@tests",
44-
"@stan"
45-
]
41+
"classmap": ["tests/"]
4642
}
4743
}

extension.neon

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
services:
22
-
3-
class: Lookyman\PHPStan\Symfony\Type\ContainerInterfaceDynamicReturnTypeExtension
4-
tags: [phpstan.broker.dynamicMethodReturnTypeExtension]
3+
class: PHPStan\Type\Symfony\ContainerInterfaceDynamicReturnTypeExtension
4+
tags:
5+
- phpstan.broker.dynamicMethodReturnTypeExtension
56
-
6-
class: Lookyman\PHPStan\Symfony\Type\ControllerDynamicReturnTypeExtension
7-
tags: [phpstan.broker.dynamicMethodReturnTypeExtension]
7+
class: PHPStan\Type\Symfony\ControllerDynamicReturnTypeExtension
8+
tags:
9+
- phpstan.broker.dynamicMethodReturnTypeExtension
810
-
9-
class: Lookyman\PHPStan\Symfony\Rules\ContainerInterfacePrivateServiceRule
10-
tags: [phpstan.rules.rule]
11+
class: PHPStan\Rules\Symfony\ContainerInterfacePrivateServiceRule
12+
tags:
13+
- phpstan.rules.rule
1114
-
12-
class: Lookyman\PHPStan\Symfony\Rules\ContainerInterfaceUnknownServiceRule
13-
tags: [phpstan.rules.rule]
14-
- Lookyman\PHPStan\Symfony\ServiceMap(%symfony.container_xml_path%)
15+
class: PHPStan\Rules\Symfony\ContainerInterfaceUnknownServiceRule
16+
tags:
17+
- phpstan.rules.rule
18+
- PHPStan\Symfony\ServiceMap(%symfony.container_xml_path%)

phpcs.xml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?xml version="1.0"?>
2+
<ruleset name="PHPStan PHPUnit extensions and rules">
3+
<rule ref="vendor/consistence/coding-standard/Consistence/ruleset.xml">
4+
<exclude name="Squiz.Functions.GlobalFunction.Found"/>
5+
<exclude name="SlevomatCodingStandard.Namespaces.FullyQualifiedClassNameAfterKeyword"/>
6+
<exclude name="SlevomatCodingStandard.Namespaces.FullyQualifiedClassNameInAnnotation"/>
7+
<exclude name="SlevomatCodingStandard.Namespaces.FullyQualifiedExceptions"/>
8+
<exclude name="SlevomatCodingStandard.Namespaces.ReferenceUsedNamesOnly"/>
9+
<exclude name="Consistence.Exceptions.ExceptionDeclaration"/>
10+
</rule>
11+
<rule ref="SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses">
12+
<properties>
13+
<property name="caseSensitive" value="false"/>
14+
</properties>
15+
</rule>
16+
<rule ref="SlevomatCodingStandard.TypeHints.DeclareStrictTypes">
17+
<properties>
18+
<property name="newlinesCountBetweenOpenTagAndDeclare" value="0"/>
19+
</properties>
20+
</rule>
21+
<rule ref="SlevomatCodingStandard.TypeHints.TypeHintDeclaration">
22+
<properties>
23+
<property name="usefulAnnotations" type="array" value="
24+
@dataProvider,
25+
@requires
26+
"/>
27+
</properties>
28+
</rule>
29+
<rule ref="SlevomatCodingStandard.ControlStructures.AssignmentInCondition"/>
30+
<rule ref="SlevomatCodingStandard.ControlStructures.DisallowEqualOperators"/>
31+
<rule ref="SlevomatCodingStandard.ControlStructures.EarlyExit"/>
32+
<rule ref="SlevomatCodingStandard.Classes.SuperfluousAbstractClassNaming"/>
33+
<rule ref="SlevomatCodingStandard.Classes.SuperfluousInterfaceNaming"/>
34+
<!-- <rule ref="SlevomatCodingStandard.ControlStructures.DisallowShortTernaryOperator"/>-->
35+
<!-- <rule ref="SlevomatCodingStandard.Namespaces.RequireOneNamespaceInFile"/> -->
36+
<!-- <rule ref="SlevomatCodingStandard.PHP.ShortList"/> -->
37+
<rule ref="SlevomatCodingStandard.Files.TypeNameMatchesFileName">
38+
<properties>
39+
<property name="rootNamespaces" type="array" value="src=>PHPStan,tests=>PHPStan"/>
40+
</properties>
41+
</rule>
42+
<exclude-pattern>tests/*/data</exclude-pattern>
43+
</ruleset>

phpcs.xml.dist

Lines changed: 0 additions & 4 deletions
This file was deleted.

phpstan.neon

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,7 @@ includes:
55

66
parameters:
77
excludes_analyse:
8-
- %rootDir%/../../../tests/*/data/*
8+
- */tests/*/data/*
9+
ignoreErrors:
10+
- '#Call to an undefined method object::noMethod\(\)\.#'
11+
- '#Offset mixed does not exist on array\(\)\.#'

0 commit comments

Comments
 (0)