Skip to content

Commit

Permalink
Merge pull request #12 from sascha-egerer/feature/phpstan-0-11-compat…
Browse files Browse the repository at this point in the history
…ibility

Add PHPStan 0.11 compatibility and add CI tests
  • Loading branch information
sascha-egerer authored Oct 25, 2019
2 parents bd61028 + 1902fa9 commit dffba86
Show file tree
Hide file tree
Showing 18 changed files with 633 additions and 494 deletions.
27 changes: 27 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
root = true

[*]
end_of_line = lf
insert_final_newline = true
charset = utf-8
trim_trailing_whitespace = true

[*.{php,phpt}]
indent_style = tab
indent_size = 4

[*.xml]
indent_style = tab
indent_size = 4

[*.neon]
indent_style = tab
indent_size = 4

[*.{yaml,yml}]
indent_style = space
indent_size = 2

[composer.json]
indent_style = tab
indent_size = 4
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
/vendor
/composer.lock
/vendor
/typo3
/.idea
/index.php
20 changes: 20 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
language: php
php:
- 7.1
- 7.2
- 7.3
env:
- dependencies=lowest
- dependencies=highest
matrix:
exclude:
- php: 7.2
env: dependencies=lowest
- php: 7.3
env: dependencies=lowest
before_script:
- composer self-update
- if [ "$dependencies" = "lowest" ]; then composer update --prefer-lowest --no-interaction; fi;
- if [ "$dependencies" = "highest" ]; then composer update --no-interaction; fi;
script:
- vendor/bin/phing
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@ Put this into your phpstan.neon config:
```
includes:
- vendor/saschaegerer/phpstan-typo3/extension.neon
```

If you do use constants of TYPO3 core you may have to
bootstrap TYPO3 first. This can be done by using the
unit testing bootstrap of the testing-framework

```
parameters:
bootstrap: %rootDir%/../../saschaegerer/phpstan-typo3/src/PhpstanTypo3Bootstrap.php
autoload_files:
- %rootDir%/../../typo3/testing-framework/Resources/Core/Build/UnitTestsBootstrap.php
```
77 changes: 77 additions & 0 deletions build.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<?xml version="1.0" encoding="utf-8"?>
<project name="PHPStan TYPO3 extensions" default="check">
<target name="check" depends="
composer,
lint,
cs,
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" />
</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"/>
</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"/>
</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"/>
</exec>
</target>
</project>
13 changes: 10 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,16 @@
"prefer-stable": true,
"require": {
"php": "~7.1",
"phpstan/phpstan": "^0.10",
"typo3/cms-core": "^8.7 || ^9.5",
"typo3/cms-extbase": "^8.7 || ^9.5"
"phpstan/phpstan": "^0.10 || ^0.11",
"typo3/cms-core": "^8.7 || ^9.5 || ^10.0",
"typo3/cms-extbase": "^8.7 || ^9.5 || ^10.0"
},
"require-dev": {
"consistence/coding-standard": "^3.8",
"dealerdirect/phpcodesniffer-composer-installer": "^0.4.4",
"jakub-onderka/php-parallel-lint": "^1.0",
"phing/phing": "^2.16.0",
"phpstan/phpstan-strict-rules": "^0.11"
},
"suggest": {
"typo3/testing-framework": "Testing framework is used in the bootstrap (src/PhpStanTypo3Bootstrap.php). In most cases you need this package but you may also use your custom bootstrap (e.g. if you use nimut/testing-framework)"
Expand Down
31 changes: 31 additions & 0 deletions phpcs.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?xml version="1.0"?>
<ruleset name="PHPStan Doctrine">
<rule ref="vendor/consistence/coding-standard/Consistence/ruleset.xml">
<exclude name="Squiz.Functions.GlobalFunction.Found"/>
<exclude name="SlevomatCodingStandard.Namespaces.FullyQualifiedClassNameAfterKeyword"/>
<exclude name="SlevomatCodingStandard.Namespaces.FullyQualifiedClassNameInAnnotation"/>
<exclude name="SlevomatCodingStandard.Namespaces.FullyQualifiedExceptions"/>
<exclude name="SlevomatCodingStandard.Namespaces.ReferenceUsedNamesOnly"/>
<exclude name="Consistence.Exceptions.ExceptionDeclaration"/>
</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="enableObjectTypeHint" value="false"/>
</properties>
</rule>
<rule ref="SlevomatCodingStandard.ControlStructures.AssignmentInCondition"/>
<rule ref="SlevomatCodingStandard.Operators.DisallowEqualOperators"/>
<rule ref="SlevomatCodingStandard.ControlStructures.EarlyExit"/>
<rule ref="SlevomatCodingStandard.Classes.SuperfluousAbstractClassNaming"/>
<rule ref="SlevomatCodingStandard.Classes.SuperfluousInterfaceNaming"/>
</ruleset>
4 changes: 2 additions & 2 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
parameters:
bootstrap: src/PhpStanTypo3Bootstrap.php
includes:
- vendor/phpstan/phpstan-strict-rules/rules.neon
48 changes: 0 additions & 48 deletions src/PhpstanTypo3Bootstrap.php

This file was deleted.

Loading

0 comments on commit dffba86

Please sign in to comment.