-
Notifications
You must be signed in to change notification settings - Fork 1
Complete modernization: 7-class architecture, PHPStan Level 9, perfor… #52
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
Conversation
…mance optimizations - Renamed package from 'video' to 'vidstack_player' (1.0.0-beta1) - Separated monolithic class into 7 focused classes: * VidstackPlayer: Fluent API for player generation * PlatformDetector: YouTube/Vimeo/Local detection * AssetHelper: DRY asset loading with lazy initialization * Utilities: HTML attributes, MIME detection * Translator: i18n helper * OembedParser: CKE5 integration * BackendIntegration: Mediapool sidebar, FFmpeg - Code quality: PHPStan Level 9 (0 errors), Psalm (0 errors, 95.54%), ESLint (0 errors) - Performance: Lazy asset loading, array+implode optimization, URL pre-generation - GitHub workflows: code-style, build-assets, publish-to-redaxo - Complete PHPDoc coverage with generics - Modern build system with ESLint + esbuild
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR represents a complete modernization and restructuring of the Vidstack video player addon for REDAXO. The main purpose is to transform the monolithic architecture into a modular, maintainable system with modern PHP practices and enhanced functionality.
Key changes include:
- Package rename from 'vidstack' to 'vidstack_player' with version reset to 1.0.0-beta1
- Architectural refactor: Split monolithic Video class into 7 focused classes (VidstackPlayer, PlatformDetector, AssetHelper, Utilities, Translator, OembedParser, BackendIntegration)
- Modern fluent API implementation with method chaining for improved developer experience
Reviewed Changes
Copilot reviewed 29 out of 30 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| package.yml | Package rename and version reset to 1.0.0-beta1 |
| lib/video.php | Removed monolithic 715-line Video class |
| lib/VidstackPlayer.php | New main player class with fluent API (388 lines) |
| lib/PlatformDetector.php | Extracted platform detection logic (97 lines) |
| lib/AssetHelper.php | DRY asset loading with cache-busting (110 lines) |
| lib/Utilities.php | HTML attributes and MIME type utilities (71 lines) |
| lib/Translator.php | i18n translation helper (45 lines) |
| lib/OembedParser.php | CKE5 integration for oEmbed parsing (48 lines) |
| lib/BackendIntegration.php | Mediapool sidebar and FFmpeg integration (150 lines) |
| lang/translations.php | Simplified translation structure |
| boot.php | Updated to use new class structure with lazy loading |
| assets/ | Updated helper JavaScript and CSS files |
| README.md | Complete rewrite with modern documentation |
| composer.json | New Composer configuration |
| build/ | Updated build system with ESLint |
| tests/README.md | Test structure documentation (coming soon) |
Files not reviewed (1)
- build/package-lock.json: Language not supported
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
lib/Utilities.php
Outdated
| } else { | ||
| /** | ||
| * @psalm-suppress MixedOperand | ||
| * @phpstan-ignore binaryOp.invalid |
Copilot
AI
Oct 19, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The PHPStan ignore comment uses an invalid rule name. The correct rule name should be 'binaryOp.invalidTypes' instead of 'binaryOp.invalid'.
| * @phpstan-ignore binaryOp.invalid | |
| * @phpstan-ignore binaryOp.invalidTypes |
lib/BackendIntegration.php
Outdated
| } | ||
|
|
||
| try { | ||
| /** @phpstan-ignore class.notFound */ |
Copilot
AI
Oct 19, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The PHPStan ignore comment uses an invalid rule name. The correct rule name should be 'class.notFound' -> 'class.notFoundInClassPath' or similar. Consider checking PHPStan documentation for the exact rule name.
| /** @phpstan-ignore class.notFound */ | |
| /** @phpstan-ignore class.notFoundInClassPath */ |
assets/vidstack_helper.js
Outdated
| */ | ||
| async function loadTranslations() { | ||
| try { | ||
| translations = await (await fetch('/assets/addons/vidstack/translations.json')).json(); |
Copilot
AI
Oct 19, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fetch URL still references the old addon name 'vidstack' but should reference 'vidstack_player' to match the renamed package.
| translations = await (await fetch('/assets/addons/vidstack/translations.json')).json(); | |
| translations = await (await fetch('/assets/addons/vidstack_player/translations.json')).json(); |
lib/VidstackPlayer.php
Outdated
| * @param string $key Attribute name | ||
| * @param mixed $value Attribute value | ||
| */ | ||
| public function attr(string $key, $value): self |
Copilot
AI
Oct 19, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The parameter $value should have a type declaration. Consider using mixed for PHP 8.0+ or string|bool|int|null for more specific typing.
| public function attr(string $key, $value): self | |
| public function attr(string $key, mixed $value): self |
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. ✨ Finishing touches🧪 Generate unit tests (beta)
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. Comment |
Export-ignore development files: - /build (source files) - /tests - /.github (workflows) - /.tools (phpstan bootstrap) - All config files (composer.json, .php-cs-fixer, etc.)
- Removed automatic OembedParser::register() from boot.php - Users must manually activate in project addon if needed - Prevents conflicts with custom consent solutions - Updated README.md and README_de.md with activation instructions
- Addon is just a player, not a consent solution - Focus on opt-in approach and preventing conflicts
- Fix PHPStan rule names: binaryOp.invalid → binaryOp.invalidTypes - Fix PHPStan rule names: class.notFound → undefinedClass - Fix assets path: /assets/addons/vidstack → vidstack_player - Add mixed type declaration to attr() method for PHP 8+ - Fix variable naming inconsistency: $info → $videoInfo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 31 out of 32 changed files in this pull request and generated 3 comments.
Files not reviewed (1)
- build/package-lock.json: Language not supported
Comments suppressed due to low confidence (1)
lang/translations.php:1
- Package name migration note shows identical names. Should be
vidstack→vidstack_playerto reflect the actual package rename.
<?php
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
- Prefix all JS functions: vidstackLoadTranslations(), vidstackApplyTranslations(), etc. - Prefix all custom CSS classes: .vidstack-video-container, .vidstack-video-wrapper - Remove unused A11Y CSS (no longer in HTML output) - Prevents naming conflicts with other scripts/styles
- All assets now minified: .min.js and .min.css - Build process: esbuild with --minify flag - Removed unused files: vs_js_out.js, vs_js_out.css - Source files (vidstack_helper.js/css) now in .gitignore - Only production-ready minified files in assets/ - Reduced file sizes: ~50% smaller Assets now: - vidstack.min.js (355.5kb, was 767.7kb) - vidstack.min.css (69.7kb, was 78.5kb) - vidstack_helper.min.js (1.1kb) - vidstack_helper.min.css (2.0kb) - translations.json
Source files now organized: - assets/src/vidstack_helper.js (source) - assets/src/vidstack_helper.css (source) - assets/vidstack_helper.min.js (compiled) - assets/vidstack_helper.min.css (compiled) Benefits: - Source and compiled files in same directory tree - Clear separation: src/ vs production files - Easier to find and edit source files
Frontend (with translations + helpers): - vidstack.min.js (357K) - Vidstack Core + Helper + Translations - vidstack.min.css (72K) - Vidstack Core + Helper Styles Backend (mediapool preview only): - vidstack-backend.min.js (356K) - Vidstack Core only - vidstack-backend.min.css (70K) - Vidstack Core only Benefits: - Backend loads faster (no translation logic) - Frontend gets everything in 2 files (1 JS + 1 CSS) - Clear separation of concerns - Smaller backend payload
Update asset checks and uploads: - vidstack.js → vidstack.min.js - vidstack.css → vidstack.min.css - Add vidstack-backend.min.js - Add vidstack-backend.min.css
Workflow improvements: - Add 'renovatio' branch to triggers - Update actions/checkout v3 → v4 - Update Node.js 20 → 22 - Split ESLint into two steps (config + source files) - Lint both build/config/*.js and assets/src/*.js ESLint config improvements: - Add assets/src/**/*.js linting - Proper globals for browser environment - sourceType: 'script' for IIFE (not module) - Cover jQuery, MutationObserver, etc. All ESLint checks pass locally ✓
Features: - Manual trigger via GitHub Actions UI - Optional checkbox to commit and push built assets - Bot commits with [skip ci] to prevent loops - Useful for updating assets after dependency updates Usage: 1. Go to Actions tab 2. Select 'Build Assets & ESLint' 3. Click 'Run workflow' 4. Check 'Commit and push built assets' if needed 5. Click 'Run workflow' button
Fix: Fatal error when FFmpeg addon is installed but class not loaded - Check if FFmpeg addon is available (isAvailable) - Check if VideoInfo class exists (class_exists) - Prevents fatal error if addon is in wrong state - Gracefully returns null if FFmpeg not ready Error was: Class FriendsOfRedaxo\FFmpeg\VideoInfo not found
…mance optimizations