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

Stop supporting PHP 7.1 and minimum required version 8.1 #48

Merged
merged 6 commits into from
Jun 9, 2024
Merged

Conversation

koriym
Copy link
Member

@koriym koriym commented Jun 1, 2024

  • app-state-diagramのphp 7.xサポートドロップのためにも

Closes #47

Improve type checks and update Psalm config

The commit introduces type checks for string variables, particularly the $docComment variable in src/DocMethod.php and path in src/XmlLoader.php. It also adjusts a boolean condition in src/DocMethod.php and modifies fields in the Psalm config file.
This commit creates a new rector.php configuration file and registers the rule InlineConstructorDefaultToPropertyRector. Additionally, it defines sets of rules available up to PHP 8.1. The PHP version requirement in composer.json is also updated to match this, now requiring PHP 8.1 or above.
Refactor code for PHP 8.1 constructor property promotion

Several classes have been refactored to use PHP 8.1's constructor property promotion. This simplifies the code by allowing properties to be defined directly in the constructor. Additionally, various classes now implement the Stringable interface. The version of "rector/rector" in the composer file has also been specified.
The GitHub actions 'static-analysis', 'continuous-integration', and 'coding-standards' have been downgraded from version 2 to version 1. Additionally, the PHP version has been updated to 8.3 in static analysis and coding standards workflows. The 'continuous-integration' workflow now considers PHP 8.3 as the current stable version with 8.1 and 8.2 as old stable versions.
Copy link

coderabbitai bot commented Jun 1, 2024

Important

Review skipped

Auto reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

The changes focus on downgrading GitHub Actions versions, updating PHP versions and dependencies, and refactoring code for better readability and maintainability. Key updates include modifying workflows, enhancing exception handling, implementing the Stringable interface in several classes, and using PHP 8.0's property promotion syntax to simplify constructors.

Changes

File/Path Change Summary
.github/workflows/coding-standards.yml Downgraded GitHub Action version to v1, added php_version: 8.3 input parameter.
.github/workflows/continuous-integration.yml Downgraded GitHub Action version to v1, added old_stable and current_stable input variables.
.github/workflows/static-analysis.yml Downgraded GitHub Action version to v1, changed configuration parameter to php_version: 8.3.
composer.json Updated PHP requirement to "^8.1", added dependency on "rector/rector": "^1.1".
phpcs.xml Added exclusions for specific SlevomatCodingStandard rules.
psalm.xml Updated xsi:schemaLocation, added findUnusedBaselineEntry and findUnusedCode attributes.
rector.php Introduced Rector configuration, including paths, rules, and rule sets.
src/AppMetaModule.php Refactored constructor to use property promotion for appMeta property.
src/Config.php Enhanced exception handling to catch Unbound without assigning it to a variable.
src/DocClass.php, src/DocMethod.php, src/DocParam.php Implemented Stringable interface, refactored constructors to use property promotion, adjusted property visibility.
src/Index.php Implemented Stringable interface, refactored constructor to use property promotion.
src/Schema.php Removed property declarations, refactored constructor to use property promotion, updated method syntax.
src/SchemaConstraints.php Implemented Stringable interface.
src/SchemaProp.php Implemented Stringable interface, refactored constructor to use property promotion, changed property visibility.
src/Src.php Implemented Stringable interface, refactored constructor to use property promotion.
src/TagLinks.php Implemented Stringable interface, refactored constructor parameter type hint.
src/TagParam.php Refactored constructor to use property promotion for type and description parameters.
src/XmlLoader.php Added type cast to realpath($path) call in locateConfigFile function.

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

An ignore comment for the PHP Code Sniffer (phpcs) was added to the DocMethod.php. This was necessary to avoid the SlevomatCodingStandard.Commenting.InlineDocCommentDeclaration.NoAssignment rule and ensure the code quality standard is met.
@koriym
Copy link
Member Author

koriym commented Jun 1, 2024

@coderabbitai review

Copy link

coderabbitai bot commented Jun 1, 2024

Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@koriym koriym requested a review from NaokiTsuchiya June 1, 2024 03:43
@koriym koriym marked this pull request as ready for review June 1, 2024 03:43
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 5

Outside diff range and nitpick comments (1)
src/DocClass.php (1)

Line range hint 73-74: JsonSchema annotation class not found.

+ use BEAR\Resource\Annotation\JsonSchema;

Ensure that the JsonSchema class is correctly imported to resolve the static analysis issue.

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between acf3535 and 7f6fb7b.

Files ignored due to path filters (1)
  • vendor-bin/tools/composer.lock is excluded by !**/*.lock
Files selected for processing (20)
  • .github/workflows/coding-standards.yml (1 hunks)
  • .github/workflows/continuous-integration.yml (1 hunks)
  • .github/workflows/static-analysis.yml (1 hunks)
  • composer.json (2 hunks)
  • phpcs.xml (1 hunks)
  • psalm.xml (1 hunks)
  • rector.php (1 hunks)
  • src/AppMetaModule.php (1 hunks)
  • src/Config.php (2 hunks)
  • src/DocClass.php (1 hunks)
  • src/DocMethod.php (4 hunks)
  • src/DocParam.php (2 hunks)
  • src/Index.php (2 hunks)
  • src/Schema.php (2 hunks)
  • src/SchemaConstraints.php (2 hunks)
  • src/SchemaProp.php (1 hunks)
  • src/Src.php (2 hunks)
  • src/TagLinks.php (2 hunks)
  • src/TagParam.php (1 hunks)
  • src/XmlLoader.php (1 hunks)
Files skipped from review due to trivial changes (3)
  • .github/workflows/coding-standards.yml
  • .github/workflows/static-analysis.yml
  • src/TagParam.php
Additional context used
PHPStan
rector.php

9-9: Parameter $rectorConfig of anonymous function has invalid type Rector\Config\RectorConfig.


16-16: Class Rector\CodeQuality\Rector\Class_\InlineConstructorDefaultToPropertyRector not found.


20-20: Access to constant UP_TO_PHP_81 on an unknown class Rector\Set\ValueObject\LevelSetList.

src/AppMetaModule.php

15-15: Class BEAR\ApiDoc\AppMetaModule extends unknown class Ray\Di\AbstractModule.


17-17: Parameter $appMeta of method BEAR\ApiDoc\AppMetaModule::__construct() has invalid type BEAR\AppMeta\AbstractAppMeta.


17-17: Parameter $module of method BEAR\ApiDoc\AppMetaModule::__construct() has invalid type Ray\Di\AbstractModule.


17-17: Property BEAR\ApiDoc\AppMetaModule::$appMeta has unknown class BEAR\AppMeta\AbstractAppMeta as its type.


19-19: BEAR\ApiDoc\AppMetaModule::__construct() calls parent::__construct() but BEAR\ApiDoc\AppMetaModule does not extend any class.


27-27: Call to an undefined method BEAR\ApiDoc\AppMetaModule::bind().


27-27: Class BEAR\AppMeta\AbstractAppMeta not found.


30-30: Call to an undefined method BEAR\ApiDoc\AppMetaModule::bind().


30-30: Class BEAR\Sunday\Extension\Application\AppInterface not found.


31-31: Call to an undefined method BEAR\ApiDoc\AppMetaModule::bind().


31-31: Class BEAR\Resource\Annotation\AppName not found.

src/Src.php

34-34: Instantiated class Rize\UriTemplate not found.


36-36: Class Rize\UriTemplate\Parser not found.


39-39: Class Rize\UriTemplate\Node\Literal not found.

src/SchemaConstraints.php

36-36: No error to ignore is reported on line 36.

src/Index.php

41-41: No error to ignore is reported on line 41.


44-44: Instantiated class phpDocumentor\Reflection\DocBlock\Description not found.


44-44: Instantiated class phpDocumentor\Reflection\DocBlock\Tags\Link not found.

src/XmlLoader.php

59-59: No error to ignore is reported on line 59.


60-60: No error to ignore is reported on line 60.


70-70: No error to ignore is reported on line 70.

src/DocClass.php

31-31: Parameter $reader of method BEAR\ApiDoc\DocClass::__construct() has invalid type Doctrine\Common\Annotations\Reader.


31-31: Property BEAR\ApiDoc\DocClass::$reader has unknown class Doctrine\Common\Annotations\Reader as its type.


73-73: Class BEAR\Resource\Annotation\JsonSchema not found.


74-74: Class BEAR\Resource\Annotation\JsonSchema not found.

src/Config.php

145-145: Instantiated class BEAR\AppMeta\Meta not found.


150-150: Instantiated class Ray\Di\Injector not found.


151-151: Class Ray\Di\InjectorInterface not found.


152-152: Class Doctrine\Common\Annotations\Reader not found.


153-153: Class Doctrine\Common\Annotations\Reader not found.


161-161: Caught class Ray\Di\Exception\Unbound not found.


169-169: Caught class Ray\Di\Exception\Unbound not found.


181-181: Class Aura\Router\Route not found.


190-190: Method BEAR\ApiDoc\Config::getRouterMap() has invalid return type Aura\Router\Map.


190-190: Parameter $injector of method BEAR\ApiDoc\Config::getRouterMap() has invalid type Ray\Di\InjectorInterface.


193-193: Class Aura\Router\RouterContainer not found.


197-197: Caught class Ray\Di\Exception\Unbound not found.

src/DocMethod.php

42-42: Parameter $reader of method BEAR\ApiDoc\DocMethod::__construct() has invalid type Doctrine\Common\Annotations\Reader.


42-42: Property BEAR\ApiDoc\DocMethod::$reader has unknown class Doctrine\Common\Annotations\Reader as its type.


45-45: Call to static method createInstance() on an unknown class phpDocumentor\Reflection\DocBlockFactory.


83-83: Parameter $docblock of method BEAR\ApiDoc\DocMethod::getTagParams() has invalid type phpDocumentor\Reflection\DocBlock.


190-190: Class BEAR\Resource\Annotation\Embed not found.


216-216: Class BEAR\Resource\Annotation\Link not found.

Additional comments not posted (19)
.github/workflows/continuous-integration.yml (1)

10-13: Ensure the downgraded GitHub Action version is compatible with the new PHP version specifications.

psalm.xml (1)

7-9: Updated xsi:schemaLocation and analysis settings align with the new PHP version requirements.

src/TagLinks.php (1)

18-25: Implementation of Stringable and use of property promotion enhance readability and maintainability.

src/SchemaProp.php (1)

14-23: Implementation of Stringable and use of property promotion enhance readability and maintainability.

src/Src.php (2)

26-29: Constructor changes look good and align with PHP 8.1 features.


Line range hint 34-34: Ensure that the classes Rize\UriTemplate, Rize\UriTemplate\Parser, and Rize\UriTemplate\Node\Literal are correctly included in the project.

Also applies to: 36-36, 39-39

src/SchemaConstraints.php (2)

24-24: Constructor changes look good and align with PHP 8.1 features.


24-24: The __toString method implementation is appropriate and well-implemented.

src/Index.php (2)

17-17: The __toString method implementation is appropriate and well-implemented.


Line range hint 44-44: Ensure that the classes phpDocumentor\Reflection\DocBlock\Description and phpDocumentor\Reflection\DocBlock\Tags\Link are correctly included in the project.

src/XmlLoader.php (2)

54-54: The __invoke method implementation is appropriate and well-implemented.


54-54: The validate method implementation is appropriate and well-implemented.

src/DocParam.php (2)

20-20: Constructor changes look good and align with PHP 8.1 features.


20-20: The __toString method implementation is appropriate and well-implemented.

phpcs.xml (1)

42-43: Configuration settings in phpcs.xml are appropriately tailored to the project's coding standards.

composer.json (1)

12-12: Updated PHP version requirement to "^8.1" aligns with the PR's objective.

src/Config.php (1)

169-169: Updated catch block to use PHP 8.0's feature for catching exceptions without variable assignment.

Verification successful

Both instances of catching the Unbound exception in src/Config.php use PHP 8.0's feature for catching exceptions without variable assignment, ensuring consistency.

  • src/Config.php: Lines 169 and another instance in the same file.
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the handling of the Unbound exception.

# Test: Search for other instances of Unbound being caught. Expect: Consistent handling.
rg --type php 'catch \(Unbound\)'

Length of output: 121

src/Schema.php (1)

48-52: Use of property promotion in the constructor simplifies the code and enhances readability.

src/DocMethod.php (1)

25-25: Implementation of the Stringable interface enhances usability by allowing objects of this class to be used directly where a string is expected.

composer.json Show resolved Hide resolved
src/DocClass.php Outdated Show resolved Hide resolved
src/XmlLoader.php Outdated Show resolved Hide resolved
rector.php Outdated Show resolved Hide resolved
src/AppMetaModule.php Outdated Show resolved Hide resolved
@koriym koriym merged commit dcd8051 into 1.x Jun 9, 2024
10 checks passed
@koriym koriym deleted the drop-php-7 branch June 9, 2024 11:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant