Skip to content

Commit

Permalink
Merge pull request #23 from InteractionDesignFoundation/update-depend…
Browse files Browse the repository at this point in the history
…encies

Support Laravel 11, update dependencies
  • Loading branch information
alies-dev authored Feb 28, 2024
2 parents fe1d64e + 6a90ddd commit de6ded9
Show file tree
Hide file tree
Showing 11 changed files with 186 additions and 57 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/format_php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ jobs:
run: |
echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Retrieve Composers cache
uses: actions/cache@v3
- name: Retrieve Composers cache
uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: |
${{ runner.os }}-composer-
Expand All @@ -49,16 +49,16 @@ jobs:
- name: Install composer dependencies -- step 2
run: 'composer install --working-dir=tools/phpcs --no-interaction --no-progress --no-scripts'

- name: Retrieve PHP-CS-Fixers cache
uses: actions/cache@v3
- name: Retrieve PHP-CS-Fixers cache
uses: actions/cache@v4
with:
path: .php-cs-fixer.cache
key: ${{ runner.os }}-php-cs-fixer-${{ hashFiles('.php-cs-fixer.php', '.phpcs/**/**') }}
restore-keys: |
${{ runner.os }}-php-cs-fixer-
- name: Retrieve PHPCSs cache
uses: actions/cache@v3
- name: Retrieve PHPCSs cache
uses: actions/cache@v4
with:
path: .phpcs.cache
key: ${{ runner.os }}-phpcs-${{ hashFiles('phpcs.xml') }}
Expand Down
9 changes: 4 additions & 5 deletions .github/workflows/psalm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,19 @@ jobs:
name: psalm
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

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

- name: Cache composer dependencies
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: vendor
key: composer-${{ hashFiles('composer.lock') }}
key: composer-${{ hashFiles('composer.json') }}

- name: Run composer install
run: |
Expand Down
13 changes: 5 additions & 8 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,23 @@ jobs:
fail-fast: true
matrix:
os: [ ubuntu-latest ]
php: [ 8.0, 8.1 ]
laravel: [ 8.*, 9.* ]
php: [ 8.3, 8.2]
laravel: [ 10.* ]
dependency-version: [ prefer-stable ]
include:
- laravel: 8.*
testbench: 6.*
- laravel: 9.*
testbench: 7.*
- laravel: 10.*
testbench: 8.*

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

steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4

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

- name: Setup problem matchers
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ auth.json

phpunit.xml
.phpunit.result.cache
.phpunit.cache/

.DS_Store
Thumbs.db
Expand Down
132 changes: 132 additions & 0 deletions .php-cs-fixer.php
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);
12 changes: 7 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@
"markdown"
],
"require": {
"php": ">=8.0",
"php": "^8.1",
"laravel/nova": "^4.20"
},
"require-dev": {
"interaction-design-foundation/coding-standard": "^0.0.4",
"orchestra/testbench": "^7.0",
"phpunit/phpunit": "^9.6 || ^10.0",
"vimeo/psalm": "^5.6"
"interaction-design-foundation/coding-standard": "^0.2.0",
"orchestra/testbench": "^8.0",
"phpunit/phpunit": "^10.5 || ^11.0",
"vimeo/psalm": "^5.22"
},
"repositories": [
{
Expand Down Expand Up @@ -52,8 +52,10 @@
}
},
"scripts": {
"cs": "@cs:fix",
"cs:check": "phpcs -p -s --colors --report-full --report-summary",
"cs:fix": "phpcbf -p --colors",
"psalm": "vendor/bin/psalm",
"test": "phpunit --colors=always"
}
}
33 changes: 21 additions & 12 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,15 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<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">
<coverage>
<include>
<directory suffix=".php">src/</directory>
</include>
</coverage>
<testsuites>
<testsuite name="IxDF Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
<php>
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd"
bootstrap="vendor/autoload.php"
backupGlobals="false"
colors="true"
processIsolation="false"
stopOnFailure="false"
cacheDirectory=".phpunit.cache"
backupStaticProperties="false">
<testsuites>
<testsuite name="Main Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
<php>
</php>
<source>
<include>
<directory suffix=".php">src/</directory>
</include>
</source>
</phpunit>
13 changes: 2 additions & 11 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
@@ -1,17 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="5.6.0@e784128902dfe01d489c4123d69918a9f3c1eac5">
<files psalm-version="5.22.2@d768d914152dbbf3486c36398802f74e80cfde48">
<file src="src/HtmlCard.php">
<MixedArgument>
<code>$htmlContent</code>
</MixedArgument>
<MixedAssignment>
<code>$htmlContent</code>
</MixedAssignment>
<PossiblyUndefinedMethod>
<code>render</code>
</PossiblyUndefinedMethod>
<PropertyNotSetInConstructor>
<code>HtmlCard</code>
<code><![CDATA[HtmlCard]]></code>
</PropertyNotSetInConstructor>
</file>
</files>
3 changes: 1 addition & 2 deletions src/CardServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace InteractionDesignFoundation\HtmlCard;

use Illuminate\Support\ServiceProvider;
use Laravel\Nova\Events\ServingNova;
use Laravel\Nova\Nova;

class CardServiceProvider extends ServiceProvider // phpcs:ignore SlevomatCodingStandard.Classes.RequireAbstractOrFinal.ClassNeitherAbstractNorFinal
Expand All @@ -14,7 +13,7 @@ class CardServiceProvider extends ServiceProvider // phpcs:ignore SlevomatCoding
*/
public function boot()
{
Nova::serving(static function (ServingNova $event) {
Nova::serving(static function (): void {
Nova::script('html-card', __DIR__.'/../dist/js/card.js');
});
}
Expand Down
11 changes: 5 additions & 6 deletions src/HtmlCard.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace InteractionDesignFoundation\HtmlCard;

use Illuminate\Support\Facades\App;
use Illuminate\Support\Facades\View;
use Laravel\Nova\Card;

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

/**
* Create a new element.
*/
/** @inheritDoc */
public function __construct(string | null $component = null)
{
parent::__construct($component);
Expand All @@ -29,7 +28,7 @@ public function __construct(string | null $component = null)
}

/** @inheritDoc */
public function component()
public function component(): string
{
return 'html-card';
}
Expand Down Expand Up @@ -58,7 +57,7 @@ public function markdown(string $markdownContent): static
*/
public function view(string $view, array $viewData = []): static
{
$htmlContent = view($view, $viewData)->render();
$htmlContent = View::make($view, $viewData)->render();

return $this->html($htmlContent);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
abstract class TestCase extends OrchestraTestCase
{
/** @inheritDoc */
protected function getPackageProviders(): array
protected function getPackageProviders($app): array
{
return [
CardServiceProvider::class,
Expand Down

0 comments on commit de6ded9

Please sign in to comment.