psr12-moodle

Validate and fix Moodle PHP code for PSR-12 compliance with Moodle-specific exceptions.

Updated Aug 27, 2026
One-click install
npx skills add https://github.com/astoeffer/plugin-marketplace --skill psr12-moodle
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: psr12-moodle
Source: https://github.com/astoeffer/plugin-marketplace/tree/main/plugins/moodle-dev-pro/skills/psr12-moodle
Command: npx skills add https://github.com/astoeffer/plugin-marketplace --skill psr12-moodle

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Enforces Moodle-adapted PSR-12 coding standards, including lowercase_with_underscores, frankenstyle prefixes, and Moodle-specific formatting.

Core Features & Use Cases

  • Moodle Exceptions: Naming conventions adjusted for Moodle legacy code.
  • Frankenstyle Prefixes: Ensures all functions/classes include component prefixes.
  • Validation & Auto-Fixes: Guidance and automated fixes for common PSR-12 issues.

Quick Start

Run the Moodle PSR-12 checker (phpcs) and apply automatic fixes with phpcbf to align code with Moodle standards.

Frequently Asked Questions about psr12-moodle

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I validate Moodle PHP code for PSR-12 compliance?

PSR-12 validation for Moodle PHP code enforces standard formatting rules adapted for Moodle's conventions, including lowercase_with_underscores naming and frankenstyle prefixes. Run phpcs with Moodle PSR-12 ruleset on your plugin files to detect violations in naming, indentation, line length, and PHPDoc blocks.

What are frankenstyle prefixes and why does Moodle code need them?

Frankenstyle prefixes are component-specific prefixes prepended to all functions and classes in Moodle plugins to avoid namespace collisions. Moodle PSR-12 standards require these prefixes on every function and class definition to maintain code isolation across plugins.

Can I automatically fix PSR-12 violations in my Moodle code?

Yes. Use phpcbf with Moodle PSR-12 ruleset to automatically correct common violations including naming conventions, indentation, line length, and PHPDoc formatting. The tool applies fixes and outputs a detailed report of all violations resolved.

Does Moodle PSR-12 differ from standard PSR-12 coding standards?

Moodle PSR-12 extends standard PSR-12 with Moodle-specific exceptions: lowercase_with_underscores naming for legacy code compatibility and mandatory frankenstyle component prefixes on all functions and classes, replacing PSR-12's standard camelCase conventions.

What happens when I refactor existing Moodle code to meet PSR-12 standards?

Refactoring Moodle code to PSR-12 involves validating naming conventions, prefixes, indentation, and PHPDoc blocks. The Skill identifies violations, applies automatic fixes via phpcbf, and generates a comprehensive report of all corrections made to align your code with Moodle standards.

Do I need phpcs and phpcbf installed to use Moodle PSR-12 validation?

Yes. The Moodle PSR-12 validation integrates with phpcs for code analysis and phpcbf for automated fixes. Both tools must be installed and configured with the Moodle PSR-12 ruleset to validate and correct your plugin PHP files.