Skip to content

Commit

Permalink
Merge pull request phpmyadmin#18969 from kamil-tekiela/Small-fixes
Browse files Browse the repository at this point in the history
Small code style fixes
  • Loading branch information
MauricioFauth authored Feb 5, 2024
2 parents 03dd66c + a848f86 commit 7a2f6f0
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 43 deletions.
5 changes: 5 additions & 0 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -16365,6 +16365,11 @@ parameters:
count: 1
path: tests/classes/HeaderTest.php

-
message: "#^Parameter \\#1 \\$urlPath of static method PhpMyAdmin\\\\Html\\\\Generator\\:\\:linkOrButton\\(\\) expects string, mixed given\\.$#"
count: 1
path: tests/classes/Html/GeneratorTest.php

-
message: "#^Property PhpMyAdmin\\\\Config\\:\\:\\$selectedServer \\(array\\{host\\: string, port\\: string, socket\\: string, ssl\\: bool, ssl_key\\: string\\|null, ssl_cert\\: string\\|null, ssl_ca\\: string\\|null, ssl_ca_path\\: string\\|null, \\.\\.\\.\\}\\) does not accept array\\{ssl\\: false, host\\: '127\\.0\\.0\\.1'\\}\\.$#"
count: 1
Expand Down
14 changes: 8 additions & 6 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9487,9 +9487,6 @@
<code>$_SESSION</code>
<code>$_SESSION</code>
</PossiblyNullArrayOffset>
<UnusedClass>
<code>UploadNoplugin</code>
</UnusedClass>
</file>
<file src="src/Plugins/Import/Upload/UploadProgress.php">
<MixedArgument>
Expand Down Expand Up @@ -14273,9 +14270,14 @@
<code><![CDATA[['ssl' => true, 'ssl_verify' => false, 'host' => 'custom.host']]]></code>
<code><![CDATA[['ssl' => true, 'ssl_verify' => true, 'host' => 'custom.host']]]></code>
</InvalidPropertyAssignmentValue>
<MixedAssignment>
<code>$result</code>
</MixedAssignment>
<MixedArgument>
<code>$params</code>
<code>$params</code>
<code>$params</code>
<code>$params</code>
<code>$params</code>
<code>$params</code>
</MixedArgument>
<PossiblyUnusedMethod>
<code>linksOrButtons</code>
<code>providerForTestGetDefaultFunctionForField</code>
Expand Down
7 changes: 1 addition & 6 deletions src/Header.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,6 @@ class Header
* Scripts instance
*/
private Scripts $scripts;
/**
* PhpMyAdmin\Console instance
*/
private Console $console;
/**
* Menu instance
*/
Expand Down Expand Up @@ -86,10 +82,9 @@ class Header
/**
* Creates a new class instance
*/
public function __construct(private readonly Template $template, Console $console)
public function __construct(private readonly Template $template, private Console $console)
{
$dbi = DatabaseInterface::getInstance();
$this->console = $console;
$this->menuEnabled = $dbi->isConnected();
$this->menu = new Menu($dbi, $this->template, Current::$database, Current::$table);
$this->scripts = new Scripts($this->template);
Expand Down
22 changes: 5 additions & 17 deletions src/Plugins/Export/ExportPdf.php
Original file line number Diff line number Diff line change
Expand Up @@ -264,23 +264,11 @@ public function exportStructure(
$pdf->setAliases($aliases);
$pdf->setPurpose($purpose);

/**
* comment display set true as presently in pdf
* format, no option is present to take user input.
*/
switch ($exportMode) {
case 'create_table':
case 'create_view':
$pdf->getTableDef($db, $table, $doRelation, true, $doMime);
break;
case 'triggers':
$pdf->getTriggers($db, $table);
break;
case 'stand_in':
// export a stand-in definition to resolve view dependencies
// Yet to develop this function
//$pdf->getTableDefStandIn($db, $table);
}
match ($exportMode) {
'create_table', 'create_view' => $pdf->getTableDef($db, $table, $doRelation, true, $doMime),
'triggers' => $pdf->getTriggers($db, $table),
default => true,
};

return true;
}
Expand Down
8 changes: 2 additions & 6 deletions tests/classes/Advisory/RulesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,10 @@ public static function providerForTestRules(): iterable
{
return [
'generic rules' => [
static function (): array {
return Rules::getGeneric();
},
Rules::getGeneric(...),
],
'rules before MySQL 8.0.3' => [
static function (): array {
return Rules::getBeforeMySql80003();
},
Rules::getBeforeMySql80003(...),
],
];
}
Expand Down
3 changes: 2 additions & 1 deletion tests/classes/Controllers/Table/ImportControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use PhpMyAdmin\Encoding;
use PhpMyAdmin\Http\Factory\ServerRequestFactory;
use PhpMyAdmin\Plugins;
use PhpMyAdmin\Plugins\Import\Upload\UploadNoplugin;
use PhpMyAdmin\Template;
use PhpMyAdmin\Tests\AbstractTestCase;
use PhpMyAdmin\Tests\Stubs\ResponseRenderer;
Expand Down Expand Up @@ -57,7 +58,7 @@ public function testImportController(): void
'page_settings_error_html' => $pageSettings->getErrorHTML(),
'page_settings_html' => $pageSettings->getHTML(),
'upload_id' => 'abc1234567890',
'handler' => 'PhpMyAdmin\Plugins\Import\Upload\UploadNoplugin',
'handler' => UploadNoplugin::class,
'hidden_inputs' => [
'noplugin' => 'abc1234567890',
'import_type' => 'table',
Expand Down
6 changes: 1 addition & 5 deletions tests/classes/Html/GeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

use function __;
use function _pgettext;
use function call_user_func_array;
use function htmlspecialchars;
use function urlencode;

Expand Down Expand Up @@ -196,10 +195,7 @@ public function testLinkOrButton(array $params, int $limit, string $match): void
$restore = $config->settings['LinkLengthLimit'] ?? 1000;
$config->settings['LinkLengthLimit'] = $limit;
try {
$result = call_user_func_array(
[Generator::class, 'linkOrButton'],
$params,
);
$result = Generator::linkOrButton(...$params);
self::assertEquals($match, $result);
} finally {
$config->settings['LinkLengthLimit'] = $restore;
Expand Down
3 changes: 2 additions & 1 deletion tests/classes/WebAuthn/WebauthnLibServerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\TestCase;
use Webauthn\Server as WebauthnServer;
use Webauthn\TrustPath\EmptyTrustPath;

use function base64_encode;
use function class_exists;
Expand Down Expand Up @@ -57,7 +58,7 @@ public function testGetCredentialRequestOptions(): void
'type' => 'public-key',
'transports' => [],
'attestationType' => 'none',
'trustPath' => ['type' => 'Webauthn\\TrustPath\\EmptyTrustPath'],
'trustPath' => ['type' => EmptyTrustPath::class],
'aaguid' => '00000000-0000-0000-0000-000000000000',
'credentialPublicKey' => 'Y3JlZGVudGlhbFB1YmxpY0tleTE', // base64url for credentialPublicKey1
'userHandle' => 'dXNlckhhbmRsZTE=', // base64 for userHandle1
Expand Down
3 changes: 2 additions & 1 deletion tests/selenium/TestBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
use function random_bytes;
use function reset;
use function sprintf;
use function str_ends_with;
use function strlen;
use function substr;
use function time;
Expand Down Expand Up @@ -253,7 +254,7 @@ private function navigateTo(string $url): void
$suiteUrl = '';
}

if (substr($suiteUrl, -1) === '/') {
if (str_ends_with($suiteUrl, '/')) {
$url = $suiteUrl . $url;
} else {
$url = $suiteUrl . '/' . $url;
Expand Down

0 comments on commit 7a2f6f0

Please sign in to comment.