Add project shortcode templates#84
Conversation
📝 WalkthroughWalkthroughThis PR introduces project-level shortcode support for static binary users. A new ChangesProject Shortcodes Feature
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 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 |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/Processor/Shortcode/ProjectShortcodeProcessor.php (1)
120-120: ⚡ Quick winConsider documenting the
=== 1return value convention.Line 120's logic
$result === 1 ? $output : $output . (string) $resultrelies on a subtle PHP behavior: when arequirestatement has no explicitreturn, it returns1. This allows templates to use eitherecho(captured via output buffering) orreturn(appended to output), but the exact-equality check against1is not self-documenting.Consider adding an inline comment explaining this convention, or documenting it in the class-level docblock.
📝 Suggested inline comment
- return $result === 1 ? $output : $output . (string) $result; + // require returns 1 when template has no explicit return; use only buffered output in that case + return $result === 1 ? $output : $output . (string) $result;🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/Processor/Shortcode/ProjectShortcodeProcessor.php` at line 120, The ternary in ProjectShortcodeProcessor method returning "$result === 1 ? $output : $output . (string) $result" relies on PHP's require returning 1 when no explicit return is used; add a short inline comment at that line explaining that "require" with no return yields int(1) so the code distinguishes between echoed output (buffered) and returned string, and also update the class-level docblock of ProjectShortcodeProcessor to document this convention for template authors (mentioning that templates may either echo or return content and that a raw integer 1 means "no return").
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@src/Processor/Shortcode/ProjectShortcodeProcessor.php`:
- Line 120: The ternary in ProjectShortcodeProcessor method returning "$result
=== 1 ? $output : $output . (string) $result" relies on PHP's require returning
1 when no explicit return is used; add a short inline comment at that line
explaining that "require" with no return yields int(1) so the code distinguishes
between echoed output (buffered) and returned string, and also update the
class-level docblock of ProjectShortcodeProcessor to document this convention
for template authors (mentioning that templates may either echo or return
content and that a raw integer 1 means "no return").
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 46f5aa16-1f28-4ca6-a28d-ee50f762ced6
📒 Files selected for processing (6)
benchmarks/ProjectShortcodeProcessorBench.phpconfig/common/di/content-pipeline.phpdocs/plugins.mdroadmap.mdsrc/Processor/Shortcode/ProjectShortcodeProcessor.phptests/Unit/Processor/ProjectShortcodeProcessorTest.php
Summary
Tests
Summary by CodeRabbit
New Features
{{< name ... >}}), enabling users to define custom shortcodes incontent/shortcodes/without modifying configuration.Documentation
Tests