Download the PHP package o0h/phpstan-spaghetti without Composer
On this page you can find all versions of the php package o0h/phpstan-spaghetti. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download o0h/phpstan-spaghetti
More information about o0h/phpstan-spaghetti
Files in o0h/phpstan-spaghetti
Package phpstan-spaghetti
Short Description PHPStan rules to enforce SPAGHETTI code style
License MIT
Homepage https://github.com/o0h/phpstan-spaghetti
Informations about the package phpstan-spaghetti
PHPStan Spaghetti
A PHPStan extension that enforces true spaghetti code principles in your PHP projects.
Why?
While most static analysis tools try to improve code quality, PHPStan Spaghetti takes a different approach: it ensures your code stays true to the classic spaghetti code style. No more clean, maintainable code - embrace the chaos!
Installation
Install via Composer:
If you also install phpstan/extension-installer then you're all set!
Manual installation
If you don't want to use `phpstan/extension-installer`, include `extension.neon` in your project's PHPStan config:Configuration
The extension is enabled by default. To disable the rules, add the following to your phpstan.neon:
To explicitly enable (default behavior):
Rules
PHPStan Spaghetti provides 21 rules organized into 5 categories to enforce true spaghetti code principles.
Control Flow
NoLoopsRule
Prohibits all loop constructs (for, while, do-while, foreach). Use goto statements instead.
Violation:
Compliant:
RestrictedIfRule
Enforces strict rules for if statements:
- No
elseorelseifclauses - Only unary conditions (no
&&,||, etc.) - Body must contain only a single
gotostatement
NoSwitchMatchRule
Prohibits switch and match expressions. Use chains of if and goto instead.
NoTryCatchRule
Prohibits try-catch-finally blocks. Handle errors with conditional checks and goto.
NoReturnRule
Prohibits return statements. Use inline code and goto instead.
NoYieldRule
Prohibits yield and yield from expressions. No generators allowed in spaghetti code.
NoThrowRule
Prohibits throw statements. Handle errors with conditional checks and goto.
Functions
NoFunctionDefinitionRule
Prohibits user-defined functions. Use inline code with goto statements instead.
NoCallableArgumentRule
Prohibits using callable types as function arguments (closures, arrow functions, string callables, etc.).
NoCallableArgumentInMethodCallRule
Prohibits using callable types as method call arguments.
NoCallableArgumentInStaticCallRule
Prohibits using callable types as static method call arguments.
Object-Oriented Programming
NoClassLikeDefinitionRule
Prohibits all class-like definitions (classes, interfaces, traits, enums). Spaghetti code should be procedural!
NoObjectInstantiationRule
Prohibits object instantiation with new keyword.
NoObjectAccessRule
Prohibits accessing object properties and methods (->, ::, ?->).
NoInstanceofRule
Prohibits instanceof operator. Spaghetti code shouldn't use objects anyway.
NoTypeCheckFunctionRule
Prohibits type check functions (is_a(), is_subclass_of(), get_class(), get_parent_class()). Spaghetti code shouldn't use objects anyway.
Operators
NoTernaryOperatorRule
Prohibits ternary operators (? :). Use if statements with goto instead.
NoNullCoalesceRule
Prohibits null coalesce operators (??, ??=).
NoSpaceshipOperatorRule
Prohibits spaceship operator (<=>).
Structure
NoNamespaceRule
Prohibits namespace declarations. Use global namespace only.
NoTypeDeclarationRule
Prohibits type declarations for parameters, return values, and properties.
Development
Running Tests
Code Style
Check code style:
Fix code style:
Static Analysis
Run All Checks
Requirements
- PHP 8.2 or higher
- PHPStan 2.0 or higher
License
MIT
Disclaimer
This package is intended for educational and entertainment purposes. Please do not actually use these coding practices in production code. Embrace clean code principles, not spaghetti code!