Adam Pippin
3 years ago
commit
4a69a7c49d
25 changed files with 8508 additions and 0 deletions
@ -0,0 +1,13 @@ |
|||||
|
root = true |
||||
|
|
||||
|
[*] |
||||
|
charset = utf-8 |
||||
|
end_of_line = lf |
||||
|
indent_style = tab |
||||
|
|
||||
|
[*.md] |
||||
|
trim_trailing_whitespace = false |
||||
|
|
||||
|
[*.yml] |
||||
|
indent_style = space |
||||
|
indent_size = 2 |
@ -0,0 +1,7 @@ |
|||||
|
* text=auto |
||||
|
/.github export-ignore |
||||
|
.styleci.yml export-ignore |
||||
|
.scrutinizer.yml export-ignore |
||||
|
BACKERS.md export-ignore |
||||
|
CONTRIBUTING.md export-ignore |
||||
|
CHANGELOG.md export-ignore |
@ -0,0 +1,32 @@ |
|||||
|
#!/usr/bin/env bash |
||||
|
|
||||
|
CURRENT_DIRECTORY=`pwd` |
||||
|
GIT_HOOKS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" |
||||
|
|
||||
|
PROJECT_DIRECTORY="$GIT_HOOKS_DIR/../.." |
||||
|
|
||||
|
cd $PROJECT_DIRECTORY; |
||||
|
|
||||
|
|
||||
|
echo "Running php-cs-fixer to format the code..." |
||||
|
|
||||
|
PHP_CS_FIXER="vendor/bin/php-cs-fixer" |
||||
|
HAS_PHP_CS_FIXER=false |
||||
|
|
||||
|
if [ -x "$PHP_CS_FIXER" ]; then |
||||
|
HAS_PHP_CS_FIXER=true |
||||
|
fi |
||||
|
|
||||
|
if $HAS_PHP_CS_FIXER; then |
||||
|
git status --porcelain | grep -e '^[AM]\(.*\).php$' | cut -c 3- | while read line; do |
||||
|
${PHP_CS_FIXER} fix --config=.php_cs.dist -q --allow-risky=yes ${line}; |
||||
|
git add "$line"; |
||||
|
done |
||||
|
else |
||||
|
echo "" |
||||
|
echo "Please run `composer install` to include php-cs-fixer." |
||||
|
echo "" |
||||
|
fi |
||||
|
|
||||
|
cd $CURRENT_DIRECTORY; |
||||
|
echo "Done." |
@ -0,0 +1,36 @@ |
|||||
|
#!/usr/bin/env bash |
||||
|
|
||||
|
CURRENT_DIRECTORY=`pwd` |
||||
|
GIT_HOOKS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" |
||||
|
|
||||
|
PROJECT_DIRECTORY="$GIT_HOOKS_DIR/../.." |
||||
|
|
||||
|
cd $PROJECT_DIRECTORY; |
||||
|
|
||||
|
|
||||
|
echo "Running phan to analyze code..." |
||||
|
PHAN="vendor/bin/phan" |
||||
|
HAS_PHAN=false |
||||
|
|
||||
|
if [ -x "$PHAN" ]; then |
||||
|
HAS_PHAN=true |
||||
|
fi |
||||
|
|
||||
|
if $HAS_PHAN; then |
||||
|
PHAN_RESULT=`$PHAN` |
||||
|
if [ ! -z "$PHAN_RESULT" ]; then |
||||
|
echo "" |
||||
|
echo "Please fix these issues with your code before committing:" |
||||
|
echo "" |
||||
|
echo $PHAN_RESULT |
||||
|
echo "" |
||||
|
exit 1 |
||||
|
fi |
||||
|
else |
||||
|
echo "" |
||||
|
echo "Please run `composer install` to include phan." |
||||
|
echo "" |
||||
|
fi |
||||
|
|
||||
|
cd $CURRENT_DIRECTORY; |
||||
|
echo "Done." |
@ -0,0 +1,5 @@ |
|||||
|
/vendor |
||||
|
/.idea |
||||
|
/.vscode |
||||
|
/.vagrant |
||||
|
.phpunit.result.cache |
@ -0,0 +1,67 @@ |
|||||
|
<?php |
||||
|
|
||||
|
declare(strict_types=1); |
||||
|
|
||||
|
return [ |
||||
|
'target_php_version' => '7.2', |
||||
|
|
||||
|
'directory_list' => [ |
||||
|
'.phan/stubs/', |
||||
|
'app/', |
||||
|
'vendor/illuminate/', |
||||
|
'vendor/laravel-zero/', |
||||
|
'vendor/nunomaduro/', |
||||
|
'vendor/composer/', |
||||
|
'vendor/symfony/', |
||||
|
'vendor/aws/' |
||||
|
], |
||||
|
|
||||
|
'exclude_analysis_directory_list' => [ |
||||
|
'vendor/', |
||||
|
'.phan/stubs/' |
||||
|
], |
||||
|
|
||||
|
'plugins' => [ |
||||
|
// stricter checks on whether a function returns the proper type |
||||
|
'AlwaysReturnPlugin', |
||||
|
// warn about trying to set duplicate keys in arrays (common mistake) |
||||
|
// warn about duplicate switch case values |
||||
|
// warn about mixing arrays/dictionaries |
||||
|
'DuplicateArrayKeyPlugin', |
||||
|
// validate regular expressions |
||||
|
'PregRegexCheckerPlugin', |
||||
|
// validate printf statements |
||||
|
'PrintfCheckerPlugin', |
||||
|
// Check for unreachable code in functions |
||||
|
'UnreachableCodePlugin', |
||||
|
// warn if you're calling a function where you probably should be using |
||||
|
// the return value (e.g., printf) but are not |
||||
|
'UseReturnValuePlugin', |
||||
|
// Infer values from phpunit tests |
||||
|
//'PHPUnitAssertionPlugin' |
||||
|
// Warn if structures are missing phpdoc plugins |
||||
|
//'HasPHPDocPlugin' |
||||
|
// warn on isset(func()['index']) and isset($array[$key]) where $array is not set |
||||
|
//'InvalidVariableIssetPlugin' |
||||
|
// warn about returning non-array values from __sleep |
||||
|
'SleepCheckerPlugin', |
||||
|
// warn about unknown return/parameter type (not documented and unable to |
||||
|
// be inferred) |
||||
|
'UnknownElementTypePlugin', |
||||
|
// warn about expressions that are likely to be a bug (e.g., a == a) |
||||
|
'DuplicateExpressionPlugin', |
||||
|
// try and use some heuristics to detect if parameters are out of order |
||||
|
// on some function calls |
||||
|
//'SuspiciousParamOrderPlugin', |
||||
|
|
||||
|
], |
||||
|
|
||||
|
'plugin_config' => [ |
||||
|
// UseReturnValuePlugin -- slow; check and see if the return value of a |
||||
|
// function is *normally* used and if so, warn where it is not. |
||||
|
//'use_return_value_dynamic_checks'=>true |
||||
|
//'use_return_value_warn_threshold_percentage'=>98, |
||||
|
], |
||||
|
|
||||
|
'minimum_severity' => 0 |
||||
|
]; |
@ -0,0 +1,50 @@ |
|||||
|
<?php |
||||
|
|
||||
|
declare(strict_types=1); |
||||
|
|
||||
|
class Log |
||||
|
{ |
||||
|
public static function emergency(string $message, array $context = []): void |
||||
|
{ |
||||
|
} |
||||
|
|
||||
|
public static function alert(string $message, array $context = []): void |
||||
|
{ |
||||
|
} |
||||
|
|
||||
|
public static function critical(string $message, array $context = []): void |
||||
|
{ |
||||
|
} |
||||
|
|
||||
|
public static function error(string $message, array $context = []): void |
||||
|
{ |
||||
|
} |
||||
|
|
||||
|
public static function warning(string $message, array $context = []): void |
||||
|
{ |
||||
|
} |
||||
|
|
||||
|
public static function notice(string $message, array $context = []): void |
||||
|
{ |
||||
|
} |
||||
|
|
||||
|
public static function info(string $message, array $context = []): void |
||||
|
{ |
||||
|
} |
||||
|
|
||||
|
public static function debug(string $message, array $context = []): void |
||||
|
{ |
||||
|
} |
||||
|
|
||||
|
public static function log($level, string $message, array $context = []): void |
||||
|
{ |
||||
|
} |
||||
|
|
||||
|
public static function channel(string $channel = null) |
||||
|
{ |
||||
|
} |
||||
|
|
||||
|
public static function stack(array $channels, string $channel = null): \Psr\Log\LoggerInterface |
||||
|
{ |
||||
|
} |
||||
|
} |
@ -0,0 +1,330 @@ |
|||||
|
<?php |
||||
|
|
||||
|
$finder = Symfony\Component\Finder\Finder::create() |
||||
|
->exclude('bootstrap/cache') |
||||
|
->exclude('storage') |
||||
|
->exclude('vendor') |
||||
|
->in(__DIR__) |
||||
|
->name('*.php') |
||||
|
->ignoreDotFiles(true) |
||||
|
->ignoreVCS(true) |
||||
|
; |
||||
|
|
||||
|
return PhpCsFixer\Config::create() |
||||
|
->setRules([ |
||||
|
'align_multiline_comment' => [ |
||||
|
'comment_type' => 'phpdocs_only' |
||||
|
], |
||||
|
'array_indentation' => true, |
||||
|
'array_syntax' => [ |
||||
|
'syntax' => 'short' |
||||
|
], |
||||
|
'binary_operator_spaces' => [ |
||||
|
'default' => 'single_space' |
||||
|
], |
||||
|
'blank_line_after_namespace' => true, |
||||
|
'blank_line_after_opening_tag' => true, |
||||
|
//'blank_line_before_statement' => [ |
||||
|
// 'statements' => ['break', 'case', 'continue', 'declare', 'default', 'die', 'do', 'exit', 'for', 'foreach', 'goto', 'if', 'include', 'include_once', 'require', 'require_once', 'return', 'switch', 'throw', 'try', 'while', 'yield'] |
||||
|
// ] |
||||
|
'braces' => [ |
||||
|
'allow_single_line_closure' => true, |
||||
|
'position_after_anonymous_constructs' => 'same', |
||||
|
'position_after_control_structures' => 'next', |
||||
|
'position_after_functions_and_oop_constructs' => 'next' |
||||
|
], |
||||
|
'cast_spaces' => [ |
||||
|
'space' => 'none' |
||||
|
], |
||||
|
'class_attributes_separation' => [ |
||||
|
'elements' => ['const', 'method', 'property'] |
||||
|
], |
||||
|
'class_definition' => [ |
||||
|
'multi_line_extends_each_single_line' => false, |
||||
|
'single_item_single_line' => false, |
||||
|
'single_line' => false |
||||
|
], |
||||
|
'class_keyword_remove' => false, |
||||
|
'combine_consecutive_issets' => false, |
||||
|
'combine_consecutive_unsets' => true, |
||||
|
'combine_nested_dirname' => true, |
||||
|
'comment_to_phpdoc' => true, |
||||
|
'compact_nullable_typehint' => true, |
||||
|
'concat_space' => [ |
||||
|
'spacing' => 'none' |
||||
|
], |
||||
|
//'date_time_immutable' => false, |
||||
|
'declare_equal_normalize' => [ |
||||
|
'space'=>'none' |
||||
|
], |
||||
|
'declare_strict_types' => true, |
||||
|
'dir_constant' => true, |
||||
|
'elseif' => true, |
||||
|
'encoding' => true, |
||||
|
'ereg_to_preg' => true, |
||||
|
'error_suppression' => [ |
||||
|
'mute_deprecation_error' => false, |
||||
|
'noise_remaining_usages' => true, |
||||
|
'noise_remaining_usages_exclude' => [] // functions to exclude |
||||
|
], |
||||
|
'escape_implicit_backslashes' => [ |
||||
|
'double_quoted' => true, |
||||
|
'heredoc_syntax' => true, |
||||
|
'single_quoted' => true |
||||
|
], |
||||
|
'explicit_indirect_variable' => true, |
||||
|
'explicit_string_variable' => false, |
||||
|
//'final_class' => true, // mark all non-abstract classes as final |
||||
|
//'final_internal_class' => [ see doc for opts ] // mark all internal classes as final |
||||
|
'fopen_flag_order' => true, |
||||
|
'fopen_flags' => [ |
||||
|
'b_mode' => true |
||||
|
], |
||||
|
'full_opening_tag' => true, |
||||
|
//'fully_qualified_strict_types' => ???, |
||||
|
'function_declaration' => [ |
||||
|
'closure_function_spacing' => 'none' |
||||
|
], |
||||
|
//'function_to_constant' => [ |
||||
|
// replaces get_called_class, get_class, php_sapi_name, phpversion, pi with |
||||
|
// constants... not sure how that could be valid? |
||||
|
//], |
||||
|
'function_typehint_space' => true, |
||||
|
'general_phpdoc_annotation_remove' => [ |
||||
|
'annotations' => [] // list of @annotations to remove form phpdoc comments |
||||
|
], |
||||
|
//'heredoc_indentation' => true, // requires php 7.3 |
||||
|
'heredoc_to_nowdoc' => true, |
||||
|
'implode_call' => true, |
||||
|
'include' => true, |
||||
|
//'increment_style' => [ |
||||
|
// 'style' => // post/pre |
||||
|
//], |
||||
|
'indentation_type' => true, |
||||
|
'is_null' => true, |
||||
|
'line_ending' => true, |
||||
|
'linebreak_after_opening_tag' => true, |
||||
|
'list_syntax' => [ |
||||
|
'syntax' => 'short' |
||||
|
], |
||||
|
'logical_operators' => true, |
||||
|
'lowercase_cast' => true, |
||||
|
'lowercase_constants' => true, |
||||
|
'lowercase_keywords' => true, |
||||
|
'lowercase_static_reference' => true, |
||||
|
'magic_constant_casing' => true, |
||||
|
'magic_method_casing' => true, |
||||
|
//'mb_str_function' => true, // replace non-mb safe with mb_ methods |
||||
|
'method_argument_space' => [ |
||||
|
'keep_multiple_spaces_after_comma' => false, |
||||
|
'on_multiline' => 'ignore' // ensure_fully_multiline, ensure_single_line, ignore |
||||
|
], |
||||
|
'method_chaining_indentation' => true, |
||||
|
'modernize_types_casting' => true, |
||||
|
'multiline_comment_opening_closing' => true, |
||||
|
'multiline_whitespace_before_semicolons' => [ |
||||
|
'strategy' => 'new_line_for_chained_calls' |
||||
|
], |
||||
|
'native_constant_invocation' => [], |
||||
|
'native_function_casing' => true, |
||||
|
'native_function_invocation' => [], |
||||
|
'native_function_type_declaration_casing' => true, |
||||
|
//'new_with_brances' => true, // no idea what this does? included in @Symfony bundle |
||||
|
'no_alias_functions' => [], |
||||
|
'no_alternative_syntax' => true, // get rid of while {} endwhile; stuff |
||||
|
'no_binary_string' => true, |
||||
|
'no_blank_lines_after_class_opening' => true, |
||||
|
'no_blank_lines_after_phpdoc' => true, |
||||
|
//'no_blank_lines_before_namespace' => true, |
||||
|
'no_break_comment' => [ |
||||
|
'comment_text' => 'no break' |
||||
|
], |
||||
|
'no_closing_tag' => true, |
||||
|
'no_empty_comment' => true, |
||||
|
'no_empty_phpdoc' => true, |
||||
|
'no_empty_statement' => true, |
||||
|
'no_extra_blank_lines' => [ |
||||
|
'tokens' => ['extra'] |
||||
|
], |
||||
|
'no_homoglyph_names' => true, |
||||
|
'no_leading_import_slash' => true, |
||||
|
'no_leading_namespace_whitespace' => true, |
||||
|
'no_mixed_echo_print' => [ |
||||
|
'use' => 'echo' |
||||
|
], |
||||
|
'no_multiline_whitespace_around_double_arrow' => true, |
||||
|
'no_null_property_initialization' => false, |
||||
|
//'no_php4_constructor' => true, |
||||
|
'no_short_bool_cast' => true, |
||||
|
'no_short_echo_tag' => false, |
||||
|
'no_singleline_whitespace_before_semicolons' => true, |
||||
|
'no_spaces_after_function_name' => true, |
||||
|
'no_spaces_around_offset' => [ |
||||
|
'positions' => ['inside', 'outside'] |
||||
|
], |
||||
|
'no_spaces_inside_parenthesis' => true, |
||||
|
//'no_superfluous_elseif' => false, // don't know what this would do? |
||||
|
//'no_superfluous_phpdoc_tags' => [ |
||||
|
// removes @param/@return that "don't provide any useful information" |
||||
|
//], |
||||
|
'no_trailing_comma_in_list_call' => true, |
||||
|
'no_trailing_comma_in_singleline_array' => true, |
||||
|
'no_trailing_whitespace' => true, |
||||
|
'no_trailing_whitespace_in_comment' => true, |
||||
|
'no_unneeded_control_parentheses' => true, |
||||
|
'no_unneeded_curly_braces' => true, |
||||
|
'no_unneeded_final_method' => true, |
||||
|
'no_unreachable_default_argument_value' => true, |
||||
|
'no_unset_cast' => true, |
||||
|
'no_unset_on_property' => false, |
||||
|
'no_unused_imports' => true, |
||||
|
'no_useless_else' => true, |
||||
|
'no_useless_return' => true, |
||||
|
'no_whitespace_before_comma_in_array' => [ |
||||
|
'after_heredoc' => false |
||||
|
], |
||||
|
'no_whitespace_in_blank_line' => true, |
||||
|
'non_printable_character' => [ |
||||
|
'use_escape_sequences_in_strings' => true // don't just remove them, make them visible to the programmer and let them sort it out |
||||
|
], |
||||
|
'normalize_index_brace' => true, |
||||
|
'not_operator_with_space' => false, |
||||
|
'not_operator_with_successor_space' => false, |
||||
|
'object_operator_without_whitespace' => true, |
||||
|
//'ordered_class_elements' => [ // lets us sort methods/props/etc in classes |
||||
|
// 'order' => [], |
||||
|
// 'sortAlgorithm'=>'' |
||||
|
//], |
||||
|
//'ordered_imports' => [ // sort use statements, off so we can retain some sort of context |
||||
|
// 'sort_algorithm' => 'alpha' |
||||
|
//], |
||||
|
//'ordered_interfaces' => [ // sort implements or interface extends |
||||
|
//], |
||||
|
'php_unit_construct' => [ // replace phpunit's ->assertSame(true, $foo) with ->assertTrue($foo) |
||||
|
], |
||||
|
'php_unit_dedicate_assert' => [ // try and replace things like assertTrue(file_exists()) with assertFileExists |
||||
|
'target'=>'newest' |
||||
|
], |
||||
|
'php_unit_dedicate_assert_internal_type' => [ |
||||
|
'target'=>'newest' |
||||
|
], |
||||
|
'php_unit_expectation' => [ // should use expectException instead of setExpectedException |
||||
|
'target' => 'newest' |
||||
|
], |
||||
|
'php_unit_fqcn_annotation' => true, |
||||
|
'php_unit_internal_class' => [ // phpunit tests should be marked internal |
||||
|
'types' => ['normal', 'final'] |
||||
|
], |
||||
|
'php_unit_mock' => [ // use createMock instead of getMock |
||||
|
'target' => 'newest' |
||||
|
], |
||||
|
'php_unit_mock_short_will_return' => true, |
||||
|
'php_unit_namespaced' => true, |
||||
|
'php_unit_no_expectation_annotation' => [ |
||||
|
'target'=>'newest' |
||||
|
], |
||||
|
'php_unit_ordered_covers' => true, |
||||
|
'php_unit_set_up_tear_down_visibility' => true, |
||||
|
//'php_unit_size_class' => true, // tests should have @small/@medium/@large annotation |
||||
|
'php_unit_strict' => [ |
||||
|
], |
||||
|
'php_unit_test_annotation' => [ // add @test annotation to tests |
||||
|
], |
||||
|
'php_unit_test_case_static_method_calls' => [ |
||||
|
], |
||||
|
'php_unit_test_class_requires_covers' => true, |
||||
|
'phpdoc_add_missing_param_annotation' => [ |
||||
|
'only_untyped' => false |
||||
|
], |
||||
|
'phpdoc_align' => [ |
||||
|
'align' => 'vertical' |
||||
|
], |
||||
|
'phpdoc_annotation_without_dot' => true, |
||||
|
'phpdoc_indent' => true, |
||||
|
'phpdoc_inline_tag' => true, |
||||
|
'phpdoc_no_access' => true, |
||||
|
//'phpdoc_no_alias_tag' => [], |
||||
|
'phpdoc_no_empty_return' => false, |
||||
|
'phpdoc_no_package' => true, |
||||
|
'phpdoc_no_useless_inheritdoc' => true, |
||||
|
'phpdoc_order' => true, |
||||
|
'phpdoc_return_self_reference' => [], |
||||
|
'phpdoc_scalar' => true, |
||||
|
'phpdoc_separation' => false, |
||||
|
'phpdoc_single_line_var_spacing' => true, |
||||
|
'phpdoc_summary' => true, |
||||
|
//'phpdoc_to_comment' => false, // we sometimes use these for phan suppression and stuff |
||||
|
//'phpdoc_to_return_type' => [ 'scalar_types' => true ], |
||||
|
'phpdoc_trim' => true, |
||||
|
'phpdoc_trim_consecutive_blank_line_separation' => true, |
||||
|
'phpdoc_types' => [ // fix casing of types in phpdoc |
||||
|
'groups' => ['simple', 'alias', 'meta'] |
||||
|
], |
||||
|
'phpdoc_types_order' => [ |
||||
|
'null_adjustment' => 'always_last', |
||||
|
'sort_algorithm' => 'none' |
||||
|
], |
||||
|
'phpdoc_var_annotation_correct_order' => true, |
||||
|
'phpdoc_var_without_name' => true, |
||||
|
'pow_to_exponentiation' => true, |
||||
|
//'protected_to_private' => true, // convert protected methods to private ones |
||||
|
'psr4' => true, // class name should match filename |
||||
|
'random_api_migration' => [ // replace rand/srand/etc with the mt_ funcs |
||||
|
], |
||||
|
'return_assignment' => true, |
||||
|
'return_type_declaration' => [ |
||||
|
'space_before' => 'none' |
||||
|
], |
||||
|
//'self_accessor' => false, // force use of self instead of class name |
||||
|
'semicolon_after_instruction' => true, |
||||
|
'set_type_to_cast' => true, // use casting not settype |
||||
|
'short_scalar_cast' => true, // use bool not boolean, int not integer, etc |
||||
|
'simple_to_complex_string_variable' => false, // convert ${var} to {$var} in strings |
||||
|
'simplified_null_return' => true, // don't `return null`, just `return` |
||||
|
'single_blank_line_at_eof' => true, |
||||
|
'single_blank_line_before_namespace' => true, |
||||
|
'single_class_element_per_statement' => [ |
||||
|
'elements' => ['const', 'property'] |
||||
|
], |
||||
|
'single_import_per_statement' => true, |
||||
|
'single_line_after_imports' => true, |
||||
|
'single_line_comment_style' => [ |
||||
|
'comment_types' => ['asterisk', 'hash'] |
||||
|
], |
||||
|
'single_quote' => [ |
||||
|
'strings_containing_single_quote_chars' => false |
||||
|
], |
||||
|
'single_trait_insert_per_statement' => true, |
||||
|
'space_after_semicolon' => [ |
||||
|
'remove_in_empty_for_expressions' => false |
||||
|
], |
||||
|
'standardize_increment' => true, |
||||
|
'standardize_not_equals' => true, |
||||
|
'static_lambda' => true, |
||||
|
//'strict_comparsion' => true, // would be good to *check* but not change |
||||
|
//'strict_param' => true, |
||||
|
//'string_line_ending' => true, // could screw up literals that are used for comparison to outside sourced data |
||||
|
'switch_case_semicolon_to_colon' => true, |
||||
|
'switch_case_space' => true, |
||||
|
'ternary_operator_spaces' => true, |
||||
|
'ternary_to_null_coalescing' => true, |
||||
|
//'trailing_comma_in_multiline_array' => [ // no option to *remove* |
||||
|
//], |
||||
|
'trim_array_spaces' => true, |
||||
|
'unary_operator_spaces' => true, |
||||
|
'visibility_required' => [ |
||||
|
'elements' => ['property', 'method', 'const'] |
||||
|
], |
||||
|
//'void_return' => true, // adds a void return type to functions without a @return/:return |
||||
|
'whitespace_after_comma_in_array' => true, |
||||
|
//'yoda_style' => [ // would be a good habit but I find it hard to read |
||||
|
// 'always_move_variable' => false, |
||||
|
// 'equal' => false, |
||||
|
// 'identical' => false, |
||||
|
// 'less_and_greater' => false |
||||
|
//] |
||||
|
]) |
||||
|
->setIndent("\t") |
||||
|
->setLineEnding("\n") |
||||
|
->setFinder($finder) |
||||
|
; |
@ -0,0 +1,36 @@ |
|||||
|
<p align="center"> |
||||
|
<img title="Laravel Zero" height="100" src="https://raw.githubusercontent.com/laravel-zero/docs/master/images/logo/laravel-zero-readme.png" /> |
||||
|
</p> |
||||
|
|
||||
|
<p align="center"> |
||||
|
<a href="https://github.com/laravel-zero/framework/actions"><img src="https://img.shields.io/github/workflow/status/laravel-zero/framework/Tests.svg" alt="Build Status"></img></a> |
||||
|
<a href="https://packagist.org/packages/laravel-zero/framework"><img src="https://img.shields.io/packagist/dt/laravel-zero/framework.svg" alt="Total Downloads"></a> |
||||
|
<a href="https://packagist.org/packages/laravel-zero/framework"><img src="https://img.shields.io/packagist/v/laravel-zero/framework.svg?label=stable" alt="Latest Stable Version"></a> |
||||
|
<a href="https://packagist.org/packages/laravel-zero/framework"><img src="https://img.shields.io/packagist/l/laravel-zero/framework.svg" alt="License"></a> |
||||
|
</p> |
||||
|
|
||||
|
<h4> <center>This is a <bold>community project</bold> and not an official Laravel one </center></h4> |
||||
|
|
||||
|
Laravel Zero was created by, and is maintained by [Nuno Maduro](https://github.com/nunomaduro), and is a micro-framework that provides an elegant starting point for your console application. It is an **unofficial** and customized version of Laravel optimized for building command-line applications. |
||||
|
|
||||
|
- Built on top of the [Laravel](https://laravel.com) components. |
||||
|
- Optional installation of Laravel [Eloquent](https://laravel-zero.com/docs/database/), Laravel [Logging](https://laravel-zero.com/docs/logging/) and many others. |
||||
|
- Supports interactive [menus](https://laravel-zero.com/docs/build-interactive-menus/) and [desktop notifications](https://laravel-zero.com/docs/send-desktop-notifications/) on Linux, Windows & MacOS. |
||||
|
- Ships with a [Scheduler](https://laravel-zero.com/docs/task-scheduling/) and a [Standalone Compiler](https://laravel-zero.com/docs/build-a-standalone-application/). |
||||
|
- Integration with [Collision](https://github.com/nunomaduro/collision) - Beautiful error reporting |
||||
|
|
||||
|
------ |
||||
|
|
||||
|
## Documentation |
||||
|
|
||||
|
For full documentation, visit [laravel-zero.com](https://laravel-zero.com/). |
||||
|
|
||||
|
## Support the development |
||||
|
**Do you like this project? Support it by donating** |
||||
|
|
||||
|
- PayPal: [Donate](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=66BYDWAT92N6L) |
||||
|
- Patreon: [Donate](https://www.patreon.com/nunomaduro) |
||||
|
|
||||
|
## License |
||||
|
|
||||
|
Laravel Zero is an open-source software licensed under the MIT license. |
@ -0,0 +1,44 @@ |
|||||
|
<?php |
||||
|
|
||||
|
namespace App\Commands; |
||||
|
|
||||
|
use Illuminate\Console\Scheduling\Schedule; |
||||
|
use LaravelZero\Framework\Commands\Command; |
||||
|
|
||||
|
class InspiringCommand extends Command |
||||
|
{ |
||||
|
/** |
||||
|
* The signature of the command. |
||||
|
* |
||||
|
* @var string |
||||
|
*/ |
||||
|
protected $signature = 'inspiring {name=Artisan}'; |
||||
|
|
||||
|
/** |
||||
|
* The description of the command. |
||||
|
* |
||||
|
* @var string |
||||
|
*/ |
||||
|
protected $description = 'Display an inspiring quote'; |
||||
|
|
||||
|
/** |
||||
|
* Execute the console command. |
||||
|
* |
||||
|
* @return mixed |
||||
|
*/ |
||||
|
public function handle() |
||||
|
{ |
||||
|
$this->info('Simplicity is the ultimate sophistication.'); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* Define the command's schedule. |
||||
|
* |
||||
|
* @param \Illuminate\Console\Scheduling\Schedule $schedule |
||||
|
* @return void |
||||
|
*/ |
||||
|
public function schedule(Schedule $schedule) |
||||
|
{ |
||||
|
// $schedule->command(static::class)->everyMinute(); |
||||
|
} |
||||
|
} |
@ -0,0 +1,28 @@ |
|||||
|
<?php |
||||
|
|
||||
|
namespace App\Providers; |
||||
|
|
||||
|
use Illuminate\Support\ServiceProvider; |
||||
|
|
||||
|
class AppServiceProvider extends ServiceProvider |
||||
|
{ |
||||
|
/** |
||||
|
* Bootstrap any application services. |
||||
|
* |
||||
|
* @return void |
||||
|
*/ |
||||
|
public function boot() |
||||
|
{ |
||||
|
// |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* Register any application services. |
||||
|
* |
||||
|
* @return void |
||||
|
*/ |
||||
|
public function register() |
||||
|
{ |
||||
|
// |
||||
|
} |
||||
|
} |
@ -0,0 +1,50 @@ |
|||||
|
<?php |
||||
|
|
||||
|
/* |
||||
|
|-------------------------------------------------------------------------- |
||||
|
| Create The Application |
||||
|
|-------------------------------------------------------------------------- |
||||
|
| |
||||
|
| The first thing we will do is create a new Laravel application instance |
||||
|
| which serves as the "glue" for all the components of Laravel, and is |
||||
|
| the IoC container for the system binding all of the various parts. |
||||
|
| |
||||
|
*/ |
||||
|
|
||||
|
$app = new LaravelZero\Framework\Application( |
||||
|
dirname(__DIR__) |
||||
|
); |
||||
|
|
||||
|
/* |
||||
|
|-------------------------------------------------------------------------- |
||||
|
| Bind Important Interfaces |
||||
|
|-------------------------------------------------------------------------- |
||||
|
| |
||||
|
| Next, we need to bind some important interfaces into the container so |
||||
|
| we will be able to resolve them when needed. The kernels serve the |
||||
|
| incoming requests to this application from both the web and CLI. |
||||
|
| |
||||
|
*/ |
||||
|
|
||||
|
$app->singleton( |
||||
|
Illuminate\Contracts\Console\Kernel::class, |
||||
|
LaravelZero\Framework\Kernel::class |
||||
|
); |
||||
|
|
||||
|
$app->singleton( |
||||
|
Illuminate\Contracts\Debug\ExceptionHandler::class, |
||||
|
Illuminate\Foundation\Exceptions\Handler::class |
||||
|
); |
||||
|
|
||||
|
/* |
||||
|
|-------------------------------------------------------------------------- |
||||
|
| Return The Application |
||||
|
|-------------------------------------------------------------------------- |
||||
|
| |
||||
|
| This script returns the application instance. The instance is given to |
||||
|
| the calling script so we can separate the building of the instances |
||||
|
| from the actual running of the application and sending responses. |
||||
|
| |
||||
|
*/ |
||||
|
|
||||
|
return $app; |
@ -0,0 +1,18 @@ |
|||||
|
{ |
||||
|
"chmod": "0755", |
||||
|
"directories": [ |
||||
|
"app", |
||||
|
"bootstrap", |
||||
|
"config", |
||||
|
"vendor" |
||||
|
], |
||||
|
"files": [ |
||||
|
"composer.json" |
||||
|
], |
||||
|
"exclude-composer-files": false, |
||||
|
"compression": "GZ", |
||||
|
"compactors": [ |
||||
|
"KevinGH\\Box\\Compactor\\Php", |
||||
|
"KevinGH\\Box\\Compactor\\Json" |
||||
|
] |
||||
|
} |
@ -0,0 +1,53 @@ |
|||||
|
#!/usr/bin/env php |
||||
|
<?php |
||||
|
|
||||
|
define('LARAVEL_START', microtime(true)); |
||||
|
|
||||
|
/* |
||||
|
|-------------------------------------------------------------------------- |
||||
|
| Register The Auto Loader |
||||
|
|-------------------------------------------------------------------------- |
||||
|
| |
||||
|
| Composer provides a convenient, automatically generated class loader |
||||
|
| for our application. We just need to utilize it! We'll require it |
||||
|
| into the script here so that we do not have to worry about the |
||||
|
| loading of any our classes "manually". Feels great to relax. |
||||
|
| |
||||
|
*/ |
||||
|
|
||||
|
$autoloader = require file_exists(__DIR__.'/vendor/autoload.php') ? __DIR__.'/vendor/autoload.php' : __DIR__.'/../../autoload.php'; |
||||
|
|
||||
|
$app = require_once __DIR__.'/bootstrap/app.php'; |
||||
|
|
||||
|
/* |
||||
|
|-------------------------------------------------------------------------- |
||||
|
| Run The Artisan Application |
||||
|
|-------------------------------------------------------------------------- |
||||
|
| |
||||
|
| When we run the console application, the current CLI command will be |
||||
|
| executed in this console and the response sent back to a terminal |
||||
|
| or another output device for the developers. Here goes nothing! |
||||
|
| |
||||
|
*/ |
||||
|
|
||||
|
$kernel = $app->make(Illuminate\Contracts\Console\Kernel::class); |
||||
|
|
||||
|
$status = $kernel->handle( |
||||
|
$input = new Symfony\Component\Console\Input\ArgvInput, |
||||
|
new Symfony\Component\Console\Output\ConsoleOutput |
||||
|
); |
||||
|
|
||||
|
/* |
||||
|
|-------------------------------------------------------------------------- |
||||
|
| Shutdown The Application |
||||
|
|-------------------------------------------------------------------------- |
||||
|
| |
||||
|
| Once Artisan has finished running, we will fire off the shutdown events |
||||
|
| so that any final work may be done by the application before we shut |
||||
|
| down the process. This is the last thing to happen to the request. |
||||
|
| |
||||
|
*/ |
||||
|
|
||||
|
$kernel->terminate($input, $status); |
||||
|
|
||||
|
exit($status); |
@ -0,0 +1,48 @@ |
|||||
|
{ |
||||
|
"name": "adampippin/cfnpp", |
||||
|
"description": "CloudFormation pre-processor", |
||||
|
"homepage": "https://adampippin.ca/", |
||||
|
"type": "project", |
||||
|
"license": "proprietary", |
||||
|
"support": { |
||||
|
"issues": "https://git.nucleardog.ca/nucleardog/cfnpp/issues", |
||||
|
"source": "https://git.nucleardog.ca/nucleardog/cfnpp" |
||||
|
}, |
||||
|
"authors": [ |
||||
|
{ |
||||
|
"name": "Adam Pippin", |
||||
|
"email": "hello@adampippin.ca" |
||||
|
} |
||||
|
], |
||||
|
"require": { |
||||
|
"php": "^7.3|^8.0", |
||||
|
"laravel-zero/framework": "^8.4" |
||||
|
}, |
||||
|
"require-dev": { |
||||
|
"friendsofphp/php-cs-fixer": "^2.18", |
||||
|
"mockery/mockery": "^1.4.2", |
||||
|
"pestphp/pest": "^1.0", |
||||
|
"phan/phan": "^4.0" |
||||
|
}, |
||||
|
"autoload": { |
||||
|
"psr-4": { |
||||
|
"App\\": "app/" |
||||
|
} |
||||
|
}, |
||||
|
"autoload-dev": { |
||||
|
"psr-4": { |
||||
|
"Tests\\": "tests/" |
||||
|
} |
||||
|
}, |
||||
|
"config": { |
||||
|
"preferred-install": "dist", |
||||
|
"sort-packages": true, |
||||
|
"optimize-autoloader": true |
||||
|
}, |
||||
|
"minimum-stability": "dev", |
||||
|
"prefer-stable": true, |
||||
|
"bin": ["cfnpp"], |
||||
|
"scripts": { |
||||
|
"post-autoload-dump": "cp .githooks/* .git/hooks/" |
||||
|
} |
||||
|
} |
File diff suppressed because it is too large
@ -0,0 +1,60 @@ |
|||||
|
<?php |
||||
|
|
||||
|
return [ |
||||
|
|
||||
|
/* |
||||
|
|-------------------------------------------------------------------------- |
||||
|
| Application Name |
||||
|
|-------------------------------------------------------------------------- |
||||
|
| |
||||
|
| This value is the name of your application. This value is used when the |
||||
|
| framework needs to place the application's name in a notification or |
||||
|
| any other location as required by the application or its packages. |
||||
|
| |
||||
|
*/ |
||||
|
|
||||
|
'name' => 'Cfnpp', |
||||
|
|
||||
|
/* |
||||
|
|-------------------------------------------------------------------------- |
||||
|
| Application Version |
||||
|
|-------------------------------------------------------------------------- |
||||
|
| |
||||
|
| This value determines the "version" your application is currently running |
||||
|
| in. You may want to follow the "Semantic Versioning" - Given a version |
||||
|
| number MAJOR.MINOR.PATCH when an update happens: https://semver.org. |
||||
|
| |
||||
|
*/ |
||||
|
|
||||
|
'version' => app('git.version'), |
||||
|
|
||||
|
/* |
||||
|
|-------------------------------------------------------------------------- |
||||
|
| Application Environment |
||||
|
|-------------------------------------------------------------------------- |
||||
|
| |
||||
|
| This value determines the "environment" your application is currently |
||||
|
| running in. This may determine how you prefer to configure various |
||||
|
| services the application utilizes. This can be overridden using |
||||
|
| the global command line "--env" option when calling commands. |
||||
|
| |
||||
|
*/ |
||||
|
|
||||
|
'env' => 'development', |
||||
|
|
||||
|
/* |
||||
|
|-------------------------------------------------------------------------- |
||||
|
| Autoloaded Service Providers |
||||
|
|-------------------------------------------------------------------------- |
||||
|
| |
||||
|
| The service providers listed here will be automatically loaded on the |
||||
|
| request to your application. Feel free to add your own services to |
||||
|
| this array to grant expanded functionality to your applications. |
||||
|
| |
||||
|
*/ |
||||
|
|
||||
|
'providers' => [ |
||||
|
App\Providers\AppServiceProvider::class, |
||||
|
], |
||||
|
|
||||
|
]; |
@ -0,0 +1,80 @@ |
|||||
|
<?php |
||||
|
|
||||
|
return [ |
||||
|
|
||||
|
/* |
||||
|
|-------------------------------------------------------------------------- |
||||
|
| Default Command |
||||
|
|-------------------------------------------------------------------------- |
||||
|
| |
||||
|
| Laravel Zero will always run the command specified below when no command name is |
||||
|
| provided. Consider update the default command for single command applications. |
||||
|
| You cannot pass arguments to the default command because they are ignored. |
||||
|
| |
||||
|
*/ |
||||
|
|
||||
|
'default' => NunoMaduro\LaravelConsoleSummary\SummaryCommand::class, |
||||
|
|
||||
|
/* |
||||
|
|-------------------------------------------------------------------------- |
||||
|
| Commands Paths |
||||
|
|-------------------------------------------------------------------------- |
||||
|
| |
||||
|
| This value determines the "paths" that should be loaded by the console's |
||||
|
| kernel. Foreach "path" present on the array provided below the kernel |
||||
|
| will extract all "Illuminate\Console\Command" based class commands. |
||||
|
| |
||||
|
*/ |
||||
|
|
||||
|
'paths' => [app_path('Commands')], |
||||
|
|
||||
|
/* |
||||
|
|-------------------------------------------------------------------------- |
||||
|
| Added Commands |
||||
|
|-------------------------------------------------------------------------- |
||||
|
| |
||||
|
| You may want to include a single command class without having to load an |
||||
|
| entire folder. Here you can specify which commands should be added to |
||||
|
| your list of commands. The console's kernel will try to load them. |
||||
|
| |
||||
|
*/ |
||||
|
|
||||
|
'add' => [ |
||||
|
// .. |
||||
|
], |
||||
|
|
||||
|
/* |
||||
|
|-------------------------------------------------------------------------- |
||||
|
| Hidden Commands |
||||
|
|-------------------------------------------------------------------------- |
||||
|
| |
||||
|
| Your application commands will always be visible on the application list |
||||
|
| of commands. But you can still make them "hidden" specifying an array |
||||
|
| of commands below. All "hidden" commands can still be run/executed. |
||||
|
| |
||||
|
*/ |
||||
|
|
||||
|
'hidden' => [ |
||||
|
NunoMaduro\LaravelConsoleSummary\SummaryCommand::class, |
||||
|
Symfony\Component\Console\Command\HelpCommand::class, |
||||
|
Illuminate\Console\Scheduling\ScheduleRunCommand::class, |
||||
|
Illuminate\Console\Scheduling\ScheduleFinishCommand::class, |
||||
|
Illuminate\Foundation\Console\VendorPublishCommand::class, |
||||
|
], |
||||
|
|
||||
|
/* |
||||
|
|-------------------------------------------------------------------------- |
||||
|
| Removed Commands |
||||
|
|-------------------------------------------------------------------------- |
||||
|
| |
||||
|
| Do you have a service provider that loads a list of commands that |
||||
|
| you don't need? No problem. Laravel Zero allows you to specify |
||||
|
| below a list of commands that you don't to see in your app. |
||||
|
| |
||||
|
*/ |
||||
|
|
||||
|
'remove' => [ |
||||
|
// .. |
||||
|
], |
||||
|
|
||||
|
]; |
@ -0,0 +1,24 @@ |
|||||
|
<?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" |
||||
|
stopOnFailure="false"> |
||||
|
<testsuites> |
||||
|
<testsuite name="Feature"> |
||||
|
<directory suffix="Test.php">./tests/Feature</directory> |
||||
|
</testsuite> |
||||
|
<testsuite name="Unit"> |
||||
|
<directory suffix="Test.php">./tests/Unit</directory> |
||||
|
</testsuite> |
||||
|
</testsuites> |
||||
|
<coverage processUncoveredFiles="true"> |
||||
|
<include> |
||||
|
<directory suffix=".php">./app</directory> |
||||
|
</include> |
||||
|
</coverage> |
||||
|
</phpunit> |
@ -0,0 +1,22 @@ |
|||||
|
<?php |
||||
|
|
||||
|
namespace Tests; |
||||
|
|
||||
|
use Illuminate\Contracts\Console\Kernel; |
||||
|
|
||||
|
trait CreatesApplication |
||||
|
{ |
||||
|
/** |
||||
|
* Creates the application. |
||||
|
* |
||||
|
* @return \Illuminate\Foundation\Application |
||||
|
*/ |
||||
|
public function createApplication() |
||||
|
{ |
||||
|
$app = require __DIR__.'/../bootstrap/app.php'; |
||||
|
|
||||
|
$app->make(Kernel::class)->bootstrap(); |
||||
|
|
||||
|
return $app; |
||||
|
} |
||||
|
} |
@ -0,0 +1,7 @@ |
|||||
|
<?php |
||||
|
|
||||
|
test('inspiring command', function () { |
||||
|
$this->artisan('inspiring') |
||||
|
->expectsOutput('Simplicity is the ultimate sophistication.') |
||||
|
->assertExitCode(0); |
||||
|
}); |
@ -0,0 +1,3 @@ |
|||||
|
<?php |
||||
|
|
||||
|
uses(Tests\TestCase::class)->in('Feature'); |
@ -0,0 +1,10 @@ |
|||||
|
<?php |
||||
|
|
||||
|
namespace Tests; |
||||
|
|
||||
|
use LaravelZero\Framework\Testing\TestCase as BaseTestCase; |
||||
|
|
||||
|
abstract class TestCase extends BaseTestCase |
||||
|
{ |
||||
|
use CreatesApplication; |
||||
|
} |
@ -0,0 +1,5 @@ |
|||||
|
<?php |
||||
|
|
||||
|
test('example', function () { |
||||
|
expect(true)->toBeTrue(); |
||||
|
}); |
Loading…
Reference in new issue