@mytechtoday/augment-extensions 0.2.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +614 -39
- package/augment-extensions/coding-standards/bash/README.md +196 -0
- package/augment-extensions/coding-standards/bash/module.json +163 -0
- package/augment-extensions/coding-standards/bash/rules/naming-conventions.md +336 -0
- package/augment-extensions/coding-standards/bash/rules/universal-standards.md +289 -0
- package/augment-extensions/coding-standards/css/README.md +40 -0
- package/augment-extensions/coding-standards/css/examples/css-examples.css +550 -0
- package/augment-extensions/coding-standards/css/module.json +44 -0
- package/augment-extensions/coding-standards/css/rules/css-modern-features.md +448 -0
- package/augment-extensions/coding-standards/css/rules/css-standards.md +492 -0
- package/augment-extensions/coding-standards/html/README.md +40 -0
- package/augment-extensions/coding-standards/html/examples/html-examples.html +267 -0
- package/augment-extensions/coding-standards/html/examples/responsive-layout.html +505 -0
- package/augment-extensions/coding-standards/html/module.json +44 -0
- package/augment-extensions/coding-standards/html/rules/html-standards.md +349 -0
- package/augment-extensions/coding-standards/html-css-js/README.md +194 -0
- package/augment-extensions/coding-standards/html-css-js/examples/async-examples.js +487 -0
- package/augment-extensions/coding-standards/html-css-js/examples/css-examples.css +550 -0
- package/augment-extensions/coding-standards/html-css-js/examples/dom-examples.js +667 -0
- package/augment-extensions/coding-standards/html-css-js/examples/html-examples.html +267 -0
- package/augment-extensions/coding-standards/html-css-js/examples/javascript-examples.js +612 -0
- package/augment-extensions/coding-standards/html-css-js/examples/responsive-layout.html +505 -0
- package/augment-extensions/coding-standards/html-css-js/module.json +48 -0
- package/augment-extensions/coding-standards/html-css-js/rules/async-patterns.md +515 -0
- package/augment-extensions/coding-standards/html-css-js/rules/css-modern-features.md +448 -0
- package/augment-extensions/coding-standards/html-css-js/rules/css-standards.md +492 -0
- package/augment-extensions/coding-standards/html-css-js/rules/dom-manipulation.md +439 -0
- package/augment-extensions/coding-standards/html-css-js/rules/html-standards.md +349 -0
- package/augment-extensions/coding-standards/html-css-js/rules/javascript-standards.md +486 -0
- package/augment-extensions/coding-standards/html-css-js/rules/performance.md +463 -0
- package/augment-extensions/coding-standards/html-css-js/rules/tooling.md +543 -0
- package/augment-extensions/coding-standards/js/README.md +46 -0
- package/augment-extensions/coding-standards/js/examples/async-examples.js +487 -0
- package/augment-extensions/coding-standards/js/examples/dom-examples.js +667 -0
- package/augment-extensions/coding-standards/js/examples/javascript-examples.js +612 -0
- package/augment-extensions/coding-standards/js/module.json +49 -0
- package/augment-extensions/coding-standards/js/rules/async-patterns.md +515 -0
- package/augment-extensions/coding-standards/js/rules/dom-manipulation.md +439 -0
- package/augment-extensions/coding-standards/js/rules/javascript-standards.md +486 -0
- package/augment-extensions/coding-standards/js/rules/performance.md +463 -0
- package/augment-extensions/coding-standards/js/rules/tooling.md +543 -0
- package/augment-extensions/coding-standards/php/README.md +248 -0
- package/augment-extensions/coding-standards/php/examples/api-endpoint-example.php +204 -0
- package/augment-extensions/coding-standards/php/examples/cli-command-example.php +206 -0
- package/augment-extensions/coding-standards/php/examples/legacy-refactoring-example.php +234 -0
- package/augment-extensions/coding-standards/php/examples/web-application-example.php +211 -0
- package/augment-extensions/coding-standards/php/examples/woocommerce-extension-example.php +215 -0
- package/augment-extensions/coding-standards/php/examples/wordpress-plugin-example.php +189 -0
- package/augment-extensions/coding-standards/php/module.json +166 -0
- package/augment-extensions/coding-standards/php/rules/api-development.md +480 -0
- package/augment-extensions/coding-standards/php/rules/category-configuration.md +332 -0
- package/augment-extensions/coding-standards/php/rules/cli-tools.md +472 -0
- package/augment-extensions/coding-standards/php/rules/cms-integration.md +561 -0
- package/augment-extensions/coding-standards/php/rules/code-quality.md +402 -0
- package/augment-extensions/coding-standards/php/rules/documentation.md +425 -0
- package/augment-extensions/coding-standards/php/rules/ecommerce.md +627 -0
- package/augment-extensions/coding-standards/php/rules/error-handling.md +336 -0
- package/augment-extensions/coding-standards/php/rules/legacy-migration.md +677 -0
- package/augment-extensions/coding-standards/php/rules/naming-conventions.md +279 -0
- package/augment-extensions/coding-standards/php/rules/performance.md +392 -0
- package/augment-extensions/coding-standards/php/rules/psr-standards.md +186 -0
- package/augment-extensions/coding-standards/php/rules/security.md +358 -0
- package/augment-extensions/coding-standards/php/rules/testing.md +403 -0
- package/augment-extensions/coding-standards/php/rules/type-declarations.md +331 -0
- package/augment-extensions/coding-standards/php/rules/web-applications.md +426 -0
- package/augment-extensions/coding-standards/powershell/README.md +154 -0
- package/augment-extensions/coding-standards/powershell/examples/admin-example.ps1 +272 -0
- package/augment-extensions/coding-standards/powershell/examples/automation-example.ps1 +173 -0
- package/augment-extensions/coding-standards/powershell/examples/cloud-example.ps1 +243 -0
- package/augment-extensions/coding-standards/powershell/examples/cross-platform-example.ps1 +297 -0
- package/augment-extensions/coding-standards/powershell/examples/dsc-example.ps1 +224 -0
- package/augment-extensions/coding-standards/powershell/examples/legacy-migration-example.ps1 +340 -0
- package/augment-extensions/coding-standards/powershell/examples/module-example.psm1 +255 -0
- package/augment-extensions/coding-standards/powershell/module.json +165 -0
- package/augment-extensions/coding-standards/powershell/rules/administrative-tools.md +439 -0
- package/augment-extensions/coding-standards/powershell/rules/automation-scripts.md +240 -0
- package/augment-extensions/coding-standards/powershell/rules/cloud-orchestration.md +384 -0
- package/augment-extensions/coding-standards/powershell/rules/configuration-schema.md +383 -0
- package/augment-extensions/coding-standards/powershell/rules/cross-platform-scripts.md +482 -0
- package/augment-extensions/coding-standards/powershell/rules/dsc-configurations.md +296 -0
- package/augment-extensions/coding-standards/powershell/rules/error-handling.md +314 -0
- package/augment-extensions/coding-standards/powershell/rules/legacy-migrations.md +466 -0
- package/augment-extensions/coding-standards/powershell/rules/modules-functions.md +244 -0
- package/augment-extensions/coding-standards/powershell/rules/naming-conventions.md +266 -0
- package/augment-extensions/coding-standards/powershell/rules/performance-optimization.md +209 -0
- package/augment-extensions/coding-standards/powershell/rules/security-practices.md +314 -0
- package/augment-extensions/coding-standards/powershell/rules/testing-guidelines.md +268 -0
- package/augment-extensions/coding-standards/powershell/rules/universal-standards.md +197 -0
- package/augment-extensions/coding-standards/python/README.md +12 -8
- package/augment-extensions/coding-standards/python/examples/best-practices.py +373 -0
- package/augment-extensions/coding-standards/python/module.json +8 -4
- package/augment-extensions/coding-standards/python/rules/async-patterns.md +884 -0
- package/augment-extensions/coding-standards/python/rules/documentation.md +831 -0
- package/augment-extensions/coding-standards/python/rules/error-handling.md +855 -68
- package/augment-extensions/coding-standards/python/rules/testing.md +409 -0
- package/augment-extensions/coding-standards/python/rules/tooling.md +446 -0
- package/augment-extensions/coding-standards/python/rules/type-hints.md +115 -50
- package/augment-extensions/collections/html-css-js/README.md +82 -0
- package/augment-extensions/collections/html-css-js/collection.json +41 -0
- package/augment-extensions/domain-rules/database/README.md +161 -0
- package/augment-extensions/domain-rules/database/examples/flat-database-example.md +793 -0
- package/augment-extensions/domain-rules/database/examples/hybrid-database-example.md +1132 -0
- package/augment-extensions/domain-rules/database/examples/nosql-document-example.md +868 -0
- package/augment-extensions/domain-rules/database/examples/nosql-graph-example.md +805 -0
- package/augment-extensions/domain-rules/database/examples/relational-schema-example.md +621 -0
- package/augment-extensions/domain-rules/database/examples/vector-database-example.md +965 -0
- package/augment-extensions/domain-rules/database/module.json +28 -0
- package/augment-extensions/domain-rules/database/rules/flat-databases.md +624 -0
- package/augment-extensions/domain-rules/database/rules/nosql-databases.md +588 -0
- package/augment-extensions/domain-rules/database/rules/nosql-document-stores.md +856 -0
- package/augment-extensions/domain-rules/database/rules/nosql-graph-databases.md +778 -0
- package/augment-extensions/domain-rules/database/rules/nosql-key-value-stores.md +963 -0
- package/augment-extensions/domain-rules/database/rules/performance-optimization.md +1076 -0
- package/augment-extensions/domain-rules/database/rules/relational-databases.md +697 -0
- package/augment-extensions/domain-rules/database/rules/relational-indexing.md +671 -0
- package/augment-extensions/domain-rules/database/rules/relational-query-optimization.md +607 -0
- package/augment-extensions/domain-rules/database/rules/relational-schema-design.md +907 -0
- package/augment-extensions/domain-rules/database/rules/relational-transactions.md +783 -0
- package/augment-extensions/domain-rules/database/rules/security-standards.md +980 -0
- package/augment-extensions/domain-rules/database/rules/universal-best-practices.md +485 -0
- package/augment-extensions/domain-rules/database/rules/vector-databases.md +521 -0
- package/augment-extensions/domain-rules/database/rules/vector-embeddings.md +858 -0
- package/augment-extensions/domain-rules/database/rules/vector-indexing.md +934 -0
- package/augment-extensions/domain-rules/mcp/README.md +150 -0
- package/augment-extensions/domain-rules/mcp/examples/compressed-example.md +522 -0
- package/augment-extensions/domain-rules/mcp/examples/graph-augmented-example.md +520 -0
- package/augment-extensions/domain-rules/mcp/examples/hybrid-example.md +570 -0
- package/augment-extensions/domain-rules/mcp/examples/state-based-example.md +427 -0
- package/augment-extensions/domain-rules/mcp/examples/token-based-example.md +435 -0
- package/augment-extensions/domain-rules/mcp/examples/vector-based-example.md +502 -0
- package/augment-extensions/domain-rules/mcp/module.json +49 -0
- package/augment-extensions/domain-rules/mcp/rules/compressed-mcp.md +595 -0
- package/augment-extensions/domain-rules/mcp/rules/configuration.md +345 -0
- package/augment-extensions/domain-rules/mcp/rules/graph-augmented-mcp.md +687 -0
- package/augment-extensions/domain-rules/mcp/rules/hybrid-mcp.md +636 -0
- package/augment-extensions/domain-rules/mcp/rules/state-based-mcp.md +484 -0
- package/augment-extensions/domain-rules/mcp/rules/testing-validation.md +360 -0
- package/augment-extensions/domain-rules/mcp/rules/token-based-mcp.md +393 -0
- package/augment-extensions/domain-rules/mcp/rules/universal-rules.md +194 -0
- package/augment-extensions/domain-rules/mcp/rules/vector-based-mcp.md +625 -0
- package/augment-extensions/workflows/beads/module.json +4 -3
- package/augment-extensions/workflows/database/README.md +195 -0
- package/augment-extensions/workflows/database/ai-prompt-testing.md +295 -0
- package/augment-extensions/workflows/database/examples/migration-example.md +498 -0
- package/augment-extensions/workflows/database/examples/optimization-example.md +496 -0
- package/augment-extensions/workflows/database/examples/schema-design-example.md +444 -0
- package/augment-extensions/workflows/database/module.json +42 -0
- package/augment-extensions/workflows/database/rules/data-migration.md +249 -0
- package/augment-extensions/workflows/database/rules/documentation-standards.md +339 -0
- package/augment-extensions/workflows/database/rules/migration-workflow.md +352 -0
- package/augment-extensions/workflows/database/rules/optimization-workflow.md +435 -0
- package/augment-extensions/workflows/database/rules/schema-design-workflow.md +535 -0
- package/augment-extensions/workflows/database/rules/testing-patterns.md +305 -0
- package/augment-extensions/workflows/database/rules/workflow.md +458 -0
- package/augment-extensions/workflows/openspec/module.json +4 -3
- package/augment-extensions/writing-standards/screenplay/README.md +171 -0
- package/augment-extensions/writing-standards/screenplay/examples/aaa-hollywood-scene.fountain +164 -0
- package/augment-extensions/writing-standards/screenplay/module.json +124 -0
- package/augment-extensions/writing-standards/screenplay/rules/universal-formatting.md +339 -0
- package/cli/MODULES.md +302 -0
- package/cli/dist/cli.js +142 -9
- package/cli/dist/cli.js.map +1 -1
- package/cli/dist/commands/catalog.d.ts +13 -0
- package/cli/dist/commands/catalog.d.ts.map +1 -0
- package/cli/dist/commands/catalog.js +104 -0
- package/cli/dist/commands/catalog.js.map +1 -0
- package/cli/dist/commands/gui.d.ts +6 -0
- package/cli/dist/commands/gui.d.ts.map +1 -0
- package/cli/dist/commands/gui.js +211 -0
- package/cli/dist/commands/gui.js.map +1 -0
- package/cli/dist/commands/init.d.ts.map +1 -1
- package/cli/dist/commands/init.js +12 -0
- package/cli/dist/commands/init.js.map +1 -1
- package/cli/dist/commands/install-rules.d.ts +14 -0
- package/cli/dist/commands/install-rules.d.ts.map +1 -0
- package/cli/dist/commands/install-rules.js +127 -0
- package/cli/dist/commands/install-rules.js.map +1 -0
- package/cli/dist/commands/link.d.ts.map +1 -1
- package/cli/dist/commands/link.js +9 -11
- package/cli/dist/commands/link.js.map +1 -1
- package/cli/dist/commands/list.d.ts.map +1 -1
- package/cli/dist/commands/list.js +11 -28
- package/cli/dist/commands/list.js.map +1 -1
- package/cli/dist/commands/mcp.d.ts +48 -0
- package/cli/dist/commands/mcp.d.ts.map +1 -0
- package/cli/dist/commands/mcp.js +229 -0
- package/cli/dist/commands/mcp.js.map +1 -0
- package/cli/dist/commands/self-remove.d.ts +7 -0
- package/cli/dist/commands/self-remove.d.ts.map +1 -0
- package/cli/dist/commands/self-remove.js +179 -0
- package/cli/dist/commands/self-remove.js.map +1 -0
- package/cli/dist/commands/show.d.ts.map +1 -1
- package/cli/dist/commands/show.js +29 -99
- package/cli/dist/commands/show.js.map +1 -1
- package/cli/dist/commands/skill.d.ts +67 -0
- package/cli/dist/commands/skill.d.ts.map +1 -0
- package/cli/dist/commands/skill.js +513 -0
- package/cli/dist/commands/skill.js.map +1 -0
- package/cli/dist/commands/unlink.d.ts +6 -0
- package/cli/dist/commands/unlink.d.ts.map +1 -0
- package/cli/dist/commands/unlink.js +115 -0
- package/cli/dist/commands/unlink.js.map +1 -0
- package/cli/dist/commands/validate.d.ts +6 -0
- package/cli/dist/commands/validate.d.ts.map +1 -0
- package/cli/dist/commands/validate.js +159 -0
- package/cli/dist/commands/validate.js.map +1 -0
- package/cli/dist/utils/catalog-sync.d.ts +22 -0
- package/cli/dist/utils/catalog-sync.d.ts.map +1 -0
- package/cli/dist/utils/catalog-sync.js +157 -0
- package/cli/dist/utils/catalog-sync.js.map +1 -0
- package/cli/dist/utils/character-count.d.ts +56 -0
- package/cli/dist/utils/character-count.d.ts.map +1 -0
- package/cli/dist/utils/character-count.js +190 -0
- package/cli/dist/utils/character-count.js.map +1 -0
- package/cli/dist/utils/documentation-validator.d.ts +18 -0
- package/cli/dist/utils/documentation-validator.d.ts.map +1 -0
- package/cli/dist/utils/documentation-validator.js +233 -0
- package/cli/dist/utils/documentation-validator.js.map +1 -0
- package/cli/dist/utils/install-rules.d.ts +32 -0
- package/cli/dist/utils/install-rules.d.ts.map +1 -0
- package/cli/dist/utils/install-rules.js +375 -0
- package/cli/dist/utils/install-rules.js.map +1 -0
- package/cli/dist/utils/mcp-integration.d.ts +70 -0
- package/cli/dist/utils/mcp-integration.d.ts.map +1 -0
- package/cli/dist/utils/mcp-integration.js +292 -0
- package/cli/dist/utils/mcp-integration.js.map +1 -0
- package/cli/dist/utils/module-system.d.ts +153 -0
- package/cli/dist/utils/module-system.d.ts.map +1 -0
- package/cli/dist/utils/module-system.js +528 -0
- package/cli/dist/utils/module-system.js.map +1 -0
- package/cli/dist/utils/modules-catalog.d.ts +33 -0
- package/cli/dist/utils/modules-catalog.d.ts.map +1 -0
- package/cli/dist/utils/modules-catalog.js +163 -0
- package/cli/dist/utils/modules-catalog.js.map +1 -0
- package/cli/dist/utils/rule-install-hooks.d.ts +19 -0
- package/cli/dist/utils/rule-install-hooks.d.ts.map +1 -0
- package/cli/dist/utils/rule-install-hooks.js +224 -0
- package/cli/dist/utils/rule-install-hooks.js.map +1 -0
- package/cli/dist/utils/skill-system.d.ts +95 -0
- package/cli/dist/utils/skill-system.d.ts.map +1 -0
- package/cli/dist/utils/skill-system.js +313 -0
- package/cli/dist/utils/skill-system.js.map +1 -0
- package/modules.md +518 -106
- package/package.json +12 -3
|
@@ -0,0 +1,402 @@
|
|
|
1
|
+
# Code Quality Tools
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
Code quality tools help maintain consistent standards, catch bugs early, and improve overall code quality. This document defines standards for static analysis, code style enforcement, and dependency management.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Static Analysis
|
|
10
|
+
|
|
11
|
+
### PHPStan
|
|
12
|
+
|
|
13
|
+
**Rules:**
|
|
14
|
+
- Use PHPStan for static analysis
|
|
15
|
+
- Start with level 0 and progressively increase
|
|
16
|
+
- Run static analysis in CI/CD pipeline
|
|
17
|
+
- Use baseline files for legacy code
|
|
18
|
+
|
|
19
|
+
**Configuration (phpstan.neon):**
|
|
20
|
+
```neon
|
|
21
|
+
# ✅ Good - PHPStan configuration
|
|
22
|
+
parameters:
|
|
23
|
+
level: 8
|
|
24
|
+
paths:
|
|
25
|
+
- src
|
|
26
|
+
- tests
|
|
27
|
+
excludePaths:
|
|
28
|
+
- src/Legacy/*
|
|
29
|
+
ignoreErrors:
|
|
30
|
+
- '#Call to an undefined method#'
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
**Usage:**
|
|
34
|
+
```bash
|
|
35
|
+
# ✅ Good - Run PHPStan
|
|
36
|
+
./vendor/bin/phpstan analyse
|
|
37
|
+
|
|
38
|
+
# ✅ Good - Generate baseline for legacy code
|
|
39
|
+
./vendor/bin/phpstan analyse --generate-baseline
|
|
40
|
+
|
|
41
|
+
# ✅ Good - Run with specific level
|
|
42
|
+
./vendor/bin/phpstan analyse --level=8
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
**Levels:**
|
|
46
|
+
- Level 0: Basic checks
|
|
47
|
+
- Level 4: Dead code detection
|
|
48
|
+
- Level 6: Type checking
|
|
49
|
+
- Level 8: Strict type checking (recommended for new projects)
|
|
50
|
+
|
|
51
|
+
### Psalm
|
|
52
|
+
|
|
53
|
+
**Rules:**
|
|
54
|
+
- Psalm is an alternative to PHPStan
|
|
55
|
+
- Use either PHPStan or Psalm, not both
|
|
56
|
+
- Configure error levels appropriately
|
|
57
|
+
|
|
58
|
+
**Configuration (psalm.xml):**
|
|
59
|
+
```xml
|
|
60
|
+
<?xml version="1.0"?>
|
|
61
|
+
<psalm
|
|
62
|
+
errorLevel="3"
|
|
63
|
+
resolveFromConfigFile="true"
|
|
64
|
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
65
|
+
xmlns="https://getpsalm.org/schema/config"
|
|
66
|
+
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
|
|
67
|
+
>
|
|
68
|
+
<projectFiles>
|
|
69
|
+
<directory name="src" />
|
|
70
|
+
<ignoreFiles>
|
|
71
|
+
<directory name="vendor" />
|
|
72
|
+
</ignoreFiles>
|
|
73
|
+
</projectFiles>
|
|
74
|
+
</psalm>
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
**Usage:**
|
|
78
|
+
```bash
|
|
79
|
+
# ✅ Good - Run Psalm
|
|
80
|
+
./vendor/bin/psalm
|
|
81
|
+
|
|
82
|
+
# ✅ Good - Fix issues automatically
|
|
83
|
+
./vendor/bin/psalm --alter --issues=all
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
---
|
|
87
|
+
|
|
88
|
+
## Code Style Enforcement
|
|
89
|
+
|
|
90
|
+
### PHP_CodeSniffer
|
|
91
|
+
|
|
92
|
+
**Rules:**
|
|
93
|
+
- Use PHP_CodeSniffer to detect style violations
|
|
94
|
+
- Follow PSR-12 coding standard
|
|
95
|
+
- Configure custom rules when needed
|
|
96
|
+
- Run in CI/CD pipeline
|
|
97
|
+
|
|
98
|
+
**Configuration (phpcs.xml):**
|
|
99
|
+
```xml
|
|
100
|
+
<?xml version="1.0"?>
|
|
101
|
+
<ruleset name="Project Coding Standard">
|
|
102
|
+
<description>Project coding standard based on PSR-12</description>
|
|
103
|
+
|
|
104
|
+
<!-- Use PSR-12 as base -->
|
|
105
|
+
<rule ref="PSR12"/>
|
|
106
|
+
|
|
107
|
+
<!-- Paths to check -->
|
|
108
|
+
<file>src</file>
|
|
109
|
+
<file>tests</file>
|
|
110
|
+
|
|
111
|
+
<!-- Exclude patterns -->
|
|
112
|
+
<exclude-pattern>*/vendor/*</exclude-pattern>
|
|
113
|
+
<exclude-pattern>*/cache/*</exclude-pattern>
|
|
114
|
+
|
|
115
|
+
<!-- Custom rules -->
|
|
116
|
+
<rule ref="Generic.Files.LineLength">
|
|
117
|
+
<properties>
|
|
118
|
+
<property name="lineLimit" value="120"/>
|
|
119
|
+
<property name="absoluteLineLimit" value="150"/>
|
|
120
|
+
</properties>
|
|
121
|
+
</rule>
|
|
122
|
+
</ruleset>
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
**Usage:**
|
|
126
|
+
```bash
|
|
127
|
+
# ✅ Good - Check code style
|
|
128
|
+
./vendor/bin/phpcs
|
|
129
|
+
|
|
130
|
+
# ✅ Good - Check specific files
|
|
131
|
+
./vendor/bin/phpcs src/Services/UserService.php
|
|
132
|
+
|
|
133
|
+
# ✅ Good - Show progress
|
|
134
|
+
./vendor/bin/phpcs -p
|
|
135
|
+
|
|
136
|
+
# ✅ Good - Generate report
|
|
137
|
+
./vendor/bin/phpcs --report=summary
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### PHP-CS-Fixer
|
|
141
|
+
|
|
142
|
+
**Rules:**
|
|
143
|
+
- Use PHP-CS-Fixer for automatic code formatting
|
|
144
|
+
- Configure to match PSR-12 standard
|
|
145
|
+
- Run before committing code
|
|
146
|
+
- Use in pre-commit hooks
|
|
147
|
+
|
|
148
|
+
**Configuration (.php-cs-fixer.php):**
|
|
149
|
+
```php
|
|
150
|
+
<?php
|
|
151
|
+
|
|
152
|
+
$finder = PhpCsFixer\Finder::create()
|
|
153
|
+
->in(__DIR__ . '/src')
|
|
154
|
+
->in(__DIR__ . '/tests')
|
|
155
|
+
->exclude('vendor')
|
|
156
|
+
->exclude('cache');
|
|
157
|
+
|
|
158
|
+
$config = new PhpCsFixer\Config();
|
|
159
|
+
return $config
|
|
160
|
+
->setRules([
|
|
161
|
+
'@PSR12' => true,
|
|
162
|
+
'array_syntax' => ['syntax' => 'short'],
|
|
163
|
+
'ordered_imports' => ['sort_algorithm' => 'alpha'],
|
|
164
|
+
'no_unused_imports' => true,
|
|
165
|
+
'not_operator_with_successor_space' => true,
|
|
166
|
+
'trailing_comma_in_multiline' => true,
|
|
167
|
+
'phpdoc_scalar' => true,
|
|
168
|
+
'unary_operator_spaces' => true,
|
|
169
|
+
'binary_operator_spaces' => true,
|
|
170
|
+
'blank_line_before_statement' => [
|
|
171
|
+
'statements' => ['break', 'continue', 'declare', 'return', 'throw', 'try'],
|
|
172
|
+
],
|
|
173
|
+
'phpdoc_single_line_var_spacing' => true,
|
|
174
|
+
'phpdoc_var_without_name' => true,
|
|
175
|
+
])
|
|
176
|
+
->setFinder($finder);
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
**Usage:**
|
|
180
|
+
```bash
|
|
181
|
+
# ✅ Good - Fix code style
|
|
182
|
+
./vendor/bin/php-cs-fixer fix
|
|
183
|
+
|
|
184
|
+
# ✅ Good - Dry run (show what would be fixed)
|
|
185
|
+
./vendor/bin/php-cs-fixer fix --dry-run --diff
|
|
186
|
+
|
|
187
|
+
# ✅ Good - Fix specific directory
|
|
188
|
+
./vendor/bin/php-cs-fixer fix src/Services
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
---
|
|
192
|
+
|
|
193
|
+
## Dependency Management
|
|
194
|
+
|
|
195
|
+
### Composer
|
|
196
|
+
|
|
197
|
+
**Rules:**
|
|
198
|
+
- Use Composer for ALL dependency management
|
|
199
|
+
- Specify version constraints appropriately
|
|
200
|
+
- Commit composer.lock to version control
|
|
201
|
+
- Regularly check for security vulnerabilities
|
|
202
|
+
|
|
203
|
+
**composer.json Best Practices:**
|
|
204
|
+
```json
|
|
205
|
+
{
|
|
206
|
+
"name": "myapp/project",
|
|
207
|
+
"description": "Project description",
|
|
208
|
+
"type": "project",
|
|
209
|
+
"require": {
|
|
210
|
+
"php": "^8.2",
|
|
211
|
+
"symfony/console": "^6.0",
|
|
212
|
+
"monolog/monolog": "^3.0"
|
|
213
|
+
},
|
|
214
|
+
"require-dev": {
|
|
215
|
+
"phpunit/phpunit": "^10.0",
|
|
216
|
+
"phpstan/phpstan": "^1.10",
|
|
217
|
+
"friendsofphp/php-cs-fixer": "^3.0"
|
|
218
|
+
},
|
|
219
|
+
"autoload": {
|
|
220
|
+
"psr-4": {
|
|
221
|
+
"App\\": "src/"
|
|
222
|
+
}
|
|
223
|
+
},
|
|
224
|
+
"autoload-dev": {
|
|
225
|
+
"psr-4": {
|
|
226
|
+
"Tests\\": "tests/"
|
|
227
|
+
}
|
|
228
|
+
},
|
|
229
|
+
"config": {
|
|
230
|
+
"optimize-autoloader": true,
|
|
231
|
+
"preferred-install": "dist",
|
|
232
|
+
"sort-packages": true
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
**Version Constraints:**
|
|
238
|
+
```json
|
|
239
|
+
{
|
|
240
|
+
"require": {
|
|
241
|
+
"vendor/package": "^1.0", // ✅ Good - Caret (allows 1.x updates)
|
|
242
|
+
"vendor/package": "~1.2", // ✅ Good - Tilde (allows 1.2.x updates)
|
|
243
|
+
"vendor/package": "1.2.3", // ⚠️ Caution - Exact version (no updates)
|
|
244
|
+
"vendor/package": "*", // ❌ Bad - Any version (unstable)
|
|
245
|
+
"vendor/package": "dev-main" // ❌ Bad - Development branch (unstable)
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
**Usage:**
|
|
251
|
+
```bash
|
|
252
|
+
# ✅ Good - Install dependencies
|
|
253
|
+
composer install
|
|
254
|
+
|
|
255
|
+
# ✅ Good - Update dependencies
|
|
256
|
+
composer update
|
|
257
|
+
|
|
258
|
+
# ✅ Good - Add new dependency
|
|
259
|
+
composer require vendor/package
|
|
260
|
+
|
|
261
|
+
# ✅ Good - Add dev dependency
|
|
262
|
+
composer require --dev phpunit/phpunit
|
|
263
|
+
|
|
264
|
+
# ✅ Good - Check for security vulnerabilities
|
|
265
|
+
composer audit
|
|
266
|
+
|
|
267
|
+
# ✅ Good - Validate composer.json
|
|
268
|
+
composer validate
|
|
269
|
+
|
|
270
|
+
# ✅ Good - Optimize autoloader for production
|
|
271
|
+
composer dump-autoload --optimize
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
### Security Auditing
|
|
275
|
+
|
|
276
|
+
**Rules:**
|
|
277
|
+
- Run security audits regularly
|
|
278
|
+
- Update vulnerable dependencies promptly
|
|
279
|
+
- Subscribe to security advisories
|
|
280
|
+
|
|
281
|
+
**Tools:**
|
|
282
|
+
```bash
|
|
283
|
+
# ✅ Good - Composer audit
|
|
284
|
+
composer audit
|
|
285
|
+
|
|
286
|
+
# ✅ Good - Local PHP Security Checker
|
|
287
|
+
local-php-security-checker
|
|
288
|
+
|
|
289
|
+
# ✅ Good - Roave Security Advisories (prevents installation of vulnerable packages)
|
|
290
|
+
composer require --dev roave/security-advisories:dev-latest
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
---
|
|
294
|
+
|
|
295
|
+
## Pre-commit Hooks
|
|
296
|
+
|
|
297
|
+
### Git Hooks
|
|
298
|
+
|
|
299
|
+
**Rules:**
|
|
300
|
+
- Use pre-commit hooks to enforce quality standards
|
|
301
|
+
- Run fast checks only (save slow checks for CI)
|
|
302
|
+
- Allow developers to bypass in emergencies
|
|
303
|
+
|
|
304
|
+
**Example (.git/hooks/pre-commit):**
|
|
305
|
+
```bash
|
|
306
|
+
#!/bin/bash
|
|
307
|
+
|
|
308
|
+
echo "Running pre-commit checks..."
|
|
309
|
+
|
|
310
|
+
# Run PHP-CS-Fixer
|
|
311
|
+
echo "Checking code style..."
|
|
312
|
+
./vendor/bin/php-cs-fixer fix --dry-run --diff
|
|
313
|
+
if [ $? -ne 0 ]; then
|
|
314
|
+
echo "Code style issues found. Run: ./vendor/bin/php-cs-fixer fix"
|
|
315
|
+
exit 1
|
|
316
|
+
fi
|
|
317
|
+
|
|
318
|
+
# Run PHPStan
|
|
319
|
+
echo "Running static analysis..."
|
|
320
|
+
./vendor/bin/phpstan analyse --no-progress
|
|
321
|
+
if [ $? -ne 0 ]; then
|
|
322
|
+
echo "Static analysis failed."
|
|
323
|
+
exit 1
|
|
324
|
+
fi
|
|
325
|
+
|
|
326
|
+
# Run tests
|
|
327
|
+
echo "Running tests..."
|
|
328
|
+
./vendor/bin/phpunit --testsuite=unit
|
|
329
|
+
if [ $? -ne 0 ]; then
|
|
330
|
+
echo "Tests failed."
|
|
331
|
+
exit 1
|
|
332
|
+
fi
|
|
333
|
+
|
|
334
|
+
echo "All checks passed!"
|
|
335
|
+
exit 0
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
---
|
|
339
|
+
|
|
340
|
+
## CI/CD Integration
|
|
341
|
+
|
|
342
|
+
### GitHub Actions Example
|
|
343
|
+
|
|
344
|
+
```yaml
|
|
345
|
+
name: PHP Quality Checks
|
|
346
|
+
|
|
347
|
+
on: [push, pull_request]
|
|
348
|
+
|
|
349
|
+
jobs:
|
|
350
|
+
quality:
|
|
351
|
+
runs-on: ubuntu-latest
|
|
352
|
+
|
|
353
|
+
steps:
|
|
354
|
+
- uses: actions/checkout@v3
|
|
355
|
+
|
|
356
|
+
- name: Setup PHP
|
|
357
|
+
uses: shivammathur/setup-php@v2
|
|
358
|
+
with:
|
|
359
|
+
php-version: '8.2'
|
|
360
|
+
|
|
361
|
+
- name: Install dependencies
|
|
362
|
+
run: composer install --prefer-dist --no-progress
|
|
363
|
+
|
|
364
|
+
- name: Run PHP-CS-Fixer
|
|
365
|
+
run: ./vendor/bin/php-cs-fixer fix --dry-run --diff
|
|
366
|
+
|
|
367
|
+
- name: Run PHPStan
|
|
368
|
+
run: ./vendor/bin/phpstan analyse
|
|
369
|
+
|
|
370
|
+
- name: Run tests
|
|
371
|
+
run: ./vendor/bin/phpunit --coverage-text
|
|
372
|
+
|
|
373
|
+
- name: Security audit
|
|
374
|
+
run: composer audit
|
|
375
|
+
```
|
|
376
|
+
|
|
377
|
+
---
|
|
378
|
+
|
|
379
|
+
## Best Practices
|
|
380
|
+
|
|
381
|
+
### Progressive Improvement
|
|
382
|
+
|
|
383
|
+
**Rules:**
|
|
384
|
+
- Start with lower strictness levels
|
|
385
|
+
- Gradually increase standards
|
|
386
|
+
- Use baseline files for legacy code
|
|
387
|
+
- Fix new code to higher standards
|
|
388
|
+
|
|
389
|
+
### Automation
|
|
390
|
+
|
|
391
|
+
**Rules:**
|
|
392
|
+
- Automate quality checks in CI/CD
|
|
393
|
+
- Use pre-commit hooks for fast feedback
|
|
394
|
+
- Generate reports for tracking progress
|
|
395
|
+
|
|
396
|
+
### Team Alignment
|
|
397
|
+
|
|
398
|
+
**Rules:**
|
|
399
|
+
- Document quality standards in README
|
|
400
|
+
- Share configurations across team
|
|
401
|
+
- Review and update standards regularly
|
|
402
|
+
|