Commit 58083f6e by Michael Bodnarchuk

A simple patch to get AspectMock and Go Aop working with Yii2

This is a very tiny patch that changes nothing in code logic, but is required to get [AspectMock](https://github.com/Codeception/AspectMock) and Go Aop working with Yii2. Go Aop is processing all `include` and `require` directives, replacing them with its filters. Unfortunately it doesn't play well with one-liners. So I had to break the code into few lines to get that working. I was trying to fix this issue in [Go Aop](https://github.com/lisachenko/go-aop-php/pull/78) but looks like, the only option is to fix that in Yii2. AspectMock can dramaticly improve unit testing in Yii2, and I plan to do a blogpost with tutorial about it.
parent a23f2334
...@@ -120,7 +120,10 @@ class SecurityBase ...@@ -120,7 +120,10 @@ class SecurityBase
static $keys; static $keys;
$keyFile = Yii::$app->getRuntimePath() . '/keys.php'; $keyFile = Yii::$app->getRuntimePath() . '/keys.php';
if ($keys === null) { if ($keys === null) {
$keys = is_file($keyFile) ? require($keyFile) : array(); $keys = array();
if (is_file($keyFile)) {
$keys = require($keyFile);
}
} }
if (!isset($keys[$name])) { if (!isset($keys[$name])) {
$keys[$name] = static::generateRandomKey($length); $keys[$name] = static::generateRandomKey($length);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment