Skip to content

Commit 1e85a44

Browse files
Prepare for first release. (#10)
1 parent ca0d97e commit 1e85a44

19 files changed

+114
-71
lines changed

.github/workflows/ecs.yml

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
on:
2+
pull_request:
3+
paths-ignore:
4+
- 'docs/**'
5+
- 'README.md'
6+
- 'CHANGELOG.md'
7+
- '.gitignore'
8+
- '.gitattributes'
9+
- 'infection.json.dist'
10+
- 'phpunit.xml.dist'
11+
12+
push:
13+
branches: ['main']
14+
paths-ignore:
15+
- 'docs/**'
16+
- 'README.md'
17+
- 'CHANGELOG.md'
18+
- '.gitignore'
19+
- '.gitattributes'
20+
- 'infection.json.dist'
21+
- 'phpunit.xml.dist'
22+
23+
name: ecs
24+
25+
jobs:
26+
easy-coding-standard:
27+
uses: php-forge/actions/.github/workflows/ecs.yml@main
28+
secrets:
29+
AUTH_TOKEN: ${{ secrets.AUTH_TOKEN }}
30+
with:
31+
composer-command: |
32+
composer require yiisoft/yii2:^2.2.x-dev --prefer-dist --no-progress --no-interaction --no-scripts --ansi
33+
os: >-
34+
['ubuntu-latest']
35+
php: >-
36+
['8.1']

.styleci.yml

+4-3
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,11 @@ enabled:
1717
- combine_nested_dirname
1818
- declare_strict_types
1919
- dir_constant
20+
- empty_loop_body_braces
2021
- fully_qualified_strict_types
2122
- function_to_constant
2223
- hash_to_slash_comment
24+
- integer_literal_case
2325
- is_null
2426
- logical_operators
2527
- magic_constant_casing
@@ -56,7 +58,6 @@ enabled:
5658
- phpdoc_order
5759
- phpdoc_property
5860
- phpdoc_scalar
59-
- phpdoc_separation
6061
- phpdoc_singular_inheritdoc
6162
- phpdoc_trim
6263
- phpdoc_trim_consecutive_blank_line_separation
@@ -78,9 +79,9 @@ enabled:
7879
- trailing_comma_in_multiline_array
7980
- unalign_double_arrow
8081
- unalign_equals
81-
- empty_loop_body_braces
82-
- integer_literal_case
8382
- union_type_without_spaces
8483

8584
disabled:
8685
- function_declaration
86+
- psr12_braces
87+
- psr12_class_definition

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Change Log

LICENSE

+11-16
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,16 @@
11
MIT License
22

3-
Copyright (c) 2023 yii2-extensions
3+
Copyright (c) 2024 by Wilmer Arámbula (https://github.com/terabytesoftw) All rights reserved.
44

5-
Permission is hereby granted, free of charge, to any person obtaining a copy
6-
of this software and associated documentation files (the "Software"), to deal
7-
in the Software without restriction, including without limitation the rights
8-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9-
copies of the Software, and to permit persons to whom the Software is
10-
furnished to do so, subject to the following conditions:
5+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
6+
documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
7+
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
8+
persons to whom the Software is furnished to do so, subject to the following conditions:
119

12-
The above copyright notice and this permission notice shall be included in all
13-
copies or substantial portions of the Software.
10+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
11+
Software.
1412

15-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21-
SOFTWARE.
13+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
14+
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
15+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16+
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

README.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@ The preferred way to install this extension is through [composer](https://getcom
2626

2727
Either run
2828

29-
```
30-
composer require --dev --prefer-dist yii2-extensions/phpstan
29+
```shel
30+
composer require --dev --prefer-dist yii2-extensions/phpstan:^0.1
3131
```
3232

3333
or add
3434

35-
```
36-
"yii2-extensions/phpstan": "dev-main"
35+
```json
36+
"yii2-extensions/phpstan": "^0.1"
3737
```
3838

3939
to the require-dev section of your `composer.json` file.
@@ -51,15 +51,15 @@ to the require-dev section of your `composer.json` file.
5151

5252
## Testing
5353

54-
[Check the documentation testing](/docs/testing.md) to learn about testing.
54+
[Check the documentation testing](docs/testing.md) to learn about testing.
5555

5656
## Our social networks
5757

5858
[![Twitter](https://img.shields.io/badge/twitter-follow-1DA1F2?logo=twitter&logoColor=1DA1F2&labelColor=555555?style=flat)](https://twitter.com/Terabytesoftw)
5959

6060
## License
6161

62-
The MIT License. Please see [License File](LICENSE.md) for more information.
62+
The MIT License. Please see [License File](LICENSE) for more information.
6363

6464
## Fork
6565

changelog.md

-2
This file was deleted.

composer.json

+7-8
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,17 @@
77
"phpstan"
88
],
99
"license": "mit",
10-
"minimum-stability": "dev",
11-
"prefer-stable": true,
1210
"require": {
1311
"php": ">=8.1",
14-
"nikic/php-parser": "^4.1.0",
15-
"phpstan/phpstan": "^1.0",
16-
"yiisoft/yii2": "*"
12+
"nikic/php-parser": "^4.1",
13+
"phpstan/phpstan": "^1.10",
14+
"yiisoft/yii2": "^2.0.49 || ^2.2"
1715
},
1816
"require-dev": {
19-
"maglnet/composer-require-checker": "^4.6",
17+
"maglnet/composer-require-checker": "^4.7",
2018
"phpstan/phpstan-phpunit": "^1.0",
21-
"phpunit/phpunit": "^10.2"
19+
"phpunit/phpunit": "^10.2",
20+
"symplify/easy-coding-standard": "^12.1"
2221
},
2322
"autoload": {
2423
"psr-4": {
@@ -32,7 +31,7 @@
3231
},
3332
"extra": {
3433
"branch-alias": {
35-
"dev-main": "1.0.x-dev"
34+
"dev-main": "0.1-dev"
3635
}
3736
},
3837
"config": {

ecs.php

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use PhpCsFixer\Fixer\ClassNotation\ClassDefinitionFixer;
6+
use PhpCsFixer\Fixer\ClassNotation\OrderedClassElementsFixer;
7+
use PhpCsFixer\Fixer\ClassNotation\OrderedTraitsFixer;
8+
use PhpCsFixer\Fixer\Import\NoUnusedImportsFixer;
9+
use Symplify\EasyCodingStandard\Config\ECSConfig;
10+
11+
return ECSConfig::configure()
12+
->withConfiguredRule(
13+
ClassDefinitionFixer::class,
14+
[
15+
'space_before_parenthesis' => true,
16+
],
17+
)
18+
->withFileExtensions(['php'])
19+
->withPaths(
20+
[
21+
__DIR__ . '/src',
22+
__DIR__ . '/tests',
23+
],
24+
)
25+
->withPhpCsFixerSets(perCS20: true)
26+
->withPreparedSets(
27+
cleanCode: true,
28+
comments:true,
29+
docblocks: true,
30+
namespaces: true,
31+
psr12: true
32+
)
33+
->withRules(
34+
[
35+
NoUnusedImportsFixer::class,
36+
OrderedClassElementsFixer::class,
37+
OrderedTraitsFixer::class,
38+
]
39+
);

phpstan-yii-config.php

-5
This file was deleted.

phpunit.xml.dist

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
stopOnFailure="false"
1212
>
1313
<testsuites>
14-
<testsuite name="Yii2-PHPstan">
14+
<testsuite name="PHPstan">
1515
<directory>tests</directory>
1616
</testsuite>
1717
</testsuites>

src/Reflection/ApplicationPropertiesClassReflectionExtension.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ public function __construct(
2222
private readonly AnnotationsPropertiesClassReflectionExtension $annotationsProperties,
2323
private readonly ReflectionProvider $reflectionProvider,
2424
private readonly ServiceMap $serviceMap
25-
) {
26-
}
25+
) {}
2726

2827
public function hasProperty(ClassReflection $classReflection, string $propertyName): bool
2928
{

src/Reflection/ComponentPropertyReflection.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@
1111

1212
final class ComponentPropertyReflection implements PropertyReflection
1313
{
14-
public function __construct(private readonly PropertyReflection $fallbackProperty, private readonly Type $type)
15-
{
16-
}
14+
public function __construct(private readonly PropertyReflection $fallbackProperty, private readonly Type $type) {}
1715

1816
public function getType(): Type
1917
{

src/Reflection/RequestMethodsClassReflectionExtension.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@
1414

1515
final class RequestMethodsClassReflectionExtension implements MethodsClassReflectionExtension
1616
{
17-
public function __construct(private readonly ReflectionProvider $reflectionProvider)
18-
{
19-
}
17+
public function __construct(private readonly ReflectionProvider $reflectionProvider) {}
2018

2119
public function hasMethod(ClassReflection $classReflection, string $methodName): bool
2220
{

src/Reflection/RequestPropertiesClassReflectionExtension.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@
1515

1616
final class RequestPropertiesClassReflectionExtension implements PropertiesClassReflectionExtension
1717
{
18-
public function __construct(private readonly ReflectionProvider $reflectionProvider)
19-
{
20-
}
18+
public function __construct(private readonly ReflectionProvider $reflectionProvider) {}
2119

2220
public function hasProperty(ClassReflection $classReflection, string $propertyName): bool
2321
{

src/Reflection/ResponsePropertiesClassReflectionExtension.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@
1515

1616
final class ResponsePropertiesClassReflectionExtension implements PropertiesClassReflectionExtension
1717
{
18-
public function __construct(private readonly ReflectionProvider $reflectionProvider)
19-
{
20-
}
18+
public function __construct(private readonly ReflectionProvider $reflectionProvider) {}
2119

2220
public function hasProperty(ClassReflection $classReflection, string $propertyName): bool
2321
{

src/Reflection/UserPropertiesClassReflectionExtension.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@
1515

1616
final class UserPropertiesClassReflectionExtension implements PropertiesClassReflectionExtension
1717
{
18-
public function __construct(private readonly AnnotationsPropertiesClassReflectionExtension $annotationsProperties)
19-
{
20-
}
18+
public function __construct(private readonly AnnotationsPropertiesClassReflectionExtension $annotationsProperties) {}
2119

2220
public function hasProperty(ClassReflection $classReflection, string $propertyName): bool
2321
{

src/ServiceMap.php

-8
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,6 @@ public function getComponentClassById(string $id): ?string
9191
}
9292

9393
/**
94-
* @param string $id
95-
* @param array|Closure|int|string $service
96-
*
9794
* @throws ReflectionException
9895
*
9996
* @phpstan-param array<mixed>|string|Closure|int $service
@@ -104,13 +101,8 @@ private function addServiceDefinition(string $id, array|string|Closure|int $serv
104101
}
105102

106103
/**
107-
* @param string $id
108-
* @param array|Closure|int|string $service
109-
*
110104
* @throws ReflectionException
111105
*
112-
* @return string
113-
*
114106
* @phpstan-param string|Closure|array<mixed>|int $service
115107
*/
116108
private function guessServiceDefinition(string $id, array|string|Closure|int $service): string

src/Type/ContainerDynamicMethodReturnTypeExtension.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@
1818

1919
final class ContainerDynamicMethodReturnTypeExtension implements DynamicMethodReturnTypeExtension
2020
{
21-
public function __construct(private readonly ServiceMap $serviceMap)
22-
{
23-
}
21+
public function __construct(private readonly ServiceMap $serviceMap) {}
2422

2523
public function getClass(): string
2624
{

tests/assets/yii-config-valid.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
'container' => [
1515
'singletons' => [
1616
'singleton-string' => MyActiveRecord::class,
17-
'singleton-closure' => static function(): SplStack {
17+
'singleton-closure' => static function (): SplStack {
1818
return new SplStack();
1919
},
2020
'singleton-service' => ['class' => SplObjectStorage::class],
@@ -23,7 +23,7 @@
2323
],
2424
],
2525
'definitions' => [
26-
'closure' => static function(): SplStack {
26+
'closure' => static function (): SplStack {
2727
return new SplStack();
2828
},
2929
'service' => ['class' => SplObjectStorage::class],

0 commit comments

Comments
 (0)