Skip to content

Update README.md, composer.json, and PHPStan configuration; enhance contact form layout and functionality. #90

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

Merged
merged 11 commits into from
Jun 9, 2025

Conversation

terabytesoftw
Copy link
Member

@terabytesoftw terabytesoftw commented Jun 9, 2025

Q A
Is bugfix ✔️
New feature
Breaks BC

Summary by CodeRabbit

  • New Features

    • Enhanced contact form layout with a modern, responsive design and improved styling for both light and dark themes.
    • Contact form success messages now display a distinct title and detailed message.
  • Improvements

    • Increased static analysis strictness for higher code quality.
    • Updated dependencies to use stable and more recent versions.
    • Improved validation and user experience for contact form fields and captcha.
    • Added Bootstrap icons to asset dependencies for richer UI elements.
    • Expanded PHP version support to include 8.1 and updated CI workflows accordingly.
  • Bug Fixes

    • Adjusted test assertions to reflect updated success messages.
  • Documentation

    • Updated documentation to reflect new static analysis level.
  • Chores

    • Added and updated PHPDoc annotations for better static analysis support.
    • Removed deprecated properties and simplified contact form handling logic.

Copy link

coderabbitai bot commented Jun 9, 2025

Warning

Rate limit exceeded

@terabytesoftw has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 1 minutes and 9 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 87d1ef6 and 1e38b61.

📒 Files selected for processing (1)
  • src/framework/resource/css/site.css (2 hunks)

Walkthrough

The changes update static analysis configuration and dependencies, enhance type annotations for PHPStan, refactor contact form logic and layout, and improve test assertions. The contact form view is redesigned with Bootstrap styling, and flash message logic is centralized. CSS is updated for theme support. Package requirements and PHPStan level are increased.

Changes

Files/Groups Change Summary
README.md Updated PHPStan badge level from 5 to 9.
composer.json Lowered PHP version requirement; changed yii2-extensions/localeurls version; added yii2-extensions/phpstan and PHPStan extensions to require-dev; updated allowed plugins.
phpstan.neon Increased analysis level to 9; removed dynamic constants and excluded paths.
src/framework/event/ContactEventHandler.php Flash message now concatenates a new title and message with an HTML line break; removed Application import and docblock type hint.
src/framework/resource/css/site.css Added theme-specific CSS for contact elements and verification code image; removed breadcrumb section comment.
src/framework/resource/layout/component/alert.php Changed session access from getSession() method to session property.
src/framework/asset/AppAsset.php Added BootstrapIconAsset dependency.
src/usecase/Controller.php Added PHPStan return type annotation to actions(); removed docblock for $layout property.
src/usecase/contact/ContactController.php Removed $formModelClass property; updated actions() PHPDoc; added 'transparent' => true to captcha config; removed form model class from action config.
src/usecase/contact/ContactForm.php Added PHPDoc annotations for attributeLabels() and sendContact() methods.
src/usecase/contact/IndexAction.php Injected Request in constructor; removed dynamic form model logic; simplified instantiation; removed unused exception handling.
src/usecase/contact/view/index.php Fully redesigned contact form view with Bootstrap layout; removed flash message display logic.
src/usecase/site/SiteController.php Added PHPStan return type annotation to actions() method.
tests/Functional/ContactCest.php Updated test to assert new flash message title; removed assertion about debugger mail panel.
tests/Unit/ContactControllerCest.php Deleted unit test class that verified exception on missing form model class property.
.github/workflows/static.yml Renamed job from psalm to phpstan and expanded PHP versions tested to 8.1–8.4.
.github/workflows/build.yml Added PHP 8.1 to matrix of tested versions.
.github/workflows/dependency-check.yml Updated PHP version for composer-require-checker job from 8.2 to 8.4.
.github/workflows/ecs.yml Updated PHP version for easy-coding-standard job from 8.2 to 8.4.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant ContactFormView
    participant ContactController
    participant IndexAction
    participant ContactForm
    participant ContactEventHandler
    participant Session

    User->>ContactFormView: Submits contact form
    ContactFormView->>ContactController: POST /contact
    ContactController->>IndexAction: run()
    IndexAction->>ContactForm: load and validate data
    alt Validation succeeds
        ContactForm->>ContactForm: sendContact()
        IndexAction->>ContactEventHandler: trigger contact event
        ContactEventHandler->>Session: Set flash message (title + message)
        IndexAction->>ContactFormView: Render view (no flash message logic)
    else Validation fails
        IndexAction->>ContactFormView: Render view with errors
    end
Loading

Poem

A rabbit hopped through code so neat,
With Bootstrap forms and flashes sweet.
PHPStan’s level climbed up high,
Type hints sparkle, tests comply.
CSS themes for day and night—
Contact us now feels just right!
🐇✨


🪧 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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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 generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this 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: 3

🧹 Nitpick comments (3)
composer.json (1)

20-21: Lock dependencies to stable versions.

Updating yii2-extensions/localeurls to ^0.1.0 and adding yiisoft/yii2-gii/yii2-extensions/phpstan in require-dev aligns with the new static analysis setup. Consider sorting entries alphabetically for better readability.

Also applies to: 40-43

src/framework/event/ContactEventHandler.php (1)

23-32: Good refactoring of flash message structure.

Separating the title and message improves localization flexibility and message clarity. The HTML concatenation is appropriate for web display.

Minor note: The period after "successfully!" in line 25 appears unusual - consider if it's intentional.

src/usecase/contact/view/index.php (1)

135-197: Consider making contact information configurable.

The contact information sidebar looks great and provides valuable context for users. However, the contact details (address, phone, email, business hours) are hard-coded in the template.

Consider moving this information to configuration parameters or the database to make it easily maintainable without code changes.

Example approach:

// In controller or config
$contactInfo = [
    'address' => '123 Main Street<br>City, State 12345',
    'phone' => '+1 (555) 123-4567',
    'email' => '[email protected]',
    'hours' => [
        'Monday - Friday' => '9:00 AM - 6:00 PM',
        'Saturday' => '10:00 AM - 4:00 PM',
        'Sunday' => 'Closed'
    ]
];
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between eb109e2 and 97ad0f3.

⛔ Files ignored due to path filters (2)
  • composer.lock is excluded by !**/*.lock
  • docs/contact.png is excluded by !**/*.png
📒 Files selected for processing (13)
  • README.md (1 hunks)
  • composer.json (2 hunks)
  • phpstan.neon (1 hunks)
  • src/framework/event/ContactEventHandler.php (1 hunks)
  • src/framework/resource/css/site.css (1 hunks)
  • src/framework/resource/layout/component/alert.php (1 hunks)
  • src/usecase/Controller.php (2 hunks)
  • src/usecase/contact/ContactController.php (1 hunks)
  • src/usecase/contact/ContactForm.php (2 hunks)
  • src/usecase/contact/IndexAction.php (2 hunks)
  • src/usecase/contact/view/index.php (1 hunks)
  • src/usecase/site/SiteController.php (1 hunks)
  • tests/Functional/ContactCest.php (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
src/usecase/contact/IndexAction.php (2)
src/usecase/contact/ContactForm.php (2)
  • ContactForm (12-60)
  • sendContact (50-59)
src/usecase/contact/ContactEvent.php (1)
  • ContactEvent (9-12)
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: codeception / PHP-8.4-windows-latest
  • GitHub Check: codeception / PHP-8.2-windows-latest
  • GitHub Check: codeception / PHP-8.3-windows-latest
  • GitHub Check: codeception / PHP-8.3-windows-latest
🔇 Additional comments (18)
README.md (1)

151-151: PHPStan badge update looks correct.

The badge level has been updated to 9 and the link targets the correct workflow. No issues found.

src/framework/resource/layout/component/alert.php (1)

7-7: Use property accessor for session.

Switching from Yii::$app->getSession() to Yii::$app->session is the recommended approach and does not change behavior.

tests/Functional/ContactCest.php (1)

60-61: Assert new flash message format.

The test now checks for "Message sent successfully!." before the thank-you message. This matches the updated handler’s output.

src/usecase/site/SiteController.php (1)

12-14: LGTM! PHPDoc annotation correctly specifies return type.

The annotation accurately describes the nested array structure returned by the actions() method and aligns with the broader static analysis improvements in this PR.

phpstan.neon (1)

1-2: Good addition of Yii2 PHPStan extension.

Including the Yii2-specific PHPStan extension will provide better static analysis for framework-specific code patterns and reduce false positives.

src/usecase/Controller.php (2)

17-19: LGTM! PHPDoc annotation correctly specifies actions() return type.

The annotation accurately describes the nested array structure for action configurations and is consistent with similar annotations across controller classes.


29-31: LGTM! PHPDoc annotation correctly specifies behaviors() return type.

The annotation properly describes the nested array structure for behavior configurations, improving static analysis accuracy.

src/usecase/contact/ContactForm.php (2)

21-23: LGTM! Enhanced type safety with proper PHPDoc annotation.

The return type annotation array<string, string> correctly describes the structure returned by attributeLabels() and aligns with the PHPStan level increase mentioned in the PR objectives.


47-49: LGTM! Proper parameter type annotation for configuration array.

The @phpstan-param array<array-key, mixed> $params annotation correctly describes the expected structure for the configuration parameters used in the mailer setup.

src/usecase/contact/ContactController.php (2)

14-14: LGTM! Proper return type annotation for actions method.

The array<array-key, array<array-key, mixed>> annotation correctly describes the nested array structure returned by the actions() method, supporting the PHPStan improvements.


26-26: LGTM! Valid captcha configuration option.

Adding 'transparent' => true is a valid CaptchaAction configuration option that makes the captcha background transparent, improving visual integration with the form.

src/usecase/contact/IndexAction.php (4)

13-25: LGTM! Improved dependency injection and type safety.

The constructor now properly injects the Request dependency and includes appropriate PHPDoc annotations. This improves testability and makes dependencies explicit.


29-29: LGTM! Simplified form instantiation.

Direct instantiation of ContactForm removes the complexity of dynamic class loading while maintaining the same functionality. This aligns with the removal of the formModelClass property from the controller.


37-37: LGTM! Cleaner event instantiation.

Inline instantiation of ContactEvent is cleaner and maintains the same functionality as the previous approach.


31-33:

❓ Verification inconclusive

Verify that the simplified condition maintains equivalent behavior.

The code now uses the injected request and simplified condition checking. Ensure that removing the controller request type check doesn't affect the form processing logic.


🏁 Script executed:

#!/bin/bash
# Description: Check for any other usages of controller request in contact-related files
# Expected: Should find minimal or no other usages that would be affected by this change

echo "Searching for controller request usage in contact files..."
rg -A 3 -B 3 "controller.*request" --type php

echo -e "\nSearching for request type checking patterns..."
rg -A 3 -B 3 "request.*post|post.*request" --type php

echo -e "\nChecking if there are any tests that verify request type checking..."
rg -A 5 "contact.*request|request.*contact" tests/

Length of output: 1072


Verify Request Handling in IndexAction

I didn’t find any other controller->request usages in contact-related code nor any tests explicitly covering request-type checks. Please double-check that removing the original controller request type guard still enforces the intended behavior (e.g. only loading and validating on POST). In particular:

  • Review src/usecase/contact/IndexAction.php around the new condition:
        $post = $this->request->post();
    
        if (is_array($post) && $contactForm->load($post) && $contactForm->validate()) {
            // …
        }
  • Ensure $this->request->post() will always return an array for valid POST submissions and something else (null/empty) otherwise.
  • Consider adding a unit or integration test for non-POST requests to confirm the form isn’t loaded/validated when it shouldn’t be.
src/usecase/contact/view/index.php (3)

19-31: LGTM! Modern responsive header design.

The centered header with title, subtitle, and horizontal rule provides a clean, professional appearance that's properly responsive across screen sizes.


36-42: LGTM! Enhanced form configuration with Bootstrap 5 features.

The form now uses Bootstrap 5's floating labels layout and proper validation classes (needs-validation, novalidate), which provides a modern UX while maintaining functionality.


44-116: LGTM! Improved form field styling and layout.

The form fields now use proper Bootstrap grid system, larger controls, and better styling. The captcha presentation in a card with clear labeling significantly improves usability.

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

🧹 Nitpick comments (1)
src/framework/event/ContactEventHandler.php (1)

22-31: Consider separating presentation logic from business logic.

The flash message now includes HTML (<br>) which couples presentation concerns with the event handler logic. Consider using an array structure or letting the view handle the formatting.

Alternative approach using array structure:

-                $app->session->setFlash('success', "{$title}<br>{$message}");
+                $app->session->setFlash('success', [
+                    'title' => $title,
+                    'message' => $message,
+                ]);

This allows the view to decide how to format the title and message.

🧰 Tools
🪛 PHPStan (2.1.15)

31-31: Access to an undefined property yii\base\Application::$session.
Learn more: https://phpstan.org/blog/solving-phpstan-access-to-undefined-property

(property.notFound)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7a7e87b and 99a182d.

📒 Files selected for processing (6)
  • .github/workflows/build.yml (1 hunks)
  • .github/workflows/dependency-check.yml (1 hunks)
  • .github/workflows/ecs.yml (1 hunks)
  • .github/workflows/static.yml (1 hunks)
  • src/framework/event/ContactEventHandler.php (1 hunks)
  • src/usecase/Controller.php (1 hunks)
✅ Files skipped from review due to trivial changes (3)
  • .github/workflows/dependency-check.yml
  • .github/workflows/ecs.yml
  • .github/workflows/build.yml
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/usecase/Controller.php
  • .github/workflows/static.yml
🧰 Additional context used
🧬 Code Graph Analysis (1)
src/framework/event/ContactEventHandler.php (2)
src/usecase/contact/IndexAction.php (1)
  • IndexAction (11-50)
src/usecase/contact/ContactEvent.php (1)
  • ContactEvent (9-12)
🪛 PHPStan (2.1.15)
src/framework/event/ContactEventHandler.php

31-31: Access to an undefined property yii\base\Application::$session.
Learn more: https://phpstan.org/blog/solving-phpstan-access-to-undefined-property

(property.notFound)

⏰ Context from checks skipped due to timeout of 90000ms (5)
  • GitHub Check: codeception / PHP-8.4-windows-latest
  • GitHub Check: codeception / PHP-8.2-windows-latest
  • GitHub Check: codeception / PHP-8.4-windows-latest
  • GitHub Check: codeception / PHP-8.3-windows-latest
  • GitHub Check: codeception / PHP-8.1-windows-latest

@terabytesoftw terabytesoftw merged commit 6e16572 into main Jun 9, 2025
31 checks passed
@terabytesoftw terabytesoftw deleted the fix-mini-5 branch June 9, 2025 21:28
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.

2 participants