Skip to content

Commit 88eb22b

Browse files
Merge pull request #19957 from kamil-tekiela/Refactor-ExportPlugin
Refactor export plugins
2 parents aa153de + 58b4fc7 commit 88eb22b

42 files changed

Lines changed: 690 additions & 1502 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

app/services.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
use PhpMyAdmin\Error\ErrorReport;
2424
use PhpMyAdmin\Export\Export;
2525
use PhpMyAdmin\Export\Options;
26+
use PhpMyAdmin\Export\OutputHandler;
2627
use PhpMyAdmin\Export\TemplateModel;
2728
use PhpMyAdmin\FileListing;
2829
use PhpMyAdmin\FlashMessenger;
@@ -99,7 +100,7 @@
99100
'arguments' => ['@http_request', '@relation', '@template', '@config'],
100101
],
101102
'events' => ['class' => Events::class, 'arguments' => ['@dbi']],
102-
Export::class => ['class' => Export::class, 'arguments' => ['@dbi']],
103+
Export::class => ['class' => Export::class, 'arguments' => ['@dbi', '@' . OutputHandler::class]],
103104
'export' => Export::class,
104105
'export_options' => [
105106
'class' => Options::class,
@@ -235,6 +236,7 @@
235236
'class' => Operations::class,
236237
'arguments' => ['$dbi' => '@dbi', '$relation' => '@relation', '$tableMover' => '@table_mover'],
237238
],
239+
OutputHandler::class => ['class' => OutputHandler::class],
238240
'partitioning_maintenance' => [
239241
'class' => Maintenance::class,
240242
'arguments' => ['$dbi' => '@dbi'],

phpstan-baseline.neon

Lines changed: 14 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -2223,30 +2223,12 @@ parameters:
22232223
count: 1
22242224
path: src/Controllers/Export/ExportController.php
22252225

2226-
-
2227-
message: '#^Parameter \#1 \$fileHandle of method PhpMyAdmin\\Export\\Export\:\:closeFile\(\) expects resource, resource\|null given\.$#'
2228-
identifier: argument.type
2229-
count: 1
2230-
path: src/Controllers/Export/ExportController.php
2231-
22322226
-
22332227
message: '#^Parameter \#3 \$tableStructure of method PhpMyAdmin\\Export\\Export\:\:exportDatabase\(\) expects array\<string\>, array\<mixed\> given\.$#'
22342228
identifier: argument.type
22352229
count: 2
22362230
path: src/Controllers/Export/ExportController.php
22372231

2238-
-
2239-
message: '#^Property PhpMyAdmin\\Export\\Export\:\:\$dumpBuffer \(string\) does not accept array\|bool\|string\.$#'
2240-
identifier: assign.propertyType
2241-
count: 2
2242-
path: src/Controllers/Export/ExportController.php
2243-
2244-
-
2245-
message: '#^Static property PhpMyAdmin\\Export\\Export\:\:\$compression \(''''\|''gzip''\|''none''\|''zip''\) does not accept string\.$#'
2246-
identifier: assign.propertyType
2247-
count: 1
2248-
path: src/Controllers/Export/ExportController.php
2249-
22502232
-
22512233
message: '#^Static property PhpMyAdmin\\Export\\Export\:\:\$tableData \(array\<string\>\) does not accept array\<mixed, mixed\>\.$#'
22522234
identifier: assign.propertyType
@@ -6144,15 +6126,6 @@ parameters:
61446126
count: 2
61456127
path: src/Export/Export.php
61466128

6147-
-
6148-
message: '''
6149-
#^Call to deprecated method getInstance\(\) of class PhpMyAdmin\\Config\:
6150-
Use dependency injection instead\.$#
6151-
'''
6152-
identifier: staticMethod.deprecated
6153-
count: 1
6154-
path: src/Export/Export.php
6155-
61566129
-
61576130
message: '#^Call to function in_array\(\) requires parameter \#3 to be set\.$#'
61586131
identifier: function.strict
@@ -6198,19 +6171,7 @@ parameters:
61986171
-
61996172
message: '#^Construct empty\(\) is not allowed\. Use more strict comparison\.$#'
62006173
identifier: empty.notAllowed
6201-
count: 4
6202-
path: src/Export/Export.php
6203-
6204-
-
6205-
message: '#^Method PhpMyAdmin\\Export\\Export\:\:compress\(\) return type has no value type specified in iterable type array\.$#'
6206-
identifier: missingType.iterableValue
6207-
count: 1
6208-
path: src/Export/Export.php
6209-
6210-
-
6211-
message: '#^Only booleans are allowed in a negated boolean, string\|false given\.$#'
6212-
identifier: booleanNot.exprNotBoolean
6213-
count: 1
6174+
count: 3
62146175
path: src/Export/Export.php
62156176

62166177
-
@@ -6219,12 +6180,6 @@ parameters:
62196180
count: 1
62206181
path: src/Export/Export.php
62216182

6222-
-
6223-
message: '#^Parameter \#1 \$stream of function fwrite expects resource, resource\|null given\.$#'
6224-
identifier: argument.type
6225-
count: 1
6226-
path: src/Export/Export.php
6227-
62286183
-
62296184
message: '#^Parameter \#2 \$dbAlias of method PhpMyAdmin\\Plugins\\ExportPlugin\:\:exportDBCreate\(\) expects string, mixed given\.$#'
62306185
identifier: argument.type
@@ -6297,6 +6252,18 @@ parameters:
62976252
count: 1
62986253
path: src/Export/Options.php
62996254

6255+
-
6256+
message: '#^Only booleans are allowed in a negated boolean, string\|false given\.$#'
6257+
identifier: booleanNot.exprNotBoolean
6258+
count: 1
6259+
path: src/Export/OutputHandler.php
6260+
6261+
-
6262+
message: '#^Property PhpMyAdmin\\Export\\OutputHandler\:\:\$dumpBuffer \(string\) does not accept string\|false\.$#'
6263+
identifier: assign.propertyType
6264+
count: 2
6265+
path: src/Export/OutputHandler.php
6266+
63006267
-
63016268
message: '#^Parameter \#1 \$id of class PhpMyAdmin\\Export\\Template constructor expects int, mixed given\.$#'
63026269
identifier: argument.type
@@ -9496,13 +9463,7 @@ parameters:
94969463
path: src/Plugins/Export/ExportPdf.php
94979464

94989465
-
9499-
message: '#^Construct empty\(\) is not allowed\. Use more strict comparison\.$#'
9500-
identifier: empty.notAllowed
9501-
count: 1
9502-
path: src/Plugins/Export/ExportPdf.php
9503-
9504-
-
9505-
message: '#^Parameter \#1 \$line of method PhpMyAdmin\\Export\\Export\:\:outputHandler\(\) expects string, mixed given\.$#'
9466+
message: '#^Parameter \#1 \$line of method PhpMyAdmin\\Export\\OutputHandler\:\:addLine\(\) expects string, mixed given\.$#'
95069467
identifier: argument.type
95079468
count: 1
95089469
path: src/Plugins/Export/ExportPdf.php

psalm-baseline.xml

Lines changed: 12 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1313,32 +1313,6 @@
13131313
<MixedPropertyTypeCoercion>
13141314
<code><![CDATA[$tableData]]></code>
13151315
</MixedPropertyTypeCoercion>
1316-
<PossiblyInvalidArgument>
1317-
<code><![CDATA[$this->export->dumpBuffer]]></code>
1318-
<code><![CDATA[$this->export->dumpBuffer]]></code>
1319-
</PossiblyInvalidArgument>
1320-
<PossiblyInvalidCast>
1321-
<code><![CDATA[$this->export->dumpBuffer]]></code>
1322-
<code><![CDATA[$this->export->dumpBuffer]]></code>
1323-
</PossiblyInvalidCast>
1324-
<PossiblyInvalidPropertyAssignmentValue>
1325-
<code><![CDATA[$this->export->compress(
1326-
$this->export->dumpBuffer,
1327-
Export::$compression,
1328-
$filename,
1329-
)]]></code>
1330-
<code><![CDATA[$this->export->compress(
1331-
$this->export->dumpBufferObjects,
1332-
Export::$compression,
1333-
$filename,
1334-
)]]></code>
1335-
</PossiblyInvalidPropertyAssignmentValue>
1336-
<PossiblyNullArgument>
1337-
<code><![CDATA[Export::$fileHandle]]></code>
1338-
</PossiblyNullArgument>
1339-
<PropertyTypeCoercion>
1340-
<code><![CDATA[$request->getParsedBodyParamAsString('compression')]]></code>
1341-
</PropertyTypeCoercion>
13421316
<RiskyTruthyFalsyComparison>
13431317
<code><![CDATA[$asSeparateFiles]]></code>
13441318
<code><![CDATA[$onServerParam]]></code>
@@ -4169,9 +4143,6 @@
41694143
<ArgumentTypeCoercion>
41704144
<code><![CDATA[(string) ini_get('memory_limit')]]></code>
41714145
</ArgumentTypeCoercion>
4172-
<DeprecatedMethod>
4173-
<code><![CDATA[Config::getInstance()]]></code>
4174-
</DeprecatedMethod>
41754146
<MixedArgument>
41764147
<code><![CDATA[$dbAlias]]></code>
41774148
<code><![CDATA[$dbAlias]]></code>
@@ -4221,15 +4192,10 @@
42214192
<MixedOperand>
42224193
<code><![CDATA[$tmpSelect]]></code>
42234194
</MixedOperand>
4224-
<PossiblyNullArgument>
4225-
<code><![CDATA[self::$fileHandle]]></code>
4226-
</PossiblyNullArgument>
42274195
<PossiblyNullArrayAccess>
42284196
<code><![CDATA[$error['message']]]></code>
42294197
</PossiblyNullArrayAccess>
42304198
<RiskyTruthyFalsyComparison>
4231-
<code><![CDATA[! ini_get('zlib.output_compression')]]></code>
4232-
<code><![CDATA[empty($_POST['onserver_overwrite'])]]></code>
42334199
<code><![CDATA[empty($postParams['structure_or_data_forced'])]]></code>
42344200
</RiskyTruthyFalsyComparison>
42354201
</file>
@@ -4256,6 +4222,14 @@
42564222
<code><![CDATA[empty($config->settings['SaveDir'])]]></code>
42574223
</RiskyTruthyFalsyComparison>
42584224
</file>
4225+
<file src="src/Export/OutputHandler.php">
4226+
<PossiblyFalsePropertyAssignmentValue>
4227+
<code><![CDATA[$zipExtension->createFile($dumpBuffer, $filename)]]></code>
4228+
</PossiblyFalsePropertyAssignmentValue>
4229+
<RiskyTruthyFalsyComparison>
4230+
<code><![CDATA[! ini_get('zlib.output_compression')]]></code>
4231+
</RiskyTruthyFalsyComparison>
4232+
</file>
42594233
<file src="src/Export/Template.php">
42604234
<MixedArgument>
42614235
<code><![CDATA[$state['data']]]></code>
@@ -6175,17 +6149,14 @@
61756149
<code><![CDATA[DatabaseInterface::getInstance()]]></code>
61766150
</DeprecatedMethod>
61776151
<MixedArgument>
6178-
<code><![CDATA[$pdf->getPDFData()]]></code>
6152+
<code><![CDATA[$this->pdf->getPDFData()]]></code>
61796153
</MixedArgument>
6180-
<PossiblyInvalidPropertyAssignmentValue>
6181-
<code><![CDATA[$_POST['pdf_report_title']]]></code>
6182-
</PossiblyInvalidPropertyAssignmentValue>
6154+
<MixedAssignment>
6155+
<code><![CDATA[$this->pdfReportTitle]]></code>
6156+
</MixedAssignment>
61836157
<PropertyNotSetInConstructor>
61846158
<code><![CDATA[$pdf]]></code>
61856159
</PropertyNotSetInConstructor>
6186-
<RiskyTruthyFalsyComparison>
6187-
<code><![CDATA[empty($_POST['pdf_report_title'])]]></code>
6188-
</RiskyTruthyFalsyComparison>
61896160
</file>
61906161
<file src="src/Plugins/Export/ExportPhparray.php">
61916162
<DeprecatedMethod>

0 commit comments

Comments
 (0)