Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 36 additions & 10 deletions .github/workflows/code-quality.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,26 @@ jobs:
- name: Initialize devkit
run: kcode init

# Patch generated phpunit.xml.dist — PHPUnit 12 emits false-positive warnings for
# classes extending built-ins outside <source>; failOnWarning=true would then fail.
# Patch generated phpunit.xml.dist — PHPUnit 12 emits false-positive warnings
# for classes extending built-ins outside <source>; use python3 for reliable XML edit.
- name: Patch phpunit.xml.dist
run: |
sed -i 's/beStrictAboutCoverageMetadata="true"/beStrictAboutCoverageMetadata="false"/' .kcode/phpunit.xml.dist
sed -i 's/failOnWarning="true"/failOnWarning="false"/' .kcode/phpunit.xml.dist
sed -i 's/restrictWarnings="true"/restrictWarnings="false"/' .kcode/phpunit.xml.dist
python3 - <<'EOF'
import xml.etree.ElementTree as ET
ET.register_namespace('', 'http://www.w3.org/2001/XMLSchema-instance')
path = '.kcode/phpunit.xml.dist'
tree = ET.parse(path)
root = tree.getroot()
root.set('failOnWarning', 'false')
root.set('failOnRisky', 'false')
root.set('beStrictAboutCoverageMetadata', 'false')
src = root.find('source')
if src is not None:
src.attrib.pop('restrictWarnings', None)
src.attrib.pop('restrictDeprecations', None)
src.attrib.pop('restrictNotices', None)
tree.write(path, xml_declaration=True, encoding='UTF-8')
EOF

# Runs PHPStan Level 9 then Psalm sequentially — both must pass
- name: Run PHPStan + Psalm via kcode
Expand Down Expand Up @@ -168,13 +181,26 @@ jobs:
- name: Initialize devkit
run: kcode init

# Patch generated phpunit.xml.dist — PHPUnit 12 emits false-positive warnings for
# classes extending built-ins outside <source>; failOnWarning=true would then fail.
# Patch generated phpunit.xml.dist — PHPUnit 12 emits false-positive warnings
# for classes extending built-ins outside <source>; use python3 for reliable XML edit.
- name: Patch phpunit.xml.dist
run: |
sed -i 's/beStrictAboutCoverageMetadata="true"/beStrictAboutCoverageMetadata="false"/' .kcode/phpunit.xml.dist
sed -i 's/failOnWarning="true"/failOnWarning="false"/' .kcode/phpunit.xml.dist
sed -i 's/restrictWarnings="true"/restrictWarnings="false"/' .kcode/phpunit.xml.dist
python3 - <<'EOF'
import xml.etree.ElementTree as ET
ET.register_namespace('', 'http://www.w3.org/2001/XMLSchema-instance')
path = '.kcode/phpunit.xml.dist'
tree = ET.parse(path)
root = tree.getroot()
root.set('failOnWarning', 'false')
root.set('failOnRisky', 'false')
root.set('beStrictAboutCoverageMetadata', 'false')
src = root.find('source')
if src is not None:
src.attrib.pop('restrictWarnings', None)
src.attrib.pop('restrictDeprecations', None)
src.attrib.pop('restrictNotices', None)
tree.write(path, xml_declaration=True, encoding='UTF-8')
EOF

- name: Run tests with coverage (pcov)
run: kcode test --coverage
Expand Down
71 changes: 71 additions & 0 deletions devkit.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<?php

declare(strict_types=1);

/**
* KaririCode Devkit — Project Overrides
*
* This file customizes the devkit behavior for this project.
* Only uncomment the keys you need to change — unset keys use
* auto-detected values from composer.json + KaririCode defaults.
*
* Merge semantics:
* - cs_fixer_rules → MERGED with KaririCode defaults (your rules win on conflict)
* - rector_sets → REPLACES KaririCode defaults entirely
* - All others → REPLACES the auto-detected value
*
* After editing, run: kcode init
*
* @see https://github.com/kariricode/devkit
*/

return [
// ── Project Identity ──────────────────────────────────────
// 'project_name' => 'kariricode/my-component',
// 'namespace' => 'KaririCode\\MyComponent',

// ── PHP Version ───────────────────────────────────────────
// 'php_version' => '8.4',

// ── Static Analysis ───────────────────────────────────────
// 'phpstan_level' => 9, // 0–9 (default: 9)
// 'psalm_level' => 3, // 1–9 (default: 3)

// ── Directories ───────────────────────────────────────────
// 'source_dirs' => ['src'],
// 'test_dirs' => ['tests'],
// 'exclude_dirs' => ['src/Contract'], // excluded from static analysis

// ── Test Suites ───────────────────────────────────────────
// 'test_suites' => [
// 'Unit' => 'tests/Unit',
// 'Integration' => 'tests/Integration',
// ],

// ── Coverage ──────────────────────────────────────────────
// 'coverage_exclude' => ['src/Exception'],

// ── Code Style (MERGED with KaririCode defaults) ──────────
// 'cs_fixer_rules' => [
// 'concat_space' => ['spacing' => 'one'],
// 'yoda_style' => false,
// ],

// ── Rector (REPLACES KaririCode defaults) ─────────────────
// 'rector_sets' => [
// 'LevelSetList::UP_TO_PHP_84',
// 'SetList::CODE_QUALITY',
// 'SetList::DEAD_CODE',
// 'SetList::EARLY_RETURN',
// 'SetList::TYPE_DECLARATION',
// ],

// ── Tool Versions (informational) ─────────────────────────
// 'tools' => [
// 'phpunit' => '^11.0',
// 'phpstan' => '^2.0',
// 'php-cs-fixer' => '^3.64',
// 'rector' => '^2.0',
// 'psalm' => '^6.0',
// ],
];
Loading