Skip to content

Commit 9c8676a

Browse files
committed
Revert removed import global namespace class
1 parent 52d689d commit 9c8676a

23 files changed

+150
-104
lines changed

.travis.yml

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,29 +22,27 @@ matrix:
2222
- VALIDATE_CODING_STYLE=false
2323
- php: 7.4
2424
env:
25-
- COLLECT_COVERAGE=false
25+
- COLLECT_COVERAGE=true
26+
- IGNORE_PLATFORMS=false
27+
- RUN_PHPSTAN=true
2628
- VALIDATE_CODING_STYLE=false
27-
- RUN_PHPSTAN=false
28-
- IGNORE_PLATFORMS=true
2929
- php: nightly
3030
env:
3131
- COLLECT_COVERAGE=false
3232
- IGNORE_PLATFORMS=true
33-
- RUN_PHPSTAN=true
33+
- RUN_PHPSTAN=false
3434
- VALIDATE_CODING_STYLE=false
3535
allow_failures:
3636
- php: nightly
3737
fast_finish: true
3838
before_install:
3939
- travis_retry composer self-update
4040
install:
41-
- if [ "$IGNORE_PLATFORMS" == "true" ]; then travis_retry composer update $COMPOSER_ARGS
42-
--ignore-platform-reqs; fi
43-
- if [ "$IGNORE_PLATFORMS" == "false" ]; then travis_retry composer update $COMPOSER_ARGS;
44-
fi
41+
- if [ "$IGNORE_PLATFORMS" == "true" ]; then travis_retry composer update $COMPOSER_ARGS --ignore-platform-reqs; fi
42+
- if [ "$IGNORE_PLATFORMS" == "false" ]; then travis_retry composer update $COMPOSER_ARGS; fi
4543
script:
46-
- if [ "$RUN_PHPSTAN" == "true" ]; then composer phpstan; fi
4744
- if [ "$VALIDATE_CODING_STYLE" == "true" ]; then composer phpcs; fi
45+
- if [ "$RUN_PHPSTAN" == "true" ]; then composer phpstan; fi
4846
- composer phpunit
4947
after_script:
5048
- if [ "$COLLECT_COVERAGE" == "true" ]; then wget https://scrutinizer-ci.com/ocular.phar

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
},
2323
"require": {
2424
"php" : "^7.2",
25-
"ext-dom" : "*",
2625
"ext-json" : "*",
2726
"ext-mbstring" : "*"
2827
},
@@ -69,7 +68,8 @@
6968
"test": "Runs full test suite"
7069
},
7170
"suggest": {
72-
"ext-iconv" : "Needed to ease transcoding CSV using iconv stream filters"
71+
"ext-iconv" : "Needed to ease transcoding CSV using iconv stream filters",
72+
"ext-dom" : "Need to use the XMLConverter class"
7373
},
7474
"extra": {
7575
"branch-alias": {

docs/7.0/reading.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,5 +203,5 @@ $nbIteration = $reader->each(function ($row, $index, $iterator) use (&$res, $fun
203203
}
204204
$res[] = $row;
205205
return true;
206-
});
206+
})
207207
~~~

docs/9.0/connections/bom.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ The `ByteSequence` interface provides the following constants :
2222
### bom_match
2323

2424
~~~php
25-
function League\Csv\bom_match(string $str): string
25+
use function Csv\bom_match;function Leaguebom_match(string $str): string
2626
~~~
2727

2828
The `League\Csv\bom_match` function expects a string and returns the BOM sequence found at its start or an empty string otherwise.

docs/9.0/connections/controls.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ echo $csv->getEscape(); //display '\'
107107
## Detecting the delimiter character
108108

109109
~~~php
110-
function League\Csv\delimiter_detect(Reader $csv, array $delimiters, $limit = 1): array
110+
use function Csv\delimiter_detect;function Leaguedelimiter_detect(Reader $csv, array $delimiters, $limit = 1): array
111111
~~~
112112

113113
The `delimiter_detect` function helps detect the possible delimiter character used by the CSV document. This function returns the number of CSV fields found in the document depending on the submitted delimiters given.
@@ -142,4 +142,4 @@ If the submitted delimiter **is invalid or not found** in the document, `0` will
142142

143143
<p class="message-info">To detect the delimiters stats on the full CSV document you need to set <code>$limit</code> to <code>-1</code>.</p>
144144
<p class="message-notice">This function only returns hints. Only the CSV providers will validate the real CSV delimiter character.</p>
145-
<p class="message-warning">This function only test the delimiters you gave it.</p>
145+
<p class="message-warning">This function only test the delimiters you gave it.</p>

docs/9.0/upgrading.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ use League\Csv\Reader;
346346
$reader = Reader::createFromPath('/path/to/file.csv', 'r');
347347
foreach ($records->fetchColumn(0) as $value) {
348348
$value = strtoupper($value);
349-
};
349+
}
350350
~~~
351351

352352
## Stream Filtering
@@ -495,4 +495,4 @@ use League\Csv\Writer;
495495

496496
$csv = Writer::createFromPath('/path/to/file.csv');
497497
$csv->addValidator(new ColumnConsistency(), 'columns_consistency');
498-
~~~
498+
~~~

src/AbstractCsv.php

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313

1414
namespace League\Csv;
1515

16+
use Generator;
17+
use SplFileObject;
1618
use function filter_var;
1719
use function get_class;
1820
use function mb_strlen;
@@ -83,7 +85,7 @@ abstract class AbstractCsv implements ByteSequence
8385
/**
8486
* The CSV document.
8587
*
86-
* @var \SplFileObject|Stream
88+
* @var SplFileObject|Stream
8789
*/
8890
protected $document;
8991

@@ -97,7 +99,7 @@ abstract class AbstractCsv implements ByteSequence
9799
/**
98100
* New instance.
99101
*
100-
* @param \SplFileObject|Stream $document The CSV Object instance
102+
* @param SplFileObject|Stream $document The CSV Object instance
101103
*/
102104
protected function __construct($document)
103105
{
@@ -134,7 +136,7 @@ public function __clone()
134136
*
135137
* @return static
136138
*/
137-
public static function createFromFileObject(\SplFileObject $file)
139+
public static function createFromFileObject(SplFileObject $file)
138140
{
139141
return new static($file);
140142
}
@@ -222,7 +224,7 @@ public function getInputBOM(): string
222224
return $this->input_bom;
223225
}
224226

225-
$this->document->setFlags(\SplFileObject::READ_CSV);
227+
$this->document->setFlags(SplFileObject::READ_CSV);
226228
$this->document->rewind();
227229
$this->input_bom = bom_match((string) $this->document->fread(4));
228230

@@ -268,7 +270,7 @@ public function isInputBOMIncluded(): bool
268270
*
269271
* @throws Exception if the number of bytes is lesser than 1
270272
*/
271-
public function chunk(int $length): \Generator
273+
public function chunk(int $length): Generator
272274
{
273275
if ($length < 1) {
274276
throw new InvalidArgument(sprintf('%s() expects the length to be a positive integer %d given', __METHOD__, $length));
@@ -357,12 +359,12 @@ protected function sendHeaders(string $filename): void
357359
$flag |= FILTER_FLAG_STRIP_HIGH;
358360
}
359361

360-
/** @var string $filteredName */
361-
$filteredName = filter_var($filename, FILTER_SANITIZE_STRING, $flag);
362-
$filenameFallback = str_replace('%', '', $filteredName);
362+
/** @var string $filtered_name */
363+
$filtered_name = filter_var($filename, FILTER_SANITIZE_STRING, $flag);
364+
$filename_fallback = str_replace('%', '', $filtered_name);
363365

364-
$disposition = sprintf('attachment; filename="%s"', str_replace('"', '\\"', $filenameFallback));
365-
if ($filename !== $filenameFallback) {
366+
$disposition = sprintf('attachment; filename="%s"', str_replace('"', '\\"', $filename_fallback));
367+
if ($filename !== $filename_fallback) {
366368
$disposition .= sprintf("; filename*=utf-8''%s", rawurlencode($filename));
367369
}
368370

src/CharsetConverter.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313

1414
namespace League\Csv;
1515

16+
use OutOfRangeException;
17+
use php_user_filter;
1618
use function array_combine;
1719
use function array_map;
1820
use function array_walk;
@@ -33,7 +35,7 @@
3335
/**
3436
* Converts resource stream or tabular data content charset.
3537
*/
36-
class CharsetConverter extends \php_user_filter
38+
class CharsetConverter extends php_user_filter
3739
{
3840
const FILTERNAME = 'convert.league.csv';
3941

@@ -103,7 +105,7 @@ public static function getFiltername(string $input_encoding, string $output_enco
103105
/**
104106
* Filter encoding charset.
105107
*
106-
* @throws \OutOfRangeException if the charset is malformed or unsupported
108+
* @throws OutOfRangeException if the charset is malformed or unsupported
107109
*/
108110
protected static function filterEncoding(string $encoding): string
109111
{
@@ -118,7 +120,7 @@ protected static function filterEncoding(string $encoding): string
118120
return $encoding_list[$key];
119121
}
120122

121-
throw new \OutOfRangeException(sprintf('The submitted charset %s is not supported by the mbstring extension', $encoding));
123+
throw new OutOfRangeException(sprintf('The submitted charset %s is not supported by the mbstring extension', $encoding));
122124
}
123125

124126
/**
@@ -139,7 +141,7 @@ public function onCreate(): bool
139141
try {
140142
$this->input_encoding = self::filterEncoding($matches['input']);
141143
$this->output_encoding = self::filterEncoding($matches['output']);
142-
} catch (\OutOfRangeException $e) {
144+
} catch (OutOfRangeException $e) {
143145
return false;
144146
}
145147

src/EncloseField.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313

1414
namespace League\Csv;
1515

16+
use InvalidArgumentException;
17+
use php_user_filter;
1618
use function in_array;
1719
use function str_replace;
1820
use function strcspn;
@@ -28,7 +30,7 @@
2830
* @see https://tools.ietf.org/html/rfc4180#section-2
2931
* @see https://bugs.php.net/bug.php?id=38301
3032
*/
31-
class EncloseField extends \php_user_filter
33+
class EncloseField extends php_user_filter
3234
{
3335
const FILTERNAME = 'convert.league.csv.enclosure';
3436

@@ -82,14 +84,14 @@ public static function register(): void
8284
/**
8385
* Static method to add the stream filter to a {@link Writer} object.
8486
*
85-
* @throws \InvalidArgumentException if the sequence is malformed
87+
* @throws InvalidArgumentException if the sequence is malformed
8688
*/
8789
public static function addTo(Writer $csv, string $sequence): Writer
8890
{
8991
self::register();
9092

9193
if (!self::isValidSequence($sequence)) {
92-
throw new \InvalidArgumentException('The sequence must contain at least one character to force enclosure');
94+
throw new InvalidArgumentException('The sequence must contain at least one character to force enclosure');
9395
}
9496

9597
$formatter = static function (array $record) use ($sequence): array {

src/EscapeFormula.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
namespace League\Csv;
1515

16+
use InvalidArgumentException;
1617
use function array_fill_keys;
1718
use function array_keys;
1819
use function array_map;
@@ -72,15 +73,15 @@ public function __construct(string $escape = "\t", array $special_chars = [])
7273
*
7374
* @param string ...$characters
7475
*
75-
* @throws \InvalidArgumentException if the string is not a single character
76+
* @throws InvalidArgumentException if the string is not a single character
7677
*
7778
* @return string[]
7879
*/
7980
protected function filterSpecialCharacters(string ...$characters): array
8081
{
8182
foreach ($characters as $str) {
8283
if (1 != strlen($str)) {
83-
throw new \InvalidArgumentException(sprintf('The submitted string %s must be a single character', $str));
84+
throw new InvalidArgumentException(sprintf('The submitted string %s must be a single character', $str));
8485
}
8586
}
8687

0 commit comments

Comments
 (0)