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

Update to PHPStan 2.0 #15

Merged
merged 2 commits into from
Nov 13, 2024
Merged

Update to PHPStan 2.0 #15

merged 2 commits into from
Nov 13, 2024

Conversation

yamadashy
Copy link
Owner

@yamadashy yamadashy commented Oct 6, 2024

This PR updates our project to use PHPStan 2.0, which includes several improvements and changes to the static analysis tool.

Copy link

coderabbitai bot commented Oct 6, 2024

📝 Walkthrough

Walkthrough

The changes involve updates to the composer.json, phpstan.neon.dist, and GitHub Actions workflow files for the yamadashy/phpstan-friendly-formatter project. The composer.json file updates the PHP version requirement and expands the compatibility of the phpstan/phpstan dependency to include version 2.0, while removing the grifart/phpstan-oneline dependency and the associated script. The phpstan.neon.dist file removes an include statement and raises the analysis level from 9 to 10. The workflow files update the PHP version matrix and standardize version management through a .tool-versions file.

Changes

File Change Summary
composer.json - Updated phpstan/phpstan dependency version from `"^0.12
phpstan.neon.dist - Removed include for vendor/grifart/phpstan-oneline/config.neon.
- Updated level parameter from 9 to 10.
- Removed excluded path tests/Abstracts/.
tests/CodeHighlight/CodeHighlighterTest.php - Updated @coversDefaultClass annotation to reference the correct namespace.
.github/workflows/tests.yml - Updated PHP version matrix to include only 7.4, 8.0, 8.1, 8.2, 8.3.
- Changed jobs php_cs_fixer and phpstan to use .tool-versions for PHP version specification.
.tool-versions - Updated PHP version from 8.3.11 to 8.3.13.

Sequence Diagram(s)

sequenceDiagram
    participant Developer
    participant Composer
    participant PHPStan

    Developer->>Composer: Update dependencies
    Composer->>PHPStan: Check compatibility with phpstan/phpstan
    PHPStan-->>Composer: Compatibility OK
    Composer-->>Developer: Dependencies updated
    Developer->>PHPStan: Run analysis
    PHPStan->>Developer: Analyze code at level 10
Loading

Possibly related PRs

  • refact(core): Refactor FriendlyErrorFormatter for improved structure … #11: The changes in this PR involve refactoring the FriendlyErrorFormatter, which is directly related to the modifications made in the main PR regarding the FriendlyErrorFormatter class and its error handling methods. The refactor aims to improve the structure and separation of concerns, aligning with the updates made in the main PR.

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between a9fc46c and d042412.

📒 Files selected for processing (5)
  • .github/workflows/tests.yml (4 hunks)
  • .tool-versions (1 hunks)
  • composer.json (1 hunks)
  • phpstan.neon.dist (1 hunks)
  • tests/CodeHighlight/CodeHighlighterTest.php (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (5)
  • .github/workflows/tests.yml
  • .tool-versions
  • composer.json
  • phpstan.neon.dist
  • tests/CodeHighlight/CodeHighlighterTest.php

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>, please review it.
    • 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @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 using 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.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration 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.

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

🧹 Outside diff range and nitpick comments (1)
phpstan.neon.dist (1)

Update composer.json to Require PHPStan 2.0 Exclusively

The current composer.json allows multiple versions of PHPStan (^0.12 || ^1.0 || ^2.0), which may lead to inconsistencies with the updated phpstan.neon.dist configuration tailored for PHPStan 2.0.

Action Items:

  • Modify the PHPStan version constraint in composer.json to "phpstan/phpstan": "^2.0" to ensure only PHPStan 2.0 is used.
  • Remove older PHPStan versions to prevent compatibility issues.
🔗 Analysis chain

Line range hint 1-41: Verify completeness of PHPStan 2.0 preparation.

The changes in this file, including increasing the PHPStan level and potentially removing the grifart/phpstan-oneline configuration, align with the PR objective of preparing for PHPStan 2.0. However, it's important to ensure that these changes are sufficient for the transition.

Please confirm:

  1. Are there any other configuration changes required for PHPStan 2.0 compatibility?
  2. Have you reviewed the PHPStan 2.0 changelog or migration guide to ensure all necessary updates have been made?
  3. Are there any deprecated features or settings in this configuration that should be updated for PHPStan 2.0?

To check for any PHPStan 2.0 related changes or mentions in the project:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for PHPStan 2.0 related changes or mentions
rg "PHPStan 2\.0|phpstan.*2\.0"

Length of output: 98

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 282b12d and d29f83b.

📒 Files selected for processing (2)
  • composer.json (1 hunks)
  • phpstan.neon.dist (1 hunks)
🧰 Additional context used
🔇 Additional comments (3)
phpstan.neon.dist (2)

7-7: Verify the validity and implications of PHPStan level 10.

The PHPStan level has been increased from 9 to 10. Traditionally, PHPStan levels range from 0 to 9, with 9 being the strictest. This change to level 10 might be related to new features in the upcoming PHPStan 2.0 release.

Please confirm:

  1. Is level 10 a valid option in PHPStan 2.0?
  2. What additional checks or stricter rules does level 10 introduce compared to level 9?
  3. Have you tested the codebase against this new level to ensure it doesn't introduce an excessive number of new errors?

To check if level 10 is mentioned in the PHPStan documentation or changelog:


1-5: Verify the removal of grifart/phpstan-oneline configuration.

The AI summary mentions the removal of an include statement for vendor/grifart/phpstan-oneline/config.neon, which is not visible in the provided code snippet. This aligns with the PR objective of removing the grifart/phpstan-oneline dependency.

Please confirm:

  1. Has the include statement for vendor/grifart/phpstan-oneline/config.neon been removed from this file?
  2. Are there any implications for the project's error reporting format due to this removal?
  3. Does PHPStan 2.0 provide a built-in alternative for the functionality previously provided by grifart/phpstan-oneline?

To check for any remaining references to grifart/phpstan-oneline:

composer.json (1)

16-16: Version constraint updated for phpstan/phpstan

The version constraint for phpstan/phpstan has been updated to include version 2.0. This change aligns with the PR objective of preparing for the PHPStan 2.0 update.

Let's verify if this is the only occurrence of the phpstan/phpstan dependency in the project:

Copy link

@standard-input standard-input bot left a comment

Choose a reason for hiding this comment

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

No issues flagged.
Standard Input can make mistakes. Check important info.

@yamadashy yamadashy changed the title Update to PHPStan 2.0 (Preparation) Update to PHPStan 2.0 Nov 13, 2024
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: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between d29f83b and ac2f07d.

📒 Files selected for processing (3)
  • composer.json (1 hunks)
  • phpstan.neon.dist (1 hunks)
  • tests/CodeHighlight/CodeHighlighterTest.php (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • phpstan.neon.dist
🔇 Additional comments (4)
composer.json (3)

16-16: LGTM! Good approach for version constraints

The version constraint "^0.12 || ^1.0 || ^2.0" maintains backward compatibility while preparing for PHPStan 2.0. This allows for a smooth transition and gives users flexibility in upgrading.


Line range hint 1-67: Verify impact of removing phpstan-oneline

The removal of grifart/phpstan-oneline and its related script needs verification to ensure no users depend on this functionality.

#!/bin/bash
# Description: Check for any references to oneline formatter in the codebase
# and documentation

# Search for oneline formatter references in markdown files and PHP files
rg -t md -t php "oneline" 

# Check if the formatter is mentioned in any GitHub issues or discussions
gh search issues "oneline formatter" --repo yamadashy/phpstan-friendly-formatter

14-14: Verify PHP 7.4 requirement for PHPStan 2.0

The minimum PHP version has been increased from 7.2 to 7.4. This is a breaking change that could affect users.

tests/CodeHighlight/CodeHighlighterTest.php (1)

12-12: LGTM! Namespace in annotation matches the import.

The updated @coversDefaultClass annotation correctly reflects the namespace of the imported class.

Let's verify the class exists in the new namespace location:

✅ Verification successful

Verified! The CodeHighlighter class exists in the new CodeHighlight namespace as expected.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the CodeHighlighter class exists in the new namespace location
# Expected: Find the class file in the CodeHighlight subdirectory

# Search for the class file
fd --type f --glob '**/CodeHighlight/CodeHighlighter.php'

# Verify namespace declaration in the found file
if [ $? -eq 0 ]; then
  rg --type php "^namespace.*CodeHighlight;" --files-with-matches
fi

Length of output: 267

@yamadashy yamadashy force-pushed the feature/phpstan-v2 branch 2 times, most recently from a9fc46c to 0ff0422 Compare November 13, 2024 14:09
@yamadashy yamadashy merged commit 3385bd3 into main Nov 13, 2024
19 checks passed
@yamadashy yamadashy deleted the feature/phpstan-v2 branch November 13, 2024 14:43
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