These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace CsvCombine\Form; |
||
4 | |||
5 | use Cake\Form\Form; |
||
6 | |||
7 | class FixedLengthImportForm extends Form |
||
8 | { |
||
9 | private $_defaultOptions = [ |
||
10 | 'line_feed_code' => "\r\n", |
||
11 | 'directory' => TMP, |
||
12 | 'array_encoding' => 'UTF-8', |
||
13 | 'import_encoding' => 'SJIS-win', |
||
14 | 'extra_fixed_options' => [] |
||
15 | ]; |
||
16 | |||
17 | /* |
||
18 | * loadData 固定長読み込みアクション |
||
19 | * |
||
20 | * @param string $fileName 固定長テキストファイ |
||
21 | * @param array $column_list 各カラム情報(name:カラム名,length:バイト数) |
||
22 | * @param array $options 下記パラメータを必要に応じて設定 |
||
23 | * line_feed_code 改行コード(デフォルトは\r\n) |
||
24 | * array_encoding 出力するする配列のエンコード(デフォルトはUTF-8 |
||
25 | * import_encoding 入力するテキストのエンコード(デフォルトはSJIS-win |
||
26 | * extra_fixed_options 出力のための固定長の設定(列によって桁数が異なる場合の設定) |
||
27 | */ |
||
28 | public function loadData($fileName, $fixed_options, $options = []) |
||
29 | { |
||
30 | $options = array_merge($this->_defaultOptions,$options); |
||
31 | extract($options); |
||
32 | |||
33 | $fp = fopen($fileName,'r'); |
||
34 | $data = fread($fp, filesize($fileName)); |
||
35 | fclose($fp); |
||
36 | |||
37 | return $this->loadDataBody($data, $fixed_options, $options); |
||
38 | } |
||
39 | |||
40 | /* |
||
41 | * loadDataBody 固定長内容読み込みアクション |
||
42 | * |
||
43 | * @param string $data 固定長テキストデータ |
||
44 | * @param array $column_list 各カラム情報(name:カラム名,length:バイト数) |
||
0 ignored issues
–
show
|
|||
45 | * @param array $options 下記パラメータを必要に応じて設定 |
||
46 | * line_feed_code 改行コード(デフォルトは\r\n) |
||
47 | * array_encoding 出力するする配列のエンコード(デフォルトはUTF-8 |
||
48 | * import_encoding 入力するテキストのエンコード(デフォルトはSJIS-win |
||
49 | * extra_fixed_options 出力のための固定長の設定(列によって桁数が異なる場合の設定) |
||
50 | */ |
||
51 | public function loadDataBody($data, $fixed_options, $options = []) |
||
52 | { |
||
53 | $options = array_merge($this->_defaultOptions,$options); |
||
54 | extract($options); |
||
55 | |||
56 | $return_info = []; |
||
57 | //まずは分割 |
||
58 | $data_explode = explode($line_feed_code, $data); |
||
59 | $list_count = count($data_explode); |
||
60 | foreach ($data_explode as $row => $text) { |
||
61 | //空行は無視 |
||
62 | if (strlen($text) === 0) { |
||
63 | continue; |
||
64 | } |
||
65 | $start_point = 0; |
||
66 | $column_list = $fixed_options; |
||
67 | View Code Duplication | if (array_key_exists($row + 1, $extra_fixed_options)) { |
|
68 | $column_list = $extra_fixed_options[$row + 1]; |
||
69 | } elseif (array_key_exists($row - $list_count + 1, $extra_fixed_options)) { |
||
70 | $column_list = $extra_fixed_options[$row - $list_count + 1]; |
||
71 | } |
||
72 | |||
73 | foreach ($column_list as $column_info) { |
||
74 | $return_info[$row][$column_info['name']] = rtrim(substr($text, $start_point, $column_info['length'])); |
||
75 | $start_point += $column_info['length']; |
||
76 | } |
||
77 | } |
||
78 | |||
79 | //最後にまとめて文字コードを変換 |
||
80 | mb_convert_variables($array_encoding, $import_encoding, $return_info); |
||
81 | |||
82 | return $return_info; |
||
83 | } |
||
84 | } |
||
85 |
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italy
is not defined by the methodfinale(...)
.The most likely cause is that the parameter was removed, but the annotation was not.