Completed
Push — master ( ea38cd...f1efd0 )
by Once
02:04
created

example2.php (1 issue)

Severity
1
<?php
2
3
require __DIR__ . '/vendor/autoload.php';
4
5
use Zhaqq\Xlsx\Writer\Builder;
6
7
date_default_timezone_set('PRC');
8
9
try {
10
    $writer = new Builder();
11
12
    $fileName = __DIR__ . '/data/xlsx_writer' . date('Ymd-His') . '.xlsx';
13
14
    $writer->buildHeader('sheet_name_1', [
15
        'title' => 'string',
16
        'content' => 'string',
17
        'weight' => 'number',
18
    ]);
19
    $writer->buildHeader('sheet_name_2', [
20
        'title' => 'string',
21
        'content' => 'string',
22
        'price' => 'price',
23
    ]);
24
25
    foreach (rows(10) as $row) {
0 ignored issues
show
The call to rows() has too many arguments starting with 10. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

25
    foreach (/** @scrutinizer ignore-call */ rows(10) as $row) {

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
26
        $writer->writeSheetRow($row[0], $row[1]);
27
    }
28
29
    $writer->writeToFile($fileName);
30
31
} catch (\Exception $exception) {
32
    var_dump($exception->getMessage());
33
}
34
35
function rows($n = 10)
36
{
37
    for ($i = 0; $i < $n; $i++) {
38
        if ($i % 2) {
39
            yield ['sheet_name_1', [
40
                'title' . $i,
41
                'content' . $i,
42
                $i+$i,
43
            ]];
44
        } else {
45
            yield ['sheet_name_2', [
46
                'title' . $i,
47
                'content' . $i,
48
                $i+$i,
49
            ]];
50
        }
51
    }
52
}