Skip to content

Commit

Permalink
Merge pull request #18 from kenjis/update-dependencies
Browse files Browse the repository at this point in the history
PHP 8.1対応
  • Loading branch information
kenjis authored Oct 4, 2022
2 parents b88bcea + dc10401 commit 5dddbd7
Show file tree
Hide file tree
Showing 50 changed files with 4,019 additions and 10,173 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/coding-standards.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.0
php-version: 8.1
tools: cs2pr
coverage: none
env:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/phpunit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:

strategy:
matrix:
php-versions: ['8.0']
php-versions: ['8.1']
db-platforms: ['MySQLi']

services:
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.0
php-version: 8.1
tools: cs2pr
coverage: none
env:
Expand Down Expand Up @@ -57,7 +57,7 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.0
php-version: 8.1
tools: cs2pr
coverage: none
env:
Expand Down Expand Up @@ -90,7 +90,7 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.0
php-version: 8.1
env:
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Expand Down Expand Up @@ -121,7 +121,7 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.0
php-version: 8.1
coverage: none
env:
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down Expand Up @@ -153,7 +153,7 @@ jobs:
# - name: Setup PHP
# uses: shivammathur/setup-php@v2
# with:
# php-version: 8.0
# php-version: 8.1
# coverage: none
# tools: composer-require-checker
# env:
Expand Down
18 changes: 12 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,18 @@

## 動作確認環境

- CodeIgniter 4.1.8 ([ci4-app-template](https://github.com/kenjis/ci4-app-template) を使用)
- PHP 8.0.14
- Composer 2.1.14
### アプリ

- CodeIgniter 4.2.6 ([ci4-app-template](https://github.com/kenjis/ci4-app-template) を使用)
- PHP 8.1.11
- Composer 2.4.2
- MySQL 5.7

### 受入テスト

- selenium-server 4.5.0
- geckodriver 0.31.0

## 「CodeIgniter 3.xで動作するように更新したもの」からの変更点

- アプリケーションクラスを名前空間付きに移行
Expand Down Expand Up @@ -60,7 +67,6 @@
- Ray.Di <https://github.com/Ray-Di/Ray.Di>
- CodeIgniter4 Attribute Routes <https://github.com/kenjis/ci4-attribute-routes>
- PHPUnit Helper <https://github.com/kenjis/phpunit-helper>
- bear/qatools <https://github.com/bearsunday/BEAR.QATools>

## インストール方法

Expand Down Expand Up @@ -129,14 +135,14 @@ $ composer coverage
Homebrewからselenium-server-standaloneとgeckodriverをインストールします。

~~~
$ brew install selenium-server-standalone
$ brew install selenium-server
$ brew install geckodriver
~~~

Seleniumサーバを起動します。

~~~
$ selenium-server standalone --port 4444
$ selenium-server standalone
~~~

受入テストを実行します。
Expand Down
10 changes: 6 additions & 4 deletions app/Config/App.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Config;

use CodeIgniter\Config\BaseConfig;
use CodeIgniter\Session\Handlers\FileHandler;

class App extends BaseConfig
{
Expand Down Expand Up @@ -43,7 +44,7 @@ class App extends BaseConfig
* URI PROTOCOL
* --------------------------------------------------------------------------
*
* This item determines which getServer global should be used to retrieve the
* This item determines which server global should be used to retrieve the
* URI string. The default setting of 'REQUEST_URI' works for most servers.
* If your links do not seem to work, try one of the other delicious flavors:
*
Expand Down Expand Up @@ -151,7 +152,7 @@ class App extends BaseConfig
*
* @var string
*/
public $sessionDriver = 'CodeIgniter\Session\Handlers\FileHandler';
public $sessionDriver = FileHandler::class;

/**
* --------------------------------------------------------------------------
Expand Down Expand Up @@ -318,7 +319,7 @@ class App extends BaseConfig
* (empty string) means default SameSite attribute set by browsers (`Lax`)
* will be set on cookies. If set to `None`, `$cookieSecure` must also be set.
*
* @var string
* @var string|null
*
* @deprecated use Config\Cookie::$samesite property instead.
*/
Expand Down Expand Up @@ -436,7 +437,8 @@ class App extends BaseConfig
* Defaults to `Lax` as recommended in this link:
*
* @see https://portswigger.net/web-security/csrf/samesite-cookies
* @deprecated Use `Config\Security` $samesite property instead of using this property.
*
* @deprecated `Config\Cookie` $samesite property is used.
*
* @var string
*/
Expand Down
39 changes: 27 additions & 12 deletions app/Config/Constants.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@
defined('HOUR') || define('HOUR', 3600);
defined('DAY') || define('DAY', 86400);
defined('WEEK') || define('WEEK', 604800);
defined('MONTH') || define('MONTH', 2592000);
defined('YEAR') || define('YEAR', 31536000);
defined('DECADE') || define('DECADE', 315360000);
defined('MONTH') || define('MONTH', 2_592_000);
defined('YEAR') || define('YEAR', 31_536_000);
defined('DECADE') || define('DECADE', 315_360_000);

/*
| --------------------------------------------------------------------------
Expand All @@ -67,13 +67,28 @@
| http://tldp.org/LDP/abs/html/exitcodes.html
|
*/
defined('EXIT_SUCCESS') || define('EXIT_SUCCESS', 0); // no errors
defined('EXIT_ERROR') || define('EXIT_ERROR', 1); // generic error
defined('EXIT_CONFIG') || define('EXIT_CONFIG', 3); // configuration error
defined('EXIT_UNKNOWN_FILE') || define('EXIT_UNKNOWN_FILE', 4); // file not found
defined('EXIT_UNKNOWN_CLASS') || define('EXIT_UNKNOWN_CLASS', 5); // unknown class
defined('EXIT_SUCCESS') || define('EXIT_SUCCESS', 0); // no errors
defined('EXIT_ERROR') || define('EXIT_ERROR', 1); // generic error
defined('EXIT_CONFIG') || define('EXIT_CONFIG', 3); // configuration error
defined('EXIT_UNKNOWN_FILE') || define('EXIT_UNKNOWN_FILE', 4); // file not found
defined('EXIT_UNKNOWN_CLASS') || define('EXIT_UNKNOWN_CLASS', 5); // unknown class
defined('EXIT_UNKNOWN_METHOD') || define('EXIT_UNKNOWN_METHOD', 6); // unknown class member
defined('EXIT_USER_INPUT') || define('EXIT_USER_INPUT', 7); // invalid user input
defined('EXIT_DATABASE') || define('EXIT_DATABASE', 8); // database error
defined('EXIT__AUTO_MIN') || define('EXIT__AUTO_MIN', 9); // lowest automatically-assigned error code
defined('EXIT__AUTO_MAX') || define('EXIT__AUTO_MAX', 125); // highest automatically-assigned error code
defined('EXIT_USER_INPUT') || define('EXIT_USER_INPUT', 7); // invalid user input
defined('EXIT_DATABASE') || define('EXIT_DATABASE', 8); // database error
defined('EXIT__AUTO_MIN') || define('EXIT__AUTO_MIN', 9); // lowest automatically-assigned error code
defined('EXIT__AUTO_MAX') || define('EXIT__AUTO_MAX', 125); // highest automatically-assigned error code

/**
* @deprecated Use \CodeIgniter\Events\Events::PRIORITY_LOW instead.
*/
define('EVENT_PRIORITY_LOW', 200);

/**
* @deprecated Use \CodeIgniter\Events\Events::PRIORITY_NORMAL instead.
*/
define('EVENT_PRIORITY_NORMAL', 100);

/**
* @deprecated Use \CodeIgniter\Events\Events::PRIORITY_HIGH instead.
*/
define('EVENT_PRIORITY_HIGH', 10);
29 changes: 25 additions & 4 deletions app/Config/ContentSecurityPolicy.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
*/
class ContentSecurityPolicy extends BaseConfig
{
//-------------------------------------------------------------------------
// -------------------------------------------------------------------------
// Broadbrush CSP management
//-------------------------------------------------------------------------
// -------------------------------------------------------------------------

/**
* Default CSP report context
Expand All @@ -43,10 +43,10 @@ class ContentSecurityPolicy extends BaseConfig
*/
public $upgradeInsecureRequests = false;

//-------------------------------------------------------------------------
// -------------------------------------------------------------------------
// Sources allowed
// Note: once you set a policy to 'none', it cannot be further restricted
//-------------------------------------------------------------------------
// -------------------------------------------------------------------------

/**
* Will default to self if not overridden
Expand Down Expand Up @@ -164,4 +164,25 @@ class ContentSecurityPolicy extends BaseConfig
* @var string|string[]|null
*/
public $sandbox;

/**
* Nonce tag for style
*
* @var string
*/
public $styleNonceTag = '{csp-style-nonce}';

/**
* Nonce tag for script
*
* @var string
*/
public $scriptNonceTag = '{csp-script-nonce}';

/**
* Replace nonce tag automatically
*
* @var bool
*/
public $autoNonce = true;
}
1 change: 1 addition & 0 deletions app/Config/Database.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ class Database extends Config
'strictOn' => false,
'failover' => [],
'port' => 3306,
'foreignKeys' => true,
];

public function __construct()
Expand Down
4 changes: 1 addition & 3 deletions app/Config/Events.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@
ob_end_flush();
}

ob_start(static function ($buffer) {
return $buffer;
});
ob_start(static fn ($buffer) => $buffer);
}

/*
Expand Down
7 changes: 6 additions & 1 deletion app/Config/Feature.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
class Feature extends BaseConfig
{
/**
* Enable multiple filters for a route or not
* Enable multiple filters for a route or not.
*
* If you enable this:
* - CodeIgniter\CodeIgniter::handleRequest() uses:
Expand All @@ -24,4 +24,9 @@ class Feature extends BaseConfig
* @var bool
*/
public $multipleFilters = true;

/**
* Use improved new auto routing instead of the default legacy version.
*/
public bool $autoRoutesImproved = false;
}
14 changes: 12 additions & 2 deletions app/Config/Filters.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ class Filters extends BaseConfig
'before' => [
// 'honeypot',
'csrf',
'invalidchars',
// SJIS文字は不正な文字とみなされるため、BBSは除外
'invalidchars' => ['except' => 'bbs/*'],
],
'after' => [
'toolbar',
Expand All @@ -51,7 +52,11 @@ class Filters extends BaseConfig
* particular HTTP method (GET, POST, etc.).
*
* Example:
* 'post' => ['csrf', 'throttle']
* 'post' => ['foo', 'bar']
*
* If you use this, you should disable auto-routing because auto-routing
* permits any HTTP method to access a controller. Accessing the controller
* with a method you don’t expect could bypass the filter.
*
* @var array
*/
Expand All @@ -71,5 +76,10 @@ class Filters extends BaseConfig
'before' => ['bbs/*'],
'after' => ['bbs/*'],
],
// @TODO bbsフィルタの後にinvalidcharsフィルタでチェックしたいが、
// rawInputにもSJIS文字が含まれるため、一旦、コメントアウト
// 'invalidchars' => [
// 'before' => ['bbs/*'],
// ],
];
}
8 changes: 5 additions & 3 deletions app/Config/Format.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

use CodeIgniter\Config\BaseConfig;
use CodeIgniter\Format\FormatterInterface;
use CodeIgniter\Format\JSONFormatter;
use CodeIgniter\Format\XMLFormatter;

class Format extends BaseConfig
{
Expand Down Expand Up @@ -40,9 +42,9 @@ class Format extends BaseConfig
* @var array<string, string>
*/
public $formatters = [
'application/json' => 'CodeIgniter\Format\JSONFormatter',
'application/xml' => 'CodeIgniter\Format\XMLFormatter',
'text/xml' => 'CodeIgniter\Format\XMLFormatter',
'application/json' => JSONFormatter::class,
'application/xml' => XMLFormatter::class,
'text/xml' => XMLFormatter::class,
];

/**
Expand Down
5 changes: 3 additions & 2 deletions app/Config/Logger.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Config;

use CodeIgniter\Log\Handlers\FileHandler;
use CodeIgniter\Config\BaseConfig;

class Logger extends BaseConfig
Expand Down Expand Up @@ -59,7 +60,7 @@ class Logger extends BaseConfig
* The logging system supports multiple actions to be taken when something
* is logged. This is done by allowing for multiple Handlers, special classes
* designed to write the log to their chosen destinations, whether that is
* a file on the getServer, a cloud-based service, or even taking actions such
* a file on the server, a cloud-based service, or even taking actions such
* as emailing the dev team.
*
* Each handler is defined by the class name used for that handler, and it
Expand All @@ -83,7 +84,7 @@ class Logger extends BaseConfig
* File Handler
* --------------------------------------------------------------------
*/
'CodeIgniter\Log\Handlers\FileHandler' => [
FileHandler::class => [

// The log levels that this handler will handle.
'handles' => [
Expand Down
Loading

0 comments on commit 5dddbd7

Please sign in to comment.