mirror of
https://github.com/PHPOffice/PhpSpreadsheet.git
synced 2026-09-22 08:09:15 +00:00
PhpUnit 10 Compatibility Part 2 (#3526)
Successor to PR #3523. There are 494 single-line changes (`public function provider` to `public static function provider`) in this PR. None of these were made manually; they were all created with the following script (adapted from https://stackoverflow.com/questions/25909820/how-to-recursively-iterate-through-files-in-php): ```php $dir = 'C:/git/unit10prep2/tests/PhpSpreadsheetTests'; $it = new RecursiveDirectoryIterator($dir); // Loop through files foreach(new RecursiveIteratorIterator($it) as $file) { if ($file->getExtension() === 'php') { $contents = file_get_contents($file); $new = preg_replace('/public function (\\w*)([Pp])rovider/', 'public static function $1$2rovider', $contents); if ($new !== $contents) { echo "changing $file\n"; file_put_contents($file, $new); } } } ``` After this PR, there will be one more, with a small number of test changes, and enabling PhpUnit 10 for Php 8.1+.
This commit is contained in:
@@ -13,7 +13,7 @@ class HtmlCommentsTest extends Functional\AbstractFunctional
|
||||
*/
|
||||
private $spreadsheet;
|
||||
|
||||
public function providerCommentRichText(): array
|
||||
public static function providerCommentRichText(): array
|
||||
{
|
||||
$valueSingle = 'I am comment.';
|
||||
$valueMulti = 'I am ' . PHP_EOL . 'multi-line' . PHP_EOL . 'comment.';
|
||||
|
||||
@@ -182,7 +182,7 @@ class HtmlNumberFormatTest extends Functional\AbstractFunctional
|
||||
$this->writeAndReload($spreadsheet, 'Html');
|
||||
}
|
||||
|
||||
public function providerNumberFormat(): array
|
||||
public static function providerNumberFormat(): array
|
||||
{
|
||||
return require __DIR__ . '/../../../data/Style/NumberFormat.php';
|
||||
}
|
||||
@@ -218,7 +218,7 @@ class HtmlNumberFormatTest extends Functional\AbstractFunctional
|
||||
$this->writeAndReload($spreadsheet, 'Html');
|
||||
}
|
||||
|
||||
public function providerNumberFormatDates(): array
|
||||
public static function providerNumberFormatDates(): array
|
||||
{
|
||||
return require __DIR__ . '/../../../data/Style/NumberFormatDates.php';
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ use PhpOffice\PhpSpreadsheetTests\Functional;
|
||||
|
||||
class XssVulnerabilityTest extends Functional\AbstractFunctional
|
||||
{
|
||||
public function providerAcceptableMarkupRichText(): array
|
||||
public static function providerAcceptableMarkupRichText(): array
|
||||
{
|
||||
return [
|
||||
'basic text' => ['Hello, I am safely viewing your site', 'Hello, I am safely viewing your site'],
|
||||
@@ -48,7 +48,7 @@ class XssVulnerabilityTest extends Functional\AbstractFunctional
|
||||
self::assertStringContainsString($adjustedTextString, $verify);
|
||||
}
|
||||
|
||||
public function providerXssRichText(): array
|
||||
public static function providerXssRichText(): array
|
||||
{
|
||||
return [
|
||||
'script tag' => ["Hello, I am trying to <script>alert('Hack');</script> your site"],
|
||||
|
||||
@@ -22,7 +22,7 @@ class PreCalcTest extends AbstractFunctional
|
||||
}
|
||||
}
|
||||
|
||||
public function providerPreCalc(): array
|
||||
public static function providerPreCalc(): array
|
||||
{
|
||||
return [
|
||||
[true, 'Xlsx'],
|
||||
|
||||
@@ -7,7 +7,7 @@ use PhpOffice\PhpSpreadsheetTests\Functional\AbstractFunctional;
|
||||
|
||||
class RetainSelectedCellsTest extends AbstractFunctional
|
||||
{
|
||||
public function providerFormats(): array
|
||||
public static function providerFormats(): array
|
||||
{
|
||||
return [
|
||||
['Xls'],
|
||||
|
||||
@@ -27,7 +27,7 @@ class VisibilityTest extends AbstractFunctional
|
||||
}
|
||||
}
|
||||
|
||||
public function dataProviderRowVisibility(): array
|
||||
public static function dataProviderRowVisibility(): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
@@ -55,7 +55,7 @@ class VisibilityTest extends AbstractFunctional
|
||||
}
|
||||
}
|
||||
|
||||
public function dataProviderColumnVisibility(): array
|
||||
public static function dataProviderColumnVisibility(): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
@@ -84,7 +84,7 @@ class VisibilityTest extends AbstractFunctional
|
||||
}
|
||||
}
|
||||
|
||||
public function dataProviderSheetVisibility(): array
|
||||
public static function dataProviderSheetVisibility(): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
|
||||
@@ -120,7 +120,7 @@ class ConditionalTest extends AbstractFunctional
|
||||
self::assertStringContainsString($expected, $data);
|
||||
}
|
||||
|
||||
public function textConditionalsProvider(): array
|
||||
public static function textConditionalsProvider(): array
|
||||
{
|
||||
return [
|
||||
'Contains' => [
|
||||
@@ -197,7 +197,7 @@ class ConditionalTest extends AbstractFunctional
|
||||
self::assertStringContainsString($expected, $data);
|
||||
}
|
||||
|
||||
public function dateConditionalsProvider(): array
|
||||
public static function dateConditionalsProvider(): array
|
||||
{
|
||||
return [
|
||||
'Yesterday' => [
|
||||
@@ -325,7 +325,7 @@ class ConditionalTest extends AbstractFunctional
|
||||
self::assertStringContainsString($expected, $data);
|
||||
}
|
||||
|
||||
public function blanksConditionalsProvider(): array
|
||||
public static function blanksConditionalsProvider(): array
|
||||
{
|
||||
return [
|
||||
'Blanks' => [
|
||||
@@ -405,7 +405,7 @@ class ConditionalTest extends AbstractFunctional
|
||||
self::assertStringContainsString($expected, $data);
|
||||
}
|
||||
|
||||
public function errorsConditionalsProvider(): array
|
||||
public static function errorsConditionalsProvider(): array
|
||||
{
|
||||
return [
|
||||
'Errors' => [
|
||||
@@ -485,7 +485,7 @@ class ConditionalTest extends AbstractFunctional
|
||||
self::assertStringContainsString($expected, $data);
|
||||
}
|
||||
|
||||
public function duplicatesConditionalsProvider(): array
|
||||
public static function duplicatesConditionalsProvider(): array
|
||||
{
|
||||
return [
|
||||
'Duplicates' => [
|
||||
@@ -545,7 +545,7 @@ class ConditionalTest extends AbstractFunctional
|
||||
self::assertStringContainsString($expected, $data);
|
||||
}
|
||||
|
||||
public function expressionsConditionalsProvider(): array
|
||||
public static function expressionsConditionalsProvider(): array
|
||||
{
|
||||
return [
|
||||
'Odd' => [
|
||||
|
||||
@@ -550,7 +550,7 @@ class DrawingsTest extends AbstractFunctional
|
||||
$reloadedSpreadsheet->disconnectWorksheets();
|
||||
}
|
||||
|
||||
public function providerEditAs(): array
|
||||
public static function providerEditAs(): array
|
||||
{
|
||||
return [
|
||||
'absolute' => ['absolute'],
|
||||
|
||||
@@ -33,7 +33,7 @@ class FloatsRetainedTest extends TestCase
|
||||
$spreadsheet2->disconnectWorksheets();
|
||||
}
|
||||
|
||||
public function providerIntyFloatsRetainedByWriter(): array
|
||||
public static function providerIntyFloatsRetainedByWriter(): array
|
||||
{
|
||||
return [
|
||||
[-1.0],
|
||||
|
||||
@@ -16,7 +16,7 @@ class FunctionPrefixTest extends TestCase
|
||||
self::assertSame($expectedResult, $result);
|
||||
}
|
||||
|
||||
public function functionPrefixProvider(): array
|
||||
public static function functionPrefixProvider(): array
|
||||
{
|
||||
return [
|
||||
'Basic Legacy Function' => ['SUM()', 'SUM()'],
|
||||
@@ -44,7 +44,7 @@ class FunctionPrefixTest extends TestCase
|
||||
// self::assertSame($expectedResult, $result);
|
||||
// }
|
||||
//
|
||||
// public function functionPrefixWithEqualsProvider(): array
|
||||
// public static function functionPrefixWithEqualsProvider(): array
|
||||
// {
|
||||
// return [
|
||||
// 'Basic Legacy Function' => ['SUM()', '=SUM()'],
|
||||
|
||||
@@ -35,7 +35,7 @@ class Issue2266Test extends AbstractFunctional
|
||||
$reloadedSpreadsheet->disconnectWorksheets();
|
||||
}
|
||||
|
||||
public function providerType(): array
|
||||
public static function providerType(): array
|
||||
{
|
||||
return [
|
||||
['Xlsx'],
|
||||
|
||||
@@ -27,7 +27,7 @@ class VisibilityTest extends AbstractFunctional
|
||||
}
|
||||
}
|
||||
|
||||
public function dataProviderRowVisibility(): array
|
||||
public static function dataProviderRowVisibility(): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
@@ -55,7 +55,7 @@ class VisibilityTest extends AbstractFunctional
|
||||
}
|
||||
}
|
||||
|
||||
public function dataProviderColumnVisibility(): array
|
||||
public static function dataProviderColumnVisibility(): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
@@ -84,7 +84,7 @@ class VisibilityTest extends AbstractFunctional
|
||||
}
|
||||
}
|
||||
|
||||
public function dataProviderSheetVisibility(): array
|
||||
public static function dataProviderSheetVisibility(): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
|
||||
Reference in New Issue
Block a user