Skip to content

Commit f2d4314

Browse files
committed
Merge pull request php-curl-class#255 from zachborboa/master
Fix php-curl-class#254: CaseInsensitiveArray not found
2 parents d49186a + d69cded commit f2d4314

File tree

8 files changed

+92
-89
lines changed

8 files changed

+92
-89
lines changed

src/Curl/CaseInsensitiveArray.php

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
<?php
2+
3+
namespace Curl;
4+
5+
class CaseInsensitiveArray implements \ArrayAccess, \Countable, \Iterator
6+
{
7+
private $container = array();
8+
9+
public function offsetSet($offset, $value)
10+
{
11+
if ($offset === null) {
12+
$this->container[] = $value;
13+
} else {
14+
$index = array_search(strtolower($offset), array_keys(array_change_key_case($this->container, CASE_LOWER)));
15+
if (!($index === false)) {
16+
$keys = array_keys($this->container);
17+
unset($this->container[$keys[$index]]);
18+
}
19+
$this->container[$offset] = $value;
20+
}
21+
}
22+
23+
public function offsetExists($offset)
24+
{
25+
return array_key_exists(strtolower($offset), array_change_key_case($this->container, CASE_LOWER));
26+
}
27+
28+
public function offsetUnset($offset)
29+
{
30+
unset($this->container[$offset]);
31+
}
32+
33+
public function offsetGet($offset)
34+
{
35+
$index = array_search(strtolower($offset), array_keys(array_change_key_case($this->container, CASE_LOWER)));
36+
if ($index === false) {
37+
return null;
38+
}
39+
40+
$values = array_values($this->container);
41+
return $values[$index];
42+
}
43+
44+
public function count()
45+
{
46+
return count($this->container);
47+
}
48+
49+
public function current()
50+
{
51+
return current($this->container);
52+
}
53+
54+
public function next()
55+
{
56+
return next($this->container);
57+
}
58+
59+
public function key()
60+
{
61+
return key($this->container);
62+
}
63+
64+
public function valid()
65+
{
66+
return !($this->current() === false);
67+
}
68+
69+
public function rewind()
70+
{
71+
reset($this->container);
72+
}
73+
}

src/Curl/Curl.php

Lines changed: 1 addition & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
class Curl
66
{
7-
const VERSION = '4.8.0';
7+
const VERSION = '4.8.1';
88
const DEFAULT_TIMEOUT = 30;
99

1010
public $curl;
@@ -997,73 +997,3 @@ public static function is_array_multidim($array)
997997
return (bool)count(array_filter($array, 'is_array'));
998998
}
999999
}
1000-
1001-
class CaseInsensitiveArray implements \ArrayAccess, \Countable, \Iterator
1002-
{
1003-
private $container = array();
1004-
1005-
public function offsetSet($offset, $value)
1006-
{
1007-
if ($offset === null) {
1008-
$this->container[] = $value;
1009-
} else {
1010-
$index = array_search(strtolower($offset), array_keys(array_change_key_case($this->container, CASE_LOWER)));
1011-
if (!($index === false)) {
1012-
$keys = array_keys($this->container);
1013-
unset($this->container[$keys[$index]]);
1014-
}
1015-
$this->container[$offset] = $value;
1016-
}
1017-
}
1018-
1019-
public function offsetExists($offset)
1020-
{
1021-
return array_key_exists(strtolower($offset), array_change_key_case($this->container, CASE_LOWER));
1022-
}
1023-
1024-
public function offsetUnset($offset)
1025-
{
1026-
unset($this->container[$offset]);
1027-
}
1028-
1029-
public function offsetGet($offset)
1030-
{
1031-
$index = array_search(strtolower($offset), array_keys(array_change_key_case($this->container, CASE_LOWER)));
1032-
if ($index === false) {
1033-
return null;
1034-
}
1035-
1036-
$values = array_values($this->container);
1037-
return $values[$index];
1038-
}
1039-
1040-
public function count()
1041-
{
1042-
return count($this->container);
1043-
}
1044-
1045-
public function current()
1046-
{
1047-
return current($this->container);
1048-
}
1049-
1050-
public function next()
1051-
{
1052-
return next($this->container);
1053-
}
1054-
1055-
public function key()
1056-
{
1057-
return key($this->container);
1058-
}
1059-
1060-
public function valid()
1061-
{
1062-
return !($this->current() === false);
1063-
}
1064-
1065-
public function rewind()
1066-
{
1067-
reset($this->container);
1068-
}
1069-
}

tests/PHPCurlClass/PHPCurlClassTest.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
<?php
2-
require '../src/Curl/Curl.php';
3-
require 'Helper.php';
42

53
use \Curl\Curl;
64
use \Curl\CaseInsensitiveArray;

tests/PHPCurlClass/PHPMultiCurlClassTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
<?php
2-
require '../src/Curl/MultiCurl.php';
32

43
use \Curl\MultiCurl;
54
use \Helper\Test;

tests/PHPCurlClass/server.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?php
2-
require 'Helper.php';
2+
require_once 'Helper.php';
33

44
use \Helper\Test;
55

tests/before_script.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
echo "TRAVIS_PHP_VERSION: ${TRAVIS_PHP_VERSION}"
2+
3+
composer self-update
4+
composer install --prefer-source --no-interaction
5+
26
if [[ "${TRAVIS_PHP_VERSION}" == "5.3" ]]; then
37
sudo add-apt-repository -y ppa:nginx/development
48
sudo apt-get update

tests/phpunit.xml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
<phpunit>
2-
<testsuite name="PHPCurlClass">
3-
<directory>.</directory>
4-
</testsuite>
5-
<logging>
6-
<log type="coverage-text" target="php://stdout" showUncoveredFiles="false" />
7-
</logging>
1+
<phpunit bootstrap="../vendor/autoload.php" colors="true">
2+
<testsuites>
3+
<testsuite name="PHPCurlClass">
4+
<directory suffix=".php">./PHPCurlClass/</directory>
5+
</testsuite>
6+
</testsuites>
87
</phpunit>

tests/script.sh

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
# Check syntax in php files.
2-
find . -type "f" -iname "*.php" -exec php -l {} \;
2+
find . -type "f" -iname "*.php" ! -path "*/vendor/*" -exec php -l {} \;
33

44
# Run tests.
5-
cd tests && phpunit --configuration phpunit.xml
5+
phpunit --configuration tests/phpunit.xml
66
if [[ "${?}" -ne 0 ]]; then
77
exit 1
88
fi
99

1010
# Enforce line ending consistency in php files.
11-
crlf_file=$(find . -type "f" -iname "*.php" -exec grep --files-with-matches $'\r' {} \;)
11+
crlf_file=$(find . -type "f" -iname "*.php" ! -path "*/vendor/*" -exec grep --files-with-matches $'\r' {} \;)
1212
if [[ ! -z "${crlf_file}" ]]; then
1313
echo "${crlf_file}" | perl -pe 's/(.*)/CRLF line terminators found in \1/'
1414
exit 1
1515
fi
1616

1717
# Enforce indentation character consistency in php files.
18-
tab_char=$(find . -type "f" -iname "*.php" -exec grep --line-number -H --perl-regexp "\t" {} \;)
18+
tab_char=$(find . -type "f" -iname "*.php" ! -path "*/vendor/*" -exec grep --line-number -H --perl-regexp "\t" {} \;)
1919
if [[ ! -z "${tab_char}" ]]; then
2020
echo -e "${tab_char}" | perl -pe 's/^(.*)$/Tab character found in \1/'
2121
exit 1
@@ -50,22 +50,22 @@ EOF
5050
# Skip hhvm "Notice: File could not be loaded: ..."
5151
if [[ "${TRAVIS_PHP_VERSION}" != "hhvm" ]]; then
5252
export -f "find_invalid_indentation"
53-
invalid_indentation=$(find . -type "f" -iname "*.php" -exec bash -c 'find_invalid_indentation "{}"' \;)
53+
invalid_indentation=$(find . -type "f" -iname "*.php" ! -path "*/vendor/*" -exec bash -c 'find_invalid_indentation "{}"' \;)
5454
if [[ ! -z "${invalid_indentation}" ]]; then
5555
echo "${invalid_indentation}"
5656
exit 1
5757
fi
5858
fi
5959

6060
# Prohibit trailing whitespace in php files.
61-
trailing_whitespace=$(find . -type "f" -iname "*.php" -exec egrep --line-number -H " +$" {} \;)
61+
trailing_whitespace=$(find . -type "f" -iname "*.php" ! -path "*/vendor/*" -exec egrep --line-number -H " +$" {} \;)
6262
if [[ ! -z "${trailing_whitespace}" ]]; then
6363
echo -e "${trailing_whitespace}" | perl -pe 's/^(.*)$/Trailing whitespace found in \1/'
6464
exit 1
6565
fi
6666

6767
# Prohibit long lines in php files.
68-
long_lines=$(find . -type "f" -iname "*.php" -exec awk '{print FILENAME":"NR" "length}' {} \; | awk '$2 > 120')
68+
long_lines=$(find . -type "f" -iname "*.php" ! -path "*/vendor/*" -exec awk '{print FILENAME":"NR" "length}' {} \; | awk '$2 > 120')
6969
if [[ ! -z "${long_lines}" ]]; then
7070
echo -e "${long_lines}" | perl -pe 's/^(.*)$/Long lines found in \1/'
7171
exit 1

0 commit comments

Comments
 (0)