Conditions | 53 |
Paths | > 20000 |
Total Lines | 205 |
Code Lines | 131 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
322 | protected function _extractList($p_path, &$p_list_detail, $p_mode, |
||
323 | $p_file_list, $p_remove_path) |
||
324 | { |
||
325 | $v_result = true; |
||
326 | $v_nb = 0; |
||
327 | $v_extract_all = true; |
||
328 | $v_listing = false; |
||
329 | |||
330 | $p_path = $this->_translateWinPath($p_path, false); |
||
331 | if ($p_path == '' || (substr($p_path, 0, 1) != '/' |
||
332 | && substr($p_path, 0, 3) != "../" && !strpos($p_path, ':'))) { |
||
333 | $p_path = "./" . $p_path; |
||
334 | } |
||
335 | $p_remove_path = $this->_translateWinPath($p_remove_path); |
||
336 | |||
337 | // ----- Look for path to remove format (should end by /) |
||
338 | if (($p_remove_path != '') && (substr($p_remove_path, -1) != '/')) |
||
339 | $p_remove_path .= '/'; |
||
340 | $p_remove_path_size = strlen($p_remove_path); |
||
341 | |||
342 | switch ($p_mode) { |
||
343 | case "complete" : |
||
344 | $v_extract_all = true; |
||
345 | $v_listing = false; |
||
346 | break; |
||
347 | case "partial" : |
||
348 | $v_extract_all = false; |
||
349 | $v_listing = false; |
||
350 | break; |
||
351 | case "list" : |
||
352 | $v_extract_all = false; |
||
353 | $v_listing = true; |
||
354 | break; |
||
355 | default : |
||
356 | $this->_error('Invalid extract mode (' . $p_mode . ')'); |
||
357 | return false; |
||
358 | } |
||
359 | |||
360 | clearstatcache(); |
||
361 | |||
362 | while (strlen($v_binary_data = $this->_readBlock()) != 0) |
||
363 | { |
||
364 | $v_extract_file = false; |
||
365 | $v_extraction_stopped = 0; |
||
366 | |||
367 | if (!$this->_readHeader($v_binary_data, $v_header)) |
||
368 | return false; |
||
369 | |||
370 | if ($v_header['filename'] == '') { |
||
371 | continue; |
||
372 | } |
||
373 | |||
374 | // ----- Look for long filename |
||
375 | if ($v_header['typeflag'] == 'L') { |
||
376 | if (!$this->_readLongHeader($v_header)) |
||
377 | return false; |
||
378 | } |
||
379 | |||
380 | if ((!$v_extract_all) && (is_array($p_file_list))) { |
||
381 | // ----- By default no unzip if the file is not found |
||
382 | $v_extract_file = false; |
||
383 | |||
384 | for ($i = 0; $i < count($p_file_list); $i++) { |
||
385 | // ----- Look if it is a directory |
||
386 | if (substr($p_file_list[$i], -1) == '/') { |
||
387 | // ----- Look if the directory is in the filename path |
||
388 | if ((strlen($v_header['filename']) > strlen($p_file_list[$i])) |
||
389 | && (substr($v_header['filename'], 0, strlen($p_file_list[$i])) |
||
390 | == $p_file_list[$i])) { |
||
391 | $v_extract_file = true; |
||
392 | break; |
||
393 | } |
||
394 | } |
||
395 | |||
396 | // ----- It is a file, so compare the file names |
||
397 | elseif ($p_file_list[$i] == $v_header['filename']) { |
||
398 | $v_extract_file = true; |
||
399 | break; |
||
400 | } |
||
401 | } |
||
402 | } else { |
||
403 | $v_extract_file = true; |
||
404 | } |
||
405 | |||
406 | // ----- Look if this file need to be extracted |
||
407 | if (($v_extract_file) && (!$v_listing)) |
||
408 | { |
||
409 | if (($p_remove_path != '') |
||
410 | && (substr($v_header['filename'], 0, $p_remove_path_size) |
||
411 | == $p_remove_path)) |
||
412 | $v_header['filename'] = substr($v_header['filename'], |
||
413 | $p_remove_path_size); |
||
414 | if (($p_path != './') && ($p_path != '/')) { |
||
415 | while (substr($p_path, -1) == '/') |
||
416 | $p_path = substr($p_path, 0, strlen($p_path) - 1); |
||
417 | |||
418 | if (substr($v_header['filename'], 0, 1) == '/') |
||
419 | $v_header['filename'] = $p_path . $v_header['filename']; |
||
420 | else |
||
421 | $v_header['filename'] = $p_path . '/' . $v_header['filename']; |
||
422 | } |
||
423 | if (file_exists($v_header['filename'])) { |
||
424 | if ((@is_dir($v_header['filename'])) |
||
425 | && ($v_header['typeflag'] == '')) { |
||
426 | $this->_error('File ' . $v_header['filename'] |
||
427 | . ' already exists as a directory'); |
||
428 | return false; |
||
429 | } |
||
430 | if (($this->_isArchive($v_header['filename'])) |
||
431 | && ($v_header['typeflag'] == "5")) { |
||
432 | $this->_error('Directory ' . $v_header['filename'] |
||
433 | . ' already exists as a file'); |
||
434 | return false; |
||
435 | } |
||
436 | if (!is_writable($v_header['filename'])) { |
||
437 | $this->_error('File ' . $v_header['filename'] |
||
438 | . ' already exists and is write protected'); |
||
439 | return false; |
||
440 | } |
||
441 | if (filemtime($v_header['filename']) > $v_header['mtime']) { |
||
442 | // To be completed : An error or silent no replace ? |
||
443 | } |
||
444 | } |
||
445 | |||
446 | // ----- Check the directory availability and create it if necessary |
||
447 | elseif (($v_result |
||
448 | = $this->_dirCheck(($v_header['typeflag'] == "5" |
||
449 | ?$v_header['filename'] |
||
450 | :dirname($v_header['filename'])))) != 1) { |
||
451 | $this->_error('Unable to create path for ' . $v_header['filename']); |
||
452 | return false; |
||
453 | } |
||
454 | |||
455 | if ($v_extract_file) { |
||
456 | if ($v_header['typeflag'] == "5") { |
||
457 | if (!@file_exists($v_header['filename'])) { |
||
458 | if (!@mkdir($v_header['filename'], PRADO_CHMOD)) { |
||
459 | $this->_error('Unable to create directory {' |
||
460 | . $v_header['filename'] . '}'); |
||
461 | return false; |
||
462 | } |
||
463 | chmod($v_header['filename'], PRADO_CHMOD); |
||
464 | } |
||
465 | } else { |
||
466 | if (($v_dest_file = @fopen($v_header['filename'], "wb")) == 0) { |
||
467 | $this->_error('Error while opening {' . $v_header['filename'] |
||
468 | . '} in write binary mode'); |
||
469 | return false; |
||
470 | } else { |
||
471 | $n = floor($v_header['size'] / 512); |
||
472 | for ($i = 0; $i < $n; $i++) { |
||
473 | $v_content = $this->_readBlock(); |
||
474 | fwrite($v_dest_file, $v_content, 512); |
||
475 | } |
||
476 | if (($v_header['size'] % 512) != 0) { |
||
477 | $v_content = $this->_readBlock(); |
||
478 | fwrite($v_dest_file, $v_content, ($v_header['size'] % 512)); |
||
479 | } |
||
480 | |||
481 | @fclose($v_dest_file); |
||
482 | |||
483 | // ----- Change the file mode, mtime |
||
484 | @touch($v_header['filename'], $v_header['mtime']); |
||
485 | // To be completed |
||
486 | //chmod($v_header[filename], DecOct($v_header[mode])); |
||
487 | } |
||
488 | |||
489 | // ----- Check the file size |
||
490 | clearstatcache(); |
||
491 | if (filesize($v_header['filename']) != $v_header['size']) { |
||
492 | $this->_error('Extracted file ' . $v_header['filename'] |
||
493 | . ' does not have the correct file size \'' |
||
494 | . filesize($v_header['filename']) |
||
495 | . '\' (' . $v_header['size'] |
||
496 | . ' expected). Archive may be corrupted.'); |
||
497 | return false; |
||
498 | } |
||
499 | } |
||
500 | } else { |
||
501 | $this->_jumpBlock(ceil(($v_header['size'] / 512))); |
||
502 | } |
||
503 | } else { |
||
504 | $this->_jumpBlock(ceil(($v_header['size'] / 512))); |
||
505 | } |
||
506 | |||
507 | /* TBC : Seems to be unused ... |
||
508 | if ($this->_compress) |
||
509 | $v_end_of_file = @gzeof($this->_file); |
||
510 | else |
||
511 | $v_end_of_file = @feof($this->_file); |
||
512 | */ |
||
513 | |||
514 | if ($v_listing || $v_extract_file || $v_extraction_stopped) { |
||
515 | // ----- Log extracted files |
||
516 | if (($v_file_dir = dirname($v_header['filename'])) |
||
517 | == $v_header['filename']) |
||
518 | $v_file_dir = ''; |
||
519 | if ((substr($v_header['filename'], 0, 1) == '/') && ($v_file_dir == '')) |
||
520 | $v_file_dir = '/'; |
||
521 | |||
522 | $p_list_detail[$v_nb++] = $v_header; |
||
523 | } |
||
524 | } |
||
525 | |||
526 | return true; |
||
527 | } |
||
574 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths