Skip to content

Commit 2482203

Browse files
authored
Resolve Scrutinizer Reports for Samples (#2691)
These are handled about 50-50 between code changes when reasonable, and annotations when not. No source code is changed.
1 parent 0ce56b1 commit 2482203

22 files changed

+45
-46
lines changed

samples/Basic/44_Worksheet_info.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
<?php
22

33
use PhpOffice\PhpSpreadsheet\IOFactory;
4-
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
4+
use PhpOffice\PhpSpreadsheet\Reader\Xlsx as Reader;
5+
use PhpOffice\PhpSpreadsheet\Writer\Xlsx as Writer;
56

67
require __DIR__ . '/../Header.php';
78

89
// Create temporary file that will be read
910
$sampleSpreadsheet = require __DIR__ . '/../templates/sampleSpreadsheet.php';
1011
$filename = $helper->getTemporaryFilename();
11-
$writer = new Xlsx($sampleSpreadsheet);
12+
$writer = new Writer($sampleSpreadsheet);
1213
$writer->save($filename);
1314

1415
$inputFileType = IOFactory::identify($filename);
15-
$reader = IOFactory::createReader($inputFileType);
16+
$reader = new Reader();
1617
$sheetList = $reader->listWorksheetNames($filename);
1718
$sheetInfo = $reader->listWorksheetInfo($filename);
1819

samples/Reader/01_Simple_file_reader_using_IOFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
require __DIR__ . '/../Header.php';
66

77
$inputFileName = __DIR__ . '/sampleData/example1.xls';
8-
$helper->log('Loading file ' . pathinfo($inputFileName, PATHINFO_BASENAME) . ' using IOFactory to identify the format');
8+
$helper->log('Loading file ' . /** @scrutinizer ignore-type */ pathinfo($inputFileName, PATHINFO_BASENAME) . ' using IOFactory to identify the format');
99
$spreadsheet = IOFactory::load($inputFileName);
1010
$sheetData = $spreadsheet->getActiveSheet()->toArray(null, true, true, true);
1111
var_dump($sheetData);

samples/Reader/02_Simple_file_reader_using_a_specified_reader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
require __DIR__ . '/../Header.php';
66
$inputFileName = __DIR__ . '/sampleData/example1.xls';
77

8-
$helper->log('Loading file ' . pathinfo($inputFileName, PATHINFO_BASENAME) . ' using ' . Xls::class);
8+
$helper->log('Loading file ' . /** @scrutinizer ignore-type */ pathinfo($inputFileName, PATHINFO_BASENAME) . ' using ' . Xls::class);
99
$reader = new Xls();
1010
$spreadsheet = $reader->load($inputFileName);
1111

samples/Reader/03_Simple_file_reader_using_the_IOFactory_to_return_a_reader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
$inputFileType = 'Xls';
88
$inputFileName = __DIR__ . '/sampleData/example1.xls';
99

10-
$helper->log('Loading file ' . pathinfo($inputFileName, PATHINFO_BASENAME) . ' using IOFactory with a defined reader type of ' . $inputFileType);
10+
$helper->log('Loading file ' . /** @scrutinizer ignore-type */ pathinfo($inputFileName, PATHINFO_BASENAME) . ' using IOFactory with a defined reader type of ' . $inputFileType);
1111
$reader = IOFactory::createReader($inputFileType);
1212
$spreadsheet = $reader->load($inputFileName);
1313

samples/Reader/04_Simple_file_reader_using_the_IOFactory_to_identify_a_reader_to_use.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
$inputFileName = __DIR__ . '/sampleData/example1.xls';
88

99
$inputFileType = IOFactory::identify($inputFileName);
10-
$helper->log('File ' . pathinfo($inputFileName, PATHINFO_BASENAME) . ' has been identified as an ' . $inputFileType . ' file');
10+
$helper->log('File ' . /** @scrutinizer ignore-type */ pathinfo($inputFileName, PATHINFO_BASENAME) . ' has been identified as an ' . $inputFileType . ' file');
1111

12-
$helper->log('Loading file ' . pathinfo($inputFileName, PATHINFO_BASENAME) . ' using IOFactory with the identified reader type');
12+
$helper->log('Loading file ' . /** @scrutinizer ignore-type */ pathinfo($inputFileName, PATHINFO_BASENAME) . ' using IOFactory with the identified reader type');
1313
$reader = IOFactory::createReader($inputFileType);
1414
$spreadsheet = $reader->load($inputFileName);
1515

samples/Reader/05_Simple_file_reader_using_the_read_data_only_option.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
$inputFileType = 'Xls';
88
$inputFileName = __DIR__ . '/sampleData/example1.xls';
99

10-
$helper->log('Loading file ' . pathinfo($inputFileName, PATHINFO_BASENAME) . ' using IOFactory with a defined reader type of ' . $inputFileType);
10+
$helper->log('Loading file ' . /** @scrutinizer ignore-type */ pathinfo($inputFileName, PATHINFO_BASENAME) . ' using IOFactory with a defined reader type of ' . $inputFileType);
1111
$reader = IOFactory::createReader($inputFileType);
1212
$helper->log('Turning Formatting off for Load');
1313
$reader->setReadDataOnly(true);

samples/Reader/06_Simple_file_reader_loading_all_worksheets.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
$inputFileType = 'Xls';
88
$inputFileName = __DIR__ . '/sampleData/example1.xls';
99

10-
$helper->log('Loading file ' . pathinfo($inputFileName, PATHINFO_BASENAME) . ' using IOFactory with a defined reader type of ' . $inputFileType);
10+
$helper->log('Loading file ' . /** @scrutinizer ignore-type */ pathinfo($inputFileName, PATHINFO_BASENAME) . ' using IOFactory with a defined reader type of ' . $inputFileType);
1111
$reader = IOFactory::createReader($inputFileType);
1212
$helper->log('Loading all WorkSheets');
1313
$reader->setLoadAllSheets();

samples/Reader/07_Simple_file_reader_loading_a_single_named_worksheet.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
$inputFileName = __DIR__ . '/sampleData/example1.xls';
99
$sheetname = 'Data Sheet #2';
1010

11-
$helper->log('Loading file ' . pathinfo($inputFileName, PATHINFO_BASENAME) . ' using IOFactory with a defined reader type of ' . $inputFileType);
11+
$helper->log('Loading file ' . /** @scrutinizer ignore-type */ pathinfo($inputFileName, PATHINFO_BASENAME) . ' using IOFactory with a defined reader type of ' . $inputFileType);
1212
$reader = IOFactory::createReader($inputFileType);
1313
$helper->log('Loading Sheet "' . $sheetname . '" only');
1414
$reader->setLoadSheetsOnly($sheetname);

samples/Reader/08_Simple_file_reader_loading_several_named_worksheets.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
$inputFileName = __DIR__ . '/sampleData/example1.xls';
99
$sheetnames = ['Data Sheet #1', 'Data Sheet #3'];
1010

11-
$helper->log('Loading file ' . pathinfo($inputFileName, PATHINFO_BASENAME) . ' using IOFactory with a defined reader type of ' . $inputFileType);
11+
$helper->log('Loading file ' . /** @scrutinizer ignore-type */ pathinfo($inputFileName, PATHINFO_BASENAME) . ' using IOFactory with a defined reader type of ' . $inputFileType);
1212
$reader = IOFactory::createReader($inputFileType);
1313
$helper->log('Loading Sheet' . ((count($sheetnames) == 1) ? '' : 's') . ' "' . implode('" and "', $sheetnames) . '" only');
1414
$reader->setLoadSheetsOnly($sheetnames);

samples/Reader/09_Simple_file_reader_using_a_read_filter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public function readCell($columnAddress, $row, $worksheetName = '')
2828

2929
$filterSubset = new MyReadFilter();
3030

31-
$helper->log('Loading file ' . pathinfo($inputFileName, PATHINFO_BASENAME) . ' using IOFactory with a defined reader type of ' . $inputFileType);
31+
$helper->log('Loading file ' . /** @scrutinizer ignore-type */ pathinfo($inputFileName, PATHINFO_BASENAME) . ' using IOFactory with a defined reader type of ' . $inputFileType);
3232
$reader = IOFactory::createReader($inputFileType);
3333
$helper->log('Loading Sheet "' . $sheetname . '" only');
3434
$reader->setLoadSheetsOnly($sheetname);

0 commit comments

Comments
 (0)