tengattack / phplint Goto Github PK
View Code? Open in Web Editor NEWA configurable linter tool for PHP.
License: MIT License
A configurable linter tool for PHP.
License: MIT License
<?php if ($event['end_time']): ?>
<?php
if ($event['create_time'] >= $_SERVER['REQUEST_TIME']) {
echo '<span class="eventstatus">未开始</span>';
} elseif (($event['end_time'] + ONE_DAY) > $_SERVER['REQUEST_TIME']) {
echo '<span class="eventstatus indate">进行中</span>';
} else {
echo '<span class="eventstatus outdate">已结束</span>';
}
?>
<?php endif; ?>
echo 这一行的代码会提示需要再缩进 4 个空格
$i++, ++$i, $i--, --$i
,递增或递减运算符与变量之间不需要空格
+<?php
+
+class Demo
+{
+ public function foo()
+ {
+ return "bar";
+ }
+}
+
+
php 代码中使用 static public
的写法统一改为 public static
<?php
class A
{
public function ignoreExceptionSave(string $a, bool $b = true, ?callable $callback = null): bool
{
// ...
return true;
}
}
$ phplint a.php
a.php:
+------+----------+----------------------------------------+-----------------+
| loc | severity | message | ruleId |
+------+----------+----------------------------------------+-----------------+
| 5:69 | error | A space is required before 'callable'. | keyword-spacing |
+------+----------+----------------------------------------+-----------------+
一行超过 120 个字符时换行时,将 use 换行写会出现 indent 问题
$records = array_reduce($res, function ($ret, $item)
use ($msgids_uuid, $msgids_userid, $now, $uuid, $user_id, $expired_msg_ids) {
// ... ...
}, []);
$records = array_reduce($res, function ($ret, $item) use ($msgids_uuid, $msgids_userid,
$now, $uuid, $user_id, $expired_msg_ids) {
// ... ...
}, []);
<?php
// ...
Yii::$app->maindb->createCommand()
->batchInsert(Yii::$app->authManager->itemChildTable,
array_keys($authitemchild_rows[0]), $authitemchild_rows)
->execute();
+------+----------+-------------------------------------------------+--------+
| loc | severity | message | ruleId |
+------+----------+-------------------------------------------------+--------+
| 68:1 | error | Expected indentation of 12 spaces but found 16. | indent |
+------+----------+-------------------------------------------------+--------+
相关 PR: https://github.com/MiaoSiLa/missevan-backend/pull/271
<? php
// ...
['attribute'=>'radio_drama_dramainfo.name',
'label'=>'剧集名称',
'format'=>'raw',
'value' => function($model) {
return Html::a(Html::encode($model->radio_drama_dramainfo->name), Yii::$app->params['domainMissevan'] . '/mdrama/' . $model->drama_id);
}],
`indent` 45:1 Expected indentation of 16 spaces but found 20.
$query->addSelect('t2.user_id AS subscribed_user_id')
->leftJoin(EventVoteDetail::tableName() . ' AS t2', 't1.event_id = t2.event_id
AND t2.user_id = :user_id')
AND 需要缩到下一格
if () {
...
} else {
if () {
....
} elseif () {
....
}
}
错误提示:
no-lonely-if
372:13 Unexpected if as the only statement in an else block.
function foo($msg, $code, $error_info)
{
// 将提示:A space is required after 'class'.
return new class($msg, $code, $error_info) extends \Exception {
/**
* @var array
*/
public $errorInfo = [];
public function __construct($msg, $code, $error_info)
{
$this->code = $code;
$this->message = $msg;
$this->errorInfo = $error_info;
}
};
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.