Skip to content

Commit

Permalink
bumped to php 7.3
Browse files Browse the repository at this point in the history
  • Loading branch information
simialbi committed Jul 28, 2022
1 parent db02017 commit 48d26f2
Show file tree
Hide file tree
Showing 22 changed files with 124 additions and 85 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: build

on: [push, pull_request]

env:
DEFAULT_COMPOSER_FLAGS: "--prefer-dist --no-interaction --no-progress --optimize-autoloader"

jobs:
phpunit:
name: PHP ${{ matrix.php }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
php: ['7.3', '7.4', '8.0', '8.1']

steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: apc, curl, dom, intl, mbstring, mcrypt
ini-values: date.timezone='UTC'
- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache composer dependencies
uses: actions/cache@v1
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
- name: Install dependencies
run: composer update $DEFAULT_COMPOSER_FLAGS
- name: PHP Unit tests
run: vendor/bin/phpunit --verbose
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,5 @@ composer.lock
# phpunit itself is not needed
phpunit.phar
# local phpunit config
/phpunit.xml
/phpunit.xml
.phpunit.result.cache
113 changes: 59 additions & 54 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,58 +1,63 @@
{
"name": "simialbi/yii2-rest-client",
"type": "yii2-extension",
"description": "REST client (AR-like model) for Yii Framework 2.0 (via yii2-http-client, extends ApexWire/yii2-restclient)",
"keywords": [
"yii2",
"rest",
"client",
"model",
"active record"
],
"license": "MIT",
"authors": [
{
"name": "ApexWire",
"email": "[email protected]"
"name": "simialbi/yii2-rest-client",
"type": "yii2-extension",
"description": "REST client (AR-like model) for Yii Framework 2.0 (via yii2-http-client, extends ApexWire/yii2-restclient)",
"keywords": [
"yii2",
"rest",
"client",
"model",
"active record"
],
"license": "MIT",
"authors": [
{
"name": "ApexWire",
"email": "[email protected]"
},
{
"name": "simialbi",
"email": "[email protected]"
}
],
"support": {
"source": "https://github.com/simialbi/yii2-rest-client",
"issues": "https://github.com/simialbi/yii2-rest-client/issues"
},
{
"name": "simialbi",
"email": "[email protected]"
}
],
"support": {
"source": "https://github.com/simialbi/yii2-rest-client",
"issues": "https://github.com/simialbi/yii2-rest-client/issues"
},
"minimum-stability": "beta",
"require": {
"php": ">=7.0",
"yiisoft/yii2": "^2.0.14",
"yiisoft/yii2-httpclient": "^2.0.0"
},
"require-dev": {
"yiisoft/yii2-coding-standards": "~2.0",
"phpunit/phpunit": "^5.0.0"
},
"autoload": {
"psr-4": {
"simialbi\\yii2\\rest\\": "src"
}
},
"autoload-dev": {
"psr-4": {
"yiiunit\\extensions\\rest\\": "tests"
}
},
"repositories": [
{
"type": "composer",
"url": "https://asset-packagist.org"
}
],
"extra": {
"branch-alias": {
"dev-master": "2.0.x-dev"
"minimum-stability": "beta",
"require": {
"php": ">=7.3",
"yiisoft/yii2": "^2.0.14",
"yiisoft/yii2-httpclient": "^2.0.0"
},
"require-dev": {
"yiisoft/yii2-coding-standards": "~2.0",
"phpunit/phpunit": "^9.5.21"
},
"autoload": {
"psr-4": {
"simialbi\\yii2\\rest\\": "src"
}
},
"autoload-dev": {
"psr-4": {
"yiiunit\\extensions\\rest\\": "tests"
}
},
"repositories": [
{
"type": "composer",
"url": "https://asset-packagist.org"
}
],
"extra": {
"branch-alias": {
"dev-master": "2.0.x-dev"
}
},
"config": {
"allow-plugins": {
"yiisoft/yii2-composer": true
}
}
}
}
2 changes: 1 addition & 1 deletion src/ActiveFixture.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public function getModel($name)
$modelClass = $this->modelClass;
$keys = [];
foreach ($modelClass::primaryKey() as $key) {
$keys[$key] = isset($row[$key]) ? $row[$key] : null;
$keys[$key] = $row[$key] ?? null;
}

/* @var $model ActiveRecord */
Expand Down
4 changes: 2 additions & 2 deletions src/ActiveQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function createCommand($db = null): Command
* {@inheritdoc}
* @throws InvalidConfigException
*/
public function prepare($builder)
public function prepare($builder): Query
{
if (!empty($this->joinWith)) {
$this->buildJoinWith();
Expand Down Expand Up @@ -179,7 +179,7 @@ private function joinWithRelation(ActiveQuery $parent, ActiveQuery $child)
/**
* {@inheritdoc}
*/
public function all($db = null)
public function all($db = null): array
{
return parent::all($db);
}
Expand Down
4 changes: 2 additions & 2 deletions src/ActiveRecord.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public static function find(): ActiveQuery
* @return null|Connection
* @throws InvalidConfigException
*/
public static function getDb()
public static function getDb(): ?Connection
{
/* @var $connection Connection */
return Yii::$app->get(Connection::getDriverName());
Expand Down Expand Up @@ -129,7 +129,7 @@ public function insert($runValidation = true, $attributes = null): bool
* @throws InvalidConfigException
* @throws Exception
*/
protected function insertInternal($attributes): bool
protected function insertInternal(?array $attributes): bool
{
if (!$this->beforeSave(true)) {
return false;
Expand Down
3 changes: 2 additions & 1 deletion src/Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

use Yii;
use yii\base\Component;
use yii\base\InvalidConfigException;
use yii\helpers\ArrayHelper;
use yii\helpers\Inflector;

Expand Down Expand Up @@ -186,7 +187,7 @@ public function update(string $model, array $data = [], string $id = null)
* @param string $model
* @param string|null $id
*
* @return mixed
* @return array|false
* @throws Exception
*/
public function delete(string $model, string $id = null)
Expand Down
2 changes: 1 addition & 1 deletion src/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ public function noCache(callable $callable)
* @throws InvalidConfigException
* @internal
*/
public function getQueryCacheInfo(int $duration = null, \yii\caching\Dependency $dependency = null)
public function getQueryCacheInfo(int $duration = null, \yii\caching\Dependency $dependency = null): ?array
{
if (!$this->enableQueryCache) {
return null;
Expand Down
4 changes: 2 additions & 2 deletions src/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function __construct($modelClass, array $config = [])
/**
* {@inheritDoc}
*/
public static function create($from)
public static function create($from): self
{
$modelClass = ($from->hasProperty('modelClass')) ? $from->modelClass : null;

Expand Down Expand Up @@ -74,7 +74,7 @@ public static function create($from)
*
* @return $this a prepared query instance which will be used by [[QueryBuilder]] to build the SQL
*/
public function prepare($builder)
public function prepare($builder): self
{
return $this;
}
Expand Down
8 changes: 3 additions & 5 deletions src/QueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,7 @@ public function buildJoin($joins, &$params): string
*/
public function buildWhere($condition, &$params): array
{
$where = $this->buildCondition($condition, $params);

return $where;
return $this->buildCondition($condition, $params);
}

/**
Expand All @@ -162,7 +160,7 @@ public function buildWhere($condition, &$params): array
*/
public function buildCondition($condition, &$params): array
{
if ($condition instanceof Expression || empty($condition) || !is_array($condition)) {
if (empty($condition) || !is_array($condition)) {
return [];
}

Expand Down Expand Up @@ -246,7 +244,7 @@ public function buildLimit($limit, $offset)
/**
* {@inheritdoc}
*/
public function bindParam($value, &$params)
public function bindParam($value, &$params): ?string
{
return $value;
}
Expand Down
1 change: 0 additions & 1 deletion src/conditions/BetweenConditionBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

namespace simialbi\yii2\rest\conditions;


use yii\db\conditions\BetweenCondition;
use yii\db\ExpressionInterface;

Expand Down
1 change: 0 additions & 1 deletion src/conditions/ConditionBuilderTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

namespace simialbi\yii2\rest\conditions;


use yii\data\DataFilter;
use yii\helpers\ArrayHelper;

Expand Down
1 change: 0 additions & 1 deletion src/conditions/ConjunctionConditionBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

namespace simialbi\yii2\rest\conditions;


use yii\db\conditions\ConjunctionCondition;
use yii\db\ExpressionInterface;

Expand Down
1 change: 0 additions & 1 deletion src/conditions/HashConditionBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

namespace simialbi\yii2\rest\conditions;


use simialbi\yii2\rest\Query;
use yii\db\conditions\InCondition;
use yii\db\ExpressionInterface;
Expand Down
1 change: 0 additions & 1 deletion src/conditions/NotConditionBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

namespace simialbi\yii2\rest\conditions;


use yii\db\conditions\NotCondition;
use yii\db\ExpressionInterface;

Expand Down
2 changes: 1 addition & 1 deletion tests/RelationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

class RelationTest extends TestCase
{
protected function setUp()
protected function setUp(): void
{
parent::setUp();

Expand Down
6 changes: 3 additions & 3 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class TestCase extends \PHPUnit\Framework\TestCase
/**
* {@inheritdoc}
*/
protected function tearDown()
protected function tearDown(): void
{
parent::tearDown();
$this->destroyApplication();
Expand All @@ -28,7 +28,7 @@ protected function tearDown()
* @param array $config
* @param string $appClass
*/
protected function mockWebApplication($config = [], $appClass = '\yii\web\Application')
protected function mockWebApplication(array $config = [], string $appClass = '\yii\web\Application')
{
new $appClass(ArrayHelper::merge([
'id' => 'testapp',
Expand Down Expand Up @@ -75,7 +75,7 @@ protected function destroyApplication()
* Parse log from index and returns data
* @return array
*/
protected function parseLogs()
protected function parseLogs(): array
{
$method = '';
$url = '';
Expand Down
2 changes: 1 addition & 1 deletion tests/UrlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

class UrlTest extends TestCase
{
protected function setUp()
protected function setUp(): void
{
parent::setUp();

Expand Down
2 changes: 1 addition & 1 deletion tests/UrlWithoutPluralisationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

class UrlWithoutPluralisationTest extends TestCase
{
protected function setUp()
protected function setUp(): void
{
parent::setUp();

Expand Down
4 changes: 2 additions & 2 deletions tests/log/ArrayTarget.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ public function export()
* Getter for cache variable
* @return array
*/
public function getCache()
public function getCache(): array
{
return $this->_cache;
}
}
}
2 changes: 1 addition & 1 deletion tests/models/RelatedRestModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class RelatedRestModel extends ActiveRecord
/**
* {@inheritDoc}
*/
public static function primaryKey()
public static function primaryKey(): array
{
return ['id'];
}
Expand Down
Loading

0 comments on commit 48d26f2

Please sign in to comment.