Skip to content

Commit

Permalink
master merge
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonas Hartmann committed Aug 22, 2016
2 parents 8fd01a1 + 0ac7ed9 commit 0775337
Show file tree
Hide file tree
Showing 581 changed files with 16,522 additions and 4,734 deletions.
18 changes: 12 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ php:
- 7.0
- 5.5
- 5.6
- 7.1

dist: trusty

Expand All @@ -18,6 +19,10 @@ env:
services:
- memcached
- redis-server
- postgresql

addons:
postgresql: "9.4"

cache:
directories:
Expand All @@ -39,6 +44,7 @@ matrix:

allow_failures:
- php: hhvm
- php: 7.1

before_install:
- if [ $HHVM != 1 && $TRAVIS_PHP_VERSION != 7.* ]; then phpenv config-rm xdebug.ini; fi
Expand All @@ -58,10 +64,10 @@ before_install:

- if [[ $TRAVIS_PHP_VERSION != 'hhvm' ]] ; then echo 'extension = memcached.so' >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi
- if [[ $TRAVIS_PHP_VERSION != 'hhvm' ]] ; then echo 'extension = redis.so' >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi
- if [[ $TRAVIS_PHP_VERSION != 'hhvm' ]] ; then echo 'extension = apcu.so' >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi
- if [[ $TRAVIS_PHP_VERSION != 'hhvm' ]] ; then echo 'apc.enable_cli = 1' >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi
- if [[ $TRAVIS_PHP_VERSION != 'hhvm' && $TRAVIS_PHP_VERSION != 7.1 ]] ; then echo 'extension = apcu.so' >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi
- if [[ $TRAVIS_PHP_VERSION != 'hhvm' && $TRAVIS_PHP_VERSION != 7.1 ]] ; then echo 'apc.enable_cli = 1' >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi
- if [[ $TRAVIS_PHP_VERSION =~ 5.[56] ]] ; then echo yes | pecl install apcu-4.0.10; fi
- if [[ $TRAVIS_PHP_VERSION = 7.* ]] ; then echo yes | pecl install apcu; fi
- if [[ $TRAVIS_PHP_VERSION = 7.0 ]] ; then echo yes | pecl install apcu; fi
- if [[ $TRAVIS_PHP_VERSION = 'hhvm' ]] ; then composer require lorenzo/multiple-iterator=~1.0; fi

- phpenv rehash
Expand All @@ -71,13 +77,13 @@ before_script:
- composer install --prefer-dist --no-interaction

script:
- if [[ $DEFAULT = 1 && $TRAVIS_PHP_VERSION = 7.* ]]; then export CODECOVERAGE=1; vendor/bin/phpunit --coverage-clover=clover.xml; fi
- if [[ $DEFAULT = 1 && $TRAVIS_PHP_VERSION != 7.* ]]; then vendor/bin/phpunit; fi
- if [[ $DEFAULT = 1 && $TRAVIS_PHP_VERSION = 7.0 ]]; then export CODECOVERAGE=1; vendor/bin/phpunit --coverage-clover=clover.xml; fi
- if [[ $DEFAULT = 1 && $TRAVIS_PHP_VERSION != 7.0 ]]; then vendor/bin/phpunit; fi

- if [[ $PHPCS = 1 ]]; then vendor/bin/phpcs -p --extensions=php --standard=vendor/cakephp/cakephp-codesniffer/CakePHP ./src ./tests; fi

after_success:
- if [[ $DEFAULT = 1 && $TRAVIS_PHP_VERSION = 7.* ]]; then bash <(curl -s https://codecov.io/bash); fi
- if [[ $DEFAULT = 1 && $TRAVIS_PHP_VERSION = 7.0 ]]; then bash <(curl -s https://codecov.io/bash); fi

notifications:
email: false
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ recommend using the [app skeleton](https://github.com/cakephp/app) as
a starting point. For existing applications you can run the following:

``` bash
$ composer require cakephp/cakephp:"~3.2"
$ composer require cakephp/cakephp:"~3.3"
```

## Running Tests
Expand Down
2 changes: 1 addition & 1 deletion VERSION.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@
// @license http://www.opensource.org/licenses/mit-license.php MIT License
// +--------------------------------------------------------------------------------------------+ //
////////////////////////////////////////////////////////////////////////////////////////////////////
3.2.12
3.3.2
10 changes: 6 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,13 @@
"php": ">=5.5.9",
"ext-intl": "*",
"ext-mbstring": "*",
"cakephp/chronos": "*",
"cakephp/chronos": "~1.0",
"aura/intl": "1.1.*",
"psr/log": "1.0"
"psr/log": "1.0",
"zendframework/zend-diactoros": "~1.0"
},
"suggest": {
"ext-openssl": "To use Security::encrypt() or have secure CSRF token generation."
"ext-openssl": "To use Security::encrypt() or have secure CSRF token generation."
},
"require-dev": {
"phpunit/phpunit": "*",
Expand All @@ -46,11 +47,12 @@
"autoload-dev": {
"psr-4": {
"Cake\\Test\\": "tests",
"Company\\TestPluginThree\\Test\\": "tests/test_app/Plugin/Company/TestPluginThree/tests",
"TestApp\\": "tests/test_app/TestApp",
"TestPlugin\\": "tests/test_app/Plugin/TestPlugin/src",
"TestPlugin\\Test\\": "tests/test_app/Plugin/TestPlugin/tests",
"TestPluginTwo\\": "tests/test_app/Plugin/TestPluginTwo/src",
"Company\\TestPluginThree\\": "tests/test_app/Plugin/Company/TestPluginThree/src",
"Company\\TestPluginThree\\Test\\": "tests/test_app/Plugin/Company/TestPluginThree/tests",
"PluginJs\\": "tests/test_app/Plugin/PluginJs/src"
}
},
Expand Down
12 changes: 0 additions & 12 deletions config/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,6 @@

define('TIME_START', microtime(true));

// @deprecated Backward compatibility with 2.x series
if (PHP_VERSION_ID < 70000) {
class_alias('Cake\Utility\Text', 'Cake\Utility\String');
}

// @deprecated Backward compatibility with 2.x, 3.0.x
class_alias('Cake\Mailer\AbstractTransport', 'Cake\Network\Email\AbstractTransport');
class_alias('Cake\Mailer\Transport\DebugTransport', 'Cake\Network\Email\DebugTransport');
class_alias('Cake\Mailer\Email', 'Cake\Network\Email\Email');
class_alias('Cake\Mailer\Transport\MailTransport', 'Cake\Network\Email\MailTransport');
class_alias('Cake\Mailer\Transport\SmtpTransport', 'Cake\Network\Email\SmtpTransport');

require CAKE . 'basics.php';

// Sets the initial router state so future reloads work.
Expand Down
1 change: 0 additions & 1 deletion src/Auth/AbstractPasswordHasher.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

/**
* Abstract password hashing class
*
*/
abstract class AbstractPasswordHasher
{
Expand Down
1 change: 0 additions & 1 deletion src/Auth/BaseAuthenticate.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

/**
* Base Authentication class with common methods and properties.
*
*/
abstract class BaseAuthenticate implements EventListenerInterface
{
Expand Down
2 changes: 1 addition & 1 deletion src/Auth/BaseAuthorize.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function __construct(ComponentRegistry $registry, array $config = [])
/**
* Checks user authorization.
*
* @param array $user Active user data
* @param array|\ArrayAccess $user Active user data
* @param \Cake\Network\Request $request Request instance.
* @return bool
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Auth/ControllerAuthorize.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public function controller(Controller $controller = null)
/**
* Checks user authorization using a controller callback.
*
* @param array $user Active user data
* @param array|\ArrayAccess $user Active user data
* @param \Cake\Network\Request $request Request instance.
* @return bool
*/
Expand Down
1 change: 0 additions & 1 deletion src/Auth/DefaultPasswordHasher.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

/**
* Default password hashing class.
*
*/
class DefaultPasswordHasher extends AbstractPasswordHasher
{
Expand Down
1 change: 0 additions & 1 deletion src/Auth/FallbackPasswordHasher.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
* A password hasher that can use multiple different hashes where only
* one is the preferred one. This is useful when trying to migrate an
* existing database of users from one password type to another.
*
*/
class FallbackPasswordHasher extends AbstractPasswordHasher
{
Expand Down
1 change: 0 additions & 1 deletion src/Auth/PasswordHasherFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

/**
* Builds password hashing objects
*
*/
class PasswordHasherFactory
{
Expand Down
2 changes: 1 addition & 1 deletion src/Auth/Storage/MemoryStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function read()
/**
* {@inheritDoc}
*/
public function write(array $user)
public function write($user)
{
$this->_user = $user;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Auth/Storage/SessionStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,10 @@ public function read()
*
* The session id is also renewed to help mitigate issues with session replays.
*
* @param array $user User record.
* @param array|\ArrayAccess $user User record.
* @return void
*/
public function write(array $user)
public function write($user)
{
$this->_user = $user;

Expand Down
4 changes: 2 additions & 2 deletions src/Auth/Storage/StorageInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ public function read();
/**
* Write user record.
*
* @param array $user User record.
* @param array|\ArrayAccess $user User record.
* @return void
*/
public function write(array $user);
public function write($user);

/**
* Delete user record.
Expand Down
1 change: 0 additions & 1 deletion src/Auth/WeakPasswordHasher.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
* Password hashing class that use weak hashing algorithms. This class is
* intended only to be used with legacy databases where passwords have
* not been migrated to a stronger algorithm yet.
*
*/
class WeakPasswordHasher extends AbstractPasswordHasher
{
Expand Down
1 change: 0 additions & 1 deletion src/Cache/CacheEngine.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

/**
* Storage engine for CakePHP caching
*
*/
abstract class CacheEngine
{
Expand Down
1 change: 0 additions & 1 deletion src/Cache/Engine/ApcEngine.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

/**
* APC storage engine for cache
*
*/
class ApcEngine extends CacheEngine
{
Expand Down
1 change: 0 additions & 1 deletion src/Cache/Engine/FileEngine.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
* engine available, or have content which is not performance sensitive.
*
* You can configure a FileEngine cache, using Cache::config()
*
*/
class FileEngine extends CacheEngine
{
Expand Down
1 change: 0 additions & 1 deletion src/Cache/Engine/MemcachedEngine.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
* support of binary protocol, and igbinary serialization
* (if memcached extension compiled with --enable-igbinary)
* Compressed keys can also be incremented/decremented
*
*/
class MemcachedEngine extends CacheEngine
{
Expand Down
1 change: 0 additions & 1 deletion src/Cache/Engine/RedisEngine.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

/**
* Redis storage engine for cache.
*
*/
class RedisEngine extends CacheEngine
{
Expand Down
32 changes: 30 additions & 2 deletions src/Collection/CollectionInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
* Describes the methods a Collection should implement. A collection is an immutable
* list of elements exposing a number of traversing and extracting method for
* generating other collections.
*
*/
interface CollectionInterface extends Iterator, JsonSerializable
{
Expand Down Expand Up @@ -620,9 +619,10 @@ public function combine($keyPath, $valuePath, $groupPath = null);
* whether an element is parent of another
* @param callable|string $parentPath the column name path to use for determining
* whether an element is child of another
* @param string $nestingKey The key name under which children are nested
* @return \Cake\Collection\CollectionInterface
*/
public function nest($idPath, $parentPath);
public function nest($idPath, $parentPath, $nestingKey = 'children');

/**
* Returns a new collection containing each of the elements found in `$values` as
Expand Down Expand Up @@ -945,4 +945,32 @@ public function isEmpty();
* @return \Iterator
*/
public function unwrap();

/**
* Transpose rows and columns into columns and rows
*
* ### Example:
*
* ```
* $items = [
* ['Products', '2012', '2013', '2014'],
* ['Product A', '200', '100', '50'],
* ['Product B', '300', '200', '100'],
* ['Product C', '400', '300', '200'],
* ]
*
* $transpose = (new Collection($items))->transpose()->toList();
*
* // Returns
* // [
* // ['Products', 'Product A', 'Product B', 'Product C'],
* // ['2012', '200', '300', '400'],
* // ['2013', '100', '200', '300'],
* // ['2014', '50', '100', '200'],
* // ]
* ```
*
* @return \Cake\Collection\CollectionInterface
*/
public function transpose();
}
31 changes: 26 additions & 5 deletions src/Collection/CollectionTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
use Cake\Collection\Iterator\ZipIterator;
use Countable;
use LimitIterator;
use LogicException;
use RecursiveIteratorIterator;
use Traversable;

Expand Down Expand Up @@ -421,22 +422,22 @@ public function combine($keyPath, $valuePath, $groupPath = null)
* {@inheritDoc}
*
*/
public function nest($idPath, $parentPath)
public function nest($idPath, $parentPath, $nestingKey = 'children')
{
$parents = [];
$idPath = $this->_propertyExtractor($idPath);
$parentPath = $this->_propertyExtractor($parentPath);
$isObject = true;

$mapper = function ($row, $key, $mapReduce) use (&$parents, $idPath, $parentPath) {
$row['children'] = [];
$mapper = function ($row, $key, $mapReduce) use (&$parents, $idPath, $parentPath, $nestingKey) {
$row[$nestingKey] = [];
$id = $idPath($row, $key);
$parentId = $parentPath($row, $key);
$parents[$id] =& $row;
$mapReduce->emitIntermediate($id, $parentId);
};

$reducer = function ($values, $key, $mapReduce) use (&$parents, &$isObject) {
$reducer = function ($values, $key, $mapReduce) use (&$parents, &$isObject, $nestingKey) {
static $foundOutType = false;
if (!$foundOutType) {
$isObject = is_object(current($parents));
Expand All @@ -455,7 +456,7 @@ public function nest($idPath, $parentPath)
foreach ($values as $id) {
$children[] =& $parents[$id];
}
$parents[$key]['children'] = $children;
$parents[$key][$nestingKey] = $children;
};

return (new Collection(new MapReduce($this->unwrap(), $mapper, $reducer)))
Expand Down Expand Up @@ -679,4 +680,24 @@ public function _unwrap()
{
return $this->unwrap();
}

/**
* {@inheritDoc}
*
* @return \Cake\Collection\CollectionInterface
*/
public function transpose()
{
$arrayValue = $this->toList();
$length = count(current($arrayValue));
$result = [];
foreach ($arrayValue as $column => $row) {
if (count($row) != $length) {
throw new LogicException('Child arrays do not have even length');
}
$result[] = array_column($arrayValue, $column);
}

return new Collection($result);
}
}
1 change: 0 additions & 1 deletion src/Collection/Iterator/NestIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
/**
* A type of collection that is aware of nested items and exposes methods to
* check or retrieve them
*
*/
class NestIterator extends Collection implements RecursiveIterator
{
Expand Down
Loading

0 comments on commit 0775337

Please sign in to comment.