Skip to content

Commit 330e738

Browse files
committed
Initial commit
1 parent ee0406a commit 330e738

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+1316
-0
lines changed

.editorconfig

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
end_of_line = lf
6+
insert_final_newline = true
7+
indent_style = space
8+
indent_size = 4
9+
trim_trailing_whitespace = true
10+
11+
[*.md]
12+
trim_trailing_whitespace = false
13+
14+
[*.yml]
15+
indent_size = 2

.gitattributes

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
* text=auto
2+
*.stub linguist-language=PHP
3+
4+
.github/ export-ignore
5+
tests/ export-ignore
6+
.editorconfig export-ignore
7+
.gitattributes export-ignore
8+
.gitignore export-ignore
9+
phpcs.xml.dist export-ignore
10+
phpstan.neon.dist export-ignore
11+
phpstan-baseline.neon export-ignore
12+
phpunit.xml.dist export-ignore

.github/workflows/phpcs.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: PHP_CodeSniffer
2+
on:
3+
pull_request: ~
4+
push:
5+
branches: [ main ]
6+
jobs:
7+
phpcs:
8+
runs-on: ubuntu-latest
9+
name: PHP_CodeSniffer
10+
steps:
11+
- name: Checkout code
12+
uses: actions/checkout@v4
13+
- name: Setup PHP
14+
uses: shivammathur/setup-php@v2
15+
with:
16+
php-version: 8.1
17+
tools: composer:v2, cs2pr
18+
coverage: none
19+
- name: Get Composer cache directory
20+
id: composer-cache
21+
run: |
22+
echo "COMPOSER_CACHE_DIR=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
23+
- name: Setup Composer cache
24+
uses: actions/cache@v4
25+
with:
26+
path: ${{ steps.composer-cache.outputs.COMPOSER_CACHE_DIR }}
27+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
28+
restore-keys: |
29+
${{ runner.os }}-composer-
30+
- name: Install Composer dependencies
31+
run: composer install --prefer-dist --no-interaction --no-progress --no-scripts
32+
- name: Run PHP_CodeSniffer
33+
run: ./vendor/bin/phpcs --report=checkstyle -q | cs2pr --graceful-warnings

.github/workflows/phpstan.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: PHPStan
2+
on:
3+
pull_request: ~
4+
push:
5+
branches: [ main ]
6+
jobs:
7+
phpstan:
8+
runs-on: ubuntu-latest
9+
name: PHPStan
10+
steps:
11+
- name: Checkout code
12+
uses: actions/checkout@v4
13+
- name: Setup PHP
14+
uses: shivammathur/setup-php@v2
15+
with:
16+
php-version: 8.1
17+
tools: composer:v2
18+
coverage: none
19+
- name: Get Composer cache directory
20+
id: composer-cache
21+
run: |
22+
echo "COMPOSER_CACHE_DIR=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
23+
- name: Setup Composer cache
24+
uses: actions/cache@v4
25+
with:
26+
path: ${{ steps.composer-cache.outputs.COMPOSER_CACHE_DIR }}
27+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
28+
restore-keys: |
29+
${{ runner.os }}-composer-
30+
- name: Install Composer dependencies
31+
run: composer install --no-interaction --no-progress
32+
- name: Run PHPStan
33+
run: ./vendor/bin/phpstan --no-progress

.github/workflows/phpunit.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: PHPUnit
2+
on:
3+
pull_request: ~
4+
push:
5+
branches: [ main ]
6+
jobs:
7+
phpunit:
8+
runs-on: ubuntu-latest
9+
name: PHPUnit
10+
steps:
11+
- name: Checkout code
12+
uses: actions/checkout@v4
13+
- name: Setup PHP
14+
uses: shivammathur/setup-php@v2
15+
with:
16+
php-version: 8.1
17+
tools: composer:v2
18+
coverage: none
19+
- name: Get Composer cache directory
20+
id: composer-cache
21+
run: |
22+
echo "COMPOSER_CACHE_DIR=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
23+
- name: Setup Composer cache
24+
uses: actions/cache@v4
25+
with:
26+
path: ${{ steps.composer-cache.outputs.COMPOSER_CACHE_DIR }}
27+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
28+
restore-keys: |
29+
${{ runner.os }}-composer-
30+
- name: Install Composer dependencies
31+
run: |
32+
composer install --no-interaction --no-progress
33+
- name: Run PHPUnit
34+
run: ./vendor/bin/phpunit

.gitignore

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

README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# resolve/phpstan-phpoption
2+
3+
PHPStan extension for [phpoption/phpoption](https://github.com/schmittjoh/php-option).
4+
5+
## Installation
6+
7+
You may install this package using Composer using the command below. PHPStan should detect the extension automatically
8+
if you have its [extension installer](https://github.com/phpstan/extension-installer) installed.
9+
10+
```bash
11+
composer require --dev resolve/phpstan-phpoption
12+
```
13+
14+
## Backwards compatibility promise
15+
16+
This library follows [semver 2.0](https://semver.org/) conventions for its configuration and use. However, PHP code is
17+
not covered by this promise and should not be relied upon directly.
18+
19+
Similarly, PHPStan reporting new errors is not considered a breaking change and may occur after updating this library.
20+
21+
## License
22+
23+
This package is licensed under the [MIT license](LICENSE).
24+

composer.json

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
{
2+
"name": "resolve/phpstan-phpoption",
3+
"description": "PHPStan extension for phpoption/phpoption",
4+
"type": "phpstan-extension",
5+
"license": "MIT",
6+
"authors": [
7+
{
8+
"name": "Choraimy Kroonstuiver",
9+
"homepage": "https://github.com/resolve-php"
10+
}
11+
],
12+
"require": {
13+
"php": "^8.1",
14+
"phpstan/phpstan": "^1.12"
15+
},
16+
"require-dev": {
17+
"phpoption/phpoption": "^1.9",
18+
"phpstan/extension-installer": "^1.4",
19+
"phpstan/phpstan-deprecation-rules": "^1.2",
20+
"phpstan/phpstan-strict-rules": "^1.6",
21+
"phpunit/phpunit": "^10.5 || ^11.3",
22+
"slevomat/coding-standard": "^8.15"
23+
},
24+
"autoload": {
25+
"psr-4": {
26+
"Resolve\\PHPStan\\": "src/"
27+
}
28+
},
29+
"autoload-dev": {
30+
"psr-4": {
31+
"Tests\\": "tests/"
32+
}
33+
},
34+
"config": {
35+
"allow-plugins": {
36+
"dealerdirect/phpcodesniffer-composer-installer": true,
37+
"phpstan/extension-installer": true
38+
},
39+
"sort-packages": true
40+
},
41+
"extra": {
42+
"phpstan": {
43+
"includes": [
44+
"extension.neon"
45+
]
46+
}
47+
}
48+
}

extension.neon

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
parameters:
2+
stubFiles:
3+
- stubs/Option.stub
4+
5+
services:
6+
- class: Resolve\PHPStan\Type\PhpOption\EnsureReturnTypeExtension
7+
tags: [phpstan.broker.dynamicStaticMethodReturnTypeExtension]
8+
- class: Resolve\PHPStan\Type\PhpOption\FilterReturnTypeExtension
9+
tags: [phpstan.broker.dynamicMethodReturnTypeExtension]
10+
- class: Resolve\PHPStan\Type\PhpOption\FromArraysValueReturnTypeExtension
11+
tags: [phpstan.broker.dynamicStaticMethodReturnTypeExtension]
12+
- class: Resolve\PHPStan\Type\PhpOption\FromReturnReturnTypeExtension
13+
tags: [phpstan.broker.dynamicStaticMethodReturnTypeExtension]
14+
- class: Resolve\PHPStan\Type\PhpOption\FromValueReturnTypeExtension
15+
tags: [phpstan.broker.dynamicStaticMethodReturnTypeExtension]
16+
- class: Resolve\PHPStan\Type\PhpOption\LiftReturnTypeExtension
17+
tags: [phpstan.broker.dynamicStaticMethodReturnTypeExtension]
18+
- class: Resolve\PHPStan\Type\PhpOption\RejectReturnTypeExtension
19+
tags: [phpstan.broker.dynamicMethodReturnTypeExtension]

phpcs.xml.dist

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
name="Coding Standard"
4+
xsi:noNamespaceSchemaLocation="./vendor/squizlabs/php_codesniffer/phpcs.xsd">
5+
6+
<arg value="sp"/>
7+
<config name="tab_width" value="4"/>
8+
9+
<rule ref="PSR12"/>
10+
11+
<rule ref="Generic.Arrays.ArrayIndent"/>
12+
<rule ref="Generic.Arrays.DisallowLongArraySyntax"/>
13+
<rule ref="Generic.Files.LineLength">
14+
<properties>
15+
<property name="ignoreComments" value="true"/>
16+
</properties>
17+
</rule>
18+
<rule ref="Generic.Formatting.SpaceAfterCast"/>
19+
<rule ref="PSR1.Classes.ClassDeclaration.MissingNamespace"/>
20+
<rule ref="PSR1.Classes.ClassDeclaration.MultipleClasses"/>
21+
<rule ref="PSR1.Files.SideEffects.FoundWithSymbols"/>
22+
<rule ref="SlevomatCodingStandard.Arrays.TrailingArrayComma"/>
23+
<rule ref="SlevomatCodingStandard.Classes.ClassMemberSpacing">
24+
<properties>
25+
<property name="linesCountBetweenMembers" value="1"/>
26+
</properties>
27+
</rule>
28+
<rule ref="SlevomatCodingStandard.Classes.MethodSpacing">
29+
<properties>
30+
<property name="minLinesCount" value="1"/>
31+
<property name="maxLinesCount" value="1"/>
32+
</properties>
33+
</rule>
34+
<rule ref="SlevomatCodingStandard.Commenting.UselessFunctionDocComment"/>
35+
<rule ref="SlevomatCodingStandard.ControlStructures.BlockControlStructureSpacing">
36+
<properties>
37+
<property name="controlStructures" type="array">
38+
<element value="for"/>
39+
<element value="foreach"/>
40+
<element value="if"/>
41+
<element value="switch"/>
42+
<element value="while"/>
43+
</property>
44+
</properties>
45+
</rule>
46+
<rule ref="SlevomatCodingStandard.ControlStructures.JumpStatementsSpacing">
47+
<properties>
48+
<property name="jumpStatements" type="array">
49+
<element value="break"/>
50+
<element value="continue"/>
51+
<element value="yield"/>
52+
<element value="yield_from"/>
53+
<element value="return"/>
54+
<element value="throw"/>
55+
</property>
56+
</properties>
57+
</rule>
58+
<rule ref="SlevomatCodingStandard.Functions.RequireTrailingCommaInCall"/>
59+
<rule ref="SlevomatCodingStandard.Functions.RequireTrailingCommaInDeclaration"/>
60+
<rule ref="SlevomatCodingStandard.Functions.StaticClosure"/>
61+
<rule ref="SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses"/>
62+
<rule ref="SlevomatCodingStandard.Namespaces.UnusedUses"/>
63+
<rule ref="SlevomatCodingStandard.Namespaces.FullyQualifiedClassNameInAnnotation"/>
64+
<rule ref="SlevomatCodingStandard.PHP.TypeCast"/>
65+
<rule ref="SlevomatCodingStandard.TypeHints.DeclareStrictTypes">
66+
<properties>
67+
<property name="spacesCountAroundEqualsSign" value="0"/>
68+
</properties>
69+
</rule>
70+
<rule ref="Squiz.Strings.DoubleQuoteUsage"/>
71+
72+
<file>./src</file>
73+
<file>./tests</file>
74+
75+
</ruleset>

0 commit comments

Comments
 (0)