diff --git a/.gitattributes b/.gitattributes index 76a35dd6..6d2ed281 100644 --- a/.gitattributes +++ b/.gitattributes @@ -11,3 +11,6 @@ docs export-ignore .github export-ignore .coveralls.yml export-ignore Makefile export-ignore +phpstan.neon export-ignore +phpstan-baseline.neon export-ignore +psalm.xml export-ignore diff --git a/.travis.yml b/.travis.yml index bf40f66b..fcfdfade 100644 --- a/.travis.yml +++ b/.travis.yml @@ -29,7 +29,7 @@ before_script: - if [[ $LOWEST = 0 ]]; then composer install --prefer-dist --no-interaction; fi - if [[ $LOWEST = 1 ]]; then composer update --prefer-lowest --prefer-dist --no-interaction; fi - - if [[ $PHPCS = 1 ]]; then composer require cakephp/cakephp-codesniffer:dev-next; fi + - if [[ $PHPCS = 1 ]]; then composer require cakephp/cakephp-codesniffer:^4.2; fi - if [[ $STATIC_ANALYSIS = 1 ]]; then composer require phpstan/phpstan:^0.12 psalm/phar:^3.7; fi script: diff --git a/config/asset_compress.ini b/config/asset_compress.ini index 24e5f1a4..df092ae6 100644 --- a/config/asset_compress.ini +++ b/config/asset_compress.ini @@ -1,16 +1,17 @@ [crudview.css] -files[]=https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.4.1/css/bootstrap.css -files[]=https://cdn.jsdelivr.net/npm/flatpickr@4.6.3/dist/flatpickr.min.css +files[]=https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@5.13/css/all.min.css +files[]=https://cdn.jsdelivr.net/npm/bootstrap@^4.5/dist/css/bootstrap.min.css +files[]=https://cdn.jsdelivr.net/npm/flatpickr@4.6/dist/flatpickr.min.css files[]=https://cdn.jsdelivr.net/npm/select2@4.0/dist/css/select2.min.css files[]=https://cdn.jsdelivr.net/npm/@ttskch/select2-bootstrap4-theme@1.2/dist/select2-bootstrap4.css files[]=plugin:CrudView:css/local.css [crudview_head.js] -files[]=https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.4/jquery.min.js -files[]=https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.4.1/js/bootstrap.min.js +files[]=https://cdn.jsdelivr.net/npm/jquery@^3.4/dist/jquery.min.js +files[]=https://cdn.jsdelivr.net/npm/bootstrap@^4.5/dist/js/bootstrap.min.js files[]=https://cdn.jsdelivr.net/npm/flatpickr@4.6 files[]=https://cdn.jsdelivr.net/npm/select2@4.0 -files[]=https://cdn.jsdelivr.net/jquery.dirtyforms/1.2.3/jquery.dirtyforms.min.js +files[]=https://cdn.jsdelivr.net/npm/jquery.dirtyforms@2/jquery.dirtyforms.min.js [crudview.js] files[]=plugin:CrudView:js/local.js diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon new file mode 100644 index 00000000..fdc99ea6 --- /dev/null +++ b/phpstan-baseline.neon @@ -0,0 +1,72 @@ +parameters: + ignoreErrors: + - + message: "#^Access to an undefined property object\\:\\:\\$query\\.$#" + count: 4 + path: src/Listener/ViewListener.php + + - + message: "#^Access to an undefined property object\\:\\:\\$params\\.$#" + count: 1 + path: src/Listener/ViewListener.php + + - + message: "#^Access to an undefined property object\\:\\:\\$element\\.$#" + count: 1 + path: src/Listener/ViewListener.php + + - + message: "#^Access to an undefined property object\\:\\:\\$type\\.$#" + count: 1 + path: src/Listener/ViewListener.php + + - + message: "#^Parameter \\#2 \\$arr2 of function array_diff_key expects array, array\\|false given\\.$#" + count: 1 + path: src/Listener/ViewListener.php + + - + message: "#^Result of \\|\\| is always false\\.$#" + count: 1 + path: src/Listener/ViewListener.php + + - + message: "#^Cannot unset offset mixed on array\\(\\)\\.$#" + count: 2 + path: src/Listener/ViewListener.php + + - + message: "#^Parameter \\#1 \\$field of method CrudView\\\\Listener\\\\ViewListener\\:\\:_deriveFieldFromContext\\(\\) expects string, array\\\\|string\\|null given\\.$#" + count: 1 + path: src/Listener/ViewListener.php + + - + message: "#^Call to an undefined method Cake\\\\ORM\\\\Table\\:\\:searchManager\\(\\)\\.$#" + count: 1 + path: src/Listener/ViewSearchListener.php + + - + message: "#^Offset 'data\\-wrap' does not exist on array\\(\\?'data\\-enable\\-seconds' \\=\\> 'true', 'data\\-date\\-format' \\=\\> string, \\?'data\\-enable\\-time' \\=\\> 'true', \\?'data\\-alt\\-format' \\=\\> mixed, \\?'data\\-alt\\-input' \\=\\> 'true', \\?'data\\-no\\-calendar' \\=\\> 'true'\\)\\.$#" + count: 1 + path: src/View/Widget/DateTimeWidget.php + + - + message: "#^Binary operation \"\\+\\=\" between array\\\\|string and array\\('data\\-date\\-format' \\=\\> string, \\?'data\\-alt\\-format' \\=\\> mixed, \\?'data\\-alt\\-input' \\=\\> 'true', \\?'data\\-no\\-calendar' \\=\\> 'true', \\?'data\\-enable\\-seconds' \\=\\> 'true', \\?'data\\-enable\\-time' \\=\\> 'true', 'data\\-wrap' \\=\\> mixed\\) results in an error\\.$#" + count: 1 + path: src/View/Widget/DateTimeWidget.php + + - + message: "#^Offset 'name' does not exist on array\\\\|string\\.$#" + count: 1 + path: src/View/Widget/DateTimeWidget.php + + - + message: "#^Offset 'templateVars' does not exist on array\\\\|string\\.$#" + count: 2 + path: src/View/Widget/DateTimeWidget.php + + - + message: "#^Parameter \\#1 \\$options of method Cake\\\\View\\\\StringTemplate\\:\\:formatAttributes\\(\\) expects array\\|null, array\\\\|string given\\.$#" + count: 1 + path: src/View/Widget/DateTimeWidget.php + diff --git a/phpstan.neon b/phpstan.neon index 7ee901cb..5c6d272c 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,16 +1,8 @@ +includes: + - phpstan-baseline.neon + parameters: level: 7 checkMissingIterableValueType: false universalObjectCratesClasses: - Crud\Event\Subject - ignoreErrors: - - '#Parameter \#1 $dateString of method Cake\\View\\Helper\\TimeHelper::nice() expects DateTime|int|string|null, DateTime|DateTimeImmutable|int|string given#' - - - message: '#Result of || is always false#' - path: 'src/Listener/ViewListener.php' - - - message: '#Call to an undefined method Cake\\ORM\\Table::searchManager\(\)#' - path: 'src/Listener/ViewSearchListener.php' - - - message: '#Method CrudView\\Action\\DashboardAction::_get\(\) should return Cake\\Http\\Response|void but return statement is missing#' - path: 'src/Action/DashboardAction.php' diff --git a/src/View/Widget/DateTimeWidget.php b/src/View/Widget/DateTimeWidget.php index 9d1046fc..d4719ab1 100644 --- a/src/View/Widget/DateTimeWidget.php +++ b/src/View/Widget/DateTimeWidget.php @@ -75,13 +75,12 @@ public function render(array $data, ContextInterface $context): string $iconClass = 'fa fa-calendar-alt'; if (isset($datetimePicker['iconClass'])) { - $iconClass = $data['iconClass']; + $iconClass = $datetimePicker['iconClass']; + unset($datetimePicker['iconClass']); } elseif ($data['type'] === 'time') { $iconClass = 'fa fa-clock'; } - unset($datetimePicker['iconClass']); - if ($this->_templates->get('datetimePicker') === null) { // phpcs:disable $this->_templates->add([ diff --git a/webroot/js/local.js b/webroot/js/local.js index f1a2d5fe..8dff5e56 100644 --- a/webroot/js/local.js +++ b/webroot/js/local.js @@ -98,6 +98,10 @@ var CrudView = { }) }, + tooltip: function () { + $('[data-toggle="tooltip"]').tooltip(); + }, + initialize: function () { this.bulkActionForm('.bulk-actions'); this.flatpickr('.flatpickr'); @@ -105,6 +109,7 @@ var CrudView = { this.autocomplete('input.autocomplete, select.autocomplete'); this.dirtyForms(); this.dropdown(); + this.tooltip(); } };