1
0
mirror of https://github.com/vrana/adminer.git synced 2025-08-08 07:36:44 +02:00

Code style: Add more checks

This commit is contained in:
Jakub Vrana
2025-03-05 16:32:51 +01:00
parent 873d6d50fd
commit d9df9693e3
4 changed files with 31 additions and 9 deletions

View File

@@ -98,8 +98,9 @@ function pre_tr($s) {
} }
$table = '(\+--[-+]+\+\n)'; $table = '(\+--[-+]+\+\n)';
$row = '(\| .* \|\n)'; $row = '(\| .* \|\n)';
echo echo preg_replace_callback(
preg_replace_callback("~^$table?$row$table?($row*)$table?~m", function ($match) { "~^$table?$row$table?($row*)$table?~m",
function ($match) {
$first_row = pre_tr($match[2]); $first_row = pre_tr($match[2]);
return "<table>\n" . ($match[1] ? "<thead>$first_row</thead>\n" : $first_row) . pre_tr($match[4]) . "\n</table>"; return "<table>\n" . ($match[1] ? "<thead>$first_row</thead>\n" : $first_row) . pre_tr($match[4]) . "\n</table>";
}, },
@@ -107,6 +108,7 @@ echo
'~(\n( -|mysql)&gt; )(.+)~', '~(\n( -|mysql)&gt; )(.+)~',
"\\1<code class='jush-sql'>\\3</code>", "\\1<code class='jush-sql'>\\3</code>",
preg_replace('~(.+)\n---+\n~', "<b>\\1</b>\n", h($routine['comment'])) preg_replace('~(.+)\n---+\n~', "<b>\\1</b>\n", h($routine['comment']))
)); )
);
?> ?>
</pre> </pre>

View File

@@ -571,9 +571,9 @@ ORDER BY conkey, conname") as $row
if ($comment !== null) { if ($comment !== null) {
$queries[] = "COMMENT ON TABLE " . table($name) . " IS " . q($comment); $queries[] = "COMMENT ON TABLE " . table($name) . " IS " . q($comment);
} }
if ($auto_increment != "") { // if ($auto_increment != "") {
//! $queries[] = "SELECT setval(pg_get_serial_sequence(" . q($name) . ", ), $auto_increment)"; //! $queries[] = "SELECT setval(pg_get_serial_sequence(" . q($name) . ", ), $auto_increment)";
} // }
foreach ($queries as $query) { foreach ($queries as $query) {
if (!queries($query)) { if (!queries($query)) {
return false; return false;

View File

@@ -591,11 +591,11 @@ function ini_bytes($ini) {
$val = ini_get($ini); $val = ini_get($ini);
switch (strtolower(substr($val, -1))) { switch (strtolower(substr($val, -1))) {
case 'g': case 'g':
$val = (int)$val * 1024; // no break $val = (int) $val * 1024; // no break
case 'm': case 'm':
$val = (int)$val * 1024; // no break $val = (int) $val * 1024; // no break
case 'k': case 'k':
$val = (int)$val * 1024; $val = (int) $val * 1024;
} }
return $val; return $val;
} }

View File

@@ -50,7 +50,27 @@
<exclude-pattern>editor/(example|sqlite)\.php</exclude-pattern> <exclude-pattern>editor/(example|sqlite)\.php</exclude-pattern>
</rule> </rule>
<rule ref="Generic.Arrays.DisallowShortArraySyntax"/>
<rule ref="Generic.Classes.OpeningBraceSameLine"/> <rule ref="Generic.Classes.OpeningBraceSameLine"/>
<rule ref="Generic.Whitespace.DisallowSpaceIndent"/> <rule ref="Generic.CodeAnalysis.EmptyPHPStatement"/>
<rule ref="Generic.CodeAnalysis.EmptyStatement"/>
<rule ref="Generic.CodeAnalysis.ForLoopShouldBeWhileLoop"/>
<rule ref="Generic.CodeAnalysis.JumbledIncrementer"/>
<rule ref="Generic.CodeAnalysis.RequireExplicitBooleanOperatorPrecedence"/>
<rule ref="Generic.CodeAnalysis.UnconditionalIfStatement"/>
<rule ref="Generic.CodeAnalysis.UnnecessaryFinalModifier"/>
<rule ref="Generic.CodeAnalysis.UselessOverridingMethod"/>
<rule ref="Generic.Files.EndFileNewline"/>
<rule ref="Generic.Files.LowercasedFilename"/>
<rule ref="Generic.Formatting.SpaceAfterCast"/>
<rule ref="Generic.Functions.CallTimePassByReference"/>
<rule ref="Generic.Functions.OpeningFunctionBraceKernighanRitchie"/> <rule ref="Generic.Functions.OpeningFunctionBraceKernighanRitchie"/>
<rule ref="Generic.NamingConventions.ConstructorName"/>
<rule ref="Generic.PHP.BacktickOperator"/>
<rule ref="Generic.PHP.DisallowRequestSuperglobal"/>
<rule ref="Generic.PHP.ForbiddenFunctions"/>
<rule ref="Generic.Strings.UnnecessaryHeredoc"/>
<rule ref="Generic.VersionControl.GitMergeConflict"/>
<rule ref="Generic.Whitespace.DisallowSpaceIndent"/>
<rule ref="Generic.WhiteSpace.LanguageConstructSpacing"/>
</ruleset> </ruleset>