Skip to content

Commit

Permalink
Fix up for PHP7.3
Browse files Browse the repository at this point in the history
  • Loading branch information
dereuromark committed Oct 27, 2021
1 parent 9136717 commit e50fd8e
Show file tree
Hide file tree
Showing 10 changed files with 29 additions and 20 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 13,4 @@ phpunit.xml.dist export-ignore
.editorconfig export-ignore
tests/test_app export-ignore
tests/test_files export-ignore
.github/ export-ignore
14 changes: 7 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 7,15 @@ on:

jobs:
testsuite:
runs-on: ubuntu-18.04
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
php-version: ['7.2', '8.0']
php-version: ['7.3', '8.0']
db-type: [sqlite, mysql, pgsql]
prefer-lowest: ['']
include:
- php-version: '7.2'
- php-version: '7.3'
db-type: 'sqlite'
prefer-lowest: 'prefer-lowest'

Expand Down Expand Up @@ -63,13 63,13 @@ jobs:
else
composer install --no-progress --prefer-dist --optimize-autoloader
fi
if ${{ matrix.prefer-lowest == 'prefer-lowest' }}; then composer require --dev dereuromark/composer-prefer-lowest:dev-master; fi
if ${{ matrix.prefer-lowest == 'prefer-lowest' }}; then composer lowest-setup; fi
- name: Run PHPUnit
run: |
if [[ ${{ matrix.db-type }} == 'sqlite' ]]; then export DB_URL='sqlite:///:memory:'; fi
if [[ ${{ matrix.db-type }} == 'mysql' ]]; then export DB_URL='mysql://root:[email protected]/cakephp'; fi
if [[ ${{ matrix.db-type }} == 'pgsql' ]]; then export DB_URL='postgres://postgres:[email protected]/postgres'; fi
if [[ ${{ matrix.php-version }} == '7.2' && ${{ matrix.db-type }} == 'sqlite' ]]; then
if [[ ${{ matrix.php-version }} == '7.3' && ${{ matrix.db-type }} == 'sqlite' ]]; then
vendor/bin/phpunit --coverage-clover=coverage.xml
else
vendor/bin/phpunit
Expand All @@ -78,12 78,12 @@ jobs:
run: if ${{ matrix.prefer-lowest == 'prefer-lowest' }}; then vendor/bin/validate-prefer-lowest -m; fi

- name: Code Coverage Report
if: success() && matrix.php-version == '7.2' && matrix.db-type == 'sqlite'
if: success() && matrix.php-version == '7.3' && matrix.db-type == 'sqlite'
uses: codecov/codecov-action@v1

validation:
name: Coding Standard & Static Analysis
runs-on: ubuntu-18.04
runs-on: ubuntu-20.04

steps:
- uses: actions/checkout@v2
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 3,20 @@
[![CI](https://github.com/dereuromark/cakephp-setup/workflows/CI/badge.svg?branch=master)](https://github.com/dereuromark/cakephp-setup/actions?query=workflow:CI branch:master)
[![Coverage](https://img.shields.io/codecov/c/github/dereuromark/cakephp-setup/master.svg)](https://codecov.io/gh/dereuromark/cakephp-setup)
[![Latest Stable Version](https://poser.pugx.org/dereuromark/cakephp-setup/v/stable.svg)](https://packagist.org/packages/dereuromark/cakephp-setup)
[![Minimum PHP Version](https://img.shields.io/badge/php->= 7.2-8892BF.svg)](https://php.net/)
[![Minimum PHP Version](https://img.shields.io/badge/php->= 7.3-8892BF.svg)](https://php.net/)
[![License](https://poser.pugx.org/dereuromark/cakephp-setup/license.svg)](https://packagist.org/packages/dereuromark/cakephp-setup)
[![Total Downloads](https://poser.pugx.org/dereuromark/cakephp-setup/d/total.svg)](https://packagist.org/packages/dereuromark/cakephp-setup)
[![Coding Standards](https://img.shields.io/badge/cs-PSR--2--R-yellow.svg)](https://github.com/php-fig-rectified/fig-rectified-standards)

Provides useful development tools for managing a CakePHP app.

Note: This branch is for **CakePHP 4.0 **. See [version map](https://github.com/dereuromark/cakephp-setup/wiki#cakephp-version-map) for details.
Note: This branch is for **CakePHP 4.2 **. See [version map](https://github.com/dereuromark/cakephp-setup/wiki#cakephp-version-map) for details.

## What is this plugin for?
This plugin aims to be a help for development of CakePHP applications. It extends and leverages
my Tools Plugin.

Currently this plugin contains only the parts I managed to migrate yet:
Currently, this plugin contains only the parts I managed to migrate yet:

* Maintenance Mode (dynamic activation and deactivation incl. dynamic IP whitelisting)
* Some very useful development tools and debugging shells
Expand Down
7 changes: 4 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 13,14 @@
}
],
"require": {
"php": ">=7.2",
"cakephp/cakephp": "^4.0.2"
"php": ">=7.3",
"cakephp/cakephp": "^4.2.0"
},
"require-dev": {
"cakephp/bake": "^2.1.0",
"dereuromark/cakephp-tools": "^2.0.0",
"fig-r/psr2r-sniffer": "dev-master"
"fig-r/psr2r-sniffer": "dev-master",
"spryker/code-sniffer": "dev-master"
},
"autoload": {
"psr-4": {
Expand Down
2 changes: 1 addition & 1 deletion src/Shell/DbConstraintsShell.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 145,7 @@ public function getOptionParser(): ConsoleOptionParser {
*
* @throws \RuntimeException
*
* @return \Cake\ORM\Table[]
* @return array<\Cake\ORM\Table>
*/
protected function _getModels($model, $plugin) {
if ($model) {
Expand Down
2 changes: 1 addition & 1 deletion src/Shell/IndentShell.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 132,7 @@ public function folder() {

/**
* @param string $file
* @param string[] $texts
* @param array<string> $texts
* @return bool Success
*/
protected function _write($file, $texts) {
Expand Down
2 changes: 1 addition & 1 deletion src/Shell/UserShell.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 44,7 @@ public function index($role = null) {
$query = $query->where(['role_id' => (int)$role]);
}

/** @var \App\Model\Entity\User[] $users */
/** @var array<\App\Model\Entity\User> $users */
$users = $query->orderDesc($this->Users->getPrimaryKey())->limit(100)->all()->toArray();

$count = count($users);
Expand Down
6 changes: 3 additions & 3 deletions src/View/Helper/SetupBakeHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 105,9 @@ public function isPaginationOrderReversed(string $field, TableSchemaInterface $s
/**
* Get field accessibility data.
*
* @param string[]|false|null $fields Fields list.
* @param string[]|null $primaryKey Primary key.
* @return bool[]
* @param array<string>|false|null $fields Fields list.
* @param array<string>|null $primaryKey Primary key.
* @return array<bool>
*/
public function getFieldAccessibility($fields = null, $primaryKey = null): array {
$accessibleFields = parent::getFieldAccessibility($fields, $primaryKey);
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/Controller/Admin/BackendControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 12,7 @@ class BackendControllerTest extends TestCase {
use IntegrationTestTrait;

/**
* @var string[]
* @var array<string>
*/
protected $fixtures = [
'core.Sessions',
Expand Down
7 changes: 7 additions & 0 deletions tests/test_app/src/Model/Entity/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 22,14 @@ public static function statuses($value = null) {
return parent::enum($value, $options);
}

/**
* @var int
*/
public const STATUS_INACTIVE = 0;

/**
* @var int
*/
public const STATUS_ACTIVE = 1;

}

0 comments on commit e50fd8e

Please sign in to comment.