Skip to content

Commit f7c183b

Browse files
authored
Merge pull request #4137 from oleibman/fixertest
Php-cs-fixer Increase Timeout, Replace Deprecated Properties
2 parents 6a8eda9 + b843d4e commit f7c183b

File tree

3 files changed

+28
-25
lines changed

3 files changed

+28
-25
lines changed

.php-cs-fixer.dist.php

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
$config
1111
->setRiskyAllowed(true)
1212
->setFinder($finder)
13-
->setParallelConfig(PhpCsFixer\Runner\Parallel\ParallelConfigFactory::detect())
13+
->setParallelConfig(PhpCsFixer\Runner\Parallel\ParallelConfigFactory::detect(null, 600))
1414
->setCacheFile(sys_get_temp_dir() . '/php-cs-fixer' . preg_replace('~\W~', '-', __DIR__))
1515
->setRules([
1616
'align_multiline_comment' => true,
@@ -19,18 +19,17 @@
1919
'backtick_to_shell_exec' => true,
2020
'binary_operator_spaces' => true,
2121
'blank_line_after_namespace' => true,
22+
'blank_lines_before_namespace' => ['max_line_breaks' => 2, 'min_line_breaks' => 2], // we want 1 blank line before namespace
2223
'blank_line_after_opening_tag' => true,
2324
'blank_line_before_statement' => true,
24-
'braces' => true,
2525
'cast_spaces' => true,
2626
'class_attributes_separation' => ['elements' => ['method' => 'one', 'property' => 'one']], // const are often grouped with other related const
2727
'class_definition' => false, // phpcs disagree
28-
'class_keyword_remove' => false, // Deprecated, and ::class keyword gives us better support in IDE
2928
'combine_consecutive_issets' => true,
3029
'combine_consecutive_unsets' => true,
3130
'combine_nested_dirname' => true,
3231
'comment_to_phpdoc' => false, // interferes with annotations
33-
'compact_nullable_typehint' => true,
32+
'compact_nullable_type_declaration' => true,
3433
'concat_space' => ['spacing' => 'one'],
3534
'constant_case' => true,
3635
'date_time_immutable' => false, // Break our unit tests
@@ -47,7 +46,6 @@
4746
'encoding' => true,
4847
'ereg_to_preg' => true,
4948
'error_suppression' => false, // it breaks \PhpOffice\PhpSpreadsheet\Helper\Handler
50-
'escape_implicit_backslashes' => true,
5149
'explicit_indirect_variable' => false, // I feel it makes the code actually harder to read
5250
'explicit_string_variable' => false, // I feel it makes the code actually harder to read
5351
'final_class' => false, // We need non-final classes
@@ -59,7 +57,6 @@
5957
'fully_qualified_strict_types' => true,
6058
'function_declaration' => true,
6159
'function_to_constant' => true,
62-
'function_typehint_space' => true,
6360
'general_phpdoc_annotation_remove' => ['annotations' => ['access', 'category', 'copyright']],
6461
'general_phpdoc_tag_rename' => true,
6562
'global_namespace_import' => true,
@@ -93,15 +90,13 @@
9390
'native_constant_invocation' => false, // Micro optimization that look messy
9491
'native_function_casing' => true,
9592
'native_function_invocation' => false, // I suppose this would be best, but I am still unconvinced about the visual aspect of it
96-
'native_function_type_declaration_casing' => true,
97-
'new_with_braces' => true,
93+
'new_with_parentheses' => ['anonymous_class' => true, 'named_class' => true],
9894
'no_alias_functions' => true,
9995
'no_alias_language_construct_call' => true,
10096
'no_alternative_syntax' => true,
10197
'no_binary_string' => true,
10298
'no_blank_lines_after_class_opening' => true,
10399
'no_blank_lines_after_phpdoc' => true,
104-
'no_blank_lines_before_namespace' => false, // we want 1 blank line before namespace
105100
'no_break_comment' => true,
106101
'no_closing_tag' => true,
107102
'no_empty_comment' => true,
@@ -121,16 +116,14 @@
121116
'no_space_around_double_colon' => true,
122117
'no_spaces_after_function_name' => true,
123118
'no_spaces_around_offset' => true,
124-
'no_spaces_inside_parenthesis' => true,
125119
'no_superfluous_elseif' => false, // Might be risky on a huge code base
126120
'no_superfluous_phpdoc_tags' => ['allow_mixed' => true],
127-
'no_trailing_comma_in_list_call' => true,
128-
'no_trailing_comma_in_singleline_array' => true,
121+
'no_trailing_comma_in_singleline' => ['elements' => ['arguments', 'array_destructuring', 'array', 'group_import']],
129122
'no_trailing_whitespace' => true,
130123
'no_trailing_whitespace_in_comment' => true,
131124
'no_trailing_whitespace_in_string' => false, // Too dangerous
132125
'no_unneeded_control_parentheses' => true,
133-
'no_unneeded_curly_braces' => true,
126+
'no_unneeded_braces' => true,
134127
'no_unneeded_final_method' => true,
135128
'no_unreachable_default_argument_value' => true,
136129
'no_unset_cast' => true,
@@ -175,7 +168,6 @@
175168
'phpdoc_align' => false, // Waste of time
176169
'phpdoc_annotation_without_dot' => true,
177170
'phpdoc_indent' => true,
178-
//'phpdoc_inline_tag' => true,
179171
'phpdoc_line_span' => false, // Unfortunately our old comments turn even uglier with this
180172
'phpdoc_no_access' => true,
181173
'phpdoc_no_alias_tag' => true,
@@ -215,20 +207,20 @@
215207
'simplified_if_return' => false, // Even if technically correct we prefer to be explicit
216208
'simplified_null_return' => false, // Even if technically correct we prefer to be explicit
217209
'single_blank_line_at_eof' => true,
218-
'single_blank_line_before_namespace' => true,
219210
'single_class_element_per_statement' => true,
220211
'single_import_per_statement' => true,
221212
'single_line_after_imports' => true,
222213
'single_line_comment_style' => true,
223214
'single_line_throw' => false, // I don't see any reason for having a special case for Exception
224215
'single_quote' => true,
225-
'single_space_after_construct' => true,
226216
'single_trait_insert_per_statement' => true,
227217
'space_after_semicolon' => true,
218+
'spaces_inside_parentheses' => ['space' => 'none'],
228219
'standardize_increment' => true,
229220
'standardize_not_equals' => true,
230221
'static_lambda' => false, // Risky if we can't guarantee nobody use `bindTo()`
231222
'strict_comparison' => false, // No, too dangerous to change that
223+
'string_implicit_backslashes' => false, // was escape_implicit_backslashes, too confusing
232224
'strict_param' => false, // No, too dangerous to change that
233225
'string_length_to_empty' => true,
234226
'string_line_ending' => true,
@@ -240,6 +232,7 @@
240232
'ternary_to_null_coalescing' => true,
241233
'trailing_comma_in_multiline' => true,
242234
'trim_array_spaces' => true,
235+
'type_declaration_spaces' => ['elements' => ['function', 'property']], // was function_typehint_space
243236
'types_spaces' => true,
244237
'unary_operator_spaces' => true,
245238
'use_arrow_functions' => true,

tests/PhpSpreadsheetTests/Chart/ChartsDynamicTitleTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ public function writeCharts(XlsxWriter $writer): void
3434
$writer->setIncludeCharts(true);
3535
}
3636

37+
#[\PHPUnit\Framework\Attributes\RunInSeparateProcess]
3738
public function testDynamicTitle(): void
3839
{
3940
// based on samples/templates/issue.3797.2007.xlsx

tests/PhpSpreadsheetTests/Reader/Xlsx/XlsxTest.php

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ public function testLoadXlsxRowColumnAttributes(): void
4141
}
4242

4343
self::assertFalse($worksheet->getColumnDimension('E')->getVisible());
44+
$spreadsheet->disconnectWorksheets();
4445
}
4546

4647
public function testLoadXlsxWithStyles(): void
@@ -65,6 +66,7 @@ public function testLoadXlsxWithStyles(): void
6566
);
6667
}
6768
}
69+
$spreadsheet->disconnectWorksheets();
6870
}
6971

7072
/**
@@ -87,6 +89,7 @@ public function testLoadXlsxWithoutStyles(): void
8789
$reloadedWorksheet = $reloadedSpreadsheet->getActiveSheet();
8890

8991
self::assertEquals('TipoDato', $reloadedWorksheet->getCell('A1')->getValue());
92+
$spreadsheet->disconnectWorksheets();
9093
}
9194

9295
/**
@@ -108,6 +111,7 @@ public function testLoadXlsxWithEmptyStyles(): void
108111

109112
$reloadedWorksheet = $reloadedSpreadsheet->getActiveSheet();
110113
self::assertEquals('TipoDato', $reloadedWorksheet->getCell('A1')->getValue());
114+
$spreadsheet->disconnectWorksheets();
111115
}
112116

113117
public function testLoadXlsxAutofilter(): void
@@ -125,6 +129,7 @@ public function testLoadXlsxAutofilter(): void
125129
AutoFilter\Column::AUTOFILTER_FILTERTYPE_FILTER,
126130
$autofilter->getColumn('A')->getFilterType()
127131
);
132+
$spreadsheet->disconnectWorksheets();
128133
}
129134

130135
public function testLoadXlsxPageSetup(): void
@@ -163,18 +168,19 @@ public function testLoadXlsxConditionalFormatting(): void
163168
self::assertEquals(Conditional::OPERATOR_BETWEEN, $conditionalRule->getOperatorType());
164169
self::assertEquals(['200', '400'], $conditionalRule->getConditions());
165170
self::assertInstanceOf(Style::class, $conditionalRule->getStyle());
171+
$spreadsheet->disconnectWorksheets();
166172
}
167173

168174
/**
169175
* Test load Xlsx file without cell reference.
170-
*
171-
* @doesNotPerformAssertions
172176
*/
173177
public function testLoadXlsxWithoutCellReference(): void
174178
{
175179
$filename = 'tests/data/Reader/XLSX/without_cell_reference.xlsx';
176180
$reader = new Xlsx();
177-
$reader->load($filename);
181+
$spreadsheet = $reader->load($filename);
182+
self::assertSame(1, $spreadsheet->getActiveSheet()->getCell('A1')->getValue());
183+
$spreadsheet->disconnectWorksheets();
178184
}
179185

180186
/**
@@ -185,24 +191,26 @@ public function testLoadWithReadFilter(): void
185191
$filename = 'tests/data/Reader/XLSX/without_cell_reference.xlsx';
186192
$reader = new Xlsx();
187193
$reader->setReadFilter(new OddColumnReadFilter());
188-
$data = $reader->load($filename)->getActiveSheet()->toArray();
194+
$spreadsheet = $reader->load($filename);
195+
$data = $spreadsheet->getActiveSheet()->toArray();
189196
$ref = [1.0, null, 3.0, null, 5.0, null, 7.0, null, 9.0, null];
190197

191198
for ($i = 0; $i < 10; ++$i) {
192199
self::assertEquals($ref, \array_slice($data[$i], 0, 10, true));
193200
}
201+
$spreadsheet->disconnectWorksheets();
194202
}
195203

196204
/**
197205
* Test load Xlsx file with drawing having double attributes.
198-
*
199-
* @doesNotPerformAssertions
200206
*/
201207
public function testLoadXlsxWithDoubleAttrDrawing(): void
202208
{
203209
$filename = 'tests/data/Reader/XLSX/double_attr_drawing.xlsx';
204210
$reader = new Xlsx();
205-
$reader->load($filename);
211+
$spreadsheet = $reader->load($filename);
212+
self::assertSame('TOSHIBA_HITACHI_SKYWORTH', $spreadsheet->getActiveSheet()->getTitle());
213+
$spreadsheet->disconnectWorksheets();
206214
}
207215

208216
/**
@@ -219,8 +227,8 @@ public function testLoadSaveWithEmptyDrawings(): void
219227
$writer->save($resultFilename);
220228
$excel = $reader->load($resultFilename);
221229
unlink($resultFilename);
222-
// Fake assert. The only thing we need is to ensure the file is loaded without exception
223-
self::assertNotNull($excel);
230+
self::assertSame(1.0, $excel->getActiveSheet()->getCell('A1')->getValue());
231+
$excel->disconnectWorksheets();
224232
}
225233

226234
/**
@@ -271,5 +279,6 @@ public function testLoadDataOnlyLoadsAlsoTables(): void
271279
['e', 'f'],
272280
['g', 'h'],
273281
], $secondSheet->toArray());
282+
$excel->disconnectWorksheets();
274283
}
275284
}

0 commit comments

Comments
 (0)