Skip to content

Commit

Permalink
Code improvements (#110)
Browse files Browse the repository at this point in the history
* Finishing styleci configuration

* adding php-cs-fixer with custom configuration
  • Loading branch information
uxweb authored Dec 24, 2019
1 parent 1a21479 commit 5ad72ef
Show file tree
Hide file tree
Showing 23 changed files with 369 additions and 203 deletions.
117 changes: 117 additions & 0 deletions .php_cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
<?php

// https://mlocati.github.io/php-cs-fixer-configurator/

$finder = PhpCsFixer\Finder::create()
->exclude('vendor')
->exclude('bootstrap')
->exclude('config')
->exclude('storage')
->exclude('public')
->notPath('server.php')
->in(__DIR__);

return PhpCsFixer\Config::create()
->setFinder($finder)
->setRules([
'@PSR2' => true,
'array_syntax' => ['syntax' => 'short'],
'combine_consecutive_unsets' => true,
'method_separation' => true,
'no_multiline_whitespace_before_semicolons' => true,
'single_quote' => true,
'ordered_imports' => [
'sortAlgorithm' => 'length',
],

'binary_operator_spaces' => [
'default' => null,
'operators' => [
'|' => 'no_space',
'=>' => 'single_space',
'=' => 'single_space',
],
],
// 'blank_line_after_opening_tag' => true,
// 'blank_line_before_return' => true,
'braces' => [
'allow_single_line_closure' => true,
],
// 'cast_spaces' => true,
// 'class_definition' => array('singleLine' => true),
'concat_space' => ['spacing' => 'one'],
'declare_equal_normalize' => true,
'function_typehint_space' => true,
'hash_to_slash_comment' => true,
'include' => true,
'lowercase_cast' => true,
// 'native_function_casing' => true,
// 'new_with_braces' => true,
'no_blank_lines_after_class_opening' => true,
// 'no_blank_lines_after_phpdoc' => true,
// 'no_empty_comment' => true,
// 'no_empty_phpdoc' => true,
// 'no_empty_statement' => true,
'no_extra_consecutive_blank_lines' => [
'curly_brace_block',
'extra',
'parenthesis_brace_block',
'square_brace_block',
'throw',
'use',
],
// 'no_leading_import_slash' => true,
// 'no_leading_namespace_whitespace' => true,
// 'no_mixed_echo_print' => array('use' => 'echo'),
'no_multiline_whitespace_around_double_arrow' => true,
// 'no_short_bool_cast' => true,
// 'no_singleline_whitespace_before_semicolons' => true,
'no_spaces_around_offset' => true,
'no_trailing_comma_in_list_call' => true,
'no_trailing_comma_in_singleline_array' => true,
// 'no_unneeded_control_parentheses' => true,
'no_unused_imports' => true,
'no_whitespace_before_comma_in_array' => true,
'no_whitespace_in_blank_line' => true,
// 'normalize_index_brace' => true,
'object_operator_without_whitespace' => true,
// 'php_unit_fqcn_annotation' => true,
// 'phpdoc_align' => true,
// 'phpdoc_annotation_without_dot' => true,
// 'phpdoc_indent' => true,
// 'phpdoc_inline_tag' => true,
// 'phpdoc_no_access' => true,
// 'phpdoc_no_alias_tag' => true,
// 'phpdoc_no_empty_return' => true,
// 'phpdoc_no_package' => true,
// 'phpdoc_no_useless_inheritdoc' => true,
// 'phpdoc_return_self_reference' => true,
// 'phpdoc_scalar' => true,
// 'phpdoc_separation' => true,
// 'phpdoc_single_line_var_spacing' => true,
// 'phpdoc_summary' => true,
// 'phpdoc_to_comment' => true,
// 'phpdoc_trim' => true,
// 'phpdoc_types' => true,
// 'phpdoc_var_without_name' => true,
// 'pre_increment' => true,
// 'return_type_declaration' => true,
// 'self_accessor' => true,
// 'short_scalar_cast' => true,
'single_blank_line_before_namespace' => true,
// 'single_class_element_per_statement' => true,
// 'space_after_semicolon' => true,
'standardize_not_equals' => true,
'ternary_operator_spaces' => true,
'trailing_comma_in_multiline_array' => true,
// 'trim_array_spaces' => true,
'unary_operator_spaces' => true,
'visibility_required' => [ 'elements' => ['property']],
'whitespace_after_comma_in_array' => true,
'php_unit_method_casing' => ['case' => 'snake_case'],
// 'method_chaining_indentation' => true,
'array_indentation' => true,
'not_operator_with_successor_space' => true,
'align_multiline_comment' => true,
])
->setLineEnding("\n");
12 changes: 12 additions & 0 deletions .styleci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
preset: laravel

enabled:
- length_ordered_imports
- long_list_syntax
- unalign_double_arrow

disabled:
- self_accessor
- short_list_syntax
- concat_without_spaces
- alpha_ordered_imports
76 changes: 41 additions & 35 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,39 +1,45 @@
{
"name": "uxweb/sweet-alert",
"description": "A simple PHP package to show Sweet Alerts with the Laravel Framework",
"keywords": ["laravel", "alert", "sweet", "notifier"],
"license": "MIT",
"authors": [
{
"name": "Uziel Bueno",
"email": "ux.webs@gmail.com"
}
],
"require": {
"php": ">=7.0",
"illuminate/support": "~5.0|^6.0|^7.0",
"illuminate/session": "~5.0|^6.0|^7.0"
},
"autoload": {
"psr-4": {
"UxWeb\\SweetAlert\\": "src/SweetAlert/"
},
"files": [
"src/SweetAlert/functions.php"
]
},
"require-dev": {
"phpunit/phpunit": "^7.0",
"mockery/mockery": "0.9.*"
"name": "uxweb/sweet-alert",
"description": "A simple PHP package to show Sweet Alerts with the Laravel Framework",
"keywords": [
"laravel",
"alert",
"sweet",
"notifier"
],
"license": "MIT",
"authors": [
{
"name": "Uziel Bueno",
"email": "ux.webs@gmail.com"
}
],
"require": {
"php": ">=7.0",
"illuminate/support": "~5.0|^6.0|^7.0",
"illuminate/session": "~5.0|^6.0|^7.0"
},
"require-dev": {
"phpunit/phpunit": "^7.0",
"mockery/mockery": "^1.0",
"friendsofphp/php-cs-fixer": "^2.16"
},
"autoload": {
"psr-4": {
"UxWeb\\SweetAlert\\": "src/SweetAlert/"
},
"extra": {
"laravel": {
"providers": [
"UxWeb\\SweetAlert\\SweetAlertServiceProvider"
],
"aliases": {
"Alert": "UxWeb\\SweetAlert\\SweetAlert"
}
}
"files": [
"src/SweetAlert/functions.php"
]
},
"extra": {
"laravel": {
"providers": [
"UxWeb\\SweetAlert\\SweetAlertServiceProvider"
],
"aliases": {
"Alert": "UxWeb\\SweetAlert\\SweetAlert"
}
}
}
}
Binary file added demos/1XySJiz.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added demos/4bvuJx9.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added demos/AnRGDY2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added demos/DxKh3Yx.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added demos/GsGOtOq.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added demos/dj3y95K.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added demos/pIeTEYz.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added demos/pQz3ijJ.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added demos/x44c12a.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 11 additions & 12 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnError="false"
stopOnFailure="false"
verbose="true"
>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnError="false"
stopOnFailure="false"
verbose="true">
<testsuites>
<testsuite name="SweetAlert Test Suite">
<directory suffix="Test.php">./tests</directory>
Expand Down
Loading

0 comments on commit 5ad72ef

Please sign in to comment.