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

Draft PHP 8.1 branch 2.2. #305

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
100 changes: 26 additions & 74 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,80 +1,32 @@
on:
- pull_request
- push
pull_request:
paths-ignore:
- 'docs/**'
- 'README.md'
- 'CHANGELOG.md'
- '.gitignore'
- '.gitattributes'
- 'infection.json.dist'
- 'psalm.xml'

push:
paths-ignore:
- 'docs/**'
- 'README.md'
- 'CHANGELOG.md'
- '.gitignore'
- '.gitattributes'
- 'infection.json.dist'
- 'psalm.xml'

name: build

jobs:
tests:
name: PHP ${{ matrix.php }} - ${{ matrix.os }}

env:
build:
uses: yiisoft/actions/.github/workflows/codeception.yml@master
with:
extensions: dom, json, gd, imagick
key: cache-v1

runs-on: ${{ matrix.os }}

strategy:
matrix:
os:
- ubuntu-latest
- windows-latest

php:
- "7.4"
- "8.0"
- "8.1"

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Setup cache environment
id: cache-env
uses: shivammathur/cache-extensions@v1
with:
php-version: ${{ matrix.php }}
extensions: ${{ env.extensions }}
key: ${{ env.key }}

- name: Cache extensions
uses: actions/cache@v1
with:
path: ${{ steps.cache-env.outputs.dir }}
key: ${{ steps.cache-env.outputs.key }}
restore-keys: ${{ steps.cache-env.outputs.key }}

- name: Install PHP with extensions
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: ${{ env.extensions }}
ini-values: date.timezone='UTC'

- name: Determine composer cache directory on Linux
if: matrix.os == 'ubuntu-latest'
run: |
echo "COMPOSER_CACHE_DIR=$(composer config cache-dir)" >> $GITHUB_ENV

- name: Determine composer cache directory on Windows
if: matrix.os == 'windows-latest'
run: |
echo "COMPOSER_CACHE_DIR=~\AppData\Local\Composer" >> $GITHUB_ENV

- name: Cache dependencies installed with composer
uses: actions/cache@v1
with:
path: ${{ steps.cache-env.outputs.dir }}
key: php${{ matrix.php }}-composer-${{ matrix.dependencies }}-${{ hashFiles('**/composer.json') }}
restore-keys: |
php${{ matrix.php }}-composer-${{ matrix.dependencies }}-

- name: Install dependencies with composer php PHP [5.6 - 8.0]
run: composer update --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi

- name: Run tests with codeception
run: |
sed -i "s/'cookieValidationKey' => ''/'cookieValidationKey' => 'testkey'/" config/web.php
php -S 127.0.0.1:8080 -t public > ./runtime/yii.log 2>&1 &
vendor/bin/codecept run
shell: bash
os: >-
['ubuntu-latest', 'windows-latest']
php: >-
['8.1', '8.2']
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,7 @@ tests/_output/*
tests/_support/_generated

#vagrant folder
/.vagrant
/.vagrant

#codeception
/c3.php
44 changes: 44 additions & 0 deletions .scrutinizer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
checks:
php: true

filter:
paths:
- "/*"
excluded_paths:
- "/config/*"
- "/runtime/*"
- "/tests/Support/*"
- "/vagrant/*"
- "/vendor/*"

build:
image: default-bionic

environment:
variables:
YII_ENV: test

php:
version: 8.1.21
ini:
xdebug.mode: coverage

nodes:
analysis:
tests:
override:
- php-scrutinizer-run

codeception:
dependencies:
override:
- composer self-update
- composer update --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi

tests:
override:
- command: vendor/bin/codecept run --coverage-xml
on_node: 1
coverage:
file: runtime/_output/coverage.xml
format: php-clover
3 changes: 3 additions & 0 deletions assets/AppAsset.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<?php

declare(strict_types=1);

/**
* @link https://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
Expand Down
13 changes: 10 additions & 3 deletions codeception.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,23 @@ actor: Tester
bootstrap: _bootstrap.php
paths:
tests: tests
output: tests/_output
data: tests/_data
helpers: tests/_support
output: runtime/_output
data: tests/Support/data
helpers: tests/Support
settings:
memory_limit: 1024M
colors: true
modules:
config:
Yii2:
configFile: 'config/test.php'
coverage:
enabled: true
include:
- /*
exclude:
- tests/*
- vendor/*

# To enable code coverage:
#coverage:
Expand Down
9 changes: 7 additions & 2 deletions commands/HelloController.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<?php

declare(strict_types=1);

/**
* @link https://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
Expand All @@ -18,14 +21,16 @@
* @author Qiang Xue <[email protected]>
* @since 2.0
*/
class HelloController extends Controller
final class HelloController extends Controller
{
/**
* This command echoes what you have entered as the message.
*
* @param string $message the message to be echoed.
*
* @return int Exit code
*/
public function actionIndex($message = 'hello world')
public function actionIndex(string $message = 'hello world'): int
{
echo $message . "\n";

Expand Down
27 changes: 15 additions & 12 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,30 @@
},
"minimum-stability": "dev",
"require": {
"php": ">=7.4.0",
"yiisoft/yii2": "~2.0.45",
"php": ">=8.1",
"yiisoft/yii2": "2.2.x-dev as 2.0.48.1",
"yiisoft/yii2-bootstrap5": "~2.0.2",
"yiisoft/yii2-symfonymailer": "~2.0.3"
},
"require-dev": {
"codeception/c3": "^2.8",
"codeception/codeception": "^5.0.0",
"codeception/lib-innerbrowser": "^4.0",
"codeception/module-asserts": "^3.0",
"codeception/module-filesystem": "^3.0",
"codeception/module-yii2": "^1.1",
"codeception/verify": "^3.0",
"maglnet/composer-require-checker": "^4.6",
"symfony/browser-kit": "^6.3",
"symfony/process": "^6.3",
"yiisoft/yii2-debug": "~2.1.0",
"yiisoft/yii2-gii": "~2.2.0",
"yiisoft/yii2-faker": "~2.0.0",
"phpunit/phpunit": "~9.5.0",
"codeception/codeception": "^5.0.0 || ^4.0",
"codeception/lib-innerbrowser": "^4.0 || ^3.0 || ^1.1",
"codeception/module-asserts": "^3.0 || ^1.1",
"codeception/module-yii2": "^1.1",
"codeception/module-filesystem": "^3.0 || ^2.0 || ^1.1",
"codeception/verify": "^3.0 || ^2.2",
"symfony/browser-kit": "^6.0 || >=2.7 <=4.2.4"
"yiisoft/yii2-gii": "~2.2.0"
},
"config": {
"allow-plugins": {
"yiisoft/yii2-composer" : true
"yiisoft/yii2-composer": true,
"codeception/c3": true
},
"process-timeout": 1800,
"fxp-asset": {
Expand Down
2 changes: 1 addition & 1 deletion config/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
'components' => [
'request' => [
// !!! insert a secret key in the following (if it is empty) - this is required by cookie validation
'cookieValidationKey' => '',
'cookieValidationKey' => '1',
],
'cache' => [
'class' => 'yii\caching\FileCache',
Expand Down
18 changes: 10 additions & 8 deletions controllers/SiteController.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace app\controllers;

use Yii;
Expand All @@ -10,12 +12,12 @@
use app\models\LoginForm;
use app\models\ContactForm;

class SiteController extends Controller
final class SiteController extends Controller
{
/**
* {@inheritdoc}
*/
public function behaviors()
public function behaviors(): array
{
return [
'access' => [
Expand All @@ -41,7 +43,7 @@ public function behaviors()
/**
* {@inheritdoc}
*/
public function actions()
public function actions(): array
{
return [
'error' => [
Expand All @@ -59,7 +61,7 @@ public function actions()
*
* @return string
*/
public function actionIndex()
public function actionIndex(): string
{
return $this->render('index');
}
Expand All @@ -69,7 +71,7 @@ public function actionIndex()
*
* @return Response|string
*/
public function actionLogin()
public function actionLogin(): Response|string
{
if (!Yii::$app->user->isGuest) {
return $this->goHome();
Expand All @@ -91,7 +93,7 @@ public function actionLogin()
*
* @return Response
*/
public function actionLogout()
public function actionLogout(): Response
{
Yii::$app->user->logout();

Expand All @@ -103,7 +105,7 @@ public function actionLogout()
*
* @return Response|string
*/
public function actionContact()
public function actionContact(): Response|string
{
$model = new ContactForm();
if ($model->load(Yii::$app->request->post()) && $model->contact(Yii::$app->params['adminEmail'])) {
Expand All @@ -121,7 +123,7 @@ public function actionContact()
*
* @return string
*/
public function actionAbout()
public function actionAbout(): string
{
return $this->render('about');
}
Expand Down
Loading