@silverassist/agents-toolkit 2.0.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/LICENSE +135 -0
- package/README.md +388 -0
- package/bin/cli.js +940 -0
- package/package.json +52 -0
- package/src/index.js +58 -0
- package/templates/agents/AGENTS.codex.md +195 -0
- package/templates/agents/AGENTS.md +195 -0
- package/templates/agents/CLAUDE.md +213 -0
- package/templates/agents/copilot-instructions.md +83 -0
- package/templates/shared/instructions/css-styling.instructions.md +142 -0
- package/templates/shared/instructions/documentation-language.instructions.md +216 -0
- package/templates/shared/instructions/github-workflow.instructions.md +245 -0
- package/templates/shared/instructions/php-standards.instructions.md +293 -0
- package/templates/shared/instructions/react-components.instructions.md +196 -0
- package/templates/shared/instructions/server-actions.instructions.md +429 -0
- package/templates/shared/instructions/testing-standards.instructions.md +264 -0
- package/templates/shared/instructions/tests.instructions.md +103 -0
- package/templates/shared/instructions/typescript.instructions.md +106 -0
- package/templates/shared/instructions/wordpress-plugin-architecture.instructions.md +238 -0
- package/templates/shared/prompts/README.md +129 -0
- package/templates/shared/prompts/_partials/README.md +57 -0
- package/templates/shared/prompts/_partials/documentation.md +203 -0
- package/templates/shared/prompts/_partials/git-operations.md +171 -0
- package/templates/shared/prompts/_partials/github-integration.md +100 -0
- package/templates/shared/prompts/_partials/jira-integration.md +155 -0
- package/templates/shared/prompts/_partials/pr-template.md +216 -0
- package/templates/shared/prompts/_partials/validations.md +87 -0
- package/templates/shared/prompts/add-tests.prompt.md +151 -0
- package/templates/shared/prompts/analyze-github-issue.prompt.md +73 -0
- package/templates/shared/prompts/analyze-ticket.prompt.md +63 -0
- package/templates/shared/prompts/create-plan.prompt.md +118 -0
- package/templates/shared/prompts/create-pr.prompt.md +139 -0
- package/templates/shared/prompts/finalize-pr.prompt.md +150 -0
- package/templates/shared/prompts/fix-issues.prompt.md +92 -0
- package/templates/shared/prompts/new-wp-component.prompt.md +51 -0
- package/templates/shared/prompts/new-wp-plugin.prompt.md +46 -0
- package/templates/shared/prompts/prepare-pr.prompt.md +123 -0
- package/templates/shared/prompts/prepare-release.prompt.md +74 -0
- package/templates/shared/prompts/quality-check.prompt.md +45 -0
- package/templates/shared/prompts/review-code.prompt.md +81 -0
- package/templates/shared/prompts/work-github-issue.prompt.md +96 -0
- package/templates/shared/prompts/work-ticket.prompt.md +98 -0
- package/templates/shared/skills/README.md +53 -0
- package/templates/shared/skills/component-architecture/SKILL.md +321 -0
- package/templates/shared/skills/create-component/SKILL.md +714 -0
- package/templates/shared/skills/domain-driven-design/SKILL.md +277 -0
- package/templates/shared/skills/plugin-creation/SKILL.md +1094 -0
- package/templates/shared/skills/quality-checks/SKILL.md +493 -0
- package/templates/shared/skills/release-management/SKILL.md +649 -0
- package/templates/shared/skills/testing/SKILL.md +682 -0
- package/templates/shared/skills/testing-patterns/SKILL.md +243 -0
|
@@ -0,0 +1,493 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: quality-checks
|
|
3
|
+
description: Run and troubleshoot code quality tools for Silver Assist WordPress plugins. Covers PHPCS (WordPress Coding Standards), PHPStan (static analysis level 8), PHPUnit test execution, the unified quality check script, and CI/CD integration. Use when fixing code style errors, running quality checks, or troubleshooting CI failures.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Silver Assist â Quality Checks
|
|
7
|
+
|
|
8
|
+
This skill covers running, configuring, and troubleshooting the code quality tools used across all Silver Assist WordPress plugins.
|
|
9
|
+
|
|
10
|
+
## When to Use
|
|
11
|
+
|
|
12
|
+
- Running PHPCS, PHPStan, or PHPUnit checks
|
|
13
|
+
- Fixing code style errors or warnings
|
|
14
|
+
- Troubleshooting CI/CD quality check failures
|
|
15
|
+
- Configuring quality tool settings
|
|
16
|
+
- Understanding PHPCS rules and exclusions
|
|
17
|
+
- Resolving PHPStan level 8 type errors
|
|
18
|
+
|
|
19
|
+
## Prerequisites
|
|
20
|
+
|
|
21
|
+
- `composer install` completed in the plugin directory
|
|
22
|
+
- PHP 8.2+ available
|
|
23
|
+
- For PHPUnit: WordPress Test Suite installed (or `--skip-wp-setup` for local)
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## Quick Reference
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
# Auto-fix formatting.
|
|
31
|
+
vendor/bin/phpcbf
|
|
32
|
+
|
|
33
|
+
# Check code standards (must pass with 0 errors).
|
|
34
|
+
vendor/bin/phpcs
|
|
35
|
+
|
|
36
|
+
# Static analysis (must pass level 8).
|
|
37
|
+
vendor/bin/phpstan analyse --memory-limit=1G
|
|
38
|
+
|
|
39
|
+
# Run tests.
|
|
40
|
+
vendor/bin/phpunit
|
|
41
|
+
|
|
42
|
+
# Run all via composer scripts.
|
|
43
|
+
composer test
|
|
44
|
+
|
|
45
|
+
# Run all via quality script.
|
|
46
|
+
./scripts/run-quality-checks.sh all
|
|
47
|
+
|
|
48
|
+
# Quick local checks (skip WordPress Test Suite setup).
|
|
49
|
+
./scripts/run-quality-checks.sh --skip-wp-setup phpcs phpstan
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
## PHPCS (PHP_CodeSniffer)
|
|
55
|
+
|
|
56
|
+
### Configuration
|
|
57
|
+
|
|
58
|
+
File: `phpcs.xml` â standard across all Silver Assist plugins.
|
|
59
|
+
|
|
60
|
+
**Base Standard**: `WordPress-Extra` with these exclusions:
|
|
61
|
+
- `Generic.Arrays.DisallowShortArraySyntax` â short arrays allowed (`[]` not `array()`)
|
|
62
|
+
- `WordPress.Files.FileName.NotHyphenatedLowercase` â PSR-4 PascalCase filenames
|
|
63
|
+
- `WordPress.Files.FileName.InvalidClassFileName` â PSR-4 class filenames
|
|
64
|
+
- `Generic.Functions.OpeningFunctionBraceKernighanRitchie` â K&R brace style allowed
|
|
65
|
+
- `Generic.Classes.OpeningBraceSameLine` â same-line braces allowed
|
|
66
|
+
|
|
67
|
+
**Additional Standards Enforced**:
|
|
68
|
+
- `WordPress-Docs` â PHPDoc coverage
|
|
69
|
+
- `WordPress.NamingConventions.PrefixAllGlobals` â plugin-specific prefixes
|
|
70
|
+
- `Generic.CodeAnalysis.UnusedFunctionParameter`
|
|
71
|
+
- `Generic.Commenting.Todo`
|
|
72
|
+
- PHP compatibility: `8.2-`
|
|
73
|
+
- Min WP version: `6.5`
|
|
74
|
+
|
|
75
|
+
### Common Commands
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
# Auto-fix what can be fixed.
|
|
79
|
+
vendor/bin/phpcbf
|
|
80
|
+
|
|
81
|
+
# Check all files.
|
|
82
|
+
vendor/bin/phpcs
|
|
83
|
+
|
|
84
|
+
# Check specific file.
|
|
85
|
+
vendor/bin/phpcs includes/Core/Plugin.php
|
|
86
|
+
|
|
87
|
+
# Check with summary report.
|
|
88
|
+
vendor/bin/phpcs --report=summary
|
|
89
|
+
|
|
90
|
+
# Ignore warnings (for CI - only fail on errors).
|
|
91
|
+
vendor/bin/phpcs --runtime-set ignore_warnings_on_exit 1
|
|
92
|
+
|
|
93
|
+
# Show only errors (suppress warnings).
|
|
94
|
+
vendor/bin/phpcs --warning-severity=0
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### Common PHPCS Errors and Fixes
|
|
98
|
+
|
|
99
|
+
#### 1. Missing global variable prefix
|
|
100
|
+
|
|
101
|
+
```php
|
|
102
|
+
// â ERROR: Non-prefixed global variable.
|
|
103
|
+
$autoload_path = PLUGIN_PATH . 'vendor/autoload.php';
|
|
104
|
+
|
|
105
|
+
// â
FIX: Add plugin prefix.
|
|
106
|
+
$plugin_prefix_autoload_path = PLUGIN_PREFIX_PATH . 'vendor/autoload.php';
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
#### 2. Inline comment missing punctuation
|
|
110
|
+
|
|
111
|
+
```php
|
|
112
|
+
// â ERROR: Comment missing period.
|
|
113
|
+
// Initialize the component
|
|
114
|
+
|
|
115
|
+
// â
FIX: Add period.
|
|
116
|
+
// Initialize the component.
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
#### 3. Double quotes without interpolation
|
|
120
|
+
|
|
121
|
+
```php
|
|
122
|
+
// â ERROR: Unnecessary double quotes.
|
|
123
|
+
$status = "active";
|
|
124
|
+
|
|
125
|
+
// â
FIX: Use single quotes.
|
|
126
|
+
$status = 'active';
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
#### 4. Missing PHPDoc
|
|
130
|
+
|
|
131
|
+
```php
|
|
132
|
+
// â ERROR: Missing doc comment.
|
|
133
|
+
public function process(): void {
|
|
134
|
+
|
|
135
|
+
// â
FIX: Add PHPDoc.
|
|
136
|
+
/**
|
|
137
|
+
* Process the request.
|
|
138
|
+
*
|
|
139
|
+
* @return void
|
|
140
|
+
*/
|
|
141
|
+
public function process(): void {
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
#### 5. Unordered sprintf placeholders
|
|
145
|
+
|
|
146
|
+
```php
|
|
147
|
+
// â ERROR: Non-positional placeholders with multiple args.
|
|
148
|
+
sprintf( __( 'Form "%s" has %d submissions', 'text-domain' ), $name, $count );
|
|
149
|
+
|
|
150
|
+
// â
FIX: Use positional placeholders with translator comment.
|
|
151
|
+
sprintf(
|
|
152
|
+
/* translators: %1$s: form name, %2$d: submission count */
|
|
153
|
+
__( 'Form "%1$s" has %2$d submissions', 'text-domain' ),
|
|
154
|
+
$name,
|
|
155
|
+
$count
|
|
156
|
+
);
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
#### 6. Missing backslash for WordPress functions
|
|
160
|
+
|
|
161
|
+
```php
|
|
162
|
+
// â ERROR in namespaced code (may cause issues).
|
|
163
|
+
add_action( 'init', [ $this, 'init' ] );
|
|
164
|
+
|
|
165
|
+
// â
FIX: Backslash prefix.
|
|
166
|
+
\add_action( 'init', [ $this, 'init' ] );
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
### PHPCS in CI/CD
|
|
170
|
+
|
|
171
|
+
**CRITICAL**: PHPCS warnings (even with 0 errors) cause exit code 1/2 under `bash -e`. Always use:
|
|
172
|
+
|
|
173
|
+
```bash
|
|
174
|
+
vendor/bin/phpcs --runtime-set ignore_warnings_on_exit 1
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
This ensures the step only fails on actual errors, not warnings.
|
|
178
|
+
|
|
179
|
+
---
|
|
180
|
+
|
|
181
|
+
## PHPStan (Static Analysis)
|
|
182
|
+
|
|
183
|
+
### Configuration
|
|
184
|
+
|
|
185
|
+
File: `phpstan.neon`
|
|
186
|
+
|
|
187
|
+
```yaml
|
|
188
|
+
includes:
|
|
189
|
+
- vendor/szepeviktor/phpstan-wordpress/extension.neon
|
|
190
|
+
|
|
191
|
+
parameters:
|
|
192
|
+
level: 8
|
|
193
|
+
paths:
|
|
194
|
+
- includes
|
|
195
|
+
bootstrapFiles:
|
|
196
|
+
- plugin-main-file.php
|
|
197
|
+
scanDirectories:
|
|
198
|
+
- vendor
|
|
199
|
+
excludePaths:
|
|
200
|
+
- tests/*
|
|
201
|
+
- build/*
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
### Level 8 Requirements
|
|
205
|
+
|
|
206
|
+
Level 8 is the strictest level. It requires:
|
|
207
|
+
- No unused variables
|
|
208
|
+
- Strict type checking on all operations
|
|
209
|
+
- Full PHPDoc coverage with accurate types
|
|
210
|
+
- No `mixed` types without explicit reason
|
|
211
|
+
- Correct nullable handling
|
|
212
|
+
- Accurate return types
|
|
213
|
+
|
|
214
|
+
### Common Commands
|
|
215
|
+
|
|
216
|
+
```bash
|
|
217
|
+
# Standard analysis.
|
|
218
|
+
vendor/bin/phpstan analyse --memory-limit=1G
|
|
219
|
+
|
|
220
|
+
# Analyze specific directory.
|
|
221
|
+
vendor/bin/phpstan analyse includes/Service/ --memory-limit=1G --no-progress
|
|
222
|
+
|
|
223
|
+
# Generate baseline (accept existing errors temporarily).
|
|
224
|
+
vendor/bin/phpstan analyse --generate-baseline
|
|
225
|
+
|
|
226
|
+
# Clear cache (if results seem stale).
|
|
227
|
+
vendor/bin/phpstan clear-result-cache
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
### Common PHPStan Errors and Fixes
|
|
231
|
+
|
|
232
|
+
#### 1. Nullable property access
|
|
233
|
+
|
|
234
|
+
```php
|
|
235
|
+
// â ERROR: Cannot call method on possibly null value.
|
|
236
|
+
$this->service->process();
|
|
237
|
+
|
|
238
|
+
// â
FIX: Null guard.
|
|
239
|
+
if ( ! $this->service ) {
|
|
240
|
+
return;
|
|
241
|
+
}
|
|
242
|
+
$this->service->process();
|
|
243
|
+
|
|
244
|
+
// â
Alternative: Null-safe operator.
|
|
245
|
+
$this->service?->process();
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
#### 2. Missing return type
|
|
249
|
+
|
|
250
|
+
```php
|
|
251
|
+
// â ERROR: Method has no return type.
|
|
252
|
+
public function get_data() {
|
|
253
|
+
|
|
254
|
+
// â
FIX: Add return type.
|
|
255
|
+
/**
|
|
256
|
+
* Get data.
|
|
257
|
+
*
|
|
258
|
+
* @return array<string, mixed>
|
|
259
|
+
*/
|
|
260
|
+
public function get_data(): array {
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
#### 3. PHPDoc/code type mismatch
|
|
264
|
+
|
|
265
|
+
```php
|
|
266
|
+
// â ERROR: PHPDoc tag @param has invalid type.
|
|
267
|
+
/** @param array $items */
|
|
268
|
+
public function process( array $items ): void {
|
|
269
|
+
|
|
270
|
+
// â
FIX: Be specific in PHPDoc.
|
|
271
|
+
/** @param array<int, string> $items */
|
|
272
|
+
public function process( array $items ): void {
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
#### 4. WordPress function return types
|
|
276
|
+
|
|
277
|
+
```php
|
|
278
|
+
// â ERROR: get_option returns mixed.
|
|
279
|
+
$value = \get_option( 'key' );
|
|
280
|
+
$this->method_expecting_string( $value );
|
|
281
|
+
|
|
282
|
+
// â
FIX: Type assertion.
|
|
283
|
+
$value = \get_option( 'key', '' );
|
|
284
|
+
if ( is_string( $value ) ) {
|
|
285
|
+
$this->method_expecting_string( $value );
|
|
286
|
+
}
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
### Memory Issues
|
|
290
|
+
|
|
291
|
+
PHPStan defaults to 128MB which is insufficient for most plugins:
|
|
292
|
+
|
|
293
|
+
```bash
|
|
294
|
+
# â Crashes at default memory.
|
|
295
|
+
vendor/bin/phpstan analyse
|
|
296
|
+
|
|
297
|
+
# â
Increase memory.
|
|
298
|
+
vendor/bin/phpstan analyse --memory-limit=1G
|
|
299
|
+
|
|
300
|
+
# â
Or via composer script (already configured).
|
|
301
|
+
composer phpstan
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
---
|
|
305
|
+
|
|
306
|
+
## PHPUnit
|
|
307
|
+
|
|
308
|
+
### Quick Commands
|
|
309
|
+
|
|
310
|
+
```bash
|
|
311
|
+
# Run all tests.
|
|
312
|
+
vendor/bin/phpunit
|
|
313
|
+
|
|
314
|
+
# Run specific suite.
|
|
315
|
+
vendor/bin/phpunit --testsuite unit
|
|
316
|
+
vendor/bin/phpunit --testsuite integration
|
|
317
|
+
|
|
318
|
+
# Run specific file.
|
|
319
|
+
vendor/bin/phpunit tests/Unit/Core/PluginTest.php
|
|
320
|
+
|
|
321
|
+
# Run specific method.
|
|
322
|
+
vendor/bin/phpunit --filter testMethodName
|
|
323
|
+
|
|
324
|
+
# With coverage.
|
|
325
|
+
vendor/bin/phpunit --coverage-html coverage/
|
|
326
|
+
vendor/bin/phpunit --coverage-text
|
|
327
|
+
|
|
328
|
+
# Human-readable output.
|
|
329
|
+
vendor/bin/phpunit --testdox
|
|
330
|
+
```
|
|
331
|
+
|
|
332
|
+
### WordPress Test Suite Required
|
|
333
|
+
|
|
334
|
+
PHPUnit tests extend `WP_UnitTestCase` which requires the WordPress Test Suite. If not installed:
|
|
335
|
+
|
|
336
|
+
```
|
|
337
|
+
Warning: WordPress Test Suite not found. Tests will run with limited functionality.
|
|
338
|
+
```
|
|
339
|
+
|
|
340
|
+
Install via:
|
|
341
|
+
|
|
342
|
+
```bash
|
|
343
|
+
bash scripts/install-wp-tests.sh wordpress_test root 'root' localhost latest true
|
|
344
|
+
```
|
|
345
|
+
|
|
346
|
+
See the **testing** skill for full details on test patterns and bootstrap.
|
|
347
|
+
|
|
348
|
+
---
|
|
349
|
+
|
|
350
|
+
## Quality Check Script
|
|
351
|
+
|
|
352
|
+
File: `scripts/run-quality-checks.sh`
|
|
353
|
+
|
|
354
|
+
This script centralizes all quality checks for consistent execution.
|
|
355
|
+
|
|
356
|
+
### Usage
|
|
357
|
+
|
|
358
|
+
```bash
|
|
359
|
+
# Run all checks (with WordPress Test Suite setup).
|
|
360
|
+
./scripts/run-quality-checks.sh all
|
|
361
|
+
|
|
362
|
+
# Skip WP setup (faster for local development).
|
|
363
|
+
./scripts/run-quality-checks.sh --skip-wp-setup all
|
|
364
|
+
|
|
365
|
+
# Run specific checks only.
|
|
366
|
+
./scripts/run-quality-checks.sh phpcs phpstan
|
|
367
|
+
./scripts/run-quality-checks.sh phpunit
|
|
368
|
+
```
|
|
369
|
+
|
|
370
|
+
### Script Pattern
|
|
371
|
+
|
|
372
|
+
**CRITICAL**: All check functions must return proper exit codes:
|
|
373
|
+
|
|
374
|
+
```bash
|
|
375
|
+
run_phpcs() {
|
|
376
|
+
print_header "đ Running PHPCS"
|
|
377
|
+
|
|
378
|
+
cd "$PROJECT_ROOT"
|
|
379
|
+
|
|
380
|
+
# â
CORRECT: Capture exit code and return appropriate value.
|
|
381
|
+
if vendor/bin/phpcs --warning-severity=0; then
|
|
382
|
+
print_success "PHPCS passed - No errors found"
|
|
383
|
+
return 0
|
|
384
|
+
else
|
|
385
|
+
print_error "PHPCS failed - Code style errors found"
|
|
386
|
+
return 1
|
|
387
|
+
fi
|
|
388
|
+
}
|
|
389
|
+
```
|
|
390
|
+
|
|
391
|
+
---
|
|
392
|
+
|
|
393
|
+
## Pre-PR Checklist (MANDATORY)
|
|
394
|
+
|
|
395
|
+
Before every commit/PR, run these checks in order:
|
|
396
|
+
|
|
397
|
+
```bash
|
|
398
|
+
# 1. Auto-fix formatting.
|
|
399
|
+
vendor/bin/phpcbf
|
|
400
|
+
|
|
401
|
+
# 2. Check standards (must be 0 errors).
|
|
402
|
+
vendor/bin/phpcs
|
|
403
|
+
|
|
404
|
+
# 3. Static analysis (must pass level 8).
|
|
405
|
+
vendor/bin/phpstan analyse --memory-limit=1G
|
|
406
|
+
|
|
407
|
+
# 4. Run tests (must pass all).
|
|
408
|
+
vendor/bin/phpunit
|
|
409
|
+
|
|
410
|
+
# 5. Update translations.
|
|
411
|
+
wp i18n make-pot . languages/plugin-text-domain.pot --domain=plugin-text-domain
|
|
412
|
+
```
|
|
413
|
+
|
|
414
|
+
---
|
|
415
|
+
|
|
416
|
+
## Troubleshooting
|
|
417
|
+
|
|
418
|
+
### PHPCS: "phpcs: command not found"
|
|
419
|
+
|
|
420
|
+
```bash
|
|
421
|
+
# Install via composer.
|
|
422
|
+
composer install
|
|
423
|
+
|
|
424
|
+
# Use vendor path.
|
|
425
|
+
vendor/bin/phpcs
|
|
426
|
+
```
|
|
427
|
+
|
|
428
|
+
### PHPCS: warnings cause CI failure
|
|
429
|
+
|
|
430
|
+
PHPCS exit codes: 0 = clean, 1 = warnings, 2 = errors. Under `bash -e` (CI), exit code 1 aborts.
|
|
431
|
+
|
|
432
|
+
**Fix**: Add `--runtime-set ignore_warnings_on_exit 1` to CI scripts.
|
|
433
|
+
|
|
434
|
+
### PHPStan: "Allowed memory size exhausted"
|
|
435
|
+
|
|
436
|
+
```bash
|
|
437
|
+
vendor/bin/phpstan analyse --memory-limit=1G
|
|
438
|
+
# or
|
|
439
|
+
php -d memory_limit=1G vendor/bin/phpstan analyse
|
|
440
|
+
```
|
|
441
|
+
|
|
442
|
+
### PHPStan: stale results after code changes
|
|
443
|
+
|
|
444
|
+
```bash
|
|
445
|
+
vendor/bin/phpstan clear-result-cache
|
|
446
|
+
vendor/bin/phpstan analyse --memory-limit=1G
|
|
447
|
+
```
|
|
448
|
+
|
|
449
|
+
### PHPUnit: "Class WP_UnitTestCase not found"
|
|
450
|
+
|
|
451
|
+
The WordPress Test Suite is not installed. Either:
|
|
452
|
+
1. Install it: `bash scripts/install-wp-tests.sh wordpress_test root 'root' localhost latest true`
|
|
453
|
+
2. Run in CI where it's automatically set up
|
|
454
|
+
3. Use `--skip-wp-setup` flag with the quality check script for local non-test checks
|
|
455
|
+
|
|
456
|
+
### PHPCBF: "No fixable errors were found"
|
|
457
|
+
|
|
458
|
+
This is success â all auto-fixable issues are already resolved.
|
|
459
|
+
|
|
460
|
+
---
|
|
461
|
+
|
|
462
|
+
## CI/CD Integration
|
|
463
|
+
|
|
464
|
+
### Workflow Strategy
|
|
465
|
+
|
|
466
|
+
| Workflow | WordPress Tests | Time | Purpose |
|
|
467
|
+
|----------|----------------|------|---------|
|
|
468
|
+
| `ci.yml` | â
Yes | ~8-10 min | Full integration testing on PRs |
|
|
469
|
+
| `release.yml` | â
Yes | ~10-12 min | Exhaustive validation before release |
|
|
470
|
+
| `dependency-updates.yml` | â No | ~2-3 min | Fast Composer package validation |
|
|
471
|
+
|
|
472
|
+
### Quality Checks in Release Workflow
|
|
473
|
+
|
|
474
|
+
The release workflow runs PHPCS and PHPStan before building:
|
|
475
|
+
|
|
476
|
+
```yaml
|
|
477
|
+
- name: Code quality
|
|
478
|
+
run: |
|
|
479
|
+
HAS_CHECKS=false
|
|
480
|
+
if [ -f phpcs.xml ] || [ -f .phpcs.xml.dist ] || [ -f phpcs.xml.dist ]; then
|
|
481
|
+
echo "âļ PHPCS"
|
|
482
|
+
vendor/bin/phpcs --runtime-set ignore_warnings_on_exit 1
|
|
483
|
+
HAS_CHECKS=true
|
|
484
|
+
fi
|
|
485
|
+
if [ -f phpstan.neon ] || [ -f phpstan.neon.dist ]; then
|
|
486
|
+
echo "âļ PHPStan"
|
|
487
|
+
vendor/bin/phpstan analyse --no-progress
|
|
488
|
+
HAS_CHECKS=true
|
|
489
|
+
fi
|
|
490
|
+
if [ "$HAS_CHECKS" = false ]; then
|
|
491
|
+
echo "âšī¸ No quality tool configs found â skipping"
|
|
492
|
+
fi
|
|
493
|
+
```
|