Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cake 5 #339

Merged
merged 47 commits into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
6f32e3f
Update for Cake 5
ADmad Jun 27, 2022
34a22b4
Merge pull request #300 from FriendsOfCake/cake-5-update
ADmad Jun 27, 2022
060cd10
Merge branch 'master' into cake-5
ADmad Dec 31, 2022
83ecacf
Updates for Cake 5
ADmad Dec 31, 2022
44ed173
Merge pull request #309 from FriendsOfCake/cake-5-updates
ADmad Dec 31, 2022
44e0c53
Updates for phpunit 10
ADmad Jul 17, 2023
d98efde
Fix errors reported by static analysis
ADmad Jul 17, 2023
71e9d56
Merge pull request #320 from FriendsOfCake/cake-5-updates
ADmad Jul 17, 2023
a49ba32
Update to stable releases
ADmad Oct 3, 2023
84be527
Fix type
ADmad Oct 4, 2023
8e70739
Fix search inline form display
ADmad Oct 6, 2023
31b08ca
Fix bootstrap 5's data attributes
ADmad Oct 6, 2023
ef8d52f
Merge branch 'master' into cake-5
ADmad Oct 11, 2023
6a67bc9
Default to empty array value when normalizing arrays.
ADmad Oct 22, 2023
0c5df68
Fix setting default label for empty select option
ADmad Oct 28, 2023
33d8ca7
Update finder_scopes.php
hmic Dec 11, 2023
59e3fb9
Merge pull request #329 from hmic/patch-8
ADmad Dec 11, 2023
86d4727
Add support for introspecting enum
ADmad Mar 28, 2024
1d7a708
Fix tests
ADmad Mar 28, 2024
13712af
Fix CS errors
ADmad Mar 28, 2024
c003ceb
Merge pull request #331 from FriendsOfCake/cake-5-enum-introspect
ADmad Mar 28, 2024
e57e739
Account for null values for formatEnum()
ADmad May 2, 2024
3ddc66e
Merge branch 'master' into cake-5
ADmad May 3, 2024
b6f1885
Fix FormProtector validation error
ADmad May 29, 2024
fe50b47
Fix array diffing
ADmad Jun 6, 2024
25640c1
If FormProtectorComponent is not loaded, FormHelper::unlockField() th…
ADmad Jul 9, 2024
31cad75
Fix #333
ADmad Jul 27, 2024
cb4c52b
bump up phpunit to 11
ADmad Jul 27, 2024
e33db3f
Fix CS error
ADmad Jul 27, 2024
1e53086
Fix stan errors
ADmad Jul 27, 2024
458a531
Merge branch 'master' into cake-5
ADmad Sep 8, 2024
a9c7a70
Fix introspection of field of associated records
ADmad Sep 7, 2024
584c713
Revamp date time values formatting
ADmad Sep 8, 2024
6269278
Fix stan errors
ADmad Sep 8, 2024
f727328
Fix CS error
ADmad Sep 8, 2024
73629d6
Fix ICU lib version specific failure
ADmad Sep 8, 2024
7250135
Allow setting CrudViewHelper config through app config
ADmad Sep 8, 2024
4820ff6
Fix CS error
ADmad Sep 8, 2024
21d75e8
Use autocomplete by default only for select fields in search form.
ADmad Sep 8, 2024
26807b0
Fix stan error
ADmad Sep 8, 2024
a3dcf6a
Updates for Bootstrap 5
ADmad Sep 8, 2024
cd728cc
Swap arguments of CrudViewHelper::fieldValue() for consistency
ADmad Sep 13, 2024
474b39a
Update CI config
ADmad Sep 17, 2024
a8eb2a7
Fix stan errors
ADmad Sep 17, 2024
2246cf0
Update readme
ADmad Sep 17, 2024
94c5812
disable unneeded plugin hooks
ADmad Sep 17, 2024
6208144
Reduce code duplication
ADmad Sep 17, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading