check-code-style

Analyze PHP code for style issues. Check for compliance with PSR-12, formatting consistency, whitespace usage, and line length.

Last repository push
GitHub Stars
109
Forks
26
Issues / PRs
1

Installation

Review the source and dependencies with a prompt. A package is available to download.

Install with an AI assistant

Copy the prompt so your assistant can review the pinned revision and dependencies first.

View promptHide prompt
Check whether SkillPI Skill Finder is installed for your current agent. If it is missing, install and enable it using the official instructions at https://github.com/Findskills/skillpi. Then use Skill Finder to locate and install "check-code-style" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-5abf4aabadc764223128ba1e59497015e4cf1dd7fe58bc4d0fee4e0470b4795b. Verify the upstream source and version against https://github.com/dykyi-roman/awesome-claude-code before installing. If they do not match, stop and report the mismatch. Report the installed path and source version.

Source and setup

github.com

Setup guidance pending

See the original source for supported tools, dependencies, and permissions.

Installation test pending

Analyze PHP code for style issues. Check for compliance with PSR-12, formatting consistency, whitespace usage, and line length.

0 Downloads

Introduction source: third_party · dykyi-roman · 0.0.1 Reference

SkillPi interpretation

Tasks
Analyzes PHP code for style issues. Checks PSR-12 compliance, formatting consistency, whitespace usage, line length.
Inputs and outputs
```markdown
Testing
Not tested

Browse files

Browse files at the source ↗

Original SKILL.md

Open original ↗
Frontmatter
name: check-code-style
description: Analyzes PHP code for style issues. Checks PSR-12 compliance, formatting consistency, whitespace usage, line length.

Code Style Check

Analyze PHP code for style consistency and PSR-12 compliance.

Detection Patterns

1. PSR-12 Violations

// BAD: Opening brace on same line for class
class User {
}

// GOOD: Opening brace on new line
class User
{
}

// BAD: Opening brace on new line for methods
public function getName()
{
}

// GOOD: Opening brace on same line for control structures
if ($condition) {
}

// BAD: No space after keywords
if($condition) {}
foreach($items as $item) {}

// GOOD: Space after keywords
if ($condition) {}
foreach ($items as $item) {}

2. Line Length

// BAD: Exceeds 120 characters
$result = $this->veryLongServiceName->processWithManyParameters($parameter1, $parameter2, $parameter3, $parameter4, $parameter5);

// GOOD: Broken into multiple lines
$result = $this->veryLongServiceName->processWithManyParameters(
    $parameter1,
    $parameter2,
    $parameter3,
    $parameter4,
    $parameter5
);

3. Indentation

// BAD: Mixed tabs and spaces
class User
{
    private string $name;  // Tab
    private int $age;      // Spaces
}

// GOOD: Consistent 4 spaces
class User
{
    private string $name;
    private int $age;
}

4. Blank Lines

// BAD: No blank line after namespace
namespace App\Service;
use App\Repository;

// GOOD: Blank line after namespace
namespace App\Service;

use App\Repository;

// BAD: No blank line between methods
public function getName(): string
{
    return $this->name;
}
public function setName(string $name): void
{
    $this->name = $name;
}

// GOOD: Blank line between methods
public function getName(): string
{
    return $this->name;
}

public function setName(string $name): void
{
    $this->name = $name;
}

5. Trailing Whitespace

// BAD: Trailing spaces at end of line
$name = 'John';
$age = 25;

// GOOD: No trailing whitespace
$name = 'John';
$age = 25;

6. Use Statement Ordering

// BAD: Unordered use statements
use App\Service\OrderService;
use App\Entity\User;
use Symfony\Component\HttpFoundation\Request;
use App\Repository\UserRepository;

// GOOD: Grouped and alphabetized
use App\Entity\User;
use App\Repository\UserRepository;
use App\Service\OrderService;
use Symfony\Component\HttpFoundation\Request;

7. Array Syntax

// BAD: Long array syntax
$items = array(1, 2, 3);
$config = array(
    'key' => 'value',
);

// GOOD: Short array syntax
$items = [1, 2, 3];
$config = [
    'key' => 'value',
];

8. Operator Spacing

// BAD: Inconsistent spacing
$sum=$a+$b;
$name = $first.$last;
$condition = $a>$b;

// GOOD: Consistent spacing
$sum = $a + $b;
$name = $first . $last;
$condition = $a > $b;

9. Comma Spacing

// BAD: No space after comma
$result = calculate($a,$b,$c);
$array = [1,2,3];

// GOOD: Space after comma
$result = calculate($a, $b, $c);
$array = [1, 2, 3];

10. Return Type Declaration

// BAD: Space before colon
public function getName() : string {}

// GOOD: No space before colon
public function getName(): string {}

// BAD: No space after colon
public function getName():string {}

// GOOD: Space after colon
public function getName(): string {}

Grep Patterns

# Opening brace on same line for class
Grep: "class\s+\w+\s*\{" --glob "**/*.php"

# No space after if/foreach/while
Grep: "(if|foreach|while|for|switch)\(" --glob "**/*.php"

# Lines over 120 chars (needs manual check)
Grep: "^.{121,}$" --glob "**/*.php"

# array() instead of []
Grep: "array\s*\(" --glob "**/*.php"

# Missing space around operators
Grep: "[^ ]==[^ ]|[^ ]!=[^ ]" --glob "**/*.php"

Severity Classification

Pattern Severity
Mixed tabs/spaces 🟠 Major
PSR-12 brace placement 🟡 Minor
Line length > 120 🟡 Minor
Operator spacing 🟢 Suggestion
Use statement order 🟢 Suggestion

Automated Fixing

Most style issues can be automatically fixed:

# PHP-CS-Fixer
php-cs-fixer fix --rules=@PSR12

# PHP_CodeSniffer
phpcbf --standard=PSR12 src/

Output Format

### Style Issue: [Description]

**Severity:** 🟠/🟡/🟢
**Location:** `file.php:line`
**Rule:** PSR-12 / Project Standard

**Issue:**
[Description of the style violation]

**Current:**
```php
if($condition){

Suggested:

if ($condition) {

Auto-fix: Run php-cs-fixer fix --rules=@PSR12

Current listing version

0.0.1

Verify the source revision ↗

Quality assessment

Out of 100 · Assessment report from SkillPi LAB.

Scenario Value75/100

Highlights

  • 提供 PHP 代码风格分析功能,针对 PSR-12 规范、格式一致性等常见问题
  • 具有明确的开发者工具定位,实用价值明确
Trigger Precision90/100

Highlights

  • description 字段完整描述了功能,触发词清晰
Structure and Standards95/100

Highlights

  • 结构完整,包含清晰的 Detection Patterns 分类和 BAD/GOOD 示例对比
  • 提供了 Grep Patterns、Severity Classification 和 Automated Fixing 方案
Execution Reliability75/100

Areas to improve

  • 缺少异常处理说明 Reported severity: Minor

    未提及如何处理 Grep 命令执行失败、文件权限问题、PHP 环境未安装等异常情况

    Recommendation: 建议在文档中补充常见异常的处理建议或错误提示

Highlights

  • 提供了具体的 Grep 命令和自动化修复工具推荐,工具来源明确
Evidence Verifiability (mean of the first four)84/100

The arithmetic mean of the first four original scores, rounded to a whole number.

Static text checks

100 / 100 · skillpi-20261123-no-r3-v1

No current rules matched the text.

This score reflects rule matches in the text and is provided for reference before use. It excludes attachments and runtime behavior.

Permissions and checks before use

Automatically summarized from this main document. Matches may be examples or defensive advice; they are not actual permission declarations. Attachments, external dependencies and runtime behavior are not covered.

These common operations were not identified in the main document. This does not mean no permissions or risks exist.

These notices grant no permissions. Your host tool must still confirm file changes, secrets, external transfers or costs as needed.

Security rating and access scope

safe · Static evidence review; not a runtime safety guarantee.

Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.