Skip to content

Commit 8795578

Browse files
author
igor-chepurnoi
committed
added compatibility with php 7.0
1 parent e5b6ca4 commit 8795578

9 files changed

+29
-21
lines changed

.travis.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
language: php
22

33
php:
4+
- 7.0
45
- 7.1
56

67
# faster builds on new travis setup not using sudo
@@ -18,4 +19,4 @@ install:
1819

1920
script:
2021
- vendor/friendsofphp/php-cs-fixer/php-cs-fixer fix --dry-run --diff
21-
- phpunit --verbose
22+
- vendor/bin/phpunit --verbose

base/ItemController.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -227,10 +227,10 @@ protected function findModel(string $id): AuthItemModel
227227
$auth = Yii::$app->getAuthManager();
228228
$item = $this->type === Item::TYPE_ROLE ? $auth->getRole($id) : $auth->getPermission($id);
229229

230-
if ($item) {
231-
return new AuthItemModel($item);
232-
} else {
230+
if (empty($item)) {
233231
throw new NotFoundHttpException(Yii::t('yii2mod.rbac', 'The requested page does not exist.'));
234232
}
233+
234+
return new AuthItemModel($item);
235235
}
236236
}

commands/MigrateController.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class MigrateController extends BaseMigrateController
4949
/**
5050
* @inheritdoc
5151
*/
52-
public function init(): void
52+
public function init()
5353
{
5454
$this->db = Instance::ensure($this->db, Connection::class);
5555

composer.json

+5-4
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,19 @@
1717
"email": "[email protected]"
1818
},
1919
{
20-
"name": "Igor Chepurnoy",
21-
"email": "igorzfort@gmail.com"
20+
"name": "Igor Chepurnoi",
21+
"email": "chepurnoi.igor@gmail.com"
2222
}
2323
],
2424
"require": {
25-
"php": ">=7.1",
25+
"php": ">=7.0.0",
2626
"yiisoft/yii2": "~2.0.10",
2727
"2amigos/yii2-arrayquery-component": "*",
2828
"yiisoft/yii2-jui": "*"
2929
},
3030
"require-dev": {
31-
"friendsofphp/php-cs-fixer": "~2.0"
31+
"friendsofphp/php-cs-fixer": "~2.0",
32+
"phpunit/phpunit": "~6.0"
3233
},
3334
"autoload": {
3435
"psr-4": {

controllers/AssignmentController.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class AssignmentController extends Controller
4646
/**
4747
* @inheritdoc
4848
*/
49-
public function init(): void
49+
public function init()
5050
{
5151
parent::init();
5252

@@ -175,8 +175,8 @@ protected function findModel(int $id)
175175

176176
if (($user = $class::findIdentity($id)) !== null) {
177177
return new AssignmentModel($user);
178-
} else {
179-
throw new NotFoundHttpException(Yii::t('yii2mod.rbac', 'The requested page does not exist.'));
180178
}
179+
180+
throw new NotFoundHttpException(Yii::t('yii2mod.rbac', 'The requested page does not exist.'));
181181
}
182182
}

models/AuthItemModel.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public function rules(): array
9898
/**
9999
* Check role is unique
100100
*/
101-
public function unique(): void
101+
public function unique()
102102
{
103103
$value = $this->name;
104104
if ($this->manager->getRole($value) !== null || $this->manager->getPermission($value) !== null) {
@@ -114,7 +114,7 @@ public function unique(): void
114114
/**
115115
* Check for rule
116116
*/
117-
public function checkRule(): void
117+
public function checkRule()
118118
{
119119
$name = $this->ruleName;
120120

@@ -292,7 +292,7 @@ public function getItems(): array
292292
/**
293293
* @return null|Item
294294
*/
295-
public function getItem(): ?Item
295+
public function getItem()
296296
{
297297
return $this->_item;
298298
}

models/BizRuleModel.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ public function save(): bool
169169
/**
170170
* @return null|Rule
171171
*/
172-
public function getItem(): ?Rule
172+
public function getItem()
173173
{
174174
return $this->_item;
175175
}

models/RouteModel.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ public function getAppRoutes(string $module = null): array
148148
/**
149149
* Invalidate the cache
150150
*/
151-
public function invalidate(): void
151+
public function invalidate()
152152
{
153153
if ($this->cache !== null) {
154154
TagDependency::invalidate($this->cache, self::CACHE_TAG);
@@ -161,7 +161,7 @@ public function invalidate(): void
161161
* @param Module $module
162162
* @param array $result
163163
*/
164-
protected function getRouteRecursive(Module $module, &$result): void
164+
protected function getRouteRecursive(Module $module, &$result)
165165
{
166166
if (!in_array($module->id, $this->excludeModules)) {
167167
$token = "Get Route of '" . get_class($module) . "' with id '" . $module->uniqueId . "'";
@@ -198,7 +198,7 @@ protected function getRouteRecursive(Module $module, &$result): void
198198
* @param string $prefix
199199
* @param mixed $result
200200
*/
201-
protected function getControllerFiles(Module $module, string $namespace, string $prefix, &$result): void
201+
protected function getControllerFiles(Module $module, string $namespace, string $prefix, &$result)
202202
{
203203
$path = Yii::getAlias('@' . str_replace('\\', '/', $namespace), false);
204204
$token = "Get controllers from '$path'";
@@ -240,7 +240,7 @@ protected function getControllerFiles(Module $module, string $namespace, string
240240
* @param Module $module
241241
* @param mixed $result
242242
*/
243-
protected function getControllerActions($type, $id, Module $module, &$result): void
243+
protected function getControllerActions($type, $id, Module $module, &$result)
244244
{
245245
$token = 'Create controller with config=' . VarDumper::dumpAsString($type) . " and id='$id'";
246246
Yii::beginProfile($token, __METHOD__);
@@ -264,7 +264,7 @@ protected function getControllerActions($type, $id, Module $module, &$result): v
264264
* @param Controller $controller
265265
* @param array $result all controller action
266266
*/
267-
protected function getActionRoutes(Controller $controller, &$result): void
267+
protected function getActionRoutes(Controller $controller, &$result)
268268
{
269269
$token = "Get actions of controller '" . $controller->uniqueId . "'";
270270
Yii::beginProfile($token, __METHOD__);

tests/TestCase.php

+6
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
*/
1111
class TestCase extends \PHPUnit\Framework\TestCase
1212
{
13+
/**
14+
* @inheritdoc
15+
*/
1316
protected function setUp()
1417
{
1518
parent::setUp();
@@ -19,6 +22,9 @@ protected function setUp()
1922
$this->setupTestDbData();
2023
}
2124

25+
/**
26+
* @inheritdoc
27+
*/
2228
protected function tearDown()
2329
{
2430
$this->destroyApplication();

0 commit comments

Comments
 (0)