Skip to content

Commit

Permalink
Prepare for first release.
Browse files Browse the repository at this point in the history
  • Loading branch information
terabytesoftw committed Feb 27, 2024
1 parent ca0d97e commit 4568e9e
Show file tree
Hide file tree
Showing 19 changed files with 114 additions and 71 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/ecs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
on:
pull_request:
paths-ignore:
- 'docs/**'
- 'README.md'
- 'CHANGELOG.md'
- '.gitignore'
- '.gitattributes'
- 'infection.json.dist'
- 'phpunit.xml.dist'

push:
branches: ['main']
paths-ignore:
- 'docs/**'
- 'README.md'
- 'CHANGELOG.md'
- '.gitignore'
- '.gitattributes'
- 'infection.json.dist'
- 'phpunit.xml.dist'

name: ecs

jobs:
easy-coding-standard:
uses: php-forge/actions/.github/workflows/ecs.yml@main
secrets:
AUTH_TOKEN: ${{ secrets.AUTH_TOKEN }}
with:
composer-command: |
composer require yiisoft/yii2:^2.2.x-dev --prefer-dist --no-progress --no-interaction --no-scripts --ansi
os: >-
['ubuntu-latest']
php: >-
['8.1']
7 changes: 4 additions & 3 deletions .styleci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@ enabled:
- combine_nested_dirname
- declare_strict_types
- dir_constant
- empty_loop_body_braces
- fully_qualified_strict_types
- function_to_constant
- hash_to_slash_comment
- integer_literal_case
- is_null
- logical_operators
- magic_constant_casing
Expand Down Expand Up @@ -56,7 +58,6 @@ enabled:
- phpdoc_order
- phpdoc_property
- phpdoc_scalar
- phpdoc_separation
- phpdoc_singular_inheritdoc
- phpdoc_trim
- phpdoc_trim_consecutive_blank_line_separation
Expand All @@ -78,9 +79,9 @@ enabled:
- trailing_comma_in_multiline_array
- unalign_double_arrow
- unalign_equals
- empty_loop_body_braces
- integer_literal_case
- union_type_without_spaces

disabled:
- function_declaration
- psr12_braces
- psr12_class_definition
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Change Log
27 changes: 11 additions & 16 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,21 +1,16 @@
MIT License

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

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

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ The preferred way to install this extension is through [composer](https://getcom

Either run

```
composer require --dev --prefer-dist yii2-extensions/phpstan
```shel
composer require --dev --prefer-dist yii2-extensions/phpstan:^0.1
```

or add

```
"yii2-extensions/phpstan": "dev-main"
```json
"yii2-extensions/phpstan": "^0.1"
```

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

## Testing

[Check the documentation testing](/docs/testing.md) to learn about testing.
[Check the documentation testing](docs/testing.md) to learn about testing.

## Our social networks

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

## License

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

## Fork

Expand Down
2 changes: 0 additions & 2 deletions changelog.md

This file was deleted.

15 changes: 7 additions & 8 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,17 @@
"phpstan"
],
"license": "mit",
"minimum-stability": "dev",
"prefer-stable": true,
"require": {
"php": ">=8.1",
"nikic/php-parser": "^4.1.0",
"phpstan/phpstan": "^1.0",
"yiisoft/yii2": "*"
"nikic/php-parser": "^4.1",
"phpstan/phpstan": "^1.10",
"yiisoft/yii2": "^2.0.49 || ^2.2"
},
"require-dev": {
"maglnet/composer-require-checker": "^4.6",
"maglnet/composer-require-checker": "^4.7",
"phpstan/phpstan-phpunit": "^1.0",
"phpunit/phpunit": "^10.2"
"phpunit/phpunit": "^10.2",
"symplify/easy-coding-standard": "^12.1"
},
"autoload": {
"psr-4": {
Expand All @@ -32,7 +31,7 @@
},
"extra": {
"branch-alias": {
"dev-main": "1.0.x-dev"
"dev-main": "0.1-dev"
}
},
"config": {
Expand Down
39 changes: 39 additions & 0 deletions ecs.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

declare(strict_types=1);

use PhpCsFixer\Fixer\ClassNotation\ClassDefinitionFixer;
use PhpCsFixer\Fixer\ClassNotation\OrderedClassElementsFixer;
use PhpCsFixer\Fixer\ClassNotation\OrderedTraitsFixer;
use PhpCsFixer\Fixer\Import\NoUnusedImportsFixer;
use Symplify\EasyCodingStandard\Config\ECSConfig;

return ECSConfig::configure()
->withConfiguredRule(
ClassDefinitionFixer::class,
[
'space_before_parenthesis' => true,
],
)
->withFileExtensions(['php'])
->withPaths(
[
__DIR__ . '/src',
__DIR__ . '/tests',
],
)
->withPhpCsFixerSets(perCS20: true)
->withPreparedSets(
cleanCode: true,
comments:true,
docblocks: true,
namespaces: true,
psr12: true
)
->withRules(
[
NoUnusedImportsFixer::class,
OrderedClassElementsFixer::class,
OrderedTraitsFixer::class,
]
);
5 changes: 0 additions & 5 deletions phpstan-yii-config.php

This file was deleted.

2 changes: 1 addition & 1 deletion phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
stopOnFailure="false"
>
<testsuites>
<testsuite name="Yii2-PHPstan">
<testsuite name="PHPstan">
<directory>tests</directory>
</testsuite>
</testsuites>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ public function __construct(
private readonly AnnotationsPropertiesClassReflectionExtension $annotationsProperties,
private readonly ReflectionProvider $reflectionProvider,
private readonly ServiceMap $serviceMap
) {
}
) {}

Check warning on line 25 in src/Reflection/ApplicationPropertiesClassReflectionExtension.php

View check run for this annotation

Codecov / codecov/patch

src/Reflection/ApplicationPropertiesClassReflectionExtension.php#L25

Added line #L25 was not covered by tests

public function hasProperty(ClassReflection $classReflection, string $propertyName): bool
{
Expand Down
4 changes: 1 addition & 3 deletions src/Reflection/ComponentPropertyReflection.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@

final class ComponentPropertyReflection implements PropertyReflection
{
public function __construct(private readonly PropertyReflection $fallbackProperty, private readonly Type $type)
{
}
public function __construct(private readonly PropertyReflection $fallbackProperty, private readonly Type $type) {}

Check warning on line 14 in src/Reflection/ComponentPropertyReflection.php

View check run for this annotation

Codecov / codecov/patch

src/Reflection/ComponentPropertyReflection.php#L14

Added line #L14 was not covered by tests

public function getType(): Type
{
Expand Down
4 changes: 1 addition & 3 deletions src/Reflection/RequestMethodsClassReflectionExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@

final class RequestMethodsClassReflectionExtension implements MethodsClassReflectionExtension
{
public function __construct(private readonly ReflectionProvider $reflectionProvider)
{
}
public function __construct(private readonly ReflectionProvider $reflectionProvider) {}

Check warning on line 18 in src/Reflection/RequestMethodsClassReflectionExtension.php

View check run for this annotation

Codecov / codecov/patch

src/Reflection/RequestMethodsClassReflectionExtension.php#L17-L18

Added lines #L17 - L18 were not covered by tests
public function hasMethod(ClassReflection $classReflection, string $methodName): bool
{
Expand Down
4 changes: 1 addition & 3 deletions src/Reflection/RequestPropertiesClassReflectionExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@

final class RequestPropertiesClassReflectionExtension implements PropertiesClassReflectionExtension
{
public function __construct(private readonly ReflectionProvider $reflectionProvider)
{
}
public function __construct(private readonly ReflectionProvider $reflectionProvider) {}

public function hasProperty(ClassReflection $classReflection, string $propertyName): bool
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@

final class ResponsePropertiesClassReflectionExtension implements PropertiesClassReflectionExtension
{
public function __construct(private readonly ReflectionProvider $reflectionProvider)
{
}
public function __construct(private readonly ReflectionProvider $reflectionProvider) {}

Check warning on line 18 in src/Reflection/ResponsePropertiesClassReflectionExtension.php

View check run for this annotation

Codecov / codecov/patch

src/Reflection/ResponsePropertiesClassReflectionExtension.php#L18

Added line #L18 was not covered by tests

public function hasProperty(ClassReflection $classReflection, string $propertyName): bool
{
Expand Down
4 changes: 1 addition & 3 deletions src/Reflection/UserPropertiesClassReflectionExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@

final class UserPropertiesClassReflectionExtension implements PropertiesClassReflectionExtension
{
public function __construct(private readonly AnnotationsPropertiesClassReflectionExtension $annotationsProperties)
{
}
public function __construct(private readonly AnnotationsPropertiesClassReflectionExtension $annotationsProperties) {}

Check warning on line 18 in src/Reflection/UserPropertiesClassReflectionExtension.php

View check run for this annotation

Codecov / codecov/patch

src/Reflection/UserPropertiesClassReflectionExtension.php#L18

Added line #L18 was not covered by tests

public function hasProperty(ClassReflection $classReflection, string $propertyName): bool
{
Expand Down
8 changes: 0 additions & 8 deletions src/ServiceMap.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,6 @@ public function getComponentClassById(string $id): ?string
}

/**
* @param string $id
* @param array|Closure|int|string $service
*
* @throws ReflectionException
*
* @phpstan-param array<mixed>|string|Closure|int $service
Expand All @@ -104,13 +101,8 @@ private function addServiceDefinition(string $id, array|string|Closure|int $serv
}

/**
* @param string $id
* @param array|Closure|int|string $service
*
* @throws ReflectionException
*
* @return string
*
* @phpstan-param string|Closure|array<mixed>|int $service
*/
private function guessServiceDefinition(string $id, array|string|Closure|int $service): string
Expand Down
4 changes: 1 addition & 3 deletions src/Type/ContainerDynamicMethodReturnTypeExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@

final class ContainerDynamicMethodReturnTypeExtension implements DynamicMethodReturnTypeExtension
{
public function __construct(private readonly ServiceMap $serviceMap)
{
}
public function __construct(private readonly ServiceMap $serviceMap) {}

Check warning on line 21 in src/Type/ContainerDynamicMethodReturnTypeExtension.php

View check run for this annotation

Codecov / codecov/patch

src/Type/ContainerDynamicMethodReturnTypeExtension.php#L21

Added line #L21 was not covered by tests

public function getClass(): string
{
Expand Down
4 changes: 2 additions & 2 deletions tests/assets/yii-config-valid.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
'container' => [
'singletons' => [
'singleton-string' => MyActiveRecord::class,
'singleton-closure' => static function(): SplStack {
'singleton-closure' => static function (): SplStack {
return new SplStack();
},
'singleton-service' => ['class' => SplObjectStorage::class],
Expand All @@ -23,7 +23,7 @@
],
],
'definitions' => [
'closure' => static function(): SplStack {
'closure' => static function (): SplStack {
return new SplStack();
},
'service' => ['class' => SplObjectStorage::class],
Expand Down

0 comments on commit 4568e9e

Please sign in to comment.