Skip to content

Winter v1.3 Support#71

Open
jaxwilko wants to merge 25 commits intomainfrom
wip/1.3
Open

Winter v1.3 Support#71
jaxwilko wants to merge 25 commits intomainfrom
wip/1.3

Conversation

@jaxwilko
Copy link
Member

@jaxwilko jaxwilko commented Jul 25, 2025

I've added support for php-parser v5, I tested and created a plugin and made some changes to that plugin and couldn't find anything broken, but anything that extends from our abstract PhpSourceParser may run into issues as the lexer property has been removed.

Summary by CodeRabbit

  • Tests

    • Enhanced test suite with refactored test names for improved clarity and maintainability.
  • Chores

    • Updated CI/CD pipeline to run tests across multiple operating systems and PHP versions (8.2, 8.3, 8.4).
    • Upgraded PHP parser dependency to v5.5.
    • Simplified PHPUnit configuration.
    • Released version 2.2.0 with support for Winter v1.3+.

@LukeTowers LukeTowers changed the title [WIP] Winter v1.3 Support Winter v1.3 Support Jul 26, 2025
@coderabbitai
Copy link

coderabbitai bot commented Feb 12, 2026

Walkthrough

The pull request modernizes the project's testing infrastructure and build pipeline. Changes include restructuring the GitHub Actions workflow with multi-OS and multi-PHP-version matrix testing and a unified setup action, upgrading the PHP parser dependency from v4 to v5, simplifying PHPUnit configuration, refactoring test files with PHP 8 attributes and renamed methods, and bumping the version for Winter v1.3+ support.

Changes

Cohort / File(s) Summary
GitHub Actions Workflow
.github/workflows/unit-tests.yaml
Restructured job matrix to run across multiple operating systems (ubuntu, windows) and PHP versions (8.2, 8.3, 8.4); replaced multi-step setup with unified wintercms/setup-winter-action@v1; added concurrency controls and GITHUB_TOKEN environment variable.
PHP Parser Implementation
classes/PhpSourceParser.php
Removed Emulative lexer; refactored parser instantiation to use ParserFactory()->createForHostVersion(); changed token retrieval from lexer to parser instance.
Dependencies
composer.json
Updated nikic/php-parser constraint from ^4.13.2 to ^5.5.
PHPUnit Configuration
phpunit.xml
Removed deprecated configuration attributes (backupGlobals, backupStaticAttributes, convertErrorsToExceptions, convertNoticesToExceptions, convertWarningsToExceptions, stopOnFailure).
Test Base Class
tests/BuilderPluginTestCase.php
Changed from conditional inheritance to direct PluginTestCase inheritance; normalized namespace and import declarations.
Test Files Modernization
tests/unit/classes/FilesystemGeneratorTest.php, tests/unit/classes/MigrationFileParserTest.php, tests/unit/classes/ModelFileParserTest.php, tests/unit/classes/ModelModelTest.php
Added PHP 8 CoversClass attributes; renamed test methods to descriptive snake_case convention; removed docblock-based @covers annotations; added parent::tearDown() calls; normalized file headers.
Version
updates/version.yaml
Added version entry "2.2.0" to support Winter v1.3+.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Winter v1.3 Support' directly and clearly summarizes the main objective of the pull request, which is to add support for Winter v1.3 (via php-parser v5 upgrade and related dependency updates).
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Merge Conflict Detection ✅ Passed ✅ No merge conflicts detected when merging into main

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch wip/1.3

Tip

Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
composer.json (1)

35-37: ⚠️ Potential issue | 🟠 Major

Update phpunit and php version constraints to match the actual project requirements.

The "phpunit/phpunit": "~4.0" constraint is severely outdated and incompatible with the tested PHP versions (8.2, 8.3, 8.4 per CI workflows). The phpunit.xml configuration already targets PHPUnit 9.3 schema, indicating a disconnect between declared and actual dependencies.

Additionally, "php": ">=7.0" doesn't reflect that CI tests against PHP 8.2+. Consider updating to:

  • "php": ">=8.2" to match CI requirements
  • "phpunit/phpunit": "^10.5" (or ^11.0 if targeting PHP 8.3+)
🤖 Fix all issues with AI agents
In `@tests/unit/classes/FilesystemGeneratorTest.php`:
- Around line 18-23: The tearDown() order is wrong: call your cleanup before
tearing down the test parent to avoid using Laravel features after the container
is destroyed. In the FilesystemGeneratorTest class, move the $this->cleanUp()
call to run before parent::tearDown() (mirror the setUp() order), ensuring
cleanup logic that uses File::deleteDirectory() executes while the
application/container is still available.
🧹 Nitpick comments (6)
tests/unit/classes/MigrationFileParserTest.php (1)

5-9: Clean adoption of PHPUnit attributes with proper import.

The use import for CoversClass and the attribute usage are clean. Note that the other two test files (ModelFileParserTest.php and ModelModelTest.php) use the fully-qualified class name inline instead of importing it. Consider aligning the style across the test suite for consistency.

tests/unit/classes/ModelFileParserTest.php (1)

8-8: Inline FQCN for attribute — inconsistent with MigrationFileParserTest.php.

MigrationFileParserTest.php imports CoversClass via a use statement (Line 5), while this file uses the fully-qualified #[\PHPUnit\Framework\Attributes\CoversClass(...)] inline. Either approach works, but the test suite should be consistent.

♻️ Suggested change for consistency
 namespace Winter\Builder\Tests\Unit\Classes;

+use PHPUnit\Framework\Attributes\CoversClass;
 use Winter\Builder\Classes\ModelFileParser;
 use Winter\Builder\Tests\BuilderPluginTestCase;

-#[\PHPUnit\Framework\Attributes\CoversClass(ModelFileParser::class)]
+#[CoversClass(ModelFileParser::class)]
 class ModelFileParserTest extends BuilderPluginTestCase
tests/unit/classes/ModelModelTest.php (2)

10-10: Same FQCN inconsistency as ModelFileParserTest.php.

Same suggestion as the other files — consider importing CoversClass via a use statement for consistency with MigrationFileParserTest.php.


48-56: Test silently passes if SystemException is not thrown.

If getModelFields() stops throwing on an invalid class name, the test won't fail — it'll just fall through to the remaining assertions. Consider using $this->expectException(SystemException::class) and separating the exception case into its own test method, or adding $this->fail() after the call.

♻️ Option A: Add a fail() guard
         // Invalid Class Name
-        try {
-            ModelModel::getModelFields(null, 'myClassName');
-        } catch (SystemException $e) {
-            $this->assertEquals($e->getMessage(), 'Invalid model class name: myClassName');
-            return;
-        }
+        $this->expectException(SystemException::class);
+        $this->expectExceptionMessage('Invalid model class name: myClassName');
+        ModelModel::getModelFields(null, 'myClassName');

This would require moving the remaining scenarios (lines 58–73) into a separate test method since expectException applies to the whole test.

.github/workflows/unit-tests.yaml (2)

30-30: CI pinned to a WIP branch (wip/1.3).

winter-ref: wip/1.3 ties CI to an unstable branch that could be rebased, force-pushed, or deleted. This is fine during active development, but should be updated to a stable ref (release tag or release branch) once Winter v1.3 is released, to prevent CI from silently breaking.


6-6: Branch trigger only covers main.

The push trigger is limited to main. If the intent is to also run tests on the current feature branch (wip/1.3) during development, consider adding it here or relying solely on the pull_request trigger.

Comment on lines 18 to 23
public function tearDown(): void
{
parent::tearDown();

$this->cleanUp();
}
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Find tearDown() patterns in test files across the repository
rg -n -B2 -A5 'function tearDown' --type=php --glob '*Test.php'

Repository: wintercms/wn-builder-plugin

Length of output: 1142


🏁 Script executed:

#!/bin/bash
# Also search for variations in naming
fd -e php -path '*Test*' | head -20 | xargs rg -l 'tearDown' 2>/dev/null | head -10

Repository: wintercms/wn-builder-plugin

Length of output: 341


🏁 Script executed:

#!/bin/bash
# Look at the parent class to understand what it does in tearDown
rg -n 'class FilesystemGeneratorTest' --type=php -A 1

Repository: wintercms/wn-builder-plugin

Length of output: 231


🏁 Script executed:

#!/bin/bash
# Find the cleanUp method in the test file to understand dependencies
rg -n 'function cleanUp' --type=php -A 10

Repository: wintercms/wn-builder-plugin

Length of output: 539


🏁 Script executed:

#!/bin/bash
# Find the parent class BuilderPluginTestCase
fd -type f -name '*.php' | xargs grep -l 'class BuilderPluginTestCase'

Repository: wintercms/wn-builder-plugin

Length of output: 243


🏁 Script executed:

#!/bin/bash
# Search for BuilderPluginTestCase and its tearDown method
rg -n 'class BuilderPluginTestCase' -A 30 --type=php

Repository: wintercms/wn-builder-plugin

Length of output: 408


🏁 Script executed:

#!/bin/bash
# Look for where BuilderPluginTestCase is defined and check parent tearDown
rg -n 'tearDown' tests/ --type=php -B 2 -A 8 | head -60

Repository: wintercms/wn-builder-plugin

Length of output: 1878


🏁 Script executed:

#!/bin/bash
# Find PluginTestCase definition
find . -name '*.php' -type f | xargs grep -l 'class PluginTestCase' 2>/dev/null

Repository: wintercms/wn-builder-plugin

Length of output: 55


🏁 Script executed:

#!/bin/bash
# Check if it's in vendor or external packages
rg 'class PluginTestCase' -A 15

Repository: wintercms/wn-builder-plugin

Length of output: 53


🏁 Script executed:

#!/bin/bash
# Check composer dependencies to understand where PluginTestCase comes from
cat composer.json | jq '.require' 2>/dev/null || cat composer.json | grep -A 20 '"require"'

Repository: wintercms/wn-builder-plugin

Length of output: 154


🏁 Script executed:

#!/bin/bash
# Check the setUp method in FilesystemGeneratorTest to verify the pattern
rg -n 'function setUp' -A 5 tests/unit/classes/FilesystemGeneratorTest.php

Repository: wintercms/wn-builder-plugin

Length of output: 186


🏁 Script executed:

#!/bin/bash
# Check setUp in ModelModelTest too for comparison
rg -n 'function setUp' -A 5 tests/unit/classes/ModelModelTest.php

Repository: wintercms/wn-builder-plugin

Length of output: 53


🏁 Script executed:

#!/bin/bash
# Search for any documentation or comments about tearDown ordering in the codebase
rg -i 'teardown.*parent\|parent.*teardown' -B 2 -A 2

Repository: wintercms/wn-builder-plugin

Length of output: 53


Reorder cleanUp() before parent::tearDown() to ensure proper cleanup.

The setUp() method calls parent::setUp() first and then cleanUp(). The tearDown() method should mirror this in reverse order: cleanup first, then parent. Currently, calling parent::tearDown() before cleanUp() risks tearing down the application container before the File facade is used by File::deleteDirectory(), potentially causing the cleanup to silently fail and leave test artifacts on disk.

Proposed fix
     public function tearDown(): void
     {
-        parent::tearDown();
-
         $this->cleanUp();
+
+        parent::tearDown();
     }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
public function tearDown(): void
{
parent::tearDown();
$this->cleanUp();
}
public function tearDown(): void
{
$this->cleanUp();
parent::tearDown();
}
🤖 Prompt for AI Agents
In `@tests/unit/classes/FilesystemGeneratorTest.php` around lines 18 - 23, The
tearDown() order is wrong: call your cleanup before tearing down the test parent
to avoid using Laravel features after the container is destroyed. In the
FilesystemGeneratorTest class, move the $this->cleanUp() call to run before
parent::tearDown() (mirror the setUp() order), ensuring cleanup logic that uses
File::deleteDirectory() executes while the application/container is still
available.

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