Include composer dependencies in repo

This commit is contained in:
Frederic Guillot
2017-10-25 16:22:10 -07:00
parent c507c54162
commit 9e2b2a32fd
1787 changed files with 123616 additions and 45 deletions

6
vendor/ramsey/array_column/.gitignore vendored Normal file
View File

@@ -0,0 +1,6 @@
.DS_Store
phpunit.xml
composer.lock
build
vendor
*.phar

26
vendor/ramsey/array_column/.travis.yml vendored Normal file
View File

@@ -0,0 +1,26 @@
language: php
php:
- 5.3
- 5.4
- 5.5
- 5.6
- 7.0
- hhvm
before_script:
- travis_retry composer self-update
- travis_retry composer install --no-interaction --prefer-source
script:
- mkdir -p build/logs
- ./vendor/bin/parallel-lint src tests
- ./vendor/bin/phpunit --coverage-text
- ./vendor/bin/phpcs src --standard=psr2 -sp
after_script:
- php vendor/bin/coveralls
matrix:
allow_failures:
- php: hhvm

37
vendor/ramsey/array_column/CHANGELOG.md vendored Normal file
View File

@@ -0,0 +1,37 @@
# array_column() Changelog
## 1.1.3
_Released 2015-03-20_
* Changing package name from "rhumsaa/array_column" to "ramsey/array_column"
* Updated Travis CI build config to test more versions of PHP
* Updated Travis CI config to lint and check PSR-2 coding standards
* Added project badges
* Added CHANGELOG
## 1.1.2
_Released 2013-07-22_
* Remove unnecessary conditionals
* Whitespace changes
## 1.1.1
_Released 2013-07-06_
* Documentation updates
## 1.1.0
_Released 2013-07-06_
* Catching up array_column() library functionality and tests with PHP 5.5.0
* Set Travis CI to run tests on PHP 5.5
## 1.0.0
_Released 2013-03-22_
* Initial release of userland library

19
vendor/ramsey/array_column/LICENSE vendored Normal file
View File

@@ -0,0 +1,19 @@
Copyright (c) 2013-2015 Ben Ramsey (http://benramsey.com)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

91
vendor/ramsey/array_column/README.md vendored Normal file
View File

@@ -0,0 +1,91 @@
# array_column() for PHP
[![Build Status](https://travis-ci.org/ramsey/array_column.svg?branch=master)](https://travis-ci.org/ramsey/array_column)
[![Coverage Status](https://coveralls.io/repos/ramsey/array_column/badge.svg?branch=master)](https://coveralls.io/r/ramsey/array_column)
[![Latest Stable Version](https://poser.pugx.org/ramsey/array_column/v/stable.svg)](https://packagist.org/packages/ramsey/array_column)
[![Total Downloads](https://poser.pugx.org/ramsey/array_column/downloads.svg)](https://packagist.org/packages/ramsey/array_column)
[![Latest Unstable Version](https://poser.pugx.org/ramsey/array_column/v/unstable.svg)](https://packagist.org/packages/ramsey/array_column)
[![License](https://poser.pugx.org/ramsey/array_column/license.svg)](https://packagist.org/packages/ramsey/array_column)
This simple library provides functionality for [`array_column()`](http://php.net/array_column)
to versions of PHP earlier than 5.5. It mimics the functionality of the built-in
function in every way.
## Usage
```
array array_column(array $input, mixed $columnKey[, mixed $indexKey])
```
Given a multi-dimensional array of data, `array_column()` returns the values
from a single column of the input array, identified by the `$columnKey`.
Optionally, you may provide an `$indexKey` to index the values in the returned
array by the values from the `$indexKey` column in the input array.
For example, using the following array of data, we tell `array_column()` to
return an array of just the last names, indexed by their record IDs.
``` php
<?php
$records = array(
array(
'id' => 2135,
'first_name' => 'John',
'last_name' => 'Doe'
),
array(
'id' => 3245,
'first_name' => 'Sally',
'last_name' => 'Smith'
),
array(
'id' => 5342,
'first_name' => 'Jane',
'last_name' => 'Jones'
),
array(
'id' => 5623,
'first_name' => 'Peter',
'last_name' => 'Doe'
)
);
$lastNames = array_column($records, 'last_name', 'id');
```
If we call `print_r()` on `$lastNames`, you'll see a resulting array that looks
a bit like this:
``` text
Array
(
[2135] => Doe
[3245] => Smith
[5342] => Jones
[5623] => Doe
)
```
## Installation
The easiest way to install this library is to use [Composer](https://getcomposer.org/):
```
php composer.phar require ramsey/array_column
```
Then, when you run `composer install`, everything will fall magically into place,
and the `array_column()` function will be available to your project, as long as
you are including Composer's autoloader.
_However, you do not need Composer to use this library._
This library has no dependencies and should work on older versions of PHP.
Download the code and include `src/array_column.php` in your project, and all
should work fine.
When you are ready to run your project on PHP 5.5, everything should
continue to run well without conflicts, even if this library remains included
in your project.

View File

@@ -0,0 +1,27 @@
{
"name": "ramsey/array_column",
"description": "Provides functionality for array_column() to projects using PHP earlier than version 5.5.",
"type": "library",
"keywords": ["array", "column", "array_column"],
"homepage": "https://github.com/ramsey/array_column",
"license": "MIT",
"authors": [
{
"name": "Ben Ramsey",
"homepage": "http://benramsey.com"
}
],
"support": {
"issues": "https://github.com/ramsey/array_column/issues",
"source": "https://github.com/ramsey/array_column"
},
"require-dev": {
"phpunit/phpunit": "~4.5",
"squizlabs/php_codesniffer": "~2.2",
"jakub-onderka/php-parallel-lint": "0.8.*",
"satooshi/php-coveralls": "0.6.*"
},
"autoload": {
"files": ["src/array_column.php"]
}
}

View File

@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="./tests/bootstrap.php" colors="true">
<testsuites>
<testsuite>
<directory>./tests</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory suffix=".php">./src</directory>
</whitelist>
</filter>
<logging>
<log type="coverage-html" target="build/coverage" title="array_column()"
charset="UTF-8" yui="true" highlight="true"
lowUpperBound="35" highLowerBound="70"/>
<log type="coverage-clover" target="build/logs/clover.xml"/>
<log type="junit" target="build/logs/junit.xml"
logIncompleteSkipped="false"/>
</logging>
</phpunit>

View File

@@ -0,0 +1,115 @@
<?php
/**
* This file is part of the array_column library
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @copyright Copyright (c) Ben Ramsey (http://benramsey.com)
* @license http://opensource.org/licenses/MIT MIT
*/
if (!function_exists('array_column')) {
/**
* Returns the values from a single column of the input array, identified by
* the $columnKey.
*
* Optionally, you may provide an $indexKey to index the values in the returned
* array by the values from the $indexKey column in the input array.
*
* @param array $input A multi-dimensional array (record set) from which to pull
* a column of values.
* @param mixed $columnKey The column of values to return. This value may be the
* integer key of the column you wish to retrieve, or it
* may be the string key name for an associative array.
* @param mixed $indexKey (Optional.) The column to use as the index/keys for
* the returned array. This value may be the integer key
* of the column, or it may be the string key name.
* @return array
*/
function array_column($input = null, $columnKey = null, $indexKey = null)
{
// Using func_get_args() in order to check for proper number of
// parameters and trigger errors exactly as the built-in array_column()
// does in PHP 5.5.
$argc = func_num_args();
$params = func_get_args();
if ($argc < 2) {
trigger_error("array_column() expects at least 2 parameters, {$argc} given", E_USER_WARNING);
return null;
}
if (!is_array($params[0])) {
trigger_error(
'array_column() expects parameter 1 to be array, ' . gettype($params[0]) . ' given',
E_USER_WARNING
);
return null;
}
if (!is_int($params[1])
&& !is_float($params[1])
&& !is_string($params[1])
&& $params[1] !== null
&& !(is_object($params[1]) && method_exists($params[1], '__toString'))
) {
trigger_error('array_column(): The column key should be either a string or an integer', E_USER_WARNING);
return false;
}
if (isset($params[2])
&& !is_int($params[2])
&& !is_float($params[2])
&& !is_string($params[2])
&& !(is_object($params[2]) && method_exists($params[2], '__toString'))
) {
trigger_error('array_column(): The index key should be either a string or an integer', E_USER_WARNING);
return false;
}
$paramsInput = $params[0];
$paramsColumnKey = ($params[1] !== null) ? (string) $params[1] : null;
$paramsIndexKey = null;
if (isset($params[2])) {
if (is_float($params[2]) || is_int($params[2])) {
$paramsIndexKey = (int) $params[2];
} else {
$paramsIndexKey = (string) $params[2];
}
}
$resultArray = array();
foreach ($paramsInput as $row) {
$key = $value = null;
$keySet = $valueSet = false;
if ($paramsIndexKey !== null && array_key_exists($paramsIndexKey, $row)) {
$keySet = true;
$key = (string) $row[$paramsIndexKey];
}
if ($paramsColumnKey === null) {
$valueSet = true;
$value = $row;
} elseif (is_array($row) && array_key_exists($paramsColumnKey, $row)) {
$valueSet = true;
$value = $row[$paramsColumnKey];
}
if ($valueSet) {
if ($keySet) {
$resultArray[$key] = $value;
} else {
$resultArray[] = $value;
}
}
}
return $resultArray;
}
}

View File

@@ -0,0 +1,422 @@
<?php
class ArrayColumnTest extends \PHPUnit_Framework_TestCase
{
protected $recordSet;
protected $multiDataTypes;
protected $numericColumns;
protected $mismatchedColumns;
protected function setUp()
{
$this->recordSet = array(
array(
'id' => 1,
'first_name' => 'John',
'last_name' => 'Doe'
),
array(
'id' => 2,
'first_name' => 'Sally',
'last_name' => 'Smith'
),
array(
'id' => 3,
'first_name' => 'Jane',
'last_name' => 'Jones'
),
);
$fh = fopen(__FILE__, 'r', true);
$this->multiDataTypes = array(
array(
'id' => 1,
'value' => new stdClass
),
array(
'id' => 2,
'value' => 34.2345
),
array(
'id' => 3,
'value' => true
),
array(
'id' => 4,
'value' => false
),
array(
'id' => 5,
'value' => null
),
array(
'id' => 6,
'value' => 1234
),
array(
'id' => 7,
'value' => 'Foo'
),
array(
'id' => 8,
'value' => $fh
),
);
$this->numericColumns = array(
array('aaa', '111'),
array('bbb', '222'),
array('ccc', '333', -1 => 'ddd'),
);
$this->mismatchedColumns = array(
array('a' => 'foo', 'b' => 'bar', 'e' => 'bbb'),
array('a' => 'baz', 'c' => 'qux', 'd' => 'aaa'),
array('a' => 'eee', 'b' => 'fff', 'e' => 'ggg'),
);
}
public function testFirstNameColumnFromRecordset()
{
$expected = array('John', 'Sally', 'Jane');
$this->assertEquals($expected, array_column($this->recordSet, 'first_name'));
}
public function testIdColumnFromRecordset()
{
$expected = array(1, 2, 3);
$this->assertEquals($expected, array_column($this->recordSet, 'id'));
}
public function testLastNameColumnKeyedByIdColumnFromRecordset()
{
$expected = array(1 => 'Doe', 2 => 'Smith', 3 => 'Jones');
$this->assertEquals($expected, array_column($this->recordSet, 'last_name', 'id'));
}
public function testLastNameColumnKeyedByFirstNameColumnFromRecordset()
{
$expected = array('John' => 'Doe', 'Sally' => 'Smith', 'Jane' => 'Jones');
$this->assertEquals($expected, array_column($this->recordSet, 'last_name', 'first_name'));
}
public function testValueColumnWithMultipleDataTypes()
{
$expected = array();
foreach ($this->multiDataTypes as $row) {
$expected[] = $row['value'];
}
$this->assertEquals($expected, array_column($this->multiDataTypes, 'value'));
}
public function testValueColumnKeyedByIdWithMultipleDataTypes()
{
$expected = array();
foreach ($this->multiDataTypes as $row) {
$expected[$row['id']] = $row['value'];
}
$this->assertEquals($expected, array_column($this->multiDataTypes, 'value', 'id'));
}
public function testNumericColumnKeys1()
{
$expected = array('111', '222', '333');
$this->assertEquals($expected, array_column($this->numericColumns, 1));
}
public function testNumericColumnKeys2()
{
$expected = array('aaa' => '111', 'bbb' => '222', 'ccc' => '333');
$this->assertEquals($expected, array_column($this->numericColumns, 1, 0));
}
public function testNumericColumnKeys3()
{
$expected = array('aaa' => '111', 'bbb' => '222', 'ccc' => '333');
$this->assertEquals($expected, array_column($this->numericColumns, 1, 0.123));
}
public function testNumericColumnKeys4()
{
$expected = array(0 => '111', 1 => '222', 'ddd' => '333');
$this->assertEquals($expected, array_column($this->numericColumns, 1, -1));
}
public function testFailureToFindColumn1()
{
$this->assertEquals(array(), array_column($this->numericColumns, 2));
}
public function testFailureToFindColumn2()
{
$this->assertEquals(array(), array_column($this->numericColumns, 'foo'));
}
public function testFailureToFindColumn3()
{
$expected = array('aaa', 'bbb', 'ccc');
$this->assertEquals($expected, array_column($this->numericColumns, 0, 'foo'));
}
public function testFailureToFindColumn4()
{
$this->assertEquals(array(), array_column($this->numericColumns, 3.14));
}
public function testSingleDimensionalArray()
{
$singleDimension = array('foo', 'bar', 'baz');
$this->assertEquals(array(), array_column($singleDimension, 1));
}
public function testMismatchedColumns1()
{
$expected = array('qux');
$this->assertEquals($expected, array_column($this->mismatchedColumns, 'c'));
}
public function testMismatchedColumns2()
{
$expected = array('baz' => 'qux');
$this->assertEquals($expected, array_column($this->mismatchedColumns, 'c', 'a'));
}
public function testMismatchedColumns3()
{
$expected = array('foo', 'aaa' => 'baz', 'eee');
$this->assertEquals($expected, array_column($this->mismatchedColumns, 'a', 'd'));
}
public function testMismatchedColumns4()
{
$expected = array('bbb' => 'foo', 'baz', 'ggg' => 'eee');
$this->assertEquals($expected, array_column($this->mismatchedColumns, 'a', 'e'));
}
public function testMismatchedColumns5()
{
$expected = array('bar', 'fff');
$this->assertEquals($expected, array_column($this->mismatchedColumns, 'b'));
}
public function testMismatchedColumns6()
{
$expected = array('foo' => 'bar', 'eee' => 'fff');
$this->assertEquals($expected, array_column($this->mismatchedColumns, 'b', 'a'));
}
public function testObjectConvertedToString()
{
$f = new Foo();
$b = new Bar();
$this->assertEquals(array('Doe', 'Smith', 'Jones'), array_column($this->recordSet, $f));
$this->assertEquals(array('John' => 'Doe', 'Sally' => 'Smith', 'Jane' => 'Jones'), array_column($this->recordSet, $f, $b));
}
/**
* @expectedException PHPUnit_Framework_Error_Warning
* @expectedExceptionMessage array_column() expects at least 2 parameters, 0 given
*/
public function testFunctionWithZeroArgs()
{
$foo = array_column();
}
public function testFunctionWithZeroArgsReturnValue()
{
$foo = @array_column();
$this->assertNull($foo);
}
/**
* @expectedException PHPUnit_Framework_Error_Warning
* @expectedExceptionMessage array_column() expects at least 2 parameters, 1 given
*/
public function testFunctionWithOneArg()
{
$foo = array_column(array());
}
public function testFunctionWithOneArgReturnValue()
{
$foo = @array_column(array());
$this->assertNull($foo);
}
/**
* @expectedException PHPUnit_Framework_Error_Warning
* @expectedExceptionMessage array_column() expects parameter 1 to be array, string given
*/
public function testFunctionWithStringAsFirstArg()
{
$foo = array_column('foo', 0);
}
public function testFunctionWithStringAsFirstArgReturnValue()
{
$foo = @array_column('foo', 0);
$this->assertNull($foo);
}
/**
* @expectedException PHPUnit_Framework_Error_Warning
* @expectedExceptionMessage array_column() expects parameter 1 to be array, integer given
*/
public function testFunctionWithIntAsFirstArg()
{
$foo = array_column(1, 'foo');
}
public function testFunctionWithIntAsFirstArgReturnValue()
{
$foo = @array_column(1, 'foo');
$this->assertNull($foo);
}
/**
* @expectedException PHPUnit_Framework_Error_Warning
* @expectedExceptionMessage array_column(): The column key should be either a string or an integer
*/
public function testFunctionWithColumnKeyAsBool()
{
$foo = array_column(array(), true);
}
public function testFunctionWithColumnKeyAsBoolReturnValue()
{
$foo = @array_column(array(), true);
$this->assertFalse($foo);
}
/**
* @expectedException PHPUnit_Framework_Error_Warning
* @expectedExceptionMessage array_column(): The column key should be either a string or an integer
*/
public function testFunctionWithColumnKeyAsArray()
{
$foo = array_column(array(), array());
}
public function testFunctionWithColumnKeyAsArrayReturnValue()
{
$foo = @array_column(array(), array());
$this->assertFalse($foo);
}
/**
* @expectedException PHPUnit_Framework_Error_Warning
* @expectedExceptionMessage array_column(): The index key should be either a string or an integer
*/
public function testFunctionWithIndexKeyAsBool()
{
$foo = array_column(array(), 'foo', true);
}
public function testFunctionWithIndexKeyAsBoolReturnValue()
{
$foo = @array_column(array(), 'foo', true);
$this->assertFalse($foo);
}
/**
* @expectedException PHPUnit_Framework_Error_Warning
* @expectedExceptionMessage array_column(): The index key should be either a string or an integer
*/
public function testFunctionWithIndexKeyAsArray()
{
$foo = array_column(array(), 'foo', array());
}
public function testFunctionWithIndexKeyAsArrayReturnValue()
{
$foo = @array_column(array(), 'foo', array());
$this->assertFalse($foo);
}
/**
* @link https://bugs.php.net/bug.php?id=64493
*/
public function testBugRequest64493()
{
// Array from Bug Request #64493 test script
$rows = array(
456 => array('id' => '3', 'title' => 'Foo', 'date' => '2013-03-25'),
457 => array('id' => '5', 'title' => 'Bar', 'date' => '2012-05-20'),
);
// pass null as second parameter to get back all columns indexed by third parameter
$expected1 = array(
3 => array('id' => '3', 'title' => 'Foo', 'date' => '2013-03-25'),
5 => array('id' => '5', 'title' => 'Bar', 'date' => '2012-05-20'),
);
$this->assertEquals($expected1, array_column($rows, null, 'id'));
// pass null as second parameter and bogus third param to get back zero-indexed array of all columns
$expected2 = array(
array('id' => '3', 'title' => 'Foo', 'date' => '2013-03-25'),
array('id' => '5', 'title' => 'Bar', 'date' => '2012-05-20'),
);
$this->assertEquals($expected2, array_column($rows, null, 'foo'));
// pass null as second parameter and no third param to get back array_values(input) (same as $expected2)
$this->assertEquals($expected2, array_column($rows, null));
}
public function testObjectCast()
{
$columnKey = new ColumnKeyClass();
$indexKey = new IndexKeyClass();
$value = new ValueClass();
$records = array(
array(
'id' => $value,
'first_name' => 'John',
'last_name' => 'XXX'
),
array(
'id' => 3245,
'first_name' => 'Sally',
'last_name' => 'Smith'
),
);
$expected = array(
2135 => 'John',
3245 => 'Sally',
);
$this->assertEquals($expected, array_column($records, $columnKey, $indexKey));
}
}
class Foo
{
public function __toString()
{
return 'last_name';
}
}
class Bar
{
public function __toString()
{
return 'first_name';
}
}
class ColumnKeyClass
{
function __toString() { return 'first_name'; }
}
class IndexKeyClass
{
function __toString() { return 'id'; }
}
class ValueClass
{
function __toString() { return '2135'; }
}

View File

@@ -0,0 +1,5 @@
<?php
error_reporting(E_ALL | E_STRICT);
require_once 'src/array_column.php';