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

Commit

Permalink
Merge pull request #54 from shinsenter/develop
Browse files Browse the repository at this point in the history
Changed namespace, added latest defer.js (1.1.12)
  • Loading branch information
shinsenter authored Dec 24, 2020
2 parents 13bf741 + 862ce03 commit cdef793
Show file tree
Hide file tree
Showing 18 changed files with 2,136 additions and 141 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
.php_cs.cache
composer.phar
/node_modules/
/vendor/
/cache/
/.scannerwork
120 changes: 56 additions & 64 deletions .php_cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
* @copyright 2019 AppSeeds
* @see https://github.com/shinsenter/defer.php/blob/develop/README.md
*/
use PhpCsFixer\Config;
use PhpCsFixer\Finder;

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

$rules = [
'@PHP56Migration' => true,
'@PHP70Migration' => true,
'@PHP71Migration' => true,
'@Symfony' => true,
'@PSR2' => true,
'align_multiline_comment' => true,
'array_indentation' => true,
'array_syntax' => ['syntax' => 'short'],
'combine_consecutive_issets' => true,
'combine_consecutive_unsets' => true,
'compact_nullable_typehint' => true,
'concat_space' => ['spacing' => 'one'],
'escape_implicit_backslashes' => true,
'explicit_indirect_variable' => true,
'explicit_string_variable' => true,
'fully_qualified_strict_types' => true,
'header_comment' => ['header' => $header, 'comment_type' => 'PHPDoc', 'location' => 'after_open', 'separate' => 'both'],
'heredoc_to_nowdoc' => true,
'increment_style' => ['style' => 'post'],
'list_syntax' => ['syntax' => 'long'],
'method_argument_space' => ['on_multiline' => 'ensure_fully_multiline'],
'method_chaining_indentation' => true,
'multiline_comment_opening_closing' => true,
'native_function_invocation' => false,
'no_alternative_syntax' => true,
'no_blank_lines_before_namespace' => false,
'no_binary_string' => true,
'no_empty_phpdoc' => true,
'no_null_property_initialization' => true,
'no_short_echo_tag' => true,
'no_superfluous_elseif' => true,
'no_unneeded_curly_braces' => true,
'no_unneeded_final_method' => true,
'no_useless_else' => true,
'no_useless_return' => true,
'ordered_class_elements' => true,
'ordered_imports' => true,
'php_unit_internal_class' => true,
'php_unit_ordered_covers' => true,
'php_unit_test_class_requires_covers' => true,
'phpdoc_add_missing_param_annotation' => true,
'phpdoc_order' => true,
'phpdoc_separation' => false,
'phpdoc_summary' => false,
'phpdoc_trim_consecutive_blank_line_separation' => true,
'phpdoc_types_order' => true,
'return_assignment' => false,
'semicolon_after_instruction' => true,
'single_line_comment_style' => false,
'single_quote' => true,
'yoda_style' => false,
'blank_line_before_statement' => [
'@Symfony' => true,
'@PSR2' => true,
'align_multiline_comment' => true,
'array_indentation' => true,
'array_syntax' => ['syntax' => 'short'],
'braces' => ['allow_single_line_closure' => true],
'combine_consecutive_issets' => true,
'combine_consecutive_unsets' => true,
'compact_nullable_typehint' => true,
'concat_space' => ['spacing' => 'one'],
'escape_implicit_backslashes' => true,
'explicit_indirect_variable' => true,
'explicit_string_variable' => true,
'fully_qualified_strict_types' => true,
'header_comment' => ['header' => $header, 'comment_type' => 'PHPDoc'],
'heredoc_to_nowdoc' => true,
'increment_style' => ['style' => 'post'],
'list_syntax' => ['syntax' => 'long'],
'method_argument_space' => ['on_multiline' => 'ensure_fully_multiline'],
'method_chaining_indentation' => true,
'multiline_comment_opening_closing' => true,
'native_function_invocation' => false,
'no_alternative_syntax' => true,
'no_blank_lines_before_namespace' => false,
'no_binary_string' => true,
'no_empty_phpdoc' => true,
'no_null_property_initialization' => true,
'no_short_echo_tag' => true,
'no_superfluous_elseif' => true,
'no_unneeded_curly_braces' => true,
'no_useless_else' => true,
'no_useless_return' => true,
'ordered_class_elements' => true,
'ordered_imports' => true,
'php_unit_internal_class' => true,
'php_unit_ordered_covers' => true,
'php_unit_test_class_requires_covers' => true,
'phpdoc_add_missing_param_annotation' => true,
'phpdoc_order' => true,
'phpdoc_separation' => false,
'phpdoc_summary' => false,
'phpdoc_types_order' => true,
'return_assignment' => false,
'semicolon_after_instruction' => true,
'single_line_comment_style' => false,
'single_quote' => true,
'yoda_style' => false,
'blank_line_before_statement' => [
'statements' => [
'continue', 'declare', 'return', 'throw', 'try',
'declare', 'for', 'foreach', 'goto', 'if',
],
],
'no_extra_blank_lines' => [
'no_extra_blank_lines' => [
'tokens' => [
'continue', 'extra', 'return', 'throw', 'use',
'parenthesis_brace_block', 'square_brace_block', 'curly_brace_block',
],
],
'braces' => [
'allow_single_line_closure' => true,
],
'binary_operator_spaces' => [
'binary_operator_spaces' => [
'default' => 'single_space',
'operators' => [
'=>' => 'align_single_space',
'=' => 'align_single_space',
'=' => 'align_single_space_minimal',
'=>' => 'align_single_space_minimal',
],
],
];

$finder = Finder::create()
$finder = \PhpCsFixer\Finder::create()
->in(__DIR__)
->name('*.php')
->exclude('.idea')
Expand All @@ -110,7 +101,8 @@ $finder = Finder::create()
->ignoreDotFiles(true)
->ignoreVCS(true);

return Config::create()
return \PhpCsFixer\Config::create()
->setFinder($finder)
->setRules($rules)
->setUsingCache(true);
->setLineEnding("\n")
->setUsingCache(false);
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ composer require shinsenter/defer.php
require_once __DIR__ . '/vendor/shinsenter/defer.php/defer.php';

// Create a Defer object
$defer = new \shinsenter\Defer();
$defer = new \AppSeeds\Defer();

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

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

// Create a Defer object
$defer = new \shinsenter\Defer();
$defer = new \AppSeeds\Defer();

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

// Create a Defer object
$defer = new \shinsenter\Defer();
$defer = new \AppSeeds\Defer();
$defer->manually_add_deferjs = true;

// Then get the optimized output
Expand Down
11 changes: 6 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"autoload": {
"files": [],
"psr-4": {
"shinsenter\\": "src/"
"AppSeeds\\": "src/"
}
},
"authors": [
Expand All @@ -49,9 +49,7 @@
],
"scripts":
{
"css": "cleancss -o public/styles.min.css assets/styles.css",
"js": "uglifyjs --config-file=.uglifyjs -o public/helpers.min.js assets/helpers.js",
"helper": ["@css","@js"],
"helper": "npm run js && npm run css",
"fixer": "php-cs-fixer fix --show-progress=estimating --verbose",
"test": "php test/test.php"
},
Expand All @@ -69,5 +67,8 @@
"minimum-stability": "dev",
"prefer-stable": true,
"type": "library",
"license": "MIT"
"license": "MIT",
"require-dev": {
"friendsofphp/php-cs-fixer": "^2.17"
}
}
Loading

0 comments on commit cdef793

Please sign in to comment.