These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace bedezign\yii2\audit\panels; |
||
4 | |||
5 | use bedezign\yii2\audit\components\panels\DataStoragePanelTrait; |
||
6 | use Yii; |
||
7 | use yii\debug\models\search\Db; |
||
8 | use yii\grid\GridViewAsset; |
||
9 | |||
10 | /** |
||
11 | * DbPanel |
||
12 | * @package bedezign\yii2\audit\panels |
||
13 | * |
||
14 | * @method bool hasExplain() |
||
15 | */ |
||
16 | class DbPanel extends \yii\debug\panels\DbPanel |
||
17 | { |
||
18 | use DataStoragePanelTrait; |
||
19 | |||
20 | /** |
||
21 | * @var array current database request timings |
||
22 | */ |
||
23 | private $_timings; |
||
24 | |||
25 | /** |
||
26 | * @inheritdoc |
||
27 | */ |
||
28 | 1 | public function getLabel() |
|
29 | { |
||
30 | 1 | $timings = $this->calculateTimings(); |
|
31 | 1 | $queryCount = count($timings); |
|
32 | 1 | $queryTime = number_format($this->getTotalQueryTime($timings) * 1000) . ' ms'; |
|
33 | 1 | return $this->getName() . ' <small>(' . $queryCount . ' / ' . $queryTime . ')</small>'; |
|
34 | } |
||
35 | |||
36 | /** |
||
37 | * @inheritdoc |
||
38 | */ |
||
39 | 3 | public function getDetail() |
|
40 | { |
||
41 | 1 | $searchModel = new Db(); |
|
42 | 1 | ||
43 | if (!$searchModel->load(Yii::$app->request->getQueryParams())) { |
||
44 | 1 | $searchModel->load($this->defaultFilter, ''); |
|
0 ignored issues
–
show
|
|||
45 | 1 | } |
|
46 | 1 | ||
47 | 1 | $dataProvider = $searchModel->search($this->getModels()); |
|
0 ignored issues
–
show
|
|||
48 | 1 | $dataProvider->getSort()->defaultOrder = $this->defaultOrder; |
|
0 ignored issues
–
show
The property
defaultOrder does not exist on object<bedezign\yii2\audit\panels\DbPanel> . Since you implemented __set , maybe consider adding a @property annotation.
Since your code implements the magic setter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
Since the property has write access only, you can use the @property-write annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property.
Loading history...
|
|||
49 | 1 | ||
50 | 2 | return Yii::$app->view->render('@yii/debug/views/default/panels/db/detail', [ |
|
51 | 'panel' => $this, |
||
52 | 18 | 'dataProvider' => $dataProvider, |
|
53 | 'searchModel' => $searchModel, |
||
54 | 18 | 'hasExplain' => method_exists($this, 'hasExplain') ? $this->hasExplain() : null, |
|
55 | 18 | ]); |
|
56 | } |
||
57 | |||
58 | public function save() |
||
59 | { |
||
60 | $data = parent::save(); |
||
61 | 1 | return (isset($data['messages']) && count($data['messages']) > 0) ? $data : null; |
|
62 | 1 | } |
|
63 | 1 | ||
64 | 1 | /** |
|
65 | * @inheritdoc |
||
66 | */ |
||
67 | public function registerAssets($view) |
||
68 | { |
||
69 | GridViewAsset::register($view); |
||
70 | } |
||
71 | 1 | ||
72 | /** |
||
73 | 1 | * Calculates given request profile timings. |
|
74 | 1 | * |
|
75 | 1 | * @return array timings [token, category, timestamp, traces, nesting level, elapsed time] |
|
76 | 1 | */ |
|
77 | 1 | public function calculateTimings() |
|
78 | 1 | { |
|
79 | 1 | if ($this->_timings === null) { |
|
80 | $this->_timings = []; |
||
81 | if (isset($this->data['messages'])) { |
||
82 | $this->_timings = Yii::getLogger()->calculateTimings($this->data['messages']); |
||
83 | } |
||
84 | } |
||
85 | return $this->_timings; |
||
86 | } |
||
87 | } |
Since your code implements the magic getter
_get
, this function will be called for any read access on an undefined variable. You can add the@property
annotation to your class or interface to document the existence of this variable.If the property has read access only, you can use the @property-read annotation instead.
Of course, you may also just have mistyped another name, in which case you should fix the error.
See also the PhpDoc documentation for @property.