@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | /** |
| 67 | 67 | * Lists of all auth items |
| 68 | 68 | * |
| 69 | - * @return mixed |
|
| 69 | + * @return string |
|
| 70 | 70 | */ |
| 71 | 71 | public function actionIndex() |
| 72 | 72 | { |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | * |
| 86 | 86 | * @param int $id |
| 87 | 87 | * |
| 88 | - * @return mixed |
|
| 88 | + * @return string |
|
| 89 | 89 | */ |
| 90 | 90 | public function actionView(int $id) |
| 91 | 91 | { |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | * |
| 145 | 145 | * @param int $id |
| 146 | 146 | * |
| 147 | - * @return mixed |
|
| 147 | + * @return Response |
|
| 148 | 148 | */ |
| 149 | 149 | public function actionDelete(int $id) |
| 150 | 150 | { |
@@ -192,7 +192,7 @@ |
||
| 192 | 192 | */ |
| 193 | 193 | public function getViewPath(): string |
| 194 | 194 | { |
| 195 | - return $this->module->getViewPath() . DIRECTORY_SEPARATOR . 'item'; |
|
| 195 | + return $this->module->getViewPath().DIRECTORY_SEPARATOR.'item'; |
|
| 196 | 196 | } |
| 197 | 197 | |
| 198 | 198 | /** |
@@ -115,7 +115,7 @@ |
||
| 115 | 115 | * |
| 116 | 116 | * @param int $id |
| 117 | 117 | * |
| 118 | - * @return mixed |
|
| 118 | + * @return string |
|
| 119 | 119 | */ |
| 120 | 120 | public function actionView($id) |
| 121 | 121 | { |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | /** |
| 48 | 48 | * List of all rules |
| 49 | 49 | * |
| 50 | - * @return mixed |
|
| 50 | + * @return string |
|
| 51 | 51 | */ |
| 52 | 52 | public function actionIndex() |
| 53 | 53 | { |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | * |
| 66 | 66 | * @param string $id |
| 67 | 67 | * |
| 68 | - * @return mixed |
|
| 68 | + * @return string |
|
| 69 | 69 | */ |
| 70 | 70 | public function actionView($id) |
| 71 | 71 | { |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | * |
| 124 | 124 | * @param string $id |
| 125 | 125 | * |
| 126 | - * @return mixed |
|
| 126 | + * @return \yii\web\Response |
|
| 127 | 127 | */ |
| 128 | 128 | public function actionDelete($id) |
| 129 | 129 | { |
@@ -162,7 +162,7 @@ |
||
| 162 | 162 | * |
| 163 | 163 | * @param string $id |
| 164 | 164 | * |
| 165 | - * @return null|\self |
|
| 165 | + * @return AuthItemModel|null |
|
| 166 | 166 | */ |
| 167 | 167 | public static function find(string $id) |
| 168 | 168 | { |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | [['name', 'description', 'data', 'ruleName'], 'trim'], |
| 87 | 87 | [['name', 'type'], 'required'], |
| 88 | 88 | ['ruleName', 'checkRule'], |
| 89 | - ['name', 'unique', 'when' => function () { |
|
| 89 | + ['name', 'unique', 'when' => function() { |
|
| 90 | 90 | return $this->getIsNewRecord() || ($this->_item->name != $this->name); |
| 91 | 91 | }], |
| 92 | 92 | ['type', 'integer'], |
@@ -292,7 +292,7 @@ discard block |
||
| 292 | 292 | /** |
| 293 | 293 | * @return null|Item |
| 294 | 294 | */ |
| 295 | - public function getItem(): ?Item |
|
| 295 | + public function getItem(): ? Item |
|
| 296 | 296 | { |
| 297 | 297 | return $this->_item; |
| 298 | 298 | } |
@@ -262,7 +262,7 @@ |
||
| 262 | 262 | * Get route of action |
| 263 | 263 | * |
| 264 | 264 | * @param \yii\base\Controller $controller |
| 265 | - * @param array $result all controller action |
|
| 265 | + * @param string $result all controller action |
|
| 266 | 266 | */ |
| 267 | 267 | protected function getActionRoutes($controller, &$result) |
| 268 | 268 | { |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | public function addNew($routes): bool |
| 63 | 63 | { |
| 64 | 64 | foreach ($routes as $route) { |
| 65 | - $this->manager->add($this->manager->createPermission('/' . trim($route, ' /'))); |
|
| 65 | + $this->manager->add($this->manager->createPermission('/'.trim($route, ' /'))); |
|
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | $this->invalidate(); |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | public function remove($routes): bool |
| 81 | 81 | { |
| 82 | 82 | foreach ($routes as $route) { |
| 83 | - $item = $this->manager->createPermission('/' . trim($route, '/')); |
|
| 83 | + $item = $this->manager->createPermission('/'.trim($route, '/')); |
|
| 84 | 84 | $this->manager->remove($item); |
| 85 | 85 | } |
| 86 | 86 | $this->invalidate(); |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | protected function getRouteRecursive($module, &$result): void |
| 163 | 163 | { |
| 164 | 164 | if (!in_array($module->id, $this->excludeModules)) { |
| 165 | - $token = "Get Route of '" . get_class($module) . "' with id '" . $module->uniqueId . "'"; |
|
| 165 | + $token = "Get Route of '".get_class($module)."' with id '".$module->uniqueId."'"; |
|
| 166 | 166 | Yii::beginProfile($token, __METHOD__); |
| 167 | 167 | |
| 168 | 168 | try { |
@@ -176,9 +176,9 @@ discard block |
||
| 176 | 176 | $this->getControllerActions($type, $id, $module, $result); |
| 177 | 177 | } |
| 178 | 178 | |
| 179 | - $namespace = trim($module->controllerNamespace, '\\') . '\\'; |
|
| 179 | + $namespace = trim($module->controllerNamespace, '\\').'\\'; |
|
| 180 | 180 | $this->getControllerFiles($module, $namespace, '', $result); |
| 181 | - $all = '/' . ltrim($module->uniqueId . '/*', '/'); |
|
| 181 | + $all = '/'.ltrim($module->uniqueId.'/*', '/'); |
|
| 182 | 182 | $result[$all] = $all; |
| 183 | 183 | } catch (\Exception $exc) { |
| 184 | 184 | Yii::error($exc->getMessage(), __METHOD__); |
@@ -200,7 +200,7 @@ discard block |
||
| 200 | 200 | */ |
| 201 | 201 | protected function getControllerFiles($module, $namespace, $prefix, &$result) |
| 202 | 202 | { |
| 203 | - $path = Yii::getAlias('@' . str_replace('\\', '/', $namespace), false); |
|
| 203 | + $path = Yii::getAlias('@'.str_replace('\\', '/', $namespace), false); |
|
| 204 | 204 | $token = "Get controllers from '$path'"; |
| 205 | 205 | Yii::beginProfile($token, __METHOD__); |
| 206 | 206 | |
@@ -213,15 +213,15 @@ discard block |
||
| 213 | 213 | if ($file == '.' || $file == '..') { |
| 214 | 214 | continue; |
| 215 | 215 | } |
| 216 | - if (is_dir($path . '/' . $file) && preg_match('%^[a-z0-9_/]+$%i', $file . '/')) { |
|
| 217 | - $this->getControllerFiles($module, $namespace . $file . '\\', $prefix . $file . '/', $result); |
|
| 216 | + if (is_dir($path.'/'.$file) && preg_match('%^[a-z0-9_/]+$%i', $file.'/')) { |
|
| 217 | + $this->getControllerFiles($module, $namespace.$file.'\\', $prefix.$file.'/', $result); |
|
| 218 | 218 | } elseif (strcmp(substr($file, -14), 'Controller.php') === 0) { |
| 219 | 219 | $baseName = substr(basename($file), 0, -14); |
| 220 | 220 | $name = strtolower(preg_replace('/(?<![A-Z])[A-Z]/', ' \0', $baseName)); |
| 221 | 221 | $id = ltrim(str_replace(' ', '-', $name), '-'); |
| 222 | - $className = $namespace . $baseName . 'Controller'; |
|
| 222 | + $className = $namespace.$baseName.'Controller'; |
|
| 223 | 223 | if (strpos($className, '-') === false && class_exists($className) && is_subclass_of($className, 'yii\base\Controller')) { |
| 224 | - $this->getControllerActions($className, $prefix . $id, $module, $result); |
|
| 224 | + $this->getControllerActions($className, $prefix.$id, $module, $result); |
|
| 225 | 225 | } |
| 226 | 226 | } |
| 227 | 227 | } |
@@ -242,7 +242,7 @@ discard block |
||
| 242 | 242 | */ |
| 243 | 243 | protected function getControllerActions($type, $id, $module, &$result) |
| 244 | 244 | { |
| 245 | - $token = 'Create controller with cofig=' . VarDumper::dumpAsString($type) . " and id='$id'"; |
|
| 245 | + $token = 'Create controller with cofig='.VarDumper::dumpAsString($type)." and id='$id'"; |
|
| 246 | 246 | Yii::beginProfile($token, __METHOD__); |
| 247 | 247 | |
| 248 | 248 | try { |
@@ -266,12 +266,12 @@ discard block |
||
| 266 | 266 | */ |
| 267 | 267 | protected function getActionRoutes($controller, &$result) |
| 268 | 268 | { |
| 269 | - $token = "Get actions of controller '" . $controller->uniqueId . "'"; |
|
| 269 | + $token = "Get actions of controller '".$controller->uniqueId."'"; |
|
| 270 | 270 | Yii::beginProfile($token, __METHOD__); |
| 271 | 271 | try { |
| 272 | - $prefix = '/' . $controller->uniqueId . '/'; |
|
| 272 | + $prefix = '/'.$controller->uniqueId.'/'; |
|
| 273 | 273 | foreach ($controller->actions() as $id => $value) { |
| 274 | - $result[$prefix . $id] = $prefix . $id; |
|
| 274 | + $result[$prefix.$id] = $prefix.$id; |
|
| 275 | 275 | } |
| 276 | 276 | $class = new \ReflectionClass($controller); |
| 277 | 277 | |
@@ -279,7 +279,7 @@ discard block |
||
| 279 | 279 | $name = $method->getName(); |
| 280 | 280 | if ($method->isPublic() && !$method->isStatic() && strpos($name, 'action') === 0 && $name !== 'actions') { |
| 281 | 281 | $name = strtolower(preg_replace('/(?<![A-Z])[A-Z]/', ' \0', substr($name, 6))); |
| 282 | - $id = $prefix . ltrim(str_replace(' ', '-', $name), '-'); |
|
| 282 | + $id = $prefix.ltrim(str_replace(' ', '-', $name), '-'); |
|
| 283 | 283 | $result[$id] = $id; |
| 284 | 284 | } |
| 285 | 285 | } |
@@ -2,7 +2,7 @@ |
||
| 2 | 2 | |
| 3 | 3 | return [ |
| 4 | 4 | // string, required, root directory of all source files |
| 5 | - 'sourcePath' => __DIR__ . DIRECTORY_SEPARATOR . '..', |
|
| 5 | + 'sourcePath' => __DIR__.DIRECTORY_SEPARATOR.'..', |
|
| 6 | 6 | // array, required, list of language codes that the extracted messages |
| 7 | 7 | // should be translated to. For example, ['zh-CN', 'de']. |
| 8 | 8 | 'languages' => ['en'], |
@@ -53,8 +53,8 @@ discard block |
||
| 53 | 53 | return true; |
| 54 | 54 | } catch (\Exception $e) { |
| 55 | 55 | echo "Rolling transaction back\n"; |
| 56 | - echo 'Exception: ' . $e->getMessage() . ' (' . $e->getFile() . ':' . $e->getLine() . ")\n"; |
|
| 57 | - echo $e->getTraceAsString() . "\n"; |
|
| 56 | + echo 'Exception: '.$e->getMessage().' ('.$e->getFile().':'.$e->getLine().")\n"; |
|
| 57 | + echo $e->getTraceAsString()."\n"; |
|
| 58 | 58 | $transaction->rollBack(); |
| 59 | 59 | |
| 60 | 60 | return false; |
@@ -79,8 +79,8 @@ discard block |
||
| 79 | 79 | return true; |
| 80 | 80 | } catch (\Exception $e) { |
| 81 | 81 | echo "Rolling transaction back\n"; |
| 82 | - echo 'Exception: ' . $e->getMessage() . ' (' . $e->getFile() . ':' . $e->getLine() . ")\n"; |
|
| 83 | - echo $e->getTraceAsString() . "\n"; |
|
| 82 | + echo 'Exception: '.$e->getMessage().' ('.$e->getFile().':'.$e->getLine().")\n"; |
|
| 83 | + echo $e->getTraceAsString()."\n"; |
|
| 84 | 84 | $transaction->rollBack(); |
| 85 | 85 | |
| 86 | 86 | return false; |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | $permission->ruleName = $ruleName; |
| 127 | 127 | $permission->data = $data; |
| 128 | 128 | $this->authManager->add($permission); |
| 129 | - echo ' done (time: ' . sprintf('%.3f', microtime(true) - $time) . "s)\n"; |
|
| 129 | + echo ' done (time: '.sprintf('%.3f', microtime(true) - $time)."s)\n"; |
|
| 130 | 130 | |
| 131 | 131 | return $permission; |
| 132 | 132 | } |
@@ -150,7 +150,7 @@ discard block |
||
| 150 | 150 | $role->ruleName = $ruleName; |
| 151 | 151 | $role->data = $data; |
| 152 | 152 | $this->authManager->add($role); |
| 153 | - echo ' done (time: ' . sprintf('%.3f', microtime(true) - $time) . "s)\n"; |
|
| 153 | + echo ' done (time: '.sprintf('%.3f', microtime(true) - $time)."s)\n"; |
|
| 154 | 154 | |
| 155 | 155 | return $role; |
| 156 | 156 | } |
@@ -178,7 +178,7 @@ discard block |
||
| 178 | 178 | /** @var Rule $rule */ |
| 179 | 179 | $rule = \Yii::createObject($definition); |
| 180 | 180 | $this->authManager->add($rule); |
| 181 | - echo ' done (time: ' . sprintf('%.3f', microtime(true) - $time) . "s)\n"; |
|
| 181 | + echo ' done (time: '.sprintf('%.3f', microtime(true) - $time)."s)\n"; |
|
| 182 | 182 | |
| 183 | 183 | return $rule; |
| 184 | 184 | } |
@@ -255,7 +255,7 @@ discard block |
||
| 255 | 255 | echo " > adding $child->name as child to $parent->name ..."; |
| 256 | 256 | $time = microtime(true); |
| 257 | 257 | $this->authManager->addChild($parent, $child); |
| 258 | - echo ' done (time: ' . sprintf('%.3f', microtime(true) - $time) . "s)\n"; |
|
| 258 | + echo ' done (time: '.sprintf('%.3f', microtime(true) - $time)."s)\n"; |
|
| 259 | 259 | } |
| 260 | 260 | |
| 261 | 261 | /** |
@@ -275,7 +275,7 @@ discard block |
||
| 275 | 275 | echo " > removing $child->name from $parent->name ..."; |
| 276 | 276 | $time = microtime(true); |
| 277 | 277 | $this->authManager->removeChild($parent, $child); |
| 278 | - echo ' done (time: ' . sprintf('%.3f', microtime(true) - $time) . "s)\n"; |
|
| 278 | + echo ' done (time: '.sprintf('%.3f', microtime(true) - $time)."s)\n"; |
|
| 279 | 279 | } |
| 280 | 280 | |
| 281 | 281 | /** |
@@ -292,7 +292,7 @@ discard block |
||
| 292 | 292 | echo " > assigning $role->name to user $userId ..."; |
| 293 | 293 | $time = microtime(true); |
| 294 | 294 | $this->authManager->assign($role, $userId); |
| 295 | - echo ' done (time: ' . sprintf('%.3f', microtime(true) - $time) . "s)\n"; |
|
| 295 | + echo ' done (time: '.sprintf('%.3f', microtime(true) - $time)."s)\n"; |
|
| 296 | 296 | } |
| 297 | 297 | |
| 298 | 298 | /** |
@@ -316,7 +316,7 @@ discard block |
||
| 316 | 316 | $role->ruleName = $ruleName; |
| 317 | 317 | $role->data = $data; |
| 318 | 318 | $this->authManager->update($role->name, $role); |
| 319 | - echo ' done (time: ' . sprintf('%.3f', microtime(true) - $time) . "s)\n"; |
|
| 319 | + echo ' done (time: '.sprintf('%.3f', microtime(true) - $time)."s)\n"; |
|
| 320 | 320 | |
| 321 | 321 | return $role; |
| 322 | 322 | } |
@@ -335,7 +335,7 @@ discard block |
||
| 335 | 335 | echo " > removing role $role->name ..."; |
| 336 | 336 | $time = microtime(true); |
| 337 | 337 | $this->authManager->remove($role); |
| 338 | - echo ' done (time: ' . sprintf('%.3f', microtime(true) - $time) . "s)\n"; |
|
| 338 | + echo ' done (time: '.sprintf('%.3f', microtime(true) - $time)."s)\n"; |
|
| 339 | 339 | } |
| 340 | 340 | |
| 341 | 341 | /** |
@@ -359,7 +359,7 @@ discard block |
||
| 359 | 359 | $permission->ruleName = $ruleName; |
| 360 | 360 | $permission->data = $data; |
| 361 | 361 | $this->authManager->update($permission->name, $permission); |
| 362 | - echo ' done (time: ' . sprintf('%.3f', microtime(true) - $time) . "s)\n"; |
|
| 362 | + echo ' done (time: '.sprintf('%.3f', microtime(true) - $time)."s)\n"; |
|
| 363 | 363 | |
| 364 | 364 | return $permission; |
| 365 | 365 | } |
@@ -378,7 +378,7 @@ discard block |
||
| 378 | 378 | echo " > removing permission $permission->name ..."; |
| 379 | 379 | $time = microtime(true); |
| 380 | 380 | $this->authManager->remove($permission); |
| 381 | - echo ' done (time: ' . sprintf('%.3f', microtime(true) - $time) . "s)\n"; |
|
| 381 | + echo ' done (time: '.sprintf('%.3f', microtime(true) - $time)."s)\n"; |
|
| 382 | 382 | } |
| 383 | 383 | |
| 384 | 384 | /** |
@@ -399,7 +399,7 @@ discard block |
||
| 399 | 399 | 'name' => $ruleName, |
| 400 | 400 | ]); |
| 401 | 401 | $this->authManager->update($ruleName, $rule); |
| 402 | - echo ' done (time: ' . sprintf('%.3f', microtime(true) - $time) . "s)\n"; |
|
| 402 | + echo ' done (time: '.sprintf('%.3f', microtime(true) - $time)."s)\n"; |
|
| 403 | 403 | |
| 404 | 404 | return $rule; |
| 405 | 405 | } |
@@ -418,6 +418,6 @@ discard block |
||
| 418 | 418 | echo " > removing rule $rule->name ..."; |
| 419 | 419 | $time = microtime(true); |
| 420 | 420 | $this->authManager->remove($rule); |
| 421 | - echo ' done (time: ' . sprintf('%.3f', microtime(true) - $time) . "s)\n"; |
|
| 421 | + echo ' done (time: '.sprintf('%.3f', microtime(true) - $time)."s)\n"; |
|
| 422 | 422 | } |
| 423 | 423 | } |
@@ -6,8 +6,8 @@ |
||
| 6 | 6 | define('YII_ENABLE_ERROR_HANDLER', false); |
| 7 | 7 | define('YII_DEBUG', true); |
| 8 | 8 | |
| 9 | -$_SERVER['SCRIPT_NAME'] = '/' . __DIR__; |
|
| 9 | +$_SERVER['SCRIPT_NAME'] = '/'.__DIR__; |
|
| 10 | 10 | $_SERVER['SCRIPT_FILENAME'] = __FILE__; |
| 11 | 11 | |
| 12 | -require_once(__DIR__ . '/../vendor/autoload.php'); |
|
| 13 | -require_once(__DIR__ . '/../vendor/yiisoft/yii2/Yii.php'); |
|
| 12 | +require_once(__DIR__.'/../vendor/autoload.php'); |
|
| 13 | +require_once(__DIR__.'/../vendor/yiisoft/yii2/Yii.php'); |
|
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | */ |
| 71 | 71 | protected function getVendorPath() |
| 72 | 72 | { |
| 73 | - return dirname(__DIR__) . '/vendor'; |
|
| 73 | + return dirname(__DIR__).'/vendor'; |
|
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | /** |
@@ -106,15 +106,15 @@ discard block |
||
| 106 | 106 | 'data' => 'string', |
| 107 | 107 | 'created_at' => 'integer', |
| 108 | 108 | 'updated_at' => 'integer', |
| 109 | - 'FOREIGN KEY (rule_name) REFERENCES ' . '{{%auth_rule}}' . ' (name) ON DELETE SET NULL ON UPDATE CASCADE', |
|
| 109 | + 'FOREIGN KEY (rule_name) REFERENCES '.'{{%auth_rule}}'.' (name) ON DELETE SET NULL ON UPDATE CASCADE', |
|
| 110 | 110 | ])->execute(); |
| 111 | 111 | |
| 112 | 112 | $db->createCommand()->createTable('{{%auth_item_child}}', [ |
| 113 | 113 | 'parent' => 'string', |
| 114 | 114 | 'child' => 'string', |
| 115 | 115 | 'PRIMARY KEY (parent, child)', |
| 116 | - 'FOREIGN KEY (parent) REFERENCES ' . '{{%auth_item}}' . ' (name) ON DELETE CASCADE ON UPDATE CASCADE', |
|
| 117 | - 'FOREIGN KEY (child) REFERENCES ' . '{{%auth_item}}' . ' (name) ON DELETE CASCADE ON UPDATE CASCADE', |
|
| 116 | + 'FOREIGN KEY (parent) REFERENCES '.'{{%auth_item}}'.' (name) ON DELETE CASCADE ON UPDATE CASCADE', |
|
| 117 | + 'FOREIGN KEY (child) REFERENCES '.'{{%auth_item}}'.' (name) ON DELETE CASCADE ON UPDATE CASCADE', |
|
| 118 | 118 | ])->execute(); |
| 119 | 119 | |
| 120 | 120 | $db->createCommand()->createTable('{{%auth_assignment}}', [ |
@@ -122,7 +122,7 @@ discard block |
||
| 122 | 122 | 'user_id' => 'integer', |
| 123 | 123 | 'created_at' => 'integer', |
| 124 | 124 | 'PRIMARY KEY (item_name, user_id)', |
| 125 | - 'FOREIGN KEY (item_name) REFERENCES ' . '{{%auth_item}}' . ' (name) ON DELETE CASCADE ON UPDATE CASCADE', |
|
| 125 | + 'FOREIGN KEY (item_name) REFERENCES '.'{{%auth_item}}'.' (name) ON DELETE CASCADE ON UPDATE CASCADE', |
|
| 126 | 126 | ])->execute(); |
| 127 | 127 | |
| 128 | 128 | $db->createCommand()->createTable('{{%user}}', [ |