Skip to content

Commit 9d4c39c

Browse files
committed
First working version
1 parent f5dc501 commit 9d4c39c

16 files changed

+973
-0
lines changed

.editorconfig

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
root = true
2+
3+
[*]
4+
end_of_line = lf
5+
insert_final_newline = true
6+
charset = utf-8
7+
trim_trailing_whitespace = true
8+
9+
[*.{php,phpt}]
10+
indent_style = tab
11+
indent_size = 4
12+
13+
[*.xml]
14+
indent_style = tab
15+
indent_size = 4
16+
17+
[*.neon]
18+
indent_style = tab
19+
indent_size = 4
20+
21+
[*.{yaml,yml}]
22+
indent_style = space
23+
indent_size = 2
24+
25+
[composer.json]
26+
indent_style = tab
27+
indent_size = 4

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/tests export-ignore

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/composer.lock
2+
/vendor

.travis.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
language: php
2+
php:
3+
- 7.1
4+
- 7.2
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;
12+
script:
13+
- vendor/bin/phing

README.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,47 @@
11
# PHPStan webmozart/assert extension
2+
3+
[![Build Status](https://travis-ci.org/phpstan/phpstan-webmozart-assert.svg)](https://travis-ci.org/phpstan/phpstan-webmozart-assert)
4+
[![Latest Stable Version](https://poser.pugx.org/phpstan/phpstan-webmozart-assert/v/stable)](https://packagist.org/packages/phpstan/phpstan-webmozart-assert)
5+
[![License](https://poser.pugx.org/phpstan/phpstan-webmozart-assert/license)](https://packagist.org/packages/phpstan/phpstan-webmozart-assert)
6+
7+
* [PHPStan](https://github.com/phpstan/phpstan)
8+
* [webmozart/assert](https://github.com/webmozart/assert)
9+
10+
This extension specifies types of values passed to:
11+
12+
* `Assert::integer`
13+
* `Assert::string`
14+
* `Assert::float`
15+
* `Assert::numeric`
16+
* `Assert::boolean`
17+
* `Assert::scalar`
18+
* `Assert::object`
19+
* `Assert::resource`
20+
* `Assert::isCallable`
21+
* `Assert::isArray`
22+
* `Assert::isIterable`
23+
* `Assert::isCountable`
24+
* `Assert::isInstanceOf`
25+
* `Assert::notInstanceOf`
26+
* `Assert::true`
27+
* `Assert::false`
28+
* `Assert::null`
29+
* `Assert::notNull`
30+
* `Assert::same`
31+
* `Assert::notSame`
32+
* `nullOr*` and `all*` variants of the above methods
33+
34+
## Usage
35+
36+
To use this extension, require it in [Composer](https://getcomposer.org/):
37+
38+
```bash
39+
composer require --dev phpstan/phpstan-webmozart-assert
40+
```
41+
42+
And include extension.neon in your project's PHPStan config:
43+
44+
```
45+
includes:
46+
- vendor/phpstan/phpstan-webmozart-assert/extension.neon
47+
```

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 webmozart/assert extension" 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: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
"name": "phpstan/phpstan-webmozart-assert",
3+
"description": "PHPStan webmozart/assert extension",
4+
"license": ["MIT"],
5+
"minimum-stability": "dev",
6+
"prefer-stable": true,
7+
"extra": {
8+
"branch-alias": {
9+
"dev-master": "0.10-dev"
10+
}
11+
},
12+
"require": {
13+
"php": "~7.1",
14+
"phpstan/phpstan": "^0.10"
15+
},
16+
"require-dev": {
17+
"consistence/coding-standard": "^3.0.1",
18+
"dealerdirect/phpcodesniffer-composer-installer": "^0.4.4",
19+
"jakub-onderka/php-parallel-lint": "^1.0",
20+
"phing/phing": "^2.16.0",
21+
"phpstan/phpstan-strict-rules": "^0.10",
22+
"phpstan/phpstan-phpunit": "^0.10",
23+
"phpunit/phpunit": "^7.1.3",
24+
"slevomat/coding-standard": "^4.5.2",
25+
"webmozart/assert": "^1.3.0"
26+
},
27+
"autoload": {
28+
"psr-4": {
29+
"PHPStan\\": "src/"
30+
}
31+
},
32+
"autoload-dev": {
33+
"classmap": ["tests/"]
34+
}
35+
}

extension.neon

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
services:
2+
-
3+
class: PHPStan\Type\WebMozartAssert\AssertTypeSpecifyingExtension
4+
tags:
5+
- phpstan.typeSpecifier.staticMethodTypeSpecifyingExtension

phpcs.xml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?xml version="1.0"?>
2+
<ruleset name="PHPStan webmozart/assert extension">
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+
</rule>
10+
<rule ref="SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses">
11+
<properties>
12+
<property name="caseSensitive" value="false"/>
13+
</properties>
14+
</rule>
15+
<rule ref="SlevomatCodingStandard.TypeHints.DeclareStrictTypes">
16+
<properties>
17+
<property name="newlinesCountBetweenOpenTagAndDeclare" value="0"/>
18+
</properties>
19+
</rule>
20+
<rule ref="SlevomatCodingStandard.TypeHints.TypeHintDeclaration">
21+
<properties>
22+
<property name="usefulAnnotations" type="array" value="
23+
@dataProvider,
24+
@requires
25+
"/>
26+
</properties>
27+
</rule>
28+
<rule ref="SlevomatCodingStandard.ControlStructures.AssignmentInCondition"/>
29+
<rule ref="SlevomatCodingStandard.ControlStructures.DisallowEqualOperators"/>
30+
<rule ref="SlevomatCodingStandard.ControlStructures.EarlyExit"/>
31+
<rule ref="SlevomatCodingStandard.Classes.SuperfluousAbstractClassNaming"/>
32+
<rule ref="SlevomatCodingStandard.Classes.SuperfluousInterfaceNaming"/>
33+
<!-- <rule ref="SlevomatCodingStandard.ControlStructures.DisallowShortTernaryOperator"/>-->
34+
<!-- <rule ref="SlevomatCodingStandard.Namespaces.RequireOneNamespaceInFile"/> -->
35+
<!-- <rule ref="SlevomatCodingStandard.PHP.ShortList"/> -->
36+
<rule ref="SlevomatCodingStandard.Files.TypeNameMatchesFileName">
37+
<properties>
38+
<property name="rootNamespaces" type="array" value="src=>PHPStan,tests=>PHPStan"/>
39+
</properties>
40+
</rule>
41+
<exclude-pattern>tests/*/data</exclude-pattern>
42+
</ruleset>

phpstan.neon

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
includes:
2+
- extension.neon
3+
- vendor/phpstan/phpstan-phpunit/extension.neon
4+
- vendor/phpstan/phpstan-phpunit/rules.neon
5+
- vendor/phpstan/phpstan-strict-rules/rules.neon
6+
7+
parameters:
8+
excludes_analyse:
9+
- */tests/*/data/*

0 commit comments

Comments
 (0)