-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 1e56add
Showing
60 changed files
with
2,146 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
; This file is for unifying the coding style for different editors and IDEs. | ||
; More information at http://editorconfig.org | ||
|
||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
indent_size = 4 | ||
indent_style = tab | ||
end_of_line = lf | ||
insert_final_newline = true | ||
trim_trailing_whitespace = true | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
name: Release | ||
|
||
on: | ||
workflow_run: | ||
workflows: ["Tests"] | ||
types: | ||
- completed | ||
branches: | ||
- master | ||
- next | ||
- next-major | ||
- beta | ||
- alpha | ||
|
||
jobs: | ||
release: | ||
name: Release | ||
runs-on: ubuntu-latest | ||
if: ${{ github.event.workflow_run.conclusion == 'success' }} | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Create a release | ||
uses: cycjimmy/semantic-release-action@v2 | ||
with: | ||
extra_plugins: | | ||
@semantic-release/changelog | ||
@semantic-release/git | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
name: Tests | ||
|
||
on: | ||
push: | ||
pull_request: | ||
|
||
jobs: | ||
phpunit: | ||
name: PHPUnit on PHP v${{ matrix.php }} | ||
|
||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
fail-fast: true | ||
matrix: | ||
php: [8.1] | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Setup PHP | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: ${{ matrix.php }} | ||
tools: composer:v2 | ||
coverage: none | ||
|
||
- name: Validate composer.json and composer.lock | ||
run: composer validate | ||
|
||
- name: Cache Composer packages | ||
id: composer-cache | ||
uses: actions/cache@v2 | ||
with: | ||
path: vendor | ||
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }} | ||
restore-keys: | | ||
${{ runner.os }}-php- | ||
- name: Install dependencies | ||
run: composer install --prefer-dist --no-progress | ||
|
||
- name: Execute phpunit | ||
run: composer test -- --colors=always | ||
|
||
php-cs-fixer: | ||
name: php-cs-fixer | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Setup PHP | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: 8.1 | ||
extensions: dom, curl, libxml, mbstring, zip | ||
tools: composer:v2 | ||
coverage: none | ||
|
||
- name: Cache Composer packages | ||
id: composer-cache | ||
uses: actions/cache@v2 | ||
with: | ||
path: vendor | ||
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }} | ||
restore-keys: | | ||
${{ runner.os }}-php- | ||
- name: Install dependencies | ||
run: composer install --prefer-dist --no-progress | ||
|
||
- name: Execute php-cs-fixer | ||
run: composer cs-fix -- --dry-run --diff --using-cache=no | ||
|
||
phpstan: | ||
name: PHPStan | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Setup PHP | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: 8.1 | ||
tools: composer:v2 | ||
coverage: none | ||
|
||
- name: Validate composer.json and composer.lock | ||
run: composer validate | ||
|
||
- name: Cache Composer packages | ||
id: composer-cache | ||
uses: actions/cache@v2 | ||
with: | ||
path: vendor | ||
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }} | ||
restore-keys: | | ||
${{ runner.os }}-php- | ||
- name: Install dependencies | ||
run: composer install --prefer-dist --no-progress | ||
|
||
- name: Execute phpstan | ||
run: composer phpstan |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Editors | ||
.idea/* | ||
!.idea/fileTemplates | ||
|
||
# Dependencies | ||
/vendor/ | ||
/composer.lock | ||
|
||
# Build/coverage | ||
/build | ||
|
||
# Cache | ||
.php-cs-fixer.cache | ||
**/.phpunit.result.cache | ||
|
||
# Temporary | ||
tmp/ | ||
|
||
# Misc | ||
.DS_Store | ||
/*.log | ||
*.swp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
<?php | ||
|
||
$finder = PhpCsFixer\Finder::create() | ||
->in('src') | ||
->in('tests') | ||
->name('*.php') | ||
->notName('_*.php') | ||
->ignoreVCS(true); | ||
|
||
return (new PhpCsFixer\Config()) | ||
->setFinder($finder) | ||
->setRiskyAllowed(true) | ||
->setIndent("\t") | ||
->setRules([ | ||
'@PhpCsFixer' => true, | ||
'@Symfony' => true, | ||
'@Symfony:risky' => true, | ||
'@PSR12' => true, | ||
'@PSR12:risky' => true, | ||
'assign_null_coalescing_to_coalesce_equal' => true, | ||
'modernize_strpos' => true, | ||
'empty_loop_condition' => true, | ||
'declare_parentheses' => true, | ||
'array_syntax' => ['syntax' => 'short'], | ||
'binary_operator_spaces' => [ | ||
'default' => 'single_space', | ||
'operators' => [ | ||
'=>' => 'align_single_space_minimal', | ||
], | ||
], | ||
'blank_line_before_statement' => [ | ||
'statements' => [ | ||
'break', 'continue', 'declare', 'default', 'do', 'while', 'for', | ||
'foreach', 'goto', 'if', 'return', 'switch', 'throw', 'try', 'yield', | ||
], | ||
], | ||
'braces' => [ | ||
'position_after_control_structures' => 'same', | ||
'allow_single_line_anonymous_class_with_empty_body' => true, | ||
], | ||
'class_attributes_separation' => [ | ||
'elements' => ['method' => 'one', 'property' => 'one'], | ||
], | ||
'concat_space' => [ | ||
'spacing' => 'one', | ||
], | ||
'increment_style' => [ | ||
'style' => 'post', | ||
], | ||
'linebreak_after_opening_tag' => true, | ||
'native_function_invocation' => false, | ||
'ordered_class_elements' => [ | ||
'order' => [ | ||
'use_trait', | ||
'constant_public', 'constant_protected', 'constant_private', | ||
'property_static', 'property_public_static', 'property_protected_static', 'property_private_static', | ||
'property_public', 'property_protected', 'property_private', | ||
'construct', 'destruct', 'magic', 'phpunit', | ||
'method_static', 'method_public_static', 'method_protected_static', 'method_private_static', | ||
'method_public', 'method_protected', 'method_private', | ||
], | ||
], | ||
'ordered_imports' => true, | ||
'phpdoc_no_empty_return' => false, | ||
'phpdoc_summary' => false, | ||
'ternary_to_null_coalescing' => true, | ||
'visibility_required' => [ | ||
'elements' => [ | ||
'const', 'property', 'method', | ||
], | ||
], | ||
'yoda_style' => ['always_move_variable' => true, 'equal' => false, 'identical' => false], | ||
'php_unit_test_class_requires_covers' => false, | ||
'php_unit_internal_class' => false, | ||
'protected_to_private' => false, | ||
// Adds stupid semicolons on newlines | ||
'multiline_whitespace_before_semicolons' => false, | ||
// Doesn't work with "nested" chaining | ||
'method_chaining_indentation' => true, | ||
'mb_str_functions' => true, | ||
'global_namespace_import' => true, | ||
'list_syntax' => [ | ||
'syntax' => 'short', | ||
], | ||
'phpdoc_line_span' => [ | ||
'const' => 'single', | ||
'property' => 'single', | ||
], | ||
'general_phpdoc_annotation_remove' => [ | ||
// We don't believe so called "checked exceptions" are a good design. We're following the logic of Kotlin: | ||
// https://kotlinlang.org/docs/reference/exceptions.html#checked-exceptions | ||
'annotations' => ['throws'], | ||
], | ||
'error_suppression' => [ | ||
// Mutes trigger_error() with E_USER_DEPRECATED, but we handle deprecations manually so this is needed. | ||
'mute_deprecation_error' => false, | ||
], | ||
'operator_linebreak' => [ | ||
'only_booleans' => true, | ||
'position' => 'end', | ||
], | ||
'native_constant_invocation' => false, | ||
'simplified_if_return' => true, | ||
'heredoc_indentation' => true, | ||
'use_arrow_functions' => true, | ||
'no_trailing_whitespace_in_string' => false, | ||
'phpdoc_no_alias_tag' => [ | ||
// Default except property-read and property-write replacement | ||
'replacements' => ['type' => 'var', 'link' => 'see'], | ||
], | ||
// Force {@inheritDoc} to @inheritDoc whenever possible. | ||
'phpdoc_tag_type' => [ | ||
'tags' => [ | ||
'inheritDoc' => 'annotation', | ||
], | ||
], | ||
// Rename lower case & plural form @inheritDoc | ||
'general_phpdoc_tag_rename' => [ | ||
'replacements' => [ | ||
'inheritDocs' => 'inheritDoc', | ||
'inheritdoc' => 'inheritDoc', | ||
], | ||
], | ||
]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2022 Oleksandr Prypkhan | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Good PHP serialization | ||
|
||
The concept is similar to Moshi, a rising Java/Kotlin library - serialization with the least | ||
effort possible without sacrificing customizability, support for different formats or ease of use. | ||
|
||
### Commands | ||
Install dependencies: | ||
`docker run -it --rm -v $PWD:/app -w /app composer install` | ||
|
||
Run tests: | ||
`docker run -it --rm -v $PWD:/app -w /app php:8.1-cli vendor/bin/pest` | ||
|
||
Run php-cs-fixer on self: | ||
`docker run -it --rm -v $PWD:/app -w /app composer cs-fix` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
{ | ||
"name": "good-php/serialization", | ||
"description": "Extendable reflection-based serializer with support for JSON and PHP primitive formats", | ||
"license": "MIT", | ||
"authors": [ | ||
{ | ||
"name": "Alex Wells (Oleksandr Prypkhan)", | ||
"email": "[email protected]" | ||
} | ||
], | ||
"require": { | ||
"php": ">=8.1", | ||
"php-ds/php-ds": "^1.3.0", | ||
"good-php/reflection": "dev-alpha", | ||
"tenantcloud/php-standard": "^1.1.0" | ||
}, | ||
"require-dev": { | ||
"pestphp/pest": "^1.21", | ||
"php-cs-fixer/shim": "~3.8.0", | ||
"phpstan/phpstan": "~1.7.15", | ||
"phake/phake": "^4.2", | ||
"phpstan/phpstan-webmozart-assert": "^1.2" | ||
}, | ||
"autoload": { | ||
"psr-0": { | ||
"": "src/" | ||
} | ||
}, | ||
"autoload-dev": { | ||
"psr-4": { | ||
"Tests\\": "tests/" | ||
} | ||
}, | ||
"scripts": { | ||
"test": "./vendor/bin/phpunit", | ||
"cs-fix": "./vendor/bin/php-cs-fixer fix -v --show-progress=dots", | ||
"phpstan": "./vendor/bin/phpstan analyse" | ||
}, | ||
"minimum-stability": "dev", | ||
"prefer-stable": true, | ||
"config": { | ||
"allow-plugins": { | ||
"pestphp/pest-plugin": true | ||
} | ||
} | ||
} |
Oops, something went wrong.