-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from InteractionDesignFoundation/dependencies
Improve CI: Add Psalm and PHP-CS-Fixer
- Loading branch information
Showing
11 changed files
with
238 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
name: Psalm | ||
|
||
on: | ||
push: | ||
paths: | ||
- '**.php' | ||
- 'psalm*' | ||
|
||
jobs: | ||
psalm: | ||
name: psalm | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Setup PHP | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: '8.3' | ||
coverage: none | ||
|
||
- name: Cache composer dependencies | ||
uses: actions/cache@v4 | ||
with: | ||
path: vendor | ||
key: composer-${{ hashFiles('composer.json') }} | ||
|
||
- name: Run composer install | ||
run: | | ||
composer config "http-basic.nova.laravel.com" "${{ secrets.NOVA_USERNAME }}" "${{ secrets.NOVA_4_LICENSE_KEY }}" | ||
composer install -n --prefer-dist | ||
- name: Run Psalm | ||
run: ./vendor/bin/psalm --shepherd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ auth.json | |
|
||
phpunit.xml | ||
.phpunit.result.cache | ||
.phpunit.cache/ | ||
|
||
.DS_Store | ||
Thumbs.db | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* @see https://mlocati.github.io/php-cs-fixer-configurator/ | ||
*/ | ||
$finder = \PhpCsFixer\Finder::create() | ||
->in(__DIR__) | ||
->exclude( | ||
[ | ||
'vendor', | ||
] | ||
) | ||
->name('*.php') | ||
->ignoreDotFiles(false) | ||
->ignoreVCS(true) | ||
->ignoreVCSIgnored(true); | ||
|
||
return (new \PhpCsFixer\Config()) | ||
->setUsingCache(true) | ||
->setRiskyAllowed(true) | ||
->setIndent(' ') | ||
->setLineEnding("\n") | ||
->setRules([ | ||
// Basic PER Coding Style 2.0 ruleset plus our "fixes" for it | ||
'@PER-CS2.0' => true, // https://www.php-fig.org/per/coding-style/} | ||
// 'concat_space' => ['spacing' => 'none'], // make strings shorter "'hello' . $name . '!'" => "'hello'.$name.'!'" | ||
// 'blank_line_after_opening_tag' => false, // it makes "<?php declare(strict_types=1);" multiline (and more verbose) | ||
'function_declaration' => false, // It makes "fn ()" into "fn()" and conflicts with our PHPCS ruleset | ||
'single_line_empty_body' => false, // It has conflict with PSR2.Classes.ClassDeclaration.OpenBraceNewLine | ||
// 'unary_operator_spaces' => false, // It has conflict with PHPCS ruleset | ||
|
||
// Additional rules on the top of PER-CS2 | ||
// Please keep these rules alphabetically | ||
'align_multiline_comment' => ['comment_type' => 'phpdocs_only'], | ||
'array_indentation' => true, | ||
'assign_null_coalescing_to_coalesce_equal' => true, | ||
'binary_operator_spaces' => ['default' => 'single_space'], | ||
'cast_spaces' => ['space' => 'single'], | ||
'class_attributes_separation' => ['elements' => ['method' => 'one']], | ||
'declare_strict_types' => true, | ||
'explicit_string_variable' => true, | ||
// 'final_public_method_for_abstract_class' => true, // @todo enable it | ||
'general_phpdoc_annotation_remove' => [ | ||
'annotations' => [ | ||
'api', | ||
'access', | ||
'author', | ||
'category', | ||
'copyright', | ||
'created', | ||
'license', | ||
'link', | ||
'package', | ||
'since', | ||
'subpackage', | ||
'version', | ||
], | ||
], | ||
'modernize_types_casting' => true, | ||
'no_alias_functions' => true, | ||
'no_binary_string' => true, | ||
'no_empty_comment' => true, | ||
'no_empty_phpdoc' => true, | ||
'no_empty_statement' => true, | ||
'no_extra_blank_lines' => ['tokens' => ['extra', 'curly_brace_block']], | ||
'no_homoglyph_names' => true, | ||
'no_leading_namespace_whitespace' => true, | ||
'no_mixed_echo_print' => true, | ||
'no_short_bool_cast' => true, | ||
'no_singleline_whitespace_before_semicolons' => true, | ||
'no_spaces_around_offset' => true, | ||
'no_trailing_comma_in_singleline' => false, // it's a good marker that there are more elements in an array | ||
'no_unneeded_braces' => true, | ||
'no_unneeded_control_parentheses' => true, | ||
'no_unneeded_final_method' => true, | ||
'no_unreachable_default_argument_value' => true, | ||
'no_unused_imports' => true, | ||
'no_useless_concat_operator' => true, | ||
'no_useless_return' => true, | ||
'no_whitespace_before_comma_in_array' => true, | ||
'normalize_index_brace' => true, | ||
'nullable_type_declaration' => ['syntax' => 'question_mark'], | ||
'object_operator_without_whitespace' => true, | ||
/* | ||
* @see https://github.com/slevomat/coding-standard/issues/1620#issuecomment-1758006718 | ||
* 'ordered_class_elements' => [ | ||
'order' => [ | ||
'use_trait', | ||
'constant', | ||
'case', // for enums only | ||
'property', | ||
'method', | ||
] | ||
],*/ | ||
'php_unit_construct' => true, | ||
'php_unit_dedicate_assert' => ['target' => 'newest'], | ||
'php_unit_expectation' => true, | ||
'php_unit_fqcn_annotation' => true, | ||
'php_unit_method_casing' => ['case' => 'snake_case'], | ||
'php_unit_no_expectation_annotation' => true, | ||
'php_unit_set_up_tear_down_visibility' => true, | ||
'php_unit_strict' => true, | ||
'php_unit_test_annotation' => ['style' => 'annotation'], | ||
'php_unit_test_class_requires_covers' => true, | ||
'phpdoc_align' => ['align' => 'left'], | ||
'phpdoc_indent' => true, | ||
'phpdoc_line_span' => ['const' => 'single', 'property' => 'single', 'method' => 'single'], | ||
'phpdoc_param_order' => true, | ||
'phpdoc_scalar' => true, | ||
'phpdoc_single_line_var_spacing' => true, | ||
'phpdoc_tag_casing' => true, | ||
'phpdoc_types' => true, | ||
'protected_to_private' => true, | ||
'psr_autoloading' => true, | ||
'self_accessor' => true, | ||
'self_static_accessor' => true, | ||
'single_line_comment_spacing' => true, | ||
'single_line_comment_style' => ['comment_types' => ['asterisk', 'hash']], | ||
'space_after_semicolon' => true, | ||
'standardize_not_equals' => true, | ||
'strict_param' => true, | ||
'ternary_to_null_coalescing' => true, | ||
'trim_array_spaces' => true, | ||
'trailing_comma_in_multiline' => true, | ||
'type_declaration_spaces' => true, | ||
'types_spaces' => ['space' => 'single'], | ||
'whitespace_after_comma_in_array' => true, | ||
'yoda_style' => ['equal' => false, 'identical' => false, 'less_and_greater' => false], | ||
]) | ||
->setFinder($finder); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<files psalm-version="5.22.2@d768d914152dbbf3486c36398802f74e80cfde48"> | ||
<file src="src/CardServiceProvider.php"> | ||
<UndefinedInterfaceMethod> | ||
<code><![CDATA[routesAreCached]]></code> | ||
</UndefinedInterfaceMethod> | ||
</file> | ||
<file src="src/Http/Controllers/WorldClockController.php"> | ||
<LessSpecificReturnStatement> | ||
<code><![CDATA[$times]]></code> | ||
</LessSpecificReturnStatement> | ||
<MixedArgument> | ||
<code><![CDATA[$timeFormat]]></code> | ||
</MixedArgument> | ||
<MixedAssignment> | ||
<code><![CDATA[$timeFormat]]></code> | ||
</MixedAssignment> | ||
<MoreSpecificReturnType> | ||
<code><![CDATA[array{string, array{name: string, time: string, night: bool}}]]></code> | ||
</MoreSpecificReturnType> | ||
</file> | ||
<file src="src/WorldClock.php"> | ||
<PropertyNotSetInConstructor> | ||
<code><![CDATA[WorldClock]]></code> | ||
</PropertyNotSetInConstructor> | ||
</file> | ||
</files> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?xml version="1.0"?> | ||
<psalm | ||
errorLevel="1" | ||
resolveFromConfigFile="true" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xmlns="https://getpsalm.org/schema/config" | ||
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd" | ||
findUnusedBaselineEntry="true" | ||
findUnusedCode="false" | ||
errorBaseline="psalm-baseline.xml" | ||
> | ||
<projectFiles> | ||
<directory name="src" /> | ||
<ignoreFiles> | ||
<directory name="vendor" /> | ||
</ignoreFiles> | ||
</projectFiles> | ||
<disableExtensions> | ||
<extension name="random"/> | ||
<extension name="redis"/> | ||
</disableExtensions> | ||
</psalm> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters