Skip to content
This repository was archived by the owner on Sep 20, 2024. It is now read-only.

Commit cdef793

Browse files
authored
Merge pull request #54 from shinsenter/develop
Changed namespace, added latest defer.js (1.1.12)
2 parents 13bf741 + 862ce03 commit cdef793

18 files changed

+2136
-141
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
.php_cs.cache
22
composer.phar
3+
/node_modules/
34
/vendor/
5+
/cache/
46
/.scannerwork

.php_cs

Lines changed: 56 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
* @copyright 2019 AppSeeds
1111
* @see https://github.com/shinsenter/defer.php/blob/develop/README.md
1212
*/
13-
use PhpCsFixer\Config;
14-
use PhpCsFixer\Finder;
1513

1614
$header = <<<'EOF'
1715
A PHP helper class to efficiently defer JavaScript for your website.
@@ -25,82 +23,75 @@ A PHP helper class to efficiently defer JavaScript for your website.
2523
EOF;
2624

2725
$rules = [
28-
'@PHP56Migration' => true,
29-
'@PHP70Migration' => true,
30-
'@PHP71Migration' => true,
31-
'@Symfony' => true,
32-
'@PSR2' => true,
33-
'align_multiline_comment' => true,
34-
'array_indentation' => true,
35-
'array_syntax' => ['syntax' => 'short'],
36-
'combine_consecutive_issets' => true,
37-
'combine_consecutive_unsets' => true,
38-
'compact_nullable_typehint' => true,
39-
'concat_space' => ['spacing' => 'one'],
40-
'escape_implicit_backslashes' => true,
41-
'explicit_indirect_variable' => true,
42-
'explicit_string_variable' => true,
43-
'fully_qualified_strict_types' => true,
44-
'header_comment' => ['header' => $header, 'comment_type' => 'PHPDoc', 'location' => 'after_open', 'separate' => 'both'],
45-
'heredoc_to_nowdoc' => true,
46-
'increment_style' => ['style' => 'post'],
47-
'list_syntax' => ['syntax' => 'long'],
48-
'method_argument_space' => ['on_multiline' => 'ensure_fully_multiline'],
49-
'method_chaining_indentation' => true,
50-
'multiline_comment_opening_closing' => true,
51-
'native_function_invocation' => false,
52-
'no_alternative_syntax' => true,
53-
'no_blank_lines_before_namespace' => false,
54-
'no_binary_string' => true,
55-
'no_empty_phpdoc' => true,
56-
'no_null_property_initialization' => true,
57-
'no_short_echo_tag' => true,
58-
'no_superfluous_elseif' => true,
59-
'no_unneeded_curly_braces' => true,
60-
'no_unneeded_final_method' => true,
61-
'no_useless_else' => true,
62-
'no_useless_return' => true,
63-
'ordered_class_elements' => true,
64-
'ordered_imports' => true,
65-
'php_unit_internal_class' => true,
66-
'php_unit_ordered_covers' => true,
67-
'php_unit_test_class_requires_covers' => true,
68-
'phpdoc_add_missing_param_annotation' => true,
69-
'phpdoc_order' => true,
70-
'phpdoc_separation' => false,
71-
'phpdoc_summary' => false,
72-
'phpdoc_trim_consecutive_blank_line_separation' => true,
73-
'phpdoc_types_order' => true,
74-
'return_assignment' => false,
75-
'semicolon_after_instruction' => true,
76-
'single_line_comment_style' => false,
77-
'single_quote' => true,
78-
'yoda_style' => false,
79-
'blank_line_before_statement' => [
26+
'@Symfony' => true,
27+
'@PSR2' => true,
28+
'align_multiline_comment' => true,
29+
'array_indentation' => true,
30+
'array_syntax' => ['syntax' => 'short'],
31+
'braces' => ['allow_single_line_closure' => true],
32+
'combine_consecutive_issets' => true,
33+
'combine_consecutive_unsets' => true,
34+
'compact_nullable_typehint' => true,
35+
'concat_space' => ['spacing' => 'one'],
36+
'escape_implicit_backslashes' => true,
37+
'explicit_indirect_variable' => true,
38+
'explicit_string_variable' => true,
39+
'fully_qualified_strict_types' => true,
40+
'header_comment' => ['header' => $header, 'comment_type' => 'PHPDoc'],
41+
'heredoc_to_nowdoc' => true,
42+
'increment_style' => ['style' => 'post'],
43+
'list_syntax' => ['syntax' => 'long'],
44+
'method_argument_space' => ['on_multiline' => 'ensure_fully_multiline'],
45+
'method_chaining_indentation' => true,
46+
'multiline_comment_opening_closing' => true,
47+
'native_function_invocation' => false,
48+
'no_alternative_syntax' => true,
49+
'no_blank_lines_before_namespace' => false,
50+
'no_binary_string' => true,
51+
'no_empty_phpdoc' => true,
52+
'no_null_property_initialization' => true,
53+
'no_short_echo_tag' => true,
54+
'no_superfluous_elseif' => true,
55+
'no_unneeded_curly_braces' => true,
56+
'no_useless_else' => true,
57+
'no_useless_return' => true,
58+
'ordered_class_elements' => true,
59+
'ordered_imports' => true,
60+
'php_unit_internal_class' => true,
61+
'php_unit_ordered_covers' => true,
62+
'php_unit_test_class_requires_covers' => true,
63+
'phpdoc_add_missing_param_annotation' => true,
64+
'phpdoc_order' => true,
65+
'phpdoc_separation' => false,
66+
'phpdoc_summary' => false,
67+
'phpdoc_types_order' => true,
68+
'return_assignment' => false,
69+
'semicolon_after_instruction' => true,
70+
'single_line_comment_style' => false,
71+
'single_quote' => true,
72+
'yoda_style' => false,
73+
'blank_line_before_statement' => [
8074
'statements' => [
8175
'continue', 'declare', 'return', 'throw', 'try',
8276
'declare', 'for', 'foreach', 'goto', 'if',
8377
],
8478
],
85-
'no_extra_blank_lines' => [
79+
'no_extra_blank_lines' => [
8680
'tokens' => [
8781
'continue', 'extra', 'return', 'throw', 'use',
8882
'parenthesis_brace_block', 'square_brace_block', 'curly_brace_block',
8983
],
9084
],
91-
'braces' => [
92-
'allow_single_line_closure' => true,
93-
],
94-
'binary_operator_spaces' => [
85+
'binary_operator_spaces' => [
9586
'default' => 'single_space',
9687
'operators' => [
97-
'=>' => 'align_single_space',
98-
'=' => 'align_single_space',
88+
'=' => 'align_single_space_minimal',
89+
'=>' => 'align_single_space_minimal',
9990
],
10091
],
10192
];
10293

103-
$finder = Finder::create()
94+
$finder = \PhpCsFixer\Finder::create()
10495
->in(__DIR__)
10596
->name('*.php')
10697
->exclude('.idea')
@@ -110,7 +101,8 @@ $finder = Finder::create()
110101
->ignoreDotFiles(true)
111102
->ignoreVCS(true);
112103

113-
return Config::create()
104+
return \PhpCsFixer\Config::create()
114105
->setFinder($finder)
115106
->setRules($rules)
116-
->setUsingCache(true);
107+
->setLineEnding("\n")
108+
->setUsingCache(false);

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ composer require shinsenter/defer.php
3737
require_once __DIR__ . '/vendor/shinsenter/defer.php/defer.php';
3838

3939
// Create a Defer object
40-
$defer = new \shinsenter\Defer();
40+
$defer = new \AppSeeds\Defer();
4141

4242
// Read HTML source from file
4343
$html_source = file_get_contents('mypage.html');
@@ -65,7 +65,7 @@ require_once __DIR__ . '/vendor/shinsenter/defer.php/defer.php';
6565
// Create a function for output optimization
6666
function deferjs_optimization($html) {
6767
// Create a Defer object
68-
$defer = new \shinsenter\Defer();
68+
$defer = new \AppSeeds\Defer();
6969

7070
// Then get the optimized output
7171
return $defer->fromHtml($html)->toHtml();
@@ -91,7 +91,7 @@ ob_end_flush();
9191
require_once __DIR__ . '/vendor/shinsenter/defer.php/defer.php';
9292

9393
// Create a Defer object
94-
$defer = new \shinsenter\Defer();
94+
$defer = new \AppSeeds\Defer();
9595

9696
// Library injection
9797
$defer->append_defer_js = false;
@@ -145,7 +145,7 @@ In some regions, you may want to serve defer.js library locally due to [The Gene
145145
require_once __DIR__ . '/vendor/shinsenter/defer.php/defer.php';
146146

147147
// Create a Defer object
148-
$defer = new \shinsenter\Defer();
148+
$defer = new \AppSeeds\Defer();
149149
$defer->manually_add_deferjs = true;
150150

151151
// Then get the optimized output

composer.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
"autoload": {
3737
"files": [],
3838
"psr-4": {
39-
"shinsenter\\": "src/"
39+
"AppSeeds\\": "src/"
4040
}
4141
},
4242
"authors": [
@@ -49,9 +49,7 @@
4949
],
5050
"scripts":
5151
{
52-
"css": "cleancss -o public/styles.min.css assets/styles.css",
53-
"js": "uglifyjs --config-file=.uglifyjs -o public/helpers.min.js assets/helpers.js",
54-
"helper": ["@css","@js"],
52+
"helper": "npm run js && npm run css",
5553
"fixer": "php-cs-fixer fix --show-progress=estimating --verbose",
5654
"test": "php test/test.php"
5755
},
@@ -69,5 +67,8 @@
6967
"minimum-stability": "dev",
7068
"prefer-stable": true,
7169
"type": "library",
72-
"license": "MIT"
70+
"license": "MIT",
71+
"require-dev": {
72+
"friendsofphp/php-cs-fixer": "^2.17"
73+
}
7374
}

0 commit comments

Comments
 (0)