Skip to content

Commit de6ded9

Browse files
authored
Merge pull request #23 from InteractionDesignFoundation/update-dependencies
Support Laravel 11, update dependencies
2 parents fe1d64e + 6a90ddd commit de6ded9

File tree

11 files changed

+186
-57
lines changed

11 files changed

+186
-57
lines changed

.github/workflows/format_php.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,11 @@ jobs:
3535
run: |
3636
echo "::set-output name=dir::$(composer config cache-files-dir)"
3737
38-
- name: Retrieve Composers cache
39-
uses: actions/cache@v3
38+
- name: Retrieve Composers cache
39+
uses: actions/cache@v4
4040
with:
4141
path: ${{ steps.composer-cache.outputs.dir }}
42-
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
42+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
4343
restore-keys: |
4444
${{ runner.os }}-composer-
4545
@@ -49,16 +49,16 @@ jobs:
4949
- name: Install composer dependencies -- step 2
5050
run: 'composer install --working-dir=tools/phpcs --no-interaction --no-progress --no-scripts'
5151

52-
- name: Retrieve PHP-CS-Fixers cache
53-
uses: actions/cache@v3
52+
- name: Retrieve PHP-CS-Fixers cache
53+
uses: actions/cache@v4
5454
with:
5555
path: .php-cs-fixer.cache
5656
key: ${{ runner.os }}-php-cs-fixer-${{ hashFiles('.php-cs-fixer.php', '.phpcs/**/**') }}
5757
restore-keys: |
5858
${{ runner.os }}-php-cs-fixer-
5959
60-
- name: Retrieve PHPCSs cache
61-
uses: actions/cache@v3
60+
- name: Retrieve PHPCSs cache
61+
uses: actions/cache@v4
6262
with:
6363
path: .phpcs.cache
6464
key: ${{ runner.os }}-phpcs-${{ hashFiles('phpcs.xml') }}

.github/workflows/psalm.yml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,19 @@ jobs:
1111
name: psalm
1212
runs-on: ubuntu-latest
1313
steps:
14-
- uses: actions/checkout@v3
14+
- uses: actions/checkout@v4
1515

1616
- name: Setup PHP
1717
uses: shivammathur/setup-php@v2
1818
with:
19-
php-version: '8.2'
20-
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl
19+
php-version: '8.3'
2120
coverage: none
2221

2322
- name: Cache composer dependencies
24-
uses: actions/cache@v3
23+
uses: actions/cache@v4
2524
with:
2625
path: vendor
27-
key: composer-${{ hashFiles('composer.lock') }}
26+
key: composer-${{ hashFiles('composer.json') }}
2827

2928
- name: Run composer install
3029
run: |

.github/workflows/run-tests.yml

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,26 +9,23 @@ jobs:
99
fail-fast: true
1010
matrix:
1111
os: [ ubuntu-latest ]
12-
php: [ 8.0, 8.1 ]
13-
laravel: [ 8.*, 9.* ]
12+
php: [ 8.3, 8.2]
13+
laravel: [ 10.* ]
1414
dependency-version: [ prefer-stable ]
1515
include:
16-
- laravel: 8.*
17-
testbench: 6.*
18-
- laravel: 9.*
19-
testbench: 7.*
16+
- laravel: 10.*
17+
testbench: 8.*
2018

2119
name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.dependency-version }} - ${{ matrix.os }}
2220

2321
steps:
2422
- name: Checkout code
25-
uses: actions/checkout@v2
23+
uses: actions/checkout@v4
2624

2725
- name: Setup PHP
2826
uses: shivammathur/setup-php@v2
2927
with:
3028
php-version: ${{ matrix.php }}
31-
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo
3229
coverage: none
3330

3431
- name: Setup problem matchers

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ auth.json
99

1010
phpunit.xml
1111
.phpunit.result.cache
12+
.phpunit.cache/
1213

1314
.DS_Store
1415
Thumbs.db

.php-cs-fixer.php

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/**
6+
* @see https://mlocati.github.io/php-cs-fixer-configurator/
7+
*/
8+
$finder = \PhpCsFixer\Finder::create()
9+
->in(__DIR__)
10+
->exclude(
11+
[
12+
'vendor',
13+
]
14+
)
15+
->name('*.php')
16+
->ignoreDotFiles(false)
17+
->ignoreVCS(true)
18+
->ignoreVCSIgnored(true);
19+
20+
return (new \PhpCsFixer\Config())
21+
->setUsingCache(true)
22+
->setRiskyAllowed(true)
23+
->setIndent(' ')
24+
->setLineEnding("\n")
25+
->setRules([
26+
// Basic PER Coding Style 2.0 ruleset plus our "fixes" for it
27+
'@PER-CS2.0' => true, // https://www.php-fig.org/per/coding-style/}
28+
// 'concat_space' => ['spacing' => 'none'], // make strings shorter "'hello' . $name . '!'" => "'hello'.$name.'!'"
29+
// 'blank_line_after_opening_tag' => false, // it makes "<?php declare(strict_types=1);" multiline (and more verbose)
30+
'function_declaration' => false, // It makes "fn ()" into "fn()" and conflicts with our PHPCS ruleset
31+
'single_line_empty_body' => false, // It has conflict with PSR2.Classes.ClassDeclaration.OpenBraceNewLine
32+
// 'unary_operator_spaces' => false, // It has conflict with PHPCS ruleset
33+
34+
// Additional rules on the top of PER-CS2
35+
// Please keep these rules alphabetically
36+
'align_multiline_comment' => ['comment_type' => 'phpdocs_only'],
37+
'array_indentation' => true,
38+
'assign_null_coalescing_to_coalesce_equal' => true,
39+
'binary_operator_spaces' => ['default' => 'single_space'],
40+
'cast_spaces' => ['space' => 'single'],
41+
'class_attributes_separation' => ['elements' => ['method' => 'one']],
42+
'declare_strict_types' => true,
43+
'explicit_string_variable' => true,
44+
// 'final_public_method_for_abstract_class' => true, // @todo enable it
45+
'general_phpdoc_annotation_remove' => [
46+
'annotations' => [
47+
'api',
48+
'access',
49+
'author',
50+
'category',
51+
'copyright',
52+
'created',
53+
'license',
54+
'link',
55+
'package',
56+
'since',
57+
'subpackage',
58+
'version',
59+
],
60+
],
61+
'modernize_types_casting' => true,
62+
'no_alias_functions' => true,
63+
'no_binary_string' => true,
64+
'no_empty_comment' => true,
65+
'no_empty_phpdoc' => true,
66+
'no_empty_statement' => true,
67+
'no_extra_blank_lines' => ['tokens' => ['extra', 'curly_brace_block']],
68+
'no_homoglyph_names' => true,
69+
'no_leading_namespace_whitespace' => true,
70+
'no_mixed_echo_print' => true,
71+
'no_short_bool_cast' => true,
72+
'no_singleline_whitespace_before_semicolons' => true,
73+
'no_spaces_around_offset' => true,
74+
'no_trailing_comma_in_singleline' => false, // it's a good marker that there are more elements in an array
75+
'no_unneeded_braces' => true,
76+
'no_unneeded_control_parentheses' => true,
77+
'no_unneeded_final_method' => true,
78+
'no_unreachable_default_argument_value' => true,
79+
'no_unused_imports' => true,
80+
'no_useless_concat_operator' => true,
81+
'no_useless_return' => true,
82+
'no_whitespace_before_comma_in_array' => true,
83+
'normalize_index_brace' => true,
84+
'nullable_type_declaration' => ['syntax' => 'question_mark'],
85+
'object_operator_without_whitespace' => true,
86+
/*
87+
* @see https://github.com/slevomat/coding-standard/issues/1620#issuecomment-1758006718
88+
* 'ordered_class_elements' => [
89+
'order' => [
90+
'use_trait',
91+
'constant',
92+
'case', // for enums only
93+
'property',
94+
'method',
95+
]
96+
],*/
97+
'php_unit_construct' => true,
98+
'php_unit_dedicate_assert' => ['target' => 'newest'],
99+
'php_unit_expectation' => true,
100+
'php_unit_fqcn_annotation' => true,
101+
'php_unit_method_casing' => ['case' => 'snake_case'],
102+
'php_unit_no_expectation_annotation' => true,
103+
'php_unit_set_up_tear_down_visibility' => true,
104+
'php_unit_strict' => true,
105+
'php_unit_test_annotation' => ['style' => 'annotation'],
106+
'php_unit_test_class_requires_covers' => true,
107+
'phpdoc_align' => ['align' => 'left'],
108+
'phpdoc_indent' => true,
109+
'phpdoc_line_span' => ['const' => 'single', 'property' => 'single', 'method' => 'single'],
110+
'phpdoc_param_order' => true,
111+
'phpdoc_scalar' => true,
112+
'phpdoc_single_line_var_spacing' => true,
113+
'phpdoc_tag_casing' => true,
114+
'phpdoc_types' => true,
115+
'protected_to_private' => true,
116+
'psr_autoloading' => true,
117+
'self_accessor' => true,
118+
'self_static_accessor' => true,
119+
'single_line_comment_spacing' => true,
120+
'single_line_comment_style' => ['comment_types' => ['asterisk', 'hash']],
121+
'space_after_semicolon' => true,
122+
'standardize_not_equals' => true,
123+
'strict_param' => true,
124+
'ternary_to_null_coalescing' => true,
125+
'trim_array_spaces' => true,
126+
'trailing_comma_in_multiline' => true,
127+
'type_declaration_spaces' => true,
128+
'types_spaces' => ['space' => 'single'],
129+
'whitespace_after_comma_in_array' => true,
130+
'yoda_style' => ['equal' => false, 'identical' => false, 'less_and_greater' => false],
131+
])
132+
->setFinder($finder);

composer.json

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@
1111
"markdown"
1212
],
1313
"require": {
14-
"php": ">=8.0",
14+
"php": "^8.1",
1515
"laravel/nova": "^4.20"
1616
},
1717
"require-dev": {
18-
"interaction-design-foundation/coding-standard": "^0.0.4",
19-
"orchestra/testbench": "^7.0",
20-
"phpunit/phpunit": "^9.6 || ^10.0",
21-
"vimeo/psalm": "^5.6"
18+
"interaction-design-foundation/coding-standard": "^0.2.0",
19+
"orchestra/testbench": "^8.0",
20+
"phpunit/phpunit": "^10.5 || ^11.0",
21+
"vimeo/psalm": "^5.22"
2222
},
2323
"repositories": [
2424
{
@@ -52,8 +52,10 @@
5252
}
5353
},
5454
"scripts": {
55+
"cs": "@cs:fix",
5556
"cs:check": "phpcs -p -s --colors --report-full --report-summary",
5657
"cs:fix": "phpcbf -p --colors",
58+
"psalm": "vendor/bin/psalm",
5759
"test": "phpunit --colors=always"
5860
}
5961
}

phpunit.xml.dist

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,24 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="vendor/autoload.php" backupGlobals="false" backupStaticAttributes="false" colors="true" verbose="true" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" processIsolation="false" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.5/phpunit.xsd">
3-
<coverage>
4-
<include>
5-
<directory suffix=".php">src/</directory>
6-
</include>
7-
</coverage>
8-
<testsuites>
9-
<testsuite name="IxDF Test Suite">
10-
<directory>tests</directory>
11-
</testsuite>
12-
</testsuites>
13-
<php>
2+
<phpunit
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd"
5+
bootstrap="vendor/autoload.php"
6+
backupGlobals="false"
7+
colors="true"
8+
processIsolation="false"
9+
stopOnFailure="false"
10+
cacheDirectory=".phpunit.cache"
11+
backupStaticProperties="false">
12+
<testsuites>
13+
<testsuite name="Main Test Suite">
14+
<directory>tests</directory>
15+
</testsuite>
16+
</testsuites>
17+
<php>
1418
</php>
19+
<source>
20+
<include>
21+
<directory suffix=".php">src/</directory>
22+
</include>
23+
</source>
1524
</phpunit>

psalm-baseline.xml

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,8 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<files psalm-version="5.6.0@e784128902dfe01d489c4123d69918a9f3c1eac5">
2+
<files psalm-version="5.22.2@d768d914152dbbf3486c36398802f74e80cfde48">
33
<file src="src/HtmlCard.php">
4-
<MixedArgument>
5-
<code>$htmlContent</code>
6-
</MixedArgument>
7-
<MixedAssignment>
8-
<code>$htmlContent</code>
9-
</MixedAssignment>
10-
<PossiblyUndefinedMethod>
11-
<code>render</code>
12-
</PossiblyUndefinedMethod>
134
<PropertyNotSetInConstructor>
14-
<code>HtmlCard</code>
5+
<code><![CDATA[HtmlCard]]></code>
156
</PropertyNotSetInConstructor>
167
</file>
178
</files>

src/CardServiceProvider.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
namespace InteractionDesignFoundation\HtmlCard;
44

55
use Illuminate\Support\ServiceProvider;
6-
use Laravel\Nova\Events\ServingNova;
76
use Laravel\Nova\Nova;
87

98
class CardServiceProvider extends ServiceProvider // phpcs:ignore SlevomatCodingStandard.Classes.RequireAbstractOrFinal.ClassNeitherAbstractNorFinal
@@ -14,7 +13,7 @@ class CardServiceProvider extends ServiceProvider // phpcs:ignore SlevomatCoding
1413
*/
1514
public function boot()
1615
{
17-
Nova::serving(static function (ServingNova $event) {
16+
Nova::serving(static function (): void {
1817
Nova::script('html-card', __DIR__.'/../dist/js/card.js');
1918
});
2019
}

src/HtmlCard.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace InteractionDesignFoundation\HtmlCard;
44

55
use Illuminate\Support\Facades\App;
6+
use Illuminate\Support\Facades\View;
67
use Laravel\Nova\Card;
78

89
class HtmlCard extends Card // phpcs:ignore SlevomatCodingStandard.Classes.RequireAbstractOrFinal.ClassNeitherAbstractNorFinal
@@ -11,11 +12,9 @@ class HtmlCard extends Card // phpcs:ignore SlevomatCodingStandard.Classes.Requi
1112
* The width of the card (1/3, 1/2, or full).
1213
* @var string
1314
*/
14-
public $width = '1/3';
15+
public $width = self::ONE_THIRD_WIDTH;
1516

16-
/**
17-
* Create a new element.
18-
*/
17+
/** @inheritDoc */
1918
public function __construct(string | null $component = null)
2019
{
2120
parent::__construct($component);
@@ -29,7 +28,7 @@ public function __construct(string | null $component = null)
2928
}
3029

3130
/** @inheritDoc */
32-
public function component()
31+
public function component(): string
3332
{
3433
return 'html-card';
3534
}
@@ -58,7 +57,7 @@ public function markdown(string $markdownContent): static
5857
*/
5958
public function view(string $view, array $viewData = []): static
6059
{
61-
$htmlContent = view($view, $viewData)->render();
60+
$htmlContent = View::make($view, $viewData)->render();
6261

6362
return $this->html($htmlContent);
6463
}

0 commit comments

Comments
 (0)