Skip to content

Commit 5335a72

Browse files
committed
initial skelton
0 parents  commit 5335a72

13 files changed

+264
-0
lines changed

.editorconfig

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# a part of this code is borrowed from PHPStan's .editorconfig
2+
# https://github.com/phpstan/phpstan-src/blob/1.10.x/.editorconfig
3+
# @license MIT
4+
5+
root = true
6+
7+
[*]
8+
end_of_line = lf
9+
insert_final_newline = true
10+
charset = utf-8
11+
trim_trailing_whitespace = true
12+
13+
[*.{php,phpt,stub}]
14+
indent_style = tab
15+
indent_size = 4
16+
17+
[*.xml]
18+
indent_style = tab
19+
indent_size = 4
20+
21+
[*.neon]
22+
indent_style = tab
23+
indent_size = 4
24+
25+
[*.{yaml,yml}]
26+
indent_style = space
27+
indent_size = 2
28+
29+
[composer.json]
30+
indent_style = tab
31+
indent_size = 4

.gitattributes

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/.github/ export-ignore
2+
/benchmark/ export-ignore
3+
/docs/ export-ignore
4+
/test/ export-ignore
5+
/.editorconfig
6+
/.gitattributes export-ignore
7+
/.gitignore export-ignore
8+
/.laminas-ci.json export-ignore
9+
/.laminas-ci export-ignore
10+
/composer-require-checker.json export-ignore
11+
/phpbench.json export-ignore
12+
/phpcs.xml export-ignore
13+
/phpunit.xml.dist export-ignore
14+
/psalm.xml export-ignore
15+
/psalm5.xml export-ignore
16+
/psalm-baseline.xml
17+
/mkdocs.yml export-ignore
18+
19+
/example/ export-ignore
20+
/vendor-bin/ export-ignore
21+
22+
/phpstan.neon export-ignore
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
name: "Continuous Integration"
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
tags:
8+
9+
jobs:
10+
ci:
11+
uses: laminas/workflow-continuous-integration/.github/workflows/continuous-integration.yml@1.x
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: "Automatic Releases"
2+
3+
on:
4+
milestone:
5+
types:
6+
- "closed"
7+
8+
jobs:
9+
release:
10+
uses: laminas/workflow-automatic-releases/.github/workflows/release-on-milestone-closed.yml@1.x
11+
secrets:
12+
GIT_AUTHOR_EMAIL: ${{ secrets.GIT_AUTHOR_EMAIL }}
13+
GIT_AUTHOR_NAME: ${{ secrets.GIT_AUTHOR_NAME }}
14+
ORGANIZATION_ADMIN_TOKEN: ${{ secrets.ORGANIZATION_ADMIN_TOKEN }}
15+
SIGNING_SECRET_KEY: ${{ secrets.SIGNING_SECRET_KEY }}

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/vendor
2+
/composer.lock
3+
/.phpcs-cache
4+
/.phpunit.cache
5+
/.phpunit.result.cache
6+
7+
/example/vendor

.laminas-ci.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"additional_checks": [
3+
{
4+
"name": "phpstan",
5+
"job": {
6+
"php": "@lowest",
7+
"command": "./vendor/bin/phpstan analyse --no-progress"
8+
}
9+
},
10+
{
11+
"name": "psalm",
12+
"job": {
13+
"php": "@latest",
14+
"command": "./vendor/bin/psalm --shepherd --stats --output-format=github --no-cache -c psalm5.xml"
15+
}
16+
},
17+
{
18+
"name": "example",
19+
"job": {
20+
"php": "@latest",
21+
"command": "diff <(./vendor/bin/phpstan analyse -c ./example/phpstan.neon --no-progress --error-format=junit | xmllint --format -) ./test/example.output"
22+
}
23+
}
24+
]
25+
}

LICENSE

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Copyright (c) 2023 struggle-for-php
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy
4+
of this software and associated documentation files (the "Software"), to deal
5+
in the Software without restriction, including without limitation the rights
6+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
copies of the Software, and to permit persons to whom the Software is
8+
furnished to do so, subject to the following conditions:
9+
10+
The above copyright notice and this permission notice shall be included in
11+
all copies or substantial portions of the Software.
12+
13+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19+
THE SOFTWARE.

composer-require-checker.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"symbol-whitelist" : [
3+
"null", "true", "false",
4+
"static", "self", "parent",
5+
"array", "string", "int", "float", "bool", "iterable", "callable", "void", "object", "mixed",
6+
"PhpParser\\Node",
7+
"PhpParser\\Node\\Arg",
8+
"PhpParser\\Node\\Expr\\ArrayItem",
9+
"PhpParser\\Node\\Expr\\Array_",
10+
"PhpParser\\Node\\Expr\\MethodCall",
11+
"PhpParser\\Node\\Identifier",
12+
"PhpParser\\Node\\Scalar\\String_",
13+
"PHPStan\\Analyser\\Scope",
14+
"PHPStan\\Rules\\Rule",
15+
"PHPStan\\Rules\\RuleErrorBuilder",
16+
"PHPStan\\Type\\ArrayType",
17+
"PHPStan\\Type\\Constant\\ConstantStringType",
18+
"PHPStan\\Type\\ObjectType",
19+
"PHPStan\\Type\\Type"
20+
]
21+
}

composer.json

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
{
2+
"name": "struggle-for-php/sfp-phpstan-dont-operation-inside-constructor",
3+
"description": "Extra strict and opinionated resource operation rules for PHPStan",
4+
"type": "phpstan-extension",
5+
"keywords": ["phpstan", "static analysis", "constructor", "operation", "resource"],
6+
"license": [
7+
"MIT"
8+
],
9+
"require": {
10+
"php": "^7.2.0 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0",
11+
"phpstan/phpstan": "^1.10",
12+
"struggle-for-php/resource-operations": "^4.0.1"
13+
},
14+
"require-dev": {
15+
"laminas/laminas-coding-standard": "^2.0.0",
16+
"maglnet/composer-require-checker": "^2|^3|^4",
17+
"phpstan/phpstan-phpunit": "^1.3",
18+
"phpunit/phpunit": "^8.5.31 || ^9.5.10",
19+
"roave/security-advisories": "dev-master",
20+
"squizlabs/php_codesniffer": "^3.7",
21+
"vimeo/psalm": "^4 || ^5.9"
22+
},
23+
"autoload": {
24+
"psr-4": {
25+
"Sfp\\PHPStan\\DontOperationInsideConstructor\\": "src"
26+
}
27+
},
28+
"autoload-dev": {
29+
"psr-4": {
30+
"SfpTest\\PHPStan\\DontOperationInsideConstructor\\": "test"
31+
}
32+
},
33+
"config": {
34+
"sort-packages": true,
35+
"allow-plugins": {
36+
"dealerdirect/phpcodesniffer-composer-installer": true
37+
}
38+
},
39+
"extra": {
40+
"phpstan": {
41+
"includes": [
42+
"extension.neon",
43+
"rules.neon"
44+
]
45+
}
46+
}
47+
}

phpcs.xml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?xml version="1.0"?>
2+
<ruleset
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:noNamespaceSchemaLocation="./vendor/squizlabs/php_codesniffer/phpcs.xsd">
5+
6+
<arg name="basepath" value="."/>
7+
<arg name="cache" value=".phpcs-cache"/>
8+
<arg name="colors"/>
9+
<arg name="extensions" value="php"/>
10+
<arg name="parallel" value="80"/>
11+
12+
<!-- Show progress -->
13+
<arg value="p"/>
14+
15+
<!-- Paths to check -->
16+
<file>src</file>
17+
<file>test</file>
18+
19+
<!-- Include all rules from Laminas Coding Standard -->
20+
<rule ref="LaminasCodingStandard"/>
21+
22+
<rule ref="PSR12">
23+
<exclude name="Generic.Files.LineLength"/>
24+
<exclude name="WebimpressCodingStandard.Formatting.StringClassReference" />
25+
</rule>
26+
</ruleset>

phpstan.neon

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
parameters:
2+
level: 9
3+
paths:
4+
- src
5+
- test
6+
excludePaths:
7+
- test/Rules/data/*
8+
9+
includes:
10+
- vendor/phpstan/phpstan-phpunit/extension.neon
11+
- vendor/phpstan/phpstan-phpunit/rules.neon

phpunit.xml.dist

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/8.5/phpunit.xsd"
5+
>
6+
<testsuites>
7+
<testsuite name="sfp-phpstan-dont-operation-inside-constructor Test Suite">
8+
<directory>./test/</directory>
9+
</testsuite>
10+
</testsuites>
11+
12+
</phpunit>

psalm5.xml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0"?>
2+
<psalm
3+
errorLevel="1"
4+
resolveFromConfigFile="true"
5+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
6+
xmlns="https://getpsalm.org/schema/config"
7+
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
8+
findUnusedBaselineEntry="true"
9+
findUnusedCode="false"
10+
>
11+
<projectFiles>
12+
<directory name="src" />
13+
<ignoreFiles>
14+
<directory name="vendor" />
15+
</ignoreFiles>
16+
</projectFiles>
17+
</psalm>

0 commit comments

Comments
 (0)