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
7 changes: 7 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
tests/ export-ignore
.github/ export-ignore

composer.lock export-ignore
phpstan.neon.dist export-ignore
phpunit.xml.dist export-ignore
.gitignore export-ignore
146 changes: 146 additions & 0 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
name: Validate push
on: [pull_request]

jobs:
install:
strategy:
matrix:
include:
- php-version: 8.4
- php-version: 8.5

runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Cache composer dependencies
uses: actions/cache@v3
with:
path: vendor/
key: ${{ runner.os }}-composer-s-${{ hashFiles('**/composer.lock') }}-${{ matrix.php-version }}
restore-keys: |
${{ runner.os }}-composer-s-${{ hashFiles('**/composer.lock') }}-${{ matrix.php-version }}

- name: PHP Setup
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
ini-values: pcov.directory=.
coverage: pcov
tools: composer

- name: Install
run: |
composer install --no-interaction --no-scripts --ansi --no-progress --prefer-dist

phpstan:
strategy:
matrix:
include:
- php-version: 8.5

runs-on: ubuntu-latest
needs: install

steps:
- uses: actions/checkout@v3

- name: Cache composer dependencies
uses: actions/cache@v3
with:
path: vendor/
key: ${{ runner.os }}-composer-s-${{ hashFiles('**/composer.lock') }}-${{ matrix.php-version }}
restore-keys: |
${{ runner.os }}-composer-s-${{ hashFiles('**/composer.lock') }}-${{ matrix.php-version }}

- name: PHP Setup
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
ini-values: pcov.directory=.
coverage: pcov
tools: composer

- name: PHPStan
run: |
vendor/bin/phpstan --ansi --no-progress

php-cs-fixer:
strategy:
matrix:
include:
- php-version: 8.4

runs-on: ubuntu-latest
needs: install

steps:
- uses: actions/checkout@v3

- name: Cache composer dependencies
uses: actions/cache@v3
with:
path: vendor/
key: ${{ runner.os }}-composer-s-${{ hashFiles('**/composer.lock') }}-${{ matrix.php-version }}
restore-keys: |
${{ runner.os }}-composer-s-${{ hashFiles('**/composer.lock') }}-${{ matrix.php-version }}

- name: PHP Setup
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
ini-values: pcov.directory=.
coverage: pcov
tools: composer

- name: PHP-CS-Fixer
run: |
vendor/bin/php-cs-fixer fix --config ./.php-cs-fixer.dist.php --dry-run --diff --ansi

test:
strategy:
matrix:
include:
- php-version: 8.4
- php-version: 8.5

runs-on: ubuntu-latest
needs:
- phpstan
- php-cs-fixer

steps:
- uses: actions/checkout@v3

- name: Cache composer dependencies
uses: actions/cache@v3
with:
path: vendor/
key: ${{ runner.os }}-composer-s-${{ hashFiles('**/composer.lock') }}-${{ matrix.php-version }}
restore-keys: |
${{ runner.os }}-composer-s-${{ hashFiles('**/composer.lock') }}-${{ matrix.php-version }}

- name: PHP Setup
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
ini-values: pcov.directory=.
coverage: pcov
tools: composer

- name: PHPUnit
run: |
vendor/bin/phpunit --coverage-cobertura artifacts/code-coverage-cobertura.xml

- name: Code Coverage Report
uses: irongut/CodeCoverageSummary@v1.3.0
with:
filename: artifacts/code-coverage-cobertura.xml
badge: true
fail_below_min: true
format: markdown
hide_branch_rate: false
hide_complexity: true
indicators: true
output: both
thresholds: '3 70' # for now it's whatever, we're working on it
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/vendor/
.php-cs-fixer.cache
.idea
63 changes: 63 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?php

$finder = new PhpCsFixer\Finder()
->in(__DIR__)
->exclude('var')
->exclude('bin')
->exclude('vendor');

return new PhpCsFixer\Config()
->setRiskyAllowed(true)
->setParallelConfig(PhpCsFixer\Runner\Parallel\ParallelConfigFactory::detect())
->setRules([
'@Symfony' => true,
'blank_line_before_statement' => [
'statements' => [
'declare',
'return',
'throw',
'try',
'if',
'for',
'while',
'foreach',
],
],
'cast_spaces' => ['space' => 'none'],
'constant_case' => ['case' => 'lower'],
'method_argument_space' => ['on_multiline' => 'ensure_fully_multiline'],
'phpdoc_align' => false,
'single_line_throw' => false,
'phpdoc_to_comment' => false,
'phpdoc_types_order' => false,
'phpdoc_scalar' => false,
'phpdoc_types' => false,
'increment_style' => false,
'ordered_class_elements' => true,
'fully_qualified_strict_types' => false,
'nullable_type_declaration_for_default_null_value' => false,
'nullable_type_declaration' => ['syntax' => 'union'],
'ordered_types' => ['sort_algorithm' => 'none', 'null_adjustment' => 'always_last'],
'php_unit_data_provider_name' => true,
'php_unit_data_provider_static' => true,
'php_unit_data_provider_return_type' => true,
'php_unit_method_casing' => ['case' => 'camel_case'],
'php_unit_set_up_tear_down_visibility' => true,
'php_unit_test_case_static_method_calls' => ['call_type' => 'static'],
'PedroTroller/line_break_between_method_arguments' => [
'max-args' => false,
'max-length' => 1,
'automatic-argument-merge' => false,
'inline-attributes' => true,
],
'trailing_comma_in_multiline' => [
'elements' => [
'arrays',
'match',
],
],
'attribute_empty_parentheses' => true,
'multiline_whitespace_before_semicolons' => ['strategy' => 'no_multi_line'],
])
->setFinder($finder)
->registerCustomFixers(new \PedroTroller\CS\Fixer\Fixers());
31 changes: 31 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"name": "pkly/enum-attribute-utils",
"description": "Helper for easy attribute load/cache/fetch etc. in PHP Enums",
"type": "library",
"license": "MIT",
"autoload": {
"psr-4": {
"Pkly\\EnumAttributeUtils\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Pkly\\Tests\\EnumAttributeUtils\\": "tests/"
}
},
"authors": [
{
"name": "pkly"
}
],
"require": {
"php": ">=8.4"
},
"require-dev": {
"phpunit/phpunit": "^12",
"friendsofphp/php-cs-fixer": "^3",
"pedrotroller/php-cs-custom-fixer": "^2",
"phpstan/phpstan": "^2",
"phpstan/phpstan-strict-rules": "^2.0"
}
}
Loading