Completed
Push — master ( 21a075...4d319b )
by Dmitry
14:54
created

main.php ➔ d()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 5
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 7
ccs 0
cts 6
cp 0
crap 2
rs 9.4285
1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 14 and the first side effect is on line 22.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
3
/*
4
 * HiPanel core package
5
 *
6
 * @link      https://hipanel.com/
7
 * @package   hipanel-core
8
 * @license   BSD-3-Clause
9
 * @copyright Copyright (c) 2014-2016, HiQDev (http://hiqdev.com/)
10
 */
11
12
use yii\helpers\ArrayHelper;
13
14
function d($a)
15
{
16
    echo '<pre>';
17
    var_dump($a);
0 ignored issues
show
Security Debugging Code introduced by
var_dump($a); looks like debug code. Are you sure you do not want to remove it? This might expose sensitive data.
Loading history...
18
    debug_print_backtrace(0, 3);
19
    die();
0 ignored issues
show
Coding Style Compatibility introduced by
The function d() contains an exit expression.

An exit expression should only be used in rare cases. For example, if you write a short command line script.

In most cases however, using an exit expression makes the code untestable and often causes incompatibilities with other libraries. Thus, unless you are absolutely sure it is required here, we recommend to refactor your code to avoid its usage.

Loading history...
20
}
21
22
$params = array_merge(
23
    require(Yii::getAlias('@hipanel/common/config/params.php')),
24
    require(Yii::getAlias('@project/common/config/params.php')),
25
    require(Yii::getAlias('@project/common/config/params-local.php'))
26
);
27
28
/// Overrides default values for 3rd part modules
29
Yii::$container->set('kartik\widgets\DatePicker', function ($container, $params, $config) {
30
    return new \kartik\widgets\DatePicker(ArrayHelper::merge([
31
        'separator' => Yii::t('app', '&larr; between &rarr;'),
32
    ], $config));
33
});
34
35
Yii::$container->set('kartik\date\DatePicker', function ($container, $params, $config) {
36
    return new \kartik\date\DatePicker(ArrayHelper::merge([
37
        'separator' => Yii::t('app', '&larr; between &rarr;'),
38
    ], $config));
39
});
40
41
Yii::$container->set('kartik\field\FieldRange', function ($container, $params, $config) {
42
    return new \kartik\field\FieldRange(ArrayHelper::merge([
43
        'separator' => Yii::t('app', '&larr; between &rarr;'),
44
    ], $config));
45
});
46
47
$config = [
48
    'vendorPath' => '@project/vendor',
49
    'aliases' => [
50
        'bower' => '@vendor/bower-asset',
51
        'npm'   => '@vendor/npm-asset',
52
    ],
53
    'components' => [
54
        'cache' => [
55
            'class' => 'hipanel\base\Cache',
56
            // 'cache' => 'yii\caching\FileCache',
0 ignored issues
show
Unused Code Comprehensibility introduced by
58% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
57
        ],
58
        'authManager' => [
59
            'class' => 'hipanel\base\AuthManager',
60
        ],
61
        'hiresource' => [
62
            'class'  => 'hipanel\base\Connection',
63
            'auth'   => function () {
64
                if (Yii::$app->user->identity) {
65
                    return ['access_token' => Yii::$app->user->identity->getAccessToken()];
66
                }
67
68
                if (Yii::$app->user->loginRequired() !== null) {
69
                    Yii::trace('Login is required. Redirecting to the login page', 'hipanel');
70
                    Yii::$app->response->send();
71
                    Yii::$app->end();
72
                }
73
74
                return [];
75
            },
76
            'config' => [
77
                'api_url'  => $params['api_url'],
78
                'base_uri' => $params['api_url'],
79
            ],
80
        ],
81
        'mailer' => [
82
            'class' => 'yii\swiftmailer\Mailer',
83
            'viewPath' => '@common/mail',
84
            // send all mails to a file by default. You have to set
85
            // 'useFileTransport' to false and configure a transport
86
            // for the mailer to send real emails.
87
            'useFileTransport' => true,
88
        ],
89
        'i18n' => [
90
            'class' => \hipanel\base\I18N::class,
91
        ],
92
    ],
93
];
94
95
if (YII_DEBUG && !YII_ENV_TEST) {
96
    // configuration adjustments for 'dev' environment
97
    $config['bootstrap']['debug'] = 'debug';
98
    $config['modules']['debug'] = [
99
        'class' => 'yii\debug\Module',
100
        'allowedIPs' => isset($params['debug_ips']) ? $params['debug_ips'] : '',
101
        'panels' => [
102
            'hiresource' => [
103
                'class' => 'hiqdev\hiart\DebugPanel',
104
            ],
105
        ],
106
    ];
107
108
    $config['bootstrap']['gii'] = 'gii';
109
    $config['modules']['gii'] = 'yii\gii\Module';
110
}
111
112
return $config;
113