PHPUnit 6 instead of 4, to get rid of wrapper

The TestCase wrapper caused PhpStorm to show warnings about
multiple implementations

Fixes #188

Improved some type hints in DocBlocks
This commit is contained in:
Petri Haikonen
2020-04-08 23:08:55 +03:00
committed by Fonata
parent 89429ebd60
commit b4e4c14b42
6 changed files with 38 additions and 44 deletions

View File

@@ -8,8 +8,6 @@ php:
- '7.2'
- '7.1'
- '7.0'
- '5.6'
- '5.5'
before_install:
- composer update

View File

@@ -34,7 +34,8 @@
"php": ">=5.5"
},
"require-dev": {
"phpunit/phpunit": "4.1.*"
"phpunit/phpunit": "^6",
"squizlabs/php_codesniffer": "^3.5"
},
"suggest": {
"illuminate/support": "Fluent array interface for map functions"

3
ruleset.xml Normal file
View File

@@ -0,0 +1,3 @@
<?xml version="1.0"?>
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="ParseCSV" xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/squizlabs/PHP_CodeSniffer/master/phpcs.xsd">
</ruleset>

View File

@@ -311,16 +311,16 @@ class Csv {
* Constructor
* Class constructor
*
* @param string|null $input The CSV string or a direct file path
* @param integer|null $offset Number of rows to ignore from the
* beginning of the data
* @param integer|null $limit Limits the number of returned rows
* to specified amount
* @param string|null $conditions Basic SQL-like conditions for row
* matching
* @param null|true $keep_file_data Keep raw file data in memory after
* successful parsing
* (useful for debugging)
* @param string|null $input The CSV string or a direct file path
* @param int|null $offset Number of rows to ignore from the
* beginning of the data
* @param int|null $limit Limits the number of returned rows
* to specified amount
* @param string|null $conditions Basic SQL-like conditions for row
* matching
* @param null|true $keep_file_data Keep raw file data in memory after
* successful parsing
* (useful for debugging)
*/
public function __construct($input = null, $offset = null, $limit = null, $conditions = null, $keep_file_data = null) {
$this->init($offset, $limit, $conditions, $keep_file_data);
@@ -331,13 +331,13 @@ class Csv {
}
/**
* @param integer|null $offset Number of rows to ignore from the
* @param int|null $offset Number of rows to ignore from the
* beginning of the data
* @param integer|null $limit Limits the number of returned rows
* @param int|null $limit Limits the number of returned rows
* to specified amount
* @param string|null $conditions Basic SQL-like conditions for row
* @param string|null $conditions Basic SQL-like conditions for row
* matching
* @param null|true $keep_file_data Keep raw file data in memory after
* @param null|true $keep_file_data Keep raw file data in memory after
* successful parsing
* (useful for debugging)
*/
@@ -368,11 +368,11 @@ class Csv {
* Parse a CSV file or string
*
* @param string|null $input The CSV string or a direct file path
* @param integer $offset Number of rows to ignore from the
* @param int|null $offset Number of rows to ignore from the
* beginning of the data
* @param integer $limit Limits the number of returned rows to
* @param int|null $limit Limits the number of returned rows to
* specified amount
* @param string $conditions Basic SQL-like conditions for row
* @param string|null $conditions Basic SQL-like conditions for row
* matching
*
* @return bool True on success
@@ -474,8 +474,10 @@ class Csv {
* Encoding
* Convert character encoding
*
* @param string $input Input character encoding, uses default if left blank
* @param string $output Output character encoding, uses default if left blank
* @param string|null $input Input character encoding, uses default if left blank
* @param string|null $output Output character encoding, uses default if left blank
*
* @return void
*/
public function encoding($input = null, $output = null) {
$this->convert_encoding = true;
@@ -495,11 +497,11 @@ class Csv {
*
* @param string|null $file Local CSV file
* @param bool $parse True/false parse file directly
* @param int $search_depth Number of rows to analyze
* @param string $preferred Preferred delimiter characters
* @param int|null $search_depth Number of rows to analyze
* @param string|null $preferred Preferred delimiter characters
* @param string|null $enclosure Enclosure character, default is double quote (").
*
* @return string The detected field delimiter
* @return string|false The detected field delimiter
*/
public function auto($file = null, $parse = true, $search_depth = null, $preferred = null, $enclosure = null) {
if (is_null($file)) {
@@ -572,12 +574,10 @@ class Csv {
$headingRow = $this->heading ? 1 : 0;
$count = substr_count($data, "\r")
return substr_count($data, "\r")
+ substr_count($data, "\n")
- substr_count($data, "\r\n")
- $headingRow;
return $count;
}
// ==============================================
@@ -613,7 +613,7 @@ class Csv {
*
* To detect field separators, please use auto() instead.
*
* @param string $data CSV data
* @param string|null $data CSV data
*
* @return array|false - 2D array with CSV data, or false on failure
*/
@@ -861,7 +861,12 @@ class Csv {
return $string;
}
private function _validate_fields_for_unparse($fields) {
/**
* @param array $fields
*
* @return array|false
*/
private function _validate_fields_for_unparse(array $fields) {
if (empty($fields)) {
$fields = $this->titles;
}
@@ -1298,7 +1303,6 @@ class Csv {
}
// remove delimiter and its line-end (the data param is by-ref!)
/** @noinspection CallableParameterUseCaseInTypeContextInspection */
$data_string = substr($data_string, $pos);
return true;
}
@@ -1309,7 +1313,7 @@ class Csv {
* @param string $enclosure Enclosure character, default is double quote
* @param string $data The file content
*/
protected function _guess_delimiter($search_depth, $preferred, $enclosure, &$data) {
protected function _guess_delimiter($search_depth, $preferred, $enclosure, $data) {
$chars = [];
$strlen = strlen($data);
$enclosed = false;

View File

@@ -26,5 +26,4 @@ class SortEnum extends AbstractEnum {
return self::$sorting[self::__DEFAULT];
}
}

View File

@@ -1,11 +0,0 @@
<?php
namespace PHPUnit\Framework;
// Only needed to keep unit test code compatible with older PHPUnit versions
/** @noinspection PhpUndefinedClassInspection */
/** @noinspection AutoloadingIssuesInspection */
class TestCase extends \PHPUnit_Framework_TestCase {
}