Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump to PHP 8.2 #110

Merged
merged 3 commits into from
Apr 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/code_analysis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:
# see https://github.com/shivammathur/setup-php
- uses: shivammathur/setup-php@v2
with:
php-version: 8.1
php-version: 8.2
coverage: none

# composer install cache - https://github.com/ramsey/composer-install
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/downgraded_release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
-
uses: "shivammathur/setup-php@v2"
with:
php-version: 8.1
php-version: 8.2
coverage: none

- uses: "ramsey/composer-install@v2"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/rector.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
-
uses: shivammathur/setup-php@v2
with:
php-version: 8.1
php-version: 8.2
coverage: none

- uses: "ramsey/composer-install@v2"
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"license": "MIT",
"keywords": ["static analysis", "phpstan-extension"],
"require": {
"php": "^8.1",
"php": "^8.2",
"phpstan/phpstan": "^1.10",
"webmozart/assert": "^1.11"
},
Expand Down
4 changes: 2 additions & 2 deletions src/CallReferece/ParentCallReferenceResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@

use PHPStan\Reflection\ReflectionProvider;

final class ParentCallReferenceResolver
final readonly class ParentCallReferenceResolver
{
public function __construct(
private readonly ReflectionProvider $reflectionProvider,
private ReflectionProvider $reflectionProvider,
) {
}

Expand Down
3 changes: 1 addition & 2 deletions src/ClassTypeDetector.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ final class ClassTypeDetector
{
public function isTestClass(ClassReflection $classReflection): bool
{
return
$classReflection->isSubclassOf('PHPUnit\Framework\TestCase')
return $classReflection->isSubclassOf('PHPUnit\Framework\TestCase')
|| $classReflection->isSubclassOf('PHPUnit_Framework_TestCase')
|| $classReflection->implementsInterface('Behat\Behat\Context\Context')
;
Expand Down
4 changes: 2 additions & 2 deletions src/Collectors/Callable_/AttributeCallableCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
/**
* @implements Collector<AttributeGroup, array<string>|null>
*/
final class AttributeCallableCollector implements Collector
final readonly class AttributeCallableCollector implements Collector
{
public function __construct(
private readonly Configuration $configuration,
private Configuration $configuration,
) {
}

Expand Down
6 changes: 3 additions & 3 deletions src/Collectors/Callable_/CallUserFuncCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
/**
* @implements Collector<FuncCall, array<string>|null>
*/
final class CallUserFuncCollector implements Collector
final readonly class CallUserFuncCollector implements Collector
{
public function __construct(
private readonly Configuration $configuration,
private readonly ClassTypeDetector $classTypeDetector,
private Configuration $configuration,
private ClassTypeDetector $classTypeDetector,
) {
}

Expand Down
6 changes: 3 additions & 3 deletions src/Collectors/ClassConstFetchCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
/**
* @implements Collector<ClassConstFetch, string[]>
*/
final class ClassConstFetchCollector implements Collector
final readonly class ClassConstFetchCollector implements Collector
{
public function __construct(
private readonly Configuration $configuration,
private readonly ClassTypeDetector $classTypeDetector,
private Configuration $configuration,
private ClassTypeDetector $classTypeDetector,
) {
}

Expand Down
4 changes: 2 additions & 2 deletions src/Collectors/FormTypeClassCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
* Match Symfony data_class element in forms types, as those use magic setters/getters
* @implements Collector<ArrayItem, array<string>|null>
*/
final class FormTypeClassCollector implements Collector
final readonly class FormTypeClassCollector implements Collector
{
public function __construct(
private readonly Configuration $configuration,
private Configuration $configuration,
) {
}

Expand Down
12 changes: 6 additions & 6 deletions src/Collectors/MethodCall/MethodCallCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@
/**
* @implements Collector<MethodCall, array<string>|null>
*/
final class MethodCallCollector implements Collector
final readonly class MethodCallCollector implements Collector
{
public function __construct(
private readonly ParentCallReferenceResolver $parentCallReferenceResolver,
private readonly ClassMethodCallReferenceResolver $classMethodCallReferenceResolver,
private readonly Configuration $configuration,
private readonly ClassTypeDetector $classTypeDetector,
private readonly CallReferencesFlatter $callReferencesFlatter,
private ParentCallReferenceResolver $parentCallReferenceResolver,
private ClassMethodCallReferenceResolver $classMethodCallReferenceResolver,
private Configuration $configuration,
private ClassTypeDetector $classTypeDetector,
private CallReferencesFlatter $callReferencesFlatter,
) {
}

Expand Down
10 changes: 5 additions & 5 deletions src/Collectors/MethodCall/MethodCallableCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@
/**
* @implements Collector<MethodCallableNode, array<string>|null>
*/
final class MethodCallableCollector implements Collector
final readonly class MethodCallableCollector implements Collector
{
public function __construct(
private readonly ClassMethodCallReferenceResolver $classMethodCallReferenceResolver,
private readonly Configuration $configuration,
private readonly ClassTypeDetector $classTypeDetector,
private readonly CallReferencesFlatter $callReferencesFlatter,
private ClassMethodCallReferenceResolver $classMethodCallReferenceResolver,
private Configuration $configuration,
private ClassTypeDetector $classTypeDetector,
private CallReferencesFlatter $callReferencesFlatter,
) {
}

Expand Down
6 changes: 3 additions & 3 deletions src/Collectors/PublicClassLikeConstCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
/**
* @implements Collector<ClassConst, array<array{class-string, string, int}>>
*/
final class PublicClassLikeConstCollector implements Collector
final readonly class PublicClassLikeConstCollector implements Collector
{
public function __construct(
private readonly ApiDocStmtAnalyzer $apiDocStmtAnalyzer,
private readonly Configuration $configuration,
private ApiDocStmtAnalyzer $apiDocStmtAnalyzer,
private Configuration $configuration,
) {
}

Expand Down
10 changes: 5 additions & 5 deletions src/Collectors/PublicClassMethodCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
/**
* @implements Collector<ClassMethod, array{class-string, string, int}|null>
*/
final class PublicClassMethodCollector implements Collector
final readonly class PublicClassMethodCollector implements Collector
{
/**
* @var string[]
Expand All @@ -38,10 +38,10 @@ final class PublicClassMethodCollector implements Collector
];

public function __construct(
private readonly ApiDocStmtAnalyzer $apiDocStmtAnalyzer,
private readonly PublicClassMethodMatcher $publicClassMethodMatcher,
private readonly MethodTypeDetector $methodTypeDetector,
private readonly Configuration $configuration,
private ApiDocStmtAnalyzer $apiDocStmtAnalyzer,
private PublicClassMethodMatcher $publicClassMethodMatcher,
private MethodTypeDetector $methodTypeDetector,
private Configuration $configuration,
) {
}

Expand Down
6 changes: 3 additions & 3 deletions src/Collectors/PublicPropertyCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@
/**
* @implements Collector<InClassNode, array<array{class-string, string, int}>>
*/
final class PublicPropertyCollector implements Collector
final readonly class PublicPropertyCollector implements Collector
{
/**
* @var array<class-string<Component>>
*/
private const CLASSES_TO_SKIP = ['Livewire\Component'];

public function __construct(
private readonly ApiDocStmtAnalyzer $apiDocStmtAnalyzer,
private readonly Configuration $configuration
private ApiDocStmtAnalyzer $apiDocStmtAnalyzer,
private Configuration $configuration
) {
}

Expand Down
6 changes: 3 additions & 3 deletions src/Collectors/PublicPropertyFetchCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@
/**
* @implements Collector<PropertyFetch, string[]>
*/
final class PublicPropertyFetchCollector implements Collector
final readonly class PublicPropertyFetchCollector implements Collector
{
public function __construct(
private readonly Configuration $configuration,
private readonly ClassTypeDetector $classTypeDetector,
private Configuration $configuration,
private ClassTypeDetector $classTypeDetector,
) {
}

Expand Down
4 changes: 2 additions & 2 deletions src/Collectors/PublicStaticPropertyFetchCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
/**
* @implements Collector<StaticPropertyFetch, string[]>
*/
final class PublicStaticPropertyFetchCollector implements Collector
final readonly class PublicStaticPropertyFetchCollector implements Collector
{
public function __construct(
private readonly Configuration $configuration
private Configuration $configuration
) {
}

Expand Down
6 changes: 3 additions & 3 deletions src/Collectors/StaticCall/StaticMethodCallCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
/**
* @implements Collector<StaticCall, array<string>|null>
*/
final class StaticMethodCallCollector implements Collector
final readonly class StaticMethodCallCollector implements Collector
{
public function __construct(
private readonly Configuration $configuration,
private readonly ClassTypeDetector $classTypeDetector,
private Configuration $configuration,
private ClassTypeDetector $classTypeDetector,
) {
}

Expand Down
6 changes: 3 additions & 3 deletions src/Collectors/StaticCall/StaticMethodCallableCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
/**
* @implements Collector<StaticMethodCallableNode, array<string>|null>
*/
final class StaticMethodCallableCollector implements Collector
final readonly class StaticMethodCallableCollector implements Collector
{
public function __construct(
private readonly Configuration $configuration,
private readonly ClassTypeDetector $classTypeDetector,
private Configuration $configuration,
private ClassTypeDetector $classTypeDetector,
) {
}

Expand Down
4 changes: 2 additions & 2 deletions src/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
/**
* @inspired by https://github.com/phpstan/phpstan-symfony/blob/1.2.x/src/Symfony/Configuration.php
*/
final class Configuration
final readonly class Configuration
{
/**
* @param array<string, mixed> $parameters
*/
public function __construct(
private readonly array $parameters
private array $parameters
) {
}

Expand Down
4 changes: 2 additions & 2 deletions src/PublicClassMethodMatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use PhpParser\Node\Stmt\ClassMethod;
use PHPStan\Reflection\ClassReflection;

final class PublicClassMethodMatcher
final readonly class PublicClassMethodMatcher
{
/**
* @var string[]
Expand All @@ -18,7 +18,7 @@ final class PublicClassMethodMatcher
];

public function __construct(
private readonly ClassTypeDetector $classTypeDetector,
private ClassTypeDetector $classTypeDetector,
) {
}

Expand Down
10 changes: 5 additions & 5 deletions src/Rules/LocalOnlyPublicClassMethodRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
/**
* @see \TomasVotruba\UnusedPublic\Tests\Rules\LocalOnlyPublicClassMethodRule\LocalOnlyPublicClassMethodRuleTest
*/
final class LocalOnlyPublicClassMethodRule implements Rule
final readonly class LocalOnlyPublicClassMethodRule implements Rule
{
/**
* @var string
Expand All @@ -36,10 +36,10 @@ final class LocalOnlyPublicClassMethodRule implements Rule
public const ERROR_MESSAGE = 'Public method "%s::%s()" is used only locally and should be turned protected/private';

public function __construct(
private readonly Configuration $configuration,
private readonly UsedMethodAnalyzer $usedMethodAnalyzer,
private readonly TemplateMethodCallsProvider $templateMethodCallsProvider,
private readonly MethodCallCollectorMapper $methodCallCollectorMapper
private Configuration $configuration,
private UsedMethodAnalyzer $usedMethodAnalyzer,
private TemplateMethodCallsProvider $templateMethodCallsProvider,
private MethodCallCollectorMapper $methodCallCollectorMapper
) {
}

Expand Down
6 changes: 3 additions & 3 deletions src/Rules/UnusedPublicClassConstRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
/**
* @see \TomasVotruba\UnusedPublic\Tests\Rules\UnusedPublicClassConstRule\UnusedPublicClassConstRuleTest
*/
final class UnusedPublicClassConstRule implements Rule
final readonly class UnusedPublicClassConstRule implements Rule
{
/**
* @var string
Expand All @@ -31,8 +31,8 @@ final class UnusedPublicClassConstRule implements Rule
public const ERROR_MESSAGE = 'Public constant "%s::%s" is never used';

public function __construct(
private readonly Configuration $configuration,
private readonly TemplateRegexFinder $templateRegexFinder,
private Configuration $configuration,
private TemplateRegexFinder $templateRegexFinder,
) {
}

Expand Down
10 changes: 5 additions & 5 deletions src/Rules/UnusedPublicClassMethodRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
/**
* @see \TomasVotruba\UnusedPublic\Tests\Rules\UnusedPublicClassMethodRule\UnusedPublicClassMethodRuleTest
*/
final class UnusedPublicClassMethodRule implements Rule
final readonly class UnusedPublicClassMethodRule implements Rule
{
/**
* @var string
Expand All @@ -38,10 +38,10 @@ final class UnusedPublicClassMethodRule implements Rule
public const ERROR_MESSAGE = 'Public method "%s::%s()" is never used';

public function __construct(
private readonly Configuration $configuration,
private readonly TemplateMethodCallsProvider $templateMethodCallsProvider,
private readonly UsedMethodAnalyzer $usedMethodAnalyzer,
private readonly MethodCallCollectorMapper $methodCallCollectorMapper,
private Configuration $configuration,
private TemplateMethodCallsProvider $templateMethodCallsProvider,
private UsedMethodAnalyzer $usedMethodAnalyzer,
private MethodCallCollectorMapper $methodCallCollectorMapper,
) {
}

Expand Down
4 changes: 2 additions & 2 deletions src/Rules/UnusedPublicPropertyRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
/**
* @see \TomasVotruba\UnusedPublic\Tests\Rules\UnusedPublicPropertyRule\UnusedPublicPropertyRuleTest
*/
final class UnusedPublicPropertyRule implements Rule
final readonly class UnusedPublicPropertyRule implements Rule
{
/**
* @var string
Expand All @@ -30,7 +30,7 @@ final class UnusedPublicPropertyRule implements Rule
public const ERROR_MESSAGE = 'Public property "%s::$%s" is never used';

public function __construct(
private readonly Configuration $configuration
private Configuration $configuration
) {
}

Expand Down
Loading
Loading