Skip to content

Commit ea66089

Browse files
committed
wip
1 parent b3d6a0b commit ea66089

File tree

13 files changed

+559
-39
lines changed

13 files changed

+559
-39
lines changed

.editorconfig

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
; This file is for unifying the coding style for different editors and IDEs.
2+
; More information at https://editorconfig.org
3+
4+
root = true
5+
6+
[*]
7+
charset = utf-8
8+
end_of_line = lf
9+
insert_final_newline = true
10+
indent_style = space
11+
indent_size = 4
12+
trim_trailing_whitespace = true
13+
14+
[*.md]
15+
trim_trailing_whitespace = false
16+
17+
[*.{yml, yaml}]
18+
indent_size = 2

.github/workflows/tests.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Tests
2+
3+
on:
4+
- push
5+
- pull_request
6+
7+
jobs:
8+
tests:
9+
name: PHP ${{ matrix.php }}
10+
runs-on: ubuntu-latest
11+
timeout-minutes: 5
12+
strategy:
13+
fail-fast: false
14+
matrix:
15+
php:
16+
- 8.1
17+
- 8.2
18+
- 8.3
19+
- 8.4
20+
21+
steps:
22+
- name: Checkout
23+
uses: actions/checkout@v4
24+
25+
- name: Setup PHP
26+
uses: shivammathur/setup-php@v2
27+
with:
28+
php-version: ${{ matrix.php }}
29+
coverage: pcov
30+
31+
- name: Install PHP dependencies
32+
run: composer install --prefer-dist --no-interaction
33+
34+
- name: Unit Tests
35+
run: composer test

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/vendor
2+
.php_cs.cache
3+
.phpunit.cache
4+
composer.lock
5+
coverage

.php-cs-fixer.dist.php

Lines changed: 195 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,195 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use PhpCsFixer\Config;
6+
use PhpCsFixer\Finder;
7+
use PhpCsFixer\Runner\Parallel\ParallelConfigFactory;
8+
9+
$rules = [
10+
'align_multiline_comment' => true,
11+
'array_indentation' => true,
12+
'array_syntax' => ['syntax' => 'short'],
13+
'blank_line_after_namespace' => true,
14+
'blank_line_after_opening_tag' => true,
15+
'braces' => true,
16+
'cast_spaces' => true,
17+
'concat_space' => [
18+
'spacing' => 'one',
19+
],
20+
'curly_braces_position' => [
21+
'control_structures_opening_brace' => 'same_line',
22+
'functions_opening_brace' => 'next_line_unless_newline_at_signature_end',
23+
'anonymous_functions_opening_brace' => 'same_line',
24+
'classes_opening_brace' => 'next_line_unless_newline_at_signature_end',
25+
'anonymous_classes_opening_brace' => 'next_line_unless_newline_at_signature_end',
26+
'allow_single_line_empty_anonymous_classes' => false,
27+
'allow_single_line_anonymous_functions' => false,
28+
],
29+
'declare_equal_normalize' => true,
30+
'declare_strict_types' => true,
31+
'elseif' => true,
32+
'encoding' => true,
33+
'full_opening_tag' => true,
34+
'fully_qualified_strict_types' => true, // added by Shift
35+
'function_declaration' => true,
36+
'function_typehint_space' => true,
37+
'heredoc_to_nowdoc' => true,
38+
'include' => true,
39+
'increment_style' => ['style' => 'post'],
40+
'indentation_type' => true,
41+
'linebreak_after_opening_tag' => true,
42+
'line_ending' => true,
43+
'lowercase_cast' => true,
44+
'lowercase_keywords' => true,
45+
'lowercase_static_reference' => true, // added from Symfony
46+
'magic_method_casing' => true, // added from Symfony
47+
'magic_constant_casing' => true,
48+
'method_argument_space' => true,
49+
'method_chaining_indentation' => true,
50+
'native_constant_invocation' => [
51+
'fix_built_in' => true,
52+
'scope' => 'namespaced',
53+
'strict' => true,
54+
],
55+
'native_function_casing' => true,
56+
'native_function_invocation' => [
57+
'include' => ['@compiler_optimized'],
58+
'scope' => 'namespaced',
59+
'strict' => true,
60+
],
61+
'no_alias_functions' => true,
62+
'no_extra_blank_lines' => [
63+
'tokens' => [
64+
'extra',
65+
'throw',
66+
'use',
67+
'use_trait',
68+
],
69+
],
70+
'no_blank_lines_after_class_opening' => true,
71+
'no_blank_lines_after_phpdoc' => true,
72+
'no_closing_tag' => true,
73+
'no_empty_phpdoc' => true,
74+
'no_empty_statement' => true,
75+
'no_leading_import_slash' => true,
76+
'no_leading_namespace_whitespace' => true,
77+
'no_mixed_echo_print' => [
78+
'use' => 'echo',
79+
],
80+
'no_multiline_whitespace_around_double_arrow' => true,
81+
'multiline_whitespace_before_semicolons' => [
82+
'strategy' => 'no_multi_line',
83+
],
84+
'no_short_bool_cast' => true,
85+
'no_singleline_whitespace_before_semicolons' => true,
86+
'no_spaces_after_function_name' => true,
87+
'no_spaces_inside_parenthesis' => true,
88+
'no_trailing_comma_in_singleline' => true,
89+
'no_trailing_whitespace' => true,
90+
'no_trailing_whitespace_in_comment' => true,
91+
'no_unreachable_default_argument_value' => true,
92+
'no_unused_imports' => true,
93+
'no_useless_return' => true,
94+
'no_whitespace_before_comma_in_array' => true,
95+
'no_whitespace_in_blank_line' => true,
96+
'normalize_index_brace' => true,
97+
'not_operator_with_successor_space' => true,
98+
'object_operator_without_whitespace' => true,
99+
'phpdoc_align' => true,
100+
'phpdoc_indent' => true,
101+
'phpdoc_no_access' => true,
102+
'phpdoc_no_package' => true,
103+
'phpdoc_no_useless_inheritdoc' => true,
104+
'phpdoc_scalar' => true,
105+
'phpdoc_single_line_var_spacing' => true,
106+
'phpdoc_summary' => true,
107+
'phpdoc_to_comment' => true,
108+
'phpdoc_trim' => true,
109+
'phpdoc_types' => true,
110+
'phpdoc_var_without_name' => true,
111+
'return_type_declaration' => true,
112+
'self_accessor' => true,
113+
'short_scalar_cast' => true,
114+
'simplified_null_return' => false, // disabled by Shift
115+
'single_blank_line_at_eof' => true,
116+
'single_blank_line_before_namespace' => true,
117+
'single_class_element_per_statement' => true,
118+
'single_import_per_statement' => true,
119+
'single_line_after_imports' => true,
120+
'single_line_comment_style' => [
121+
'comment_types' => ['hash'],
122+
],
123+
'single_quote' => true,
124+
'single_trait_insert_per_statement' => true,
125+
'space_after_semicolon' => true,
126+
'standardize_not_equals' => true,
127+
'switch_case_semicolon_to_colon' => true,
128+
'switch_case_space' => true,
129+
'ternary_operator_spaces' => true,
130+
131+
'trim_array_spaces' => true,
132+
'unary_operator_spaces' => true,
133+
'whitespace_after_comma_in_array' => true,
134+
135+
// php-cs-fixer 3: Renamed rules
136+
'constant_case' => ['case' => 'lower'],
137+
'general_phpdoc_tag_rename' => true,
138+
'phpdoc_inline_tag_normalizer' => true,
139+
'phpdoc_tag_type' => true,
140+
'psr_autoloading' => true,
141+
'trailing_comma_in_multiline' => ['elements' => ['arrays']],
142+
143+
// php-cs-fixer 3: Changed options
144+
'binary_operator_spaces' => [
145+
'default' => 'single_space',
146+
'operators' => [],
147+
],
148+
'blank_line_before_statement' => [
149+
'statements' => ['return'],
150+
],
151+
'class_attributes_separation' => [
152+
'elements' => [
153+
'const' => 'one',
154+
'method' => 'one',
155+
'property' => 'one',
156+
],
157+
],
158+
'class_definition' => [
159+
'multi_line_extends_each_single_line' => true,
160+
'single_item_single_line' => true,
161+
'single_line' => true,
162+
],
163+
'ordered_imports' => [
164+
'sort_algorithm' => 'alpha',
165+
],
166+
167+
// php-cs-fixer 3: Removed rootless options (*)
168+
'no_unneeded_control_parentheses' => [
169+
'statements' => ['break', 'clone', 'continue', 'echo_print', 'return', 'switch_case', 'yield'],
170+
],
171+
'no_spaces_around_offset' => [
172+
'positions' => ['inside', 'outside'],
173+
],
174+
'visibility_required' => [
175+
'elements' => ['property', 'method', 'const'],
176+
],
177+
178+
];
179+
180+
$finder = Finder::create()
181+
->in([
182+
__DIR__ . '/src',
183+
__DIR__ . '/tests',
184+
])
185+
->name('*.php')
186+
->notName('*.blade.php')
187+
->ignoreDotFiles(true)
188+
->ignoreVCS(true);
189+
190+
return (new Config())
191+
->setParallelConfig(ParallelConfigFactory::detect())
192+
->setFinder($finder)
193+
->setRules($rules)
194+
->setRiskyAllowed(true)
195+
->setUsingCache(true);

README.md

Lines changed: 10 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
# Project name
1+
# PHP Enum Utils
22

33
[![GitHub contributors][ico-contributors]][link-contributors]
44
[![GitHub last commit][ico-last-commit]][link-last-commit]
55
[![License: MPL 2.0][ico-license]][link-license]
66

7-
Insert bullets description of the project if available.
8-
9-
[See the project live][link-production]
7+
[![GitHub contributors][ico-contributors]][link-contributors]
8+
[![GitHub last commit][ico-last-commit]][link-last-commit]
9+
[![License: MPL 2.0][ico-license]][link-license]
1010

11-
Give a short introduction of your project. Let this section explain the objectives or the motivation behind this project.
11+
Collection of utilities for working with enums.
1212

13-
[Contributing](#contributing) | [Built with](#built-with) | [Repos and projects](#repos-and-projects) | [Deployment](#deployment) | [Feedback](#feedback) | [License](#license) | [About Code for Romania](#about-code-for-romania)
13+
[Contributing](#contributing) | [Feedback](#feedback) | [License](#license) | [About Code for Romania](#about-code-for-romania)
1414

1515
## Contributing
1616

@@ -20,32 +20,6 @@ Help us out by testing this project in the [staging environment][link-staging].
2020

2121
If you would like to suggest new functionality, open an Issue and mark it as a __[Feature request]__. Please be specific about why you think this functionality will be of use. If you can, please include some visual description of what you would like the UI to look like, if you are suggesting new UI elements.
2222

23-
## Built With
24-
25-
### Programming languages
26-
27-
### Platforms
28-
29-
### Frontend framework
30-
31-
### Package managers
32-
33-
### Database technology & provider
34-
35-
## Repos and projects
36-
37-
Mention all related repos and projects.
38-
39-
## Deployment
40-
41-
Guide users through getting your code up and running on their own system. In this section you can talk about:
42-
1. Installation process
43-
2. Software dependencies
44-
3. Latest releases
45-
4. API references
46-
47-
Describe and show how to build your code and run the tests.
48-
4923
## Feedback
5024

5125
* Request a new feature on GitHub.
@@ -64,17 +38,14 @@ Started in 2016, Code for Romania is a civic tech NGO, official member of the Co
6438
Last, but not least, we rely on donations to ensure the infrastructure, logistics and management of our community that is widely spread across 11 timezones, coding for social change to make Romania and the world a better place. If you want to support us, [you can do it here][link-donate].
6539

6640

67-
[ico-contributors]: https://img.shields.io/github/contributors/code4romania/standard-repo-template.svg?style=for-the-badge
68-
[ico-last-commit]: https://img.shields.io/github/last-commit/code4romania/standard-repo-template.svg?style=for-the-badge
41+
[ico-contributors]: https://img.shields.io/github/contributors/code4romania/php-enum-utils.svg?style=for-the-badge
42+
[ico-last-commit]: https://img.shields.io/github/last-commit/code4romania/php-enum-utils.svg?style=for-the-badge
6943
[ico-license]: https://img.shields.io/badge/license-MPL%202.0-brightgreen.svg?style=for-the-badge
7044

71-
[link-contributors]: https://github.com/code4romania/standard-repo-template/graphs/contributors
72-
[link-last-commit]: https://github.com/code4romania/standard-repo-template/commits/main
45+
[link-contributors]: https://github.com/code4romania/php-enum-utils/graphs/contributors
46+
[link-last-commit]: https://github.com/code4romania/php-enum-utils/commits/main
7347
[link-license]: https://opensource.org/licenses/MPL-2.0
7448
[link-contributing]: https://github.com/code4romania/.github/blob/main/CONTRIBUTING.md
7549

76-
[link-production]: insert_link_here
77-
[link-staging]: insert_link_here
78-
7950
[link-code4]: https://www.code4.ro/en/
8051
[link-donate]: https://code4.ro/en/donate/

composer.json

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"name": "commitglobal/enum-utils",
3+
"type": "library",
4+
"description": "Collection of PHP utilities for working with enums",
5+
"license": "MPL-2.0",
6+
7+
"require": {
8+
"php": "^8.1",
9+
"illuminate/support": "^11.0|^12.0"
10+
},
11+
"require-dev": {
12+
"friendsofphp/php-cs-fixer": "^3.84",
13+
"orchestra/testbench": "^9.0|^10.0"
14+
},
15+
"autoload": {
16+
"psr-4": {
17+
"CommitGlobal\\Enums\\": "src"
18+
}
19+
},
20+
"autoload-dev": {
21+
"psr-4": {
22+
"CommitGlobal\\Enums\\Tests\\": "tests"
23+
}
24+
},
25+
"scripts": {
26+
"test": "phpunit"
27+
},
28+
"config": {
29+
"sort-packages": true
30+
},
31+
"minimum-stability": "stable",
32+
"prefer-stable": true
33+
}

phpunit.xml.dist

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd" bootstrap="vendor/autoload.php" colors="true" testdox="true" stopOnFailure="false" cacheDirectory=".phpunit.cache">
3+
<testsuites>
4+
<testsuite name="Package Test Suite">
5+
<directory>tests</directory>
6+
</testsuite>
7+
</testsuites>
8+
<source>
9+
<include>
10+
<directory>src</directory>
11+
</include>
12+
</source>
13+
<coverage>
14+
<report>
15+
<clover outputFile="coverage/clover.xml"/>
16+
</report>
17+
</coverage>
18+
</phpunit>

0 commit comments

Comments
 (0)