Skip to content

Commit

Permalink
Merge pull request #390 from FriendsOfCake/cake-5
Browse files Browse the repository at this point in the history
Cake 5
  • Loading branch information
ADmad authored Sep 13, 2023
2 parents bd65698 + d27300d commit 7ce12a7
Show file tree
Hide file tree
Showing 40 changed files with 265 additions and 332 deletions.
65 changes: 9 additions & 56 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,75 +8,28 @@ on:
branches:
- '*'

permissions:
contents: read

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

services:
postgres:
image: postgres
ports:
- 5432:5432
env:
POSTGRES_PASSWORD: postgres

steps:
- uses: actions/checkout@v3

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

- name: Composer install
run: |
if ${{ matrix.prefer-lowest == 'prefer-lowest' }}; then
composer update --prefer-lowest --prefer-stable
else
composer install
fi
- name: Setup problem matchers for PHPUnit
if: matrix.php-version == '7.4'
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"

- name: Run PHPUnit
run: |
if [[ ${{ matrix.php-version }} == '7.4' ]]; then
vendor/bin/phpunit --coverage-clover=coverage.xml
else
vendor/bin/phpunit
fi
continue-on-error: ${{ matrix.prefer-lowest == 'prefer-lowest' }}

- 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-18.04
runs-on: ubuntu-22.04

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

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

- name: Composer Install
run: composer install
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ vendor/
composer.lock
node_modules
.phpunit.result.cache
.phpunit.cache

# Generated test files
tests/test_app/webroot/bootstrap_u_i
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
[package]: https://packagist.org/packages/friendsofcake/bootstrap-ui
[license]: LICENSE.txt

Transparently use [Bootstrap 5][bs] with [CakePHP 4][cakephp].
Transparently use [Bootstrap 5][bs] with [CakePHP 5][cakephp].

For version info see [version map](https://github.com/FriendsOfCake/bootstrap-ui/wiki#version-map).

## Requirements

* CakePHP 4.x
* CakePHP 5.x
* Bootstrap 5.x
* npm 6.x
* Popper.js 2.x
Expand Down
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
}
],
"require": {
"cakephp/cakephp": "^4.0"
"cakephp/cakephp": "^5.0"
},
"require-dev": {
"phpunit/phpunit": "^8.5 || ^9.3",
"cakephp/bake": "^2.1",
"cakephp/cakephp-codesniffer": "^4.1"
"phpunit/phpunit": "^10.1",
"cakephp/bake": "^3.0",
"cakephp/cakephp-codesniffer": "^5.0"
},
"support": {
"issues": "http://github.com/friendsofcake/bootstrap-ui/issues",
Expand Down
33 changes: 13 additions & 20 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,27 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
colors="true"
stopOnFailure="false"
bootstrap="./tests/bootstrap.php"
>

<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" colors="true" stopOnFailure="false" bootstrap="./tests/bootstrap.php" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.2/phpunit.xsd" cacheDirectory=".phpunit.cache">
<testsuites>
<testsuite name="bootstrap">
<directory>tests/TestCase/</directory>
<exclude>tests/TestCase/View/Helper/FormHelper/AbstractFormHelperTest.php</exclude>
</testsuite>
</testsuites>

<listeners>
<listener class="Cake\TestSuite\Fixture\FixtureInjector">
<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>
2 changes: 2 additions & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
autoloader="tests/bootstrap.php"
findUnusedBaselineEntry="false"
findUnusedCode="false"
>
<projectFiles>
<directory name="src" />
Expand Down
10 changes: 5 additions & 5 deletions src/Plugin.php → src/BootstrapUIPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,28 @@
use Cake\Console\CommandCollection;
use Cake\Core\BasePlugin;

class Plugin extends BasePlugin
class BootstrapUIPlugin extends BasePlugin
{
/**
* Plugin name.
*
* @var string
* @var string|null
*/
protected $name = 'BootstrapUI';
protected ?string $name = 'BootstrapUI';

/**
* Do bootstrapping or not
*
* @var bool
*/
protected $bootstrapEnabled = false;
protected bool $bootstrapEnabled = false;

/**
* Load routes or not
*
* @var bool
*/
protected $routesEnabled = false;
protected bool $routesEnabled = false;

/**
* @inheritDoc
Expand Down
4 changes: 2 additions & 2 deletions src/Command/BootstrapCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class BootstrapCommand extends Command implements CommandCollectionAwareInterfac
*
* @var \Cake\Console\CommandCollection
*/
protected $commands;
protected CommandCollection $commands;

/**
* @inheritDoc
Expand All @@ -34,7 +34,7 @@ public function setCommandCollection(CommandCollection $commands): void
/**
* @inheritDoc
*/
public function execute(Arguments $args, ConsoleIo $io)
public function execute(Arguments $args, ConsoleIo $io): ?int
{
$io->warning('No command provided. Run `bootstrap --help` to get a list of commands.');

Expand Down
4 changes: 2 additions & 2 deletions src/Command/CopyLayoutsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use Cake\Console\ConsoleIo;
use Cake\Console\ConsoleOptionParser;
use Cake\Core\Plugin;
use Cake\Filesystem\Filesystem;
use Cake\Utility\Filesystem;

/**
* Copies the sample layouts into the application's layout templates folder.
Expand All @@ -18,7 +18,7 @@ class CopyLayoutsCommand extends Command
/**
* @inheritDoc
*/
public function execute(Arguments $args, ConsoleIo $io)
public function execute(Arguments $args, ConsoleIo $io): ?int
{
$io->info('Copying sample layouts...');

Expand Down
8 changes: 4 additions & 4 deletions src/Command/InstallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use Cake\Console\ConsoleIo;
use Cake\Console\ConsoleOptionParser;
use Cake\Core\Plugin;
use Cake\Filesystem\Filesystem;
use Cake\Utility\Filesystem;

/**
* Installs Bootstrap dependencies and links the assets to the application's webroot.
Expand All @@ -20,7 +20,7 @@ class InstallCommand extends Command
/**
* @inheritDoc
*/
public function execute(Arguments $args, ConsoleIo $io)
public function execute(Arguments $args, ConsoleIo $io): ?int
{
$this->installPackages($args, $io);
$this->refreshAssetBuffer($io);
Expand Down Expand Up @@ -250,7 +250,7 @@ protected function _deleteBufferedPackageAssets(ConsoleIo $io): bool
/**
* Finds the buffered package assets.
*
* @return \SplFileInfo[]
* @return array<\SplFileInfo>
*/
protected function _findBufferedPackageAssets(): array
{
Expand Down Expand Up @@ -344,7 +344,7 @@ protected function _bufferPackageAssets(ConsoleIo $io): bool
/**
* Finds the package assets to buffer.
*
* @return \SplFileInfo[]
* @return array<\SplFileInfo>
*/
protected function _findPackageAssets(): array
{
Expand Down
6 changes: 3 additions & 3 deletions src/Command/ModifyViewCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class ModifyViewCommand extends Command
/**
* @inheritDoc
*/
public function execute(Arguments $args, ConsoleIo $io)
public function execute(Arguments $args, ConsoleIo $io): ?int
{
$io->info('Modifying view...');

Expand Down Expand Up @@ -86,9 +86,9 @@ protected function _isFile(string $filePath): bool
* Reads a files contents.
*
* @param string $filePath The file path.
* @return false|string
* @return string|false
*/
protected function _readFile(string $filePath)
protected function _readFile(string $filePath): false|string
{
return file_get_contents($filePath);
}
Expand Down
4 changes: 2 additions & 2 deletions src/View/Helper/BreadcrumbsHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class BreadcrumbsHelper extends CoreBreadcrumbsHelper
/**
* @inheritDoc
*/
protected $_defaultConfig = [
protected array $_defaultConfig = [
'ariaCurrent' => 'last',
'templates' => [
'wrapper' => '<nav aria-label="breadcrumb"><ol{{attrs}}>{{content}}</ol></nav>',
Expand All @@ -27,7 +27,7 @@ class BreadcrumbsHelper extends CoreBreadcrumbsHelper
*
* @var array
*/
protected $_defaultAttributes = [
protected array $_defaultAttributes = [
'class' => [
'wrapper' => 'breadcrumb',
'item' => 'breadcrumb-item',
Expand Down
5 changes: 3 additions & 2 deletions src/View/Helper/FlashHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
namespace BootstrapUI\View\Helper;

use Cake\View\Helper;
use UnexpectedValueException;

/**
* FlashHelper class to render flash messages.
Expand All @@ -20,7 +21,7 @@ class FlashHelper extends Helper
*
* @var array<string, mixed>
*/
protected $_defaultConfig = [
protected array $_defaultConfig = [
'class' => ['alert', 'alert-dismissible', 'fade', 'show', 'd-flex', 'align-items-center'],
'attributes' => ['role' => 'alert'],
'icon' => true,
Expand Down Expand Up @@ -55,7 +56,7 @@ public function render(string $key = 'flash', array $options = []): ?string
}

if (!is_array($stack)) {
throw new \UnexpectedValueException(sprintf(
throw new UnexpectedValueException(sprintf(
'Value for flash setting key "%s" must be an array.',
$key
));
Expand Down
Loading

0 comments on commit 7ce12a7

Please sign in to comment.