144 Commits

Author SHA1 Message Date
Christian Bläul
086cd15b44 Added requires to keep Composer-free environments working 2018-03-07 09:51:50 +01:00
Christian Bläul
c9e7997643 Don't break people's code just because they don't have Composer 2018-03-02 17:15:31 +01:00
Christian Bläul
b0355be96a Re-added the parsecsv.lib.php file for compatibility 2018-02-21 19:00:41 +01:00
Susann Sgorzaly
a7a0bc34a4 init introduce namespaces 2018-02-17 23:41:03 +01:00
Susann Sgorzaly
5babb55879 review changes 2018-02-14 14:03:00 +01:00
Susann Sgorzaly
d788135bbe exclude datatype detection in its own trait 2018-02-14 12:12:01 +01:00
Susann Sgorzaly
301f6da3e6 init new functionality to identify datatypes of columns 2018-02-13 17:18:01 +01:00
Christian Bläul
b9721a9aff Slightly improved PHPDoc comments 2018-02-02 11:13:49 +01:00
Christian Bläul
3c31b70724 Added accidentally removed regex modifier i 2018-02-02 11:13:49 +01:00
Christian Bläul
488b8f9d9b Prevent an "Uninitialized string offset" error
Got triggered by testMissingEndingLineBreak.
2018-02-02 11:13:49 +01:00
Christian Bläul
b004911218 $this->auto_non_chars didn't work the way I would have expected:
The "-" was taken literally, and thus 0 was forbidden, but 1 was allowed.

Fixes #55.
Also see #61
2018-02-02 11:13:49 +01:00
Christian Bläul
2d7ab4b2f0 Added documentation to parse_string()
Fixes #76
2018-02-02 11:13:49 +01:00
Christian Bläul
f41a18b1c0 Added support for DOS double line endings
Fixed GitHub issue #75
2018-02-02 11:13:49 +01:00
Christian Bläul
d8aefa792e Made PhpStorm inspections happy:
- avoid empty for-loop bodies as they are unusual and look a bit like
  forgotten implementations
- removed 'i' modifier from regular expressions that contain no letters
- replaced consecutive 'str_replace' calls by single 'strtr' call
- introduced new variable $is_newline to make the intend of a complex
  'if' more obvious and get rid of the operator precedence inspection
2018-02-02 11:13:49 +01:00
Christian Bläul
a92506d078 Prevent quoting of sinlge-column file. Needed because auto() with...
...single-column file will not set field delimiter. This commit is a bug fix.

For a test see testSaveWithDefaultSettings.
2018-02-02 11:13:49 +01:00
Christian Bläul
54e846ee30 Construct array key just once instead for better readability 2018-02-02 11:13:49 +01:00
Christian Bläul
8ae09c604b Added support for mb_convert_encoding() instead of iconv()
See issue #109 at GitHub
2018-02-02 11:13:49 +01:00
Alexander Vlasov
5a9a10aeed Incorrect parsing with single quote during auto-detection delimiter. 2018-01-21 21:43:42 +01:00
Christian Bläul
631fae5191 Improved PHPDoc of _check_count; Refactored vars in _guess_delimiter
This commit does not contain functional changes.
2018-01-21 01:15:56 +01:00
Christian Bläul
18ddde98c0 Comparison in _enclose_value: put least expensive condition first 2018-01-21 01:15:56 +01:00
Christian Bläul
a07de14bba Slightly more meaningful variable names in 'unparse' function 2018-01-21 01:15:56 +01:00
Christian Bläul
e87a5ae0e6 Improved source code formatting (no functional change) 2018-01-21 01:15:56 +01:00
Christian Bläul
c04fc89c43 Removed @access PHPDoc because it doesn't add value.
Today's phpDocumentor detects visiblity from the PHP keywords.
2018-01-21 01:15:56 +01:00
Christian Bläul
cc908fd096 _detect_and_remove_sep_row_from_data: improved comments to make it more ...
obvious that $data given is changed.
2018-01-21 01:15:56 +01:00
Christian Bläul
155c50ad7a Slightly improved code quality, no functionality changes
E.g.:
- Improved PHPDoc to reflect/include actual types
- Removed unnecessary brackets in ternary statements
- _check_count: Added return statement (code smell)
- added type-safe comparison where it doesn't change results
2018-01-21 01:15:56 +01:00
Christian Bläul
0ac5064d58 Only call iconv if input and output encoding differ.
This saves some headache if characters are invalid according to iconv.
2017-12-21 09:33:23 +01:00
Christian Bläul
4d011827f5 When we find a BOM, we know the input encoding. Let's use it!
Also: UTF tests not failing anymore because we are specifying
the output encoding now.
2017-12-21 09:33:23 +01:00
Christian Bläul
c818fff81a Only improved spelling in source code comments 2017-12-21 09:33:23 +01:00
Matthew de Marillac
ccad5c8360 Remove BOM from UTF files.
Implementation similar to suggestion from, and thus closes #83
2017-12-21 09:33:23 +01:00
Christian Bläul
0d14ca01be Improved sep= detection and added it to auto() 2017-12-06 02:25:54 +01:00
Christian Bläul
a4a0dfa2fd Extracted the long detection algorithm from 'auto()' into new function.
Also removed unnecessary brackets () in ternary on the way.
2017-12-06 02:25:54 +01:00
Christian Bläul
f5851ba9ac Only improved comments in source code 2017-12-06 02:25:54 +01:00
Jan Piskvor Martinec
fad5ebcdc8 Added function to detect delimiter using sep= file header 2017-12-06 02:25:54 +01:00
Salem Ouerdani
1321c3b693 Should fix #99 (zeros breaking lines)
see https://github.com/parsecsv/parsecsv-for-php/issues/99
2017-11-03 21:35:58 +01:00
Christian Bläul
b9cf7cb0c1 Improved PHPDoc blocks
Added missing parameters, wrapped at 80 characters, added types.
2017-11-03 20:25:56 +01:00
Christian Bläul
4bae0d2bcf Re-added the code to grap object-level filename in output()
Follow-up on pull request #88: No breaking compatibality with
older parsecsv versions.

If no output to browser is desired, set $output_filename to null,
or use unparse() function.
2017-11-03 20:23:12 +01:00
Jan Piskvor Martinec
189746405f Do not force filename if not set explicitly
Per docblock, the function output() is supposed to output to browser
    only if filename is passed into it.
    If not, it should return the CSV as a string, not auto-set filename.
2017-11-03 11:30:55 -06:00
Marvin Feldmann
fa5aea7631 Suppress file name too long warning
Suppress Warning: "File name is longer than the maximum allowed path length on this platform (4096)"
2015-09-14 17:15:10 +02:00
William Knauss
4f144f2662 Addresses #62 2015-07-11 13:15:34 -04:00
William Knauss
ba4c30add1 Addresses #51 2015-07-11 13:09:20 -04:00
William Knauss
8bb51f8bab Fixing flock issue
Why not make life easier just use file put contents
2015-03-25 22:19:54 -04:00
Sergio Melendez
5e8a5df988 Added iconv() to output method 2014-10-07 08:46:14 -05:00
William Knauss
2f3732e350 _wfile 2014-06-05 20:53:19 -04:00
William Knauss
01e71adf36 _rfile 2014-06-05 20:52:43 -04:00
William Knauss
0c4a804db1 _check_count 2014-06-05 20:52:23 -04:00
William Knauss
4366201dc0 _check_data 2014-06-05 20:51:26 -04:00
William Knauss
0422d5d9fe _enclose_value 2014-06-05 20:50:48 -04:00
William Knauss
6f4d150e6f _validate_offset 2014-06-05 20:50:08 -04:00
William Knauss
494087ab1d _validate_row_condition 2014-06-05 20:49:49 -04:00
William Knauss
ce19deec4e _validate_row_conditions 2014-06-05 20:48:11 -04:00