Skip to content

Commit

Permalink
Merge pull request #339 from FriendsOfCake/cake-5
Browse files Browse the repository at this point in the history
Cake 5
  • Loading branch information
ADmad authored Sep 17, 2024
2 parents d0f6605 + 6208144 commit 999a19c
Show file tree
Hide file tree
Showing 53 changed files with 592 additions and 514 deletions.
70 changes: 7 additions & 63 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,70 +2,14 @@ name: CI

on: [push, pull_request]

permissions:
contents: read

jobs:
testsuite:
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
php-version: ['7.4', '8.0', '8.1', '8.2']
dependencies: ['highest']
include:
- php-version: '7.2'
dependencies: 'lowest'

steps:
- uses: actions/checkout@v3

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
extensions: mbstring, intl, pdo_${{ matrix.db-type }}
coverage: pcov

- name: Composer install
uses: ramsey/composer-install@v2
with:
dependency-versions: ${{ matrix.dependencies }}

- name: Run PHPUnit
run: |
if [[ ${{ matrix.php-version }} == '7.4' ]]; then
vendor/bin/phpunit --coverage-clover=coverage.xml
else
vendor/bin/phpunit
fi
- name: Code Coverage Report
if: matrix.php-version == '7.4'
uses: codecov/codecov-action@v3
uses: cakephp/.github/.github/workflows/[email protected]
secrets: inherit

cs-stan:
name: Coding Standard & Static Analysis
runs-on: ubuntu-22.04

steps:
- uses: actions/checkout@v3

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
extensions: mbstring, intl
coverage: none
tools: vimeo/psalm:5.9, phpstan:1.10

- name: Composer Install
run: composer require --dev cakephp/cakephp-codesniffer:^4.1

- name: Run phpcs
run: vendor/bin/phpcs --report=checkstyle --standard=vendor/cakephp/cakephp-codesniffer/CakePHP src/ tests/

- name: Run psalm
if: success() || failure()
run: psalm --output-format=github

- name: Run phpstan
if: success() || failure()
run: phpstan analyse --error-format=github
uses: ADmad/.github/.github/workflows/cs-stan.yml@master
secrets: inherit
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ vendor/
composer.lock
tmp
.phpunit.result.cache
.phpunit.cache
9 changes: 0 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,3 @@ If you happen to stumble upon a bug, please feel free to create a pull request w
(optionally with a test), and a description of the bug and how it was resolved.

You can also create an issue with a description to raise awareness of the bug.

# Features

If you have a good idea for a Crud View feature, please join us on IRC and let's discuss it. Pull
requests are always more than welcome.

# Support / Questions

You can join us on IRC in the #FriendsOfCake freenode channel for any support or questions.
13 changes: 6 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@
}
],
"require": {
"cakephp/cakephp": "^4.0",
"friendsofcake/bootstrap-ui": "^3.0",
"friendsofcake/crud": "^6.0"
"cakephp/cakephp": "^5.0",
"friendsofcake/crud": "^7.0",
"friendsofcake/bootstrap-ui": "^5.0"
},
"require-dev": {
"friendsofcake/cakephp-test-utilities": "^2.0",
"markstory/asset_compress": "^4.0",
"phpunit/phpunit": "~8.5.0 || ^9.3"
"friendsofcake/cakephp-test-utilities": "^3.0",
"markstory/asset_compress": "^5.0",
"phpunit/phpunit": "^10.1 || ^11.0"
},
"autoload": {
"psr-4": {
Expand All @@ -54,7 +54,6 @@
"wiki": "http://cakephp.nu/cakephp-crud/",
"irc": "irc://irc.freenode.org/friendsofcake"
},
"prefer-stable": true,
"config": {
"sort-packages": true,
"allow-plugins": {
Expand Down
8 changes: 4 additions & 4 deletions config/asset_compress.ini
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
[crudview.css]
files[]=https://cdn.jsdelivr.net/npm/bootstrap@4.5/dist/css/bootstrap.min.css
files[]=https://cdn.jsdelivr.net/npm/bootstrap@5.3/dist/css/bootstrap.min.css
files[]=https://cdn.jsdelivr.net/npm/[email protected]/dist/flatpickr.min.css
files[]=https://cdn.jsdelivr.net/npm/[email protected]/dist/css/select2.min.css
files[]=https://cdn.jsdelivr.net/npm/@ttskch/select2-bootstrap4-theme@1.2/dist/select2-bootstrap4.css
files[]=https://cdn.jsdelivr.net/npm/select2-bootstrap-5-theme@1.3/dist/select2-bootstrap-5-theme.min.css
files[]=plugin:CrudView:css/local.css

[crudview_head.js]
files[]=https://cdn.jsdelivr.net/npm/jquery@3.5/dist/jquery.min.js
files[]=https://cdn.jsdelivr.net/npm/bootstrap@4.5/dist/js/bootstrap.min.js
files[]=https://cdn.jsdelivr.net/npm/jquery@3.7/dist/jquery.min.js
files[]=https://cdn.jsdelivr.net/npm/bootstrap@5.3/dist/js/bootstrap.min.js
files[]=https://cdn.jsdelivr.net/npm/[email protected]
files[]=https://cdn.jsdelivr.net/npm/[email protected]
files[]=https://cdn.jsdelivr.net/npm/[email protected]/jquery.dirtyforms.min.js
Expand Down
1 change: 1 addition & 0 deletions config/defaults.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,6 @@
'tablesBlacklist' => [
'phinxlog',
],
'helperConfig' => [],
],
];
23 changes: 1 addition & 22 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ parameters:
path: src/Listener/ViewListener.php

-
message: "#^Parameter \\#1 \\$field of method CrudView\\\\Listener\\\\ViewListener\\:\\:_deriveFieldFromContext\\(\\) expects string, array\\<string\\>\\|string\\|null given\\.$#"
message: "#^Parameter \\#1 \\$field of method CrudView\\\\Listener\\\\ViewListener\\:\\:_deriveFieldFromContext\\(\\) expects string, array\\<int, string\\>\\|string\\|null given\\.$#"
count: 1
path: src/Listener/ViewListener.php

Expand All @@ -24,24 +24,3 @@ parameters:
message: "#^Call to an undefined method Cake\\\\ORM\\\\Table\\:\\:searchManager\\(\\)\\.$#"
count: 1
path: src/Listener/ViewSearchListener.php

-
message: "#^Binary operation \"\\+\" between string and non\\-empty\\-array results in an error\\.$#"
count: 1
path: src/View/Widget/DateTimeWidget.php

-
message: "#^Offset 'name' does not exist on array\\<string\\>\\|string\\.$#"
count: 1
path: src/View/Widget/DateTimeWidget.php

-
message: "#^Offset 'templateVars' does not exist on array\\<string\\>\\|string\\.$#"
count: 2
path: src/View/Widget/DateTimeWidget.php

-
message: "#^Parameter \\#1 \\$options of method Cake\\\\View\\\\StringTemplate\\:\\:formatAttributes\\(\\) expects array\\<string, mixed\\>\\|null, array\\<string\\>\\|string given\\.$#"
count: 1
path: src/View/Widget/DateTimeWidget.php

9 changes: 4 additions & 5 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@ includes:
- phpstan-baseline.neon

parameters:
level: 7
checkMissingIterableValueType: false
checkGenericClassInNonGenericObjectType: false
level: 8
paths:
- src
universalObjectCratesClasses:
- Crud\Event\Subject
bootstrapFiles:
- vendor/cakephp/cakephp/src/Database/Exception/DatabaseException.php
ignoreErrors:
- identifier: missingType.iterableValue
- identifier: missingType.generics
41 changes: 12 additions & 29 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,36 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
colors="true"
processIsolation="false"
stopOnFailure="false"
bootstrap="./tests/bootstrap.php"
>
<php>
<ini name="memory_limit" value="-1"/>
</php>

<!-- Add any additional test suites you want to run here -->
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" colors="true" processIsolation="false" stopOnFailure="false" bootstrap="./tests/bootstrap.php" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.2/phpunit.xsd" cacheDirectory=".phpunit.cache">
<testsuites>
<testsuite name="CrudView Tests">
<directory>./tests/TestCase</directory>
</testsuite>
<!-- Add plugin test suites here. -->
</testsuites>

<!-- Setup a listener for fixtures -->
<listeners>
<listener
class="\Cake\TestSuite\Fixture\FixtureInjector"
file="./vendor/cakephp/cakephp/src/TestSuite/Fixture/FixtureInjector.php">
<arguments>
<object class="\Cake\TestSuite\Fixture\FixtureManager" />
</arguments>
</listener>
</listeners>

<filter>
<whitelist>
<directory suffix=".php">./src/</directory>
</whitelist>
</filter>
<extensions>
<bootstrap class="Cake\TestSuite\Fixture\Extension\PHPUnitExtension"/>
</extensions>
<php>
<env name="FIXTURE_SCHEMA_METADATA" value="./tests/schema.php"/>
</php>
<source>
<include>
<directory suffix=".php">src/</directory>
</include>
</source>
</phpunit>
3 changes: 3 additions & 0 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="5.23.1@8471a896ccea3526b26d082f4461eeea467f10a4">
</files>
3 changes: 2 additions & 1 deletion psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
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"
errorBaseline="psalm-baseline.xml"
usePhpDocMethodsWithoutMagicCall="true"
findUnusedBaselineEntry="true"
findUnusedCode="false"

>
<projectFiles>
<directory name="src" />
Expand Down
5 changes: 3 additions & 2 deletions src/Action/DashboardAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@
use Crud\Action\BaseAction;
use Crud\Traits\ViewTrait;
use CrudView\Dashboard\Dashboard;
use function Cake\I18n\__d;

class DashboardAction extends BaseAction
{
use ViewTrait;

protected $_defaultConfig = [
protected array $_defaultConfig = [
'enabled' => true,
'view' => null,
];
Expand All @@ -21,7 +22,7 @@ class DashboardAction extends BaseAction
*
* @return void
*/
protected function _get()
protected function _get(): void
{
$pageTitle = $this->getConfig('scaffold.page_title', __d('CrudView', 'Dashboard'));
$this->setConfig('scaffold.page_title', $pageTitle);
Expand Down
2 changes: 1 addition & 1 deletion src/Breadcrumb/ActiveBreadcrumb.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class ActiveBreadcrumb extends Breadcrumb
* @inheritDoc
* @psalm-suppress MissingParamType
*/
public function __construct($title, $url = null, array $options = [])
public function __construct(string|array $title, string|array|null $url = null, array $options = [])
{
if (!isset($options['class'])) {
$options['class'] = '';
Expand Down
24 changes: 12 additions & 12 deletions src/Breadcrumb/Breadcrumb.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,43 +10,43 @@ class Breadcrumb
* If the specified $url is a link, then this will
* also be wrapped by `<a>` tags.
*
* @var string|array
* @var array|string
**/
protected $title;
protected string|array $title;

/**
* Cake-relative URL or array of URL parameters, or
* external URL (starts with http://)
*
* @var string|array|null
* @var array|string|null
*/
protected $url = null;
protected string|array|null $url = null;

/**
* Array of options and HTML attributes.
*
* @var array
**/
protected $options = [];
protected array $options = [];

/**
* Contains a breadcrumb entry
*
* @param string|array $title If provided as a string, it represents the title of the crumb.
* @param array|string $title If provided as a string, it represents the title of the crumb.
* Alternatively, if you want to add multiple crumbs at once, you can provide an array, with each values being a
* single crumb. Arrays are expected to be of this form:
* - *title* The title of the crumb
* - *link* The link of the crumb. If not provided, no link will be made
* - *options* Options of the crumb. See description of params option of this method.
* @param string|array|null $url URL of the crumb. Either a string, an array of route params to pass to
* @param array|string|null $url URL of the crumb. Either a string, an array of route params to pass to
* Url::build() or null / empty if the crumb does not have a link.
* @param array $options Array of options. These options will be used as attributes HTML attribute the crumb will
* be rendered in (a <li> tag by default). It accepts two special keys:
* - *innerAttrs*: An array that allows you to define attributes for the inner element of the crumb (by default, to
* the link)
* - *templateVars*: Specific template vars in case you override the templates provided.
*/
public function __construct($title, $url = null, array $options = [])
public function __construct(string|array $title, string|array|null $url = null, array $options = [])
{
$this->title = $title;
$this->url = $url;
Expand All @@ -56,19 +56,19 @@ public function __construct($title, $url = null, array $options = [])
/**
* Returns the menu item title
*
* @return string|array
* @return array|string
*/
public function getTitle()
public function getTitle(): string|array
{
return $this->title;
}

/**
* Returns the menu item ur
*
* @return string|array|null
* @return array|string|null
*/
public function getUrl()
public function getUrl(): string|array|null
{
return $this->url;
}
Expand Down
Loading

0 comments on commit 999a19c

Please sign in to comment.