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

Drop PHP 7.x support and add PHP 8.3 support #11

Merged
merged 12 commits into from
Jun 9, 2024
Merged

Drop PHP 7.x support and add PHP 8.3 support #11

merged 12 commits into from
Jun 9, 2024

Conversation

koriym
Copy link
Member

@koriym koriym commented Jun 8, 2024

Closes #10

koriym added 11 commits June 8, 2024 23:38
The .scrutinizer.yml file has been updated to run PHP tests specifically on version 8.2. Additionally, the previous list of tools has been removed, including PHP mess detector, PHP analyzer, etc., presumably because they are no longer needed.
This commit added 'bamarni/composer-bin-plugin' to the allowed plugins section in the composer.json configuration. This is necessary to ensure compatibility and functionality with this particular plugin.
This commit removes the entire build.xml file, a configuration file for build tools. This document provided specific instructions to the build process, including tasks for various test and report generation. The deletion may suggest a shift to a different build process.
The PHP version requirement has been updated in composer.json. The support now is for PHP version 8.1 only, older versions (7.3 and 8.0) are not included in the "require" field anymore.
The annotation syntax for Stream has been migrated from Doctrine to the native PHP 8 Attributes. Changes have been made in several files including Streamer.php, Annotation/Stream.php, and StreamTransferInject.php. Also, the dependency on "doctrine/annotations" has been removed from composer.json as it is no longer needed.
Updated the doctrine/coding-standard from version 8.2 to version 11 in composer.json. Also added configuration to allow the use of dealerdirect/phpcodesniffer-composer-installer plugin.
The code has been refactored to improve clarity and compatibility with PHP 8. Key changes involve using constructor property and parameter promotion and changing comments to PHP 8's more intuitive format. The random number generator in the StreamRenderer has also been modified for better randomness.
Add Stream annotation and update StreamProvider comments

Stream annotation is added in Streamer.php. The comments in StreamProvider.php are updated to explicitly state that it implements ProviderInterface<resource>. This gives better understanding of the code structure and the relationship between StreamProvider and ProviderInterface.
The update ensures that the `ResourceObject` body is iterable before processing. It also tweaks the `StreamResponder` to avoid setting HTTP response codes when running under command-line interface (CLI) and only attempts to render `ResourceObject` if its `view` property is `null`. Unnecessary annotation in `IntegrateTest` was also removed and `StreamTransferInject` was updated with necessary dependencies.
Updated phpstan.neon configuration file from 'excludes_analyse' to 'excludePaths'. This change suits the new syntax guidelines for the application paths, specifically for the 'tests/Fake' directory.
This commit dramatically simplifies our GitHub workflows for continuous integration, coding standards checking, and static analysis. We've switched to utilizing shared workflows from ray-di GitHub instead of maintaining several complex, custom workflows. This change streamlines the validation process and reduces redundancy in our codebase while upgrading PHP version to 8.3.
Copy link

coderabbitai bot commented Jun 8, 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 recent changes across various configuration and source files primarily focus on updating PHP compatibility to version 8.3. This includes modifying GitHub workflows, updating Composer dependencies, and refactoring source code for better type safety and modern PHP features. The updates aim to streamline coding standards, continuous integration, and static analysis processes while ensuring compatibility with the latest PHP versions.

Changes

Files/Paths Change Summary
.github/workflows/coding-standards.yml Replaced multiple steps with a single GitHub action for coding standards using PHP 8.3.
.github/workflows/continuous-integration.yml Replaced phpunit job with a new ci job using a different action for old and current stable PHP versions.
.github/workflows/static-analysis.yml Replaced multiple static analysis jobs with a single job using a different setup and PHP 8.3.
.scrutinizer.yml Updated PHP version to 8.2 and simplified configuration by removing various tools.
composer.json Updated PHP requirement to ^8.1 and phpunit/phpunit to ^9.6.19.
phpstan.neon Renamed excludes_analyse parameter to excludePaths.
src/Annotation/Stream.php Replaced @Annotation and @Target annotations with PHP 8 attributes.
src/StreamProvider.php Added @implements ProviderInterface<resource> annotation.
src/StreamRenderer.php Various refactoring including visibility changes, type declarations, and assertion additions.
src/StreamResponder.php Refactored constructor and conditional checks.
src/StreamTransferInject.php Replaced annotations with PHP 8 attributes in methods.
src/Streamer.php Refactored property and constructor declarations for type safety.
src/StreamerInterface.php Minor modification in PHP docblock comment for addStreams method.
tests/IntegrateTest.php Refactored class properties and updated type declarations.
vendor-bin/tools/composer.json Updated doctrine/coding-standard version and added configuration for phpcodesniffer-composer-installer.

Assessment against linked issues

Objective Addressed Explanation
Enable latest PHP compat (#10)
Introduce configuration settings for language server integration (#10) The changes do not explicitly mention language server integration settings.

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.

The current version of PHPUnit used for development has been updated to "^9.6.19". This is to ensure that our testing framework remains current and incorporates the latest features and security fixes available in this version.
@koriym koriym marked this pull request as ready for review June 8, 2024 15:43
@koriym
Copy link
Member Author

koriym commented Jun 8, 2024

@coderabbitai review

Copy link

coderabbitai bot commented Jun 8, 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.

1 similar comment
Copy link

coderabbitai bot commented Jun 8, 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.

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: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 76978ee and 4472724.

Files selected for processing (15)
  • .github/workflows/coding-standards.yml (1 hunks)
  • .github/workflows/continuous-integration.yml (1 hunks)
  • .github/workflows/static-analysis.yml (1 hunks)
  • .scrutinizer.yml (1 hunks)
  • composer.json (2 hunks)
  • phpstan.neon (1 hunks)
  • src/Annotation/Stream.php (1 hunks)
  • src/StreamProvider.php (1 hunks)
  • src/StreamRenderer.php (3 hunks)
  • src/StreamResponder.php (3 hunks)
  • src/StreamTransferInject.php (2 hunks)
  • src/Streamer.php (1 hunks)
  • src/StreamerInterface.php (1 hunks)
  • tests/IntegrateTest.php (3 hunks)
  • vendor-bin/tools/composer.json (1 hunks)
Files skipped from review due to trivial changes (2)
  • .scrutinizer.yml
  • src/StreamerInterface.php
Additional comments not posted (20)
phpstan.neon (1)

6-6: Change aligns with PHPStan's latest configuration standards.

.github/workflows/static-analysis.yml (1)

9-12: Simplification of the static analysis workflow is well-aligned with the project's goals.

.github/workflows/coding-standards.yml (1)

9-12: Update to coding standards workflow is consistent with the modernization efforts.

Verification successful

The recent runs of the coding-standards.yml workflow show successful completions for the latest changes, indicating that the new configuration is working as expected.

Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the correct execution of the new coding standards workflow.

# Test: Trigger the workflow manually via GitHub Actions to ensure it runs correctly with the new configuration.
echo "Manually trigger the workflow in GitHub Actions and check for successful completion."

Length of output: 178



Script:

#!/bin/bash
# Description: Check the recent runs of the coding-standards.yml workflow and their statuses.

# List the recent runs of the coding-standards.yml workflow
gh run list --workflow=coding-standards.yml --limit 5

Length of output: 603

src/Annotation/Stream.php (1)

9-9: Transition to PHP 8 attributes is correctly implemented.

.github/workflows/continuous-integration.yml (1)

9-13: LGTM! Verify the new GitHub action for compatibility and functionality.

vendor-bin/tools/composer.json (1)

3-3: LGTM! Ensure compatibility of the new coding standard and plugin with PHP 8.3.

Also applies to: 10-14

src/StreamProvider.php (1)

13-13: LGTM! The explicit interface implementation enhances type safety and clarity.

src/StreamTransferInject.php (1)

17-19: LGTM! Verify the correct functionality of the new PHP 8 attributes in practice.

Also applies to: 25-26

Verification successful

The attributes #[Inject] and #[Stream] are present in the codebase, specifically in the src/StreamTransferInject.php file. This confirms that the attributes have been correctly applied in the methods.

  • #[Inject] is found in src/StreamTransferInject.php.
  • #[Stream] is found in both src/StreamTransferInject.php and src/Streamer.php.
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the correct functionality of the new PHP 8 attributes in `setRenderer` and `setTransfer` methods.

# Test: Check if the attributes are correctly interpreted and function as expected.
ast-grep --lang php --pattern $'trait StreamTransferInject {
  $$$
  #[Inject]
  #[Stream]
  $_($_) {
    $$$
  }
  $$$
}'

Length of output: 230



Script:

#!/bin/bash
# Description: Verify the correct functionality of the new PHP 8 attributes in `setRenderer` and `setTransfer` methods.

# Test: Check if the attributes are correctly interpreted and function as expected.
rg --multiline --multiline-dotall 'trait StreamTransferInject \{.*?#[Inject].*?#[Stream].*?\}' --glob '*.php'

Length of output: 111



Script:

#!/bin/bash
# Description: Verify the correct functionality of the new PHP 8 attributes in `setRenderer` and `setTransfer` methods.

# Test: Check if the `#[Inject]` attribute is present in the codebase.
rg --multiline --multiline-dotall '#\[Inject\]' --glob '*.php'

# Test: Check if the `#[Stream]` attribute is present in the codebase.
rg --multiline --multiline-dotall '#\[Stream\]' --glob '*.php'

Length of output: 332

src/StreamResponder.php (3)

19-19: Constructor now correctly uses private readonly for immutability.


30-30: Improved null check enhances type safety and clarity.


40-42: CLI check around http_response_code is a good practice to avoid unnecessary operations in CLI mode.

src/Streamer.php (2)

24-24: Adding array type declaration enhances type safety.


28-28: Use of PHP 8 constructor property promotion enhances code simplicity and readability.

src/StreamRenderer.php (2)

26-31: Constructor and property changes correctly use PHP 8 features for better immutability and type safety.


80-80: Use of assert for checking iterability enhances robustness and prevents runtime errors.

composer.json (2)

29-29: Updated PHP version requirement aligns with the PR's objectives to support newer PHP versions.


36-36: Updated phpunit version ensures compatibility with the new PHP version.

tests/IntegrateTest.php (3)

27-29: Type declarations for properties enhance type safety and maintainability.


39-39: Improved annotation for caseProvider enhances clarity on the expected return type.


74-74: Proper use of assertions and stream handling in testRender ensures robust testing.

@koriym koriym requested a review from NaokiTsuchiya June 9, 2024 01:05
@koriym koriym merged commit dff3f56 into 1.x Jun 9, 2024
24 checks passed
@koriym koriym deleted the php8.3 branch June 9, 2024 11:02
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