Skip to content

Commit 2c6cb1d

Browse files
committed
refactor for 0.8.0 release
Signed-off-by: Rob Frawley 2nd <[email protected]>
1 parent abd1992 commit 2c6cb1d

27 files changed

+817
-489
lines changed

.bldr

Submodule .bldr updated 52 files

.bldr.yml

+16-16
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
api_branch : origin/master
2-
api_parser : ~
3-
api_cfgmod : clone
4-
api_runner : ~
5-
api_paths : lib
6-
env_make : ~
7-
env_prep : get-composer
8-
env_post : ci-coveralls,ci-codacy
9-
php_conf : timezone
10-
php_exts : igbinary
11-
app_prep : dep-composer
12-
app_post : ~
13-
app_path : ~
14-
pkg_name : augustus-serializer-library
15-
pkg_desc : "simple abstraction on serialize functions with support for php- json- and igbinary-based serialization"
16-
pkg_bndl : false
1+
api_branch: origin/master
2+
api_parser: ~
3+
api_cfgmod: clone
4+
api_runner: ~
5+
api_paths: lib
6+
env_make: ~
7+
env_prep: composer-get
8+
php_conf: timezone
9+
php_exts: igbinary
10+
app_prep: composer-req
11+
app_post: ~
12+
env_post: composer-del,ci-coveralls,ci-codacy
13+
app_path: ~
14+
pkg_name: augustus-serializer-library
15+
pkg_desc: "A simple serialization abstraction with support for php- json- and igbinary-based serialization."
16+
pkg_bndl: false

.coveralls.yml

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
---
21

3-
coverage_clover : var/build/clover.xml
4-
json_path : var/build/coveralls-upload.json
2+
coverage_clover: var/build/clover.xml
3+
json_path: var/build/coveralls-upload.json

.editorconfig

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11

2+
; top-most EditorConfig file
23
root = true
34

5+
; unix-style newlines globally
46
[*]
57
end_of_line = lf
8+
9+
[*.{php|yml|yaml|json|xml},.php_cs.dist,phpunit.xml.dist]
610
insert_final_newline = true
711
trim_trailing_whitespace = true
812
indent_style = space
913
indent_size = 4
1014
charset = utf-8
11-
12-
[*.{js|css|scss|less|yml|json}]
13-
indent_size = 2

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
LICENSE
6262
README
6363

64-
# phpcsfixer cache
64+
# PHP-CS-Fixer
6565
.php_cs.cache
6666

6767
# EOF

.gitmodules

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[submodule ".bldr"]
22
path = .bldr
3-
url = https://github.com/src-run/usr-src-builder.git
3+
url = https://github.com/src-run/usr-src-builder-bash.git

.php_cs.dist

+71-12
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,89 @@
11
<?php
22

33
/*
4-
* This file is part of the `src-run/augustus-serializer-library` project.
4+
* This file is part of the `src-run/augustus-exception-library` project.
55
*
66
* (c) Rob Frawley 2nd <[email protected]>
77
*
88
* For the full copyright and license information, please view the LICENSE.md
99
* file that was distributed with this source code.
1010
*/
1111

12-
use SLLH\StyleCIBridge\ConfigBridge;
12+
use PhpCsFixer\Config;
13+
use PhpCsFixer\Finder;
1314

14-
require_once __DIR__.'/vendor/autoload.php';
15-
16-
$headerString = <<<EOF
15+
$header = <<<HEADER
1716
This file is part of the `src-run/augustus-serializer-library` project.
1817
1918
(c) Rob Frawley 2nd <[email protected]>
2019
2120
For the full copyright and license information, please view the LICENSE.md
2221
file that was distributed with this source code.
23-
EOF;
24-
25-
$headerConfig = [ 'header_comment' => [ 'header' => $headerString ] ];
26-
27-
$config = ConfigBridge::create();
28-
$config->setRules(array_merge($config->getRules(), $headerConfig));
22+
HEADER;
2923

30-
return $config;
24+
return Config::create()
25+
->setUsingCache(true)
26+
->setRiskyAllowed(true)
27+
->setFinder((new Finder())->in(__DIR__))
28+
->setHideProgress(false)
29+
->setLineEnding("\n")
30+
->setIndent(' ')
31+
->setRules([
32+
'@Symfony' => true,
33+
'@Symfony:risky' => true,
34+
'@PHPUnit57Migration:risky' => true,
35+
'array_syntax' => [
36+
'syntax' => 'short'
37+
],
38+
'combine_consecutive_issets' => true,
39+
'combine_consecutive_unsets' => true,
40+
'escape_implicit_backslashes' => true,
41+
'explicit_indirect_variable' => true,
42+
'final_internal_class' => true,
43+
'header_comment' => [
44+
'header' => $header,
45+
'separate' => 'both'
46+
],
47+
'heredoc_to_nowdoc' => true,
48+
'linebreak_after_opening_tag' => true,
49+
'list_syntax' => [
50+
'syntax' => 'short',
51+
],
52+
'mb_str_functions' => true,
53+
'multiline_whitespace_before_semicolons' => [
54+
'strategy' => 'no_multi_line',
55+
],
56+
'no_php4_constructor' => true,
57+
'no_short_echo_tag' => true,
58+
'no_unreachable_default_argument_value' => true,
59+
'no_useless_else' => true,
60+
'no_useless_return' => true,
61+
'ordered_class_elements' => [
62+
'order' => [
63+
'use_trait',
64+
'constant_public',
65+
'constant_protected',
66+
'constant_private',
67+
'property_public',
68+
'property_protected',
69+
'property_private',
70+
'construct',
71+
'destruct',
72+
'magic',
73+
'phpunit',
74+
'method_public',
75+
'method_protected',
76+
'method_private'
77+
],
78+
],
79+
'ordered_imports' => true,
80+
'php_unit_strict' => true,
81+
'php_unit_no_expectation_annotation' => true,
82+
'php_unit_test_class_requires_covers' => true,
83+
'phpdoc_order' => true,
84+
'phpdoc_summary' => false,
85+
'psr4' => true,
86+
'semicolon_after_instruction' => true,
87+
'strict_comparison' => true,
88+
'strict_param' => true,
89+
]);

.styleci.yml

+4-7
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,9 @@ enabled:
1313
- php_unit_strict
1414
- short_array_syntax
1515

16-
disabled:
17-
- simplified_null_return
18-
19-
finder:
20-
exclude:
21-
- 'vendor'
22-
- 'var'
16+
finder :
17+
name : [ '*.php' ]
18+
exclude : [ 'vendor', 'var' ]
19+
path : [ '.' ]
2320

2421
...

.travis.yml

+4-6
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
sudo : false
1313
language : php
14-
php : [ 7.0, 7.1 ]
14+
php : [ 7.1, 7.2, nightly ]
1515

1616
git:
1717
depth: 3
@@ -21,14 +21,12 @@ env:
2121
- secure: "ZUzB7VhBBIGORmgDGKeVW2RLxQkSzYaXLIXYBerplikLmpnQCdiV16NcZTPZ8JVUJ9dTYWuVF0h2yoGmAgyrawWwmxo8g3Z/KdhzzMOl/1nyDZotROwNp89Iy7RpUpnFyKBV3/Hp2WZry+11QgqqBLLAHUd++ucaRr0mtBrSoD92oiQ3scbQyFkqkVDbseSm6sxYX87tw0r4GKC8DS7A9m7zlVky3KD7oPrnPfNvGq0MPsT3m9TCHIGrSuBLwQM9wCQOZ+CeayjjzJM8ByzCOSXEF9in9DI+Qgst+BgB2b6Tp1GmG3Se+I2u7eCGL+JOv0I934LFJXaXEIrJkH4xSNGcUcOALFng5NgDGNoa1gml1oqcb4YbO7DSGTlv7vmxpBF3DWOsh7ahad9PBeYqs1epQ3WoFsk6NyYAHshBAienbz+Vm6IoAUkT94b/KFHU8PZ0s1crYddbgtn9hPAVvfpI2LbtiEzjNmZwT8UBLRd79a/AYT9hKRD/XRxRdQHYUS+scSSVrR1P9sHm0vCO3wIqsBOa2WZXOtN28TN/jweAk7HRVgOrwQqnLp2ber+u0hTfoyX1wrUAW/jiiI/XzlhC/tAZifv8BgQbPpK3Pv/SlIOIOHNiuXDfdCTxJyY+R8SFCG12Tyi0Js7W7Am5VbqohUTKNzxNhGTkJJiR5dw="
2222

2323
install :
24-
- bash .bldr/bldr -b up-env -q
25-
- bash .bldr/bldr -b up-app -q
24+
- bash .bldr/bldr -b up
2625

2726
script :
28-
- bin/phpunit -vvv
27+
- bin/simple-phpunit || bin/phpunit
2928

3029
after_script :
31-
- bash .bldr/bldr -b down-app -q
32-
- bash .bldr/bldr -b down-env -q
30+
- bash .bldr/bldr -b down
3331

3432
...

LICENSE.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# The MIT License (MIT)
22

3-
**Copyright © 2016 Rob Frawley 2nd <[rmf at src dot run]([email protected])>**
3+
**Copyright © 2016–2018 Rob Frawley 2nd <[rmf at src dot run]([email protected])>**
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy of
66
this software and associated documentation files (the "Software"), to deal in

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
[Welcome](https://src.run/go/readme_welcome)!
1212
The `src-run/augustus-serializer-library` package provides the following
1313

14-
> A simple library to facilitate dumping of files to native php.
14+
> A simple serialization abstraction with support for php- json- and igbinary-based serialization.
1515
1616
### Grouping
1717

composer.json

+10-14
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,13 @@
33
"license": "MIT",
44
"type": "library",
55
"homepage": "https://src.run/augustus-serializer-library",
6-
"description": "Basic serialize implementations supporting for php, json, and igbinary serializer.",
6+
"description": "A simple serialization abstraction with support for php- json- and igbinary-based serialization.",
77
"support": {
88
"email": "[email protected]",
99
"issues": "https://src.run/augustus-serializer-library/issues",
1010
"source": "https://src.run/augustus-serializer-library/git"
1111
},
12-
"keywords": [
13-
"augustus-serializer-library", "augustus", "serializer", "library", "rmf", "src-run"
14-
],
12+
"keywords": [ "augustus-serializer-library", "augustus", "serializer", "library", "rmf", "src-run" ],
1513
"authors": [
1614
{
1715
"name": "Rob Frawley 2nd",
@@ -21,20 +19,18 @@
2119
}
2220
],
2321
"require": {
24-
"php": "~7.0",
25-
"src-run/augustus-utility-library": "~0.7"
22+
"php": "~7.1",
23+
"src-run/augustus-utility-library": "~0.8,>=0.8.6"
2624
},
2725
"require-dev": {
28-
"codacy/coverage": "~1.0",
2926
"ext-igbinary": "*",
30-
"friendsofphp/php-cs-fixer": "v2.0.0-alpha",
31-
"phpunit/phpunit": "~5.4",
32-
"satooshi/php-coveralls": "~1.0",
33-
"sllh/php-cs-fixer-styleci-bridge": "~2.1",
34-
"symfony/phpunit-bridge": "~3.0"
27+
"codacy/coverage": "~1.0",
28+
"friendsofphp/php-cs-fixer": "~2.0",
29+
"satooshi/php-coveralls": "~2.0",
30+
"symfony/phpunit-bridge": "~4.0"
3531
},
3632
"suggest": {
37-
"ext-igbinary": "Require to use igbinary serializer implementation."
33+
"ext-igbinary": "Required to use igbinary serializer implementation."
3834
},
3935
"autoload": {
4036
"psr-4": {
@@ -54,7 +50,7 @@
5450
},
5551
"extra": {
5652
"branch-alias": {
57-
"dev-master": "0.7-dev"
53+
"dev-master": "0.8-dev"
5854
}
5955
}
6056
}

lib/Handler/ClosureHandler.php

+82
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the `src-run/augustus-serializer-library` project.
5+
*
6+
* (c) Rob Frawley 2nd <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE.md
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace SR\Serializer\Handler;
13+
14+
use SR\Serializer\Visitor\VisitorInterface;
15+
16+
class ClosureHandler implements HandlerInterface
17+
{
18+
/**
19+
* @var \Closure
20+
*/
21+
protected $doSerializationClosure;
22+
23+
/**
24+
* @var \Closure
25+
*/
26+
protected $unSerializationClosure;
27+
28+
/**
29+
* @param \Closure $doSerializationClosure
30+
* @param \Closure $unSerializationHandler
31+
*/
32+
public function __construct(\Closure $doSerializationClosure, \Closure $unSerializationHandler)
33+
{
34+
$this->doSerializationClosure = $doSerializationClosure;
35+
$this->unSerializationClosure = $unSerializationHandler;
36+
}
37+
38+
/**
39+
* @return bool
40+
*/
41+
public static function isSupported(): bool
42+
{
43+
return true;
44+
}
45+
46+
/**
47+
* @param mixed|null $data
48+
* @param VisitorInterface ...$visitors
49+
*
50+
* @return string
51+
*/
52+
public function doSerialization($data = null, VisitorInterface ...$visitors): string
53+
{
54+
return ($this->doSerializationClosure)($this->visitVisitors($data, $visitors));
55+
}
56+
57+
/**
58+
* @param string|null $data
59+
* @param VisitorInterface ...$visitors
60+
*
61+
* @return mixed
62+
*/
63+
public function unSerialization(string $data = null, VisitorInterface ...$visitors)
64+
{
65+
return $this->visitVisitors(($this->unSerializationClosure)($data), $visitors);
66+
}
67+
68+
/**
69+
* @param mixed $data
70+
* @param VisitorInterface[] $visitors
71+
*
72+
* @return mixed
73+
*/
74+
private function visitVisitors($data, array $visitors)
75+
{
76+
foreach ($visitors as $visitor) {
77+
$data = $visitor->visit($data);
78+
}
79+
80+
return $data;
81+
}
82+
}

0 commit comments

Comments
 (0)