From 01a93308b739a4031b76268b69e7bd0943d4c677 Mon Sep 17 00:00:00 2001
From: Thomas Steur <thomas.steur@gmail.com>
Date: Thu, 3 Sep 2015 07:55:43 +0000
Subject: [PATCH] refs #8689 started working on PHP 7 support

---
 .travis.yml                                   |  16 +-
 composer.json                                 |   2 +-
 composer.lock                                 | 252 +++++++++---------
 core/Composer/ScriptHandler.php               |  15 +-
 core/Db/Adapter.php                           |   8 +-
 core/ExceptionHandler.php                     |  20 +-
 core/Plugin/Dimension/VisitDimension.php      |  49 +++-
 .../Diagnostic/PhpSettingsCheck.php           |   8 +-
 .../Insights/tests/Unit/FilterOrderByTest.php |   7 +-
 .../Framework/TestCase/SystemTestCase.php     |   5 +
 tests/PHPUnit/Integration/PiwikTest.php       |   8 +-
 .../Plugin/Dimension/VisitDimensionTest.php   |  33 ++-
 tests/PHPUnit/Unit/FilesystemTest.php         |   6 +
 tests/PHPUnit/Unit/Period/DayTest.php         |   2 +
 14 files changed, 286 insertions(+), 145 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index eef27e1d5e..3e8905be9c 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -10,6 +10,7 @@
 language: php
 
 php:
+  - 7
   - 5.6
   - 5.3.3
 #  - hhvm
@@ -43,6 +44,7 @@ matrix:
   fast_finish: true
   allow_failures:
     - php: hhvm
+    - php: 7
   exclude:
     # Run test suites separately only on PHP 5.6 with PDO
     - php: 5.3.3
@@ -51,6 +53,8 @@ matrix:
       env: TEST_SUITE=IntegrationTests MYSQL_ADAPTER=PDO_MYSQL
     - php: 5.3.3
       env: TEST_SUITE=AllTests MYSQL_ADAPTER=PDO_MYSQL
+    - php: 7
+      env: TEST_SUITE=AllTests MYSQL_ADAPTER=PDO_MYSQL
     - php: 5.3.3
       env: TEST_SUITE=UnitTests MYSQL_ADAPTER=PDO_MYSQL
     - php: hhvm
@@ -69,6 +73,8 @@ matrix:
       env: TEST_SUITE=AllTests MYSQL_ADAPTER=PDO_MYSQL
     - php: 5.3.3
       env: TEST_SUITE=AllTests MYSQL_ADAPTER=MYSQLI
+    - php: 7
+      env: TEST_SUITE=AllTests MYSQL_ADAPTER=MYSQLI
     - php: hhvm
       env: TEST_SUITE=AllTests MYSQL_ADAPTER=MYSQLI
     # Javascript tests need to run only on one PHP version
@@ -76,11 +82,15 @@ matrix:
       env: TEST_SUITE=JavascriptTests MYSQL_ADAPTER=PDO_MYSQL SKIP_COMPOSER_INSTALL=1
     - php: hhvm
       env: TEST_SUITE=JavascriptTests MYSQL_ADAPTER=PDO_MYSQL SKIP_COMPOSER_INSTALL=1
+    - php: 7
+      env: TEST_SUITE=JavascriptTests MYSQL_ADAPTER=PDO_MYSQL SKIP_COMPOSER_INSTALL=1
     # AngularJS tests need to run only on one PHP version
     - php: 5.3.3
       env: TEST_SUITE=AngularJSTests MYSQL_ADAPTER=PDO_MYSQL SKIP_COMPOSER_INSTALL=1
     - php: hhvm
       env: TEST_SUITE=AngularJSTests MYSQL_ADAPTER=PDO_MYSQL SKIP_COMPOSER_INSTALL=1
+    - php: 7
+      env: TEST_SUITE=AngularJSTests MYSQL_ADAPTER=PDO_MYSQL SKIP_COMPOSER_INSTALL=1
 
 sudo: required
 
@@ -93,8 +103,8 @@ before_install:
 install:
   - git fetch -q
 
-  - export GENERATE_TRAVIS_YML_COMMAND="php ./tests/travis/generator/main.php generate:travis-yml --core --verbose"
-  - '[[ "$TRAVIS_JOB_NUMBER" != *.1 || "$TRAVIS_PULL_REQUEST" != "false" ]] || ./tests/travis/autoupdate_travis_yml.sh'
+#  - export GENERATE_TRAVIS_YML_COMMAND="php ./tests/travis/generator/main.php generate:travis-yml --core --verbose"
+#  - '[[ "$TRAVIS_JOB_NUMBER" != *.1 || "$TRAVIS_PULL_REQUEST" != "false" ]] || ./tests/travis/autoupdate_travis_yml.sh'
 
   - '[ ! -f ./tests/travis/install_mysql_5.6.sh ] || ./tests/travis/install_mysql_5.6.sh'
 
@@ -110,7 +120,7 @@ install:
 
 
 before_script:
-  - phpenv config-rm xdebug.ini;
+  - if [[ "$TRAVIS_PHP_VERSION" != 7* ]]; then phpenv config-rm xdebug.ini; fi
 
   # add always_populate_raw_post_data=-1 to php.ini
   - echo "always_populate_raw_post_data=-1" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
diff --git a/composer.json b/composer.json
index 8cc4cfdadb..1943bd6c2f 100644
--- a/composer.json
+++ b/composer.json
@@ -58,7 +58,7 @@
     },
     "require-dev": {
         "aws/aws-sdk-php": "2.7.1",
-        "phpunit/phpunit": "~4.1",
+        "phpunit/phpunit": "~4.8",
         "facebook/xhprof": "dev-master",
         "phpseclib/phpseclib": "~0.3.8",
         "symfony/var-dumper": "~2.6.0",
diff --git a/composer.lock b/composer.lock
index 7879657d88..ca7c89576c 100644
--- a/composer.lock
+++ b/composer.lock
@@ -4,7 +4,7 @@
         "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
         "This file is @generated automatically"
     ],
-    "hash": "1f60c1756d33943d2da85062b6d2c4d1",
+    "hash": "500550a2b3c6f91d0a34461f2e6f8654",
     "packages": [
         {
             "name": "container-interop/container-interop",
@@ -35,16 +35,16 @@
         },
         {
             "name": "doctrine/annotations",
-            "version": "v1.2.6",
+            "version": "v1.2.7",
             "source": {
                 "type": "git",
                 "url": "https://github.com/doctrine/annotations.git",
-                "reference": "f4a91702ca3cd2e568c3736aa031ed00c3752af4"
+                "reference": "f25c8aab83e0c3e976fd7d19875f198ccf2f7535"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/doctrine/annotations/zipball/f4a91702ca3cd2e568c3736aa031ed00c3752af4",
-                "reference": "f4a91702ca3cd2e568c3736aa031ed00c3752af4",
+                "url": "https://api.github.com/repos/doctrine/annotations/zipball/f25c8aab83e0c3e976fd7d19875f198ccf2f7535",
+                "reference": "f25c8aab83e0c3e976fd7d19875f198ccf2f7535",
                 "shasum": ""
             },
             "require": {
@@ -99,20 +99,20 @@
                 "docblock",
                 "parser"
             ],
-            "time": "2015-06-17 12:21:22"
+            "time": "2015-08-31 12:32:49"
         },
         {
             "name": "doctrine/cache",
-            "version": "v1.4.1",
+            "version": "v1.4.2",
             "source": {
                 "type": "git",
                 "url": "https://github.com/doctrine/cache.git",
-                "reference": "c9eadeb743ac6199f7eec423cb9426bc518b7b03"
+                "reference": "8c434000f420ade76a07c64cbe08ca47e5c101ca"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/doctrine/cache/zipball/c9eadeb743ac6199f7eec423cb9426bc518b7b03",
-                "reference": "c9eadeb743ac6199f7eec423cb9426bc518b7b03",
+                "url": "https://api.github.com/repos/doctrine/cache/zipball/8c434000f420ade76a07c64cbe08ca47e5c101ca",
+                "reference": "8c434000f420ade76a07c64cbe08ca47e5c101ca",
                 "shasum": ""
             },
             "require": {
@@ -169,7 +169,7 @@
                 "cache",
                 "caching"
             ],
-            "time": "2015-04-15 00:11:59"
+            "time": "2015-08-31 12:36:41"
         },
         {
             "name": "doctrine/lexer",
@@ -303,16 +303,16 @@
         },
         {
             "name": "monolog/monolog",
-            "version": "1.15.0",
+            "version": "1.17.1",
             "source": {
                 "type": "git",
                 "url": "https://github.com/Seldaek/monolog.git",
-                "reference": "dc5150cc608f2334c72c3b6a553ec9668a4156b0"
+                "reference": "0524c87587ab85bc4c2d6f5b41253ccb930a5422"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/Seldaek/monolog/zipball/dc5150cc608f2334c72c3b6a553ec9668a4156b0",
-                "reference": "dc5150cc608f2334c72c3b6a553ec9668a4156b0",
+                "url": "https://api.github.com/repos/Seldaek/monolog/zipball/0524c87587ab85bc4c2d6f5b41253ccb930a5422",
+                "reference": "0524c87587ab85bc4c2d6f5b41253ccb930a5422",
                 "shasum": ""
             },
             "require": {
@@ -329,7 +329,7 @@
                 "php-console/php-console": "^3.1.3",
                 "phpunit/phpunit": "~4.5",
                 "phpunit/phpunit-mock-objects": "2.3.0",
-                "raven/raven": "~0.8",
+                "raven/raven": "~0.11",
                 "ruflin/elastica": ">=0.90 <3.0",
                 "swiftmailer/swiftmailer": "~5.3",
                 "videlalvaro/php-amqplib": "~2.4"
@@ -349,7 +349,7 @@
             "type": "library",
             "extra": {
                 "branch-alias": {
-                    "dev-master": "1.15.x-dev"
+                    "dev-master": "1.16.x-dev"
                 }
             },
             "autoload": {
@@ -375,7 +375,7 @@
                 "logging",
                 "psr-3"
             ],
-            "time": "2015-07-12 13:54:09"
+            "time": "2015-08-31 09:17:37"
         },
         {
             "name": "mustangostang/spyc",
@@ -426,16 +426,16 @@
         },
         {
             "name": "pear/archive_tar",
-            "version": "1.3.16",
+            "version": "1.4.0",
             "source": {
                 "type": "git",
                 "url": "https://github.com/pear/Archive_Tar.git",
-                "reference": "fd358553f84a4587ad38f6da98936af494dda94b"
+                "reference": "e337c40bf467a1fcde6b770fce8ca6dc32dcc38f"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/pear/Archive_Tar/zipball/fd358553f84a4587ad38f6da98936af494dda94b",
-                "reference": "fd358553f84a4587ad38f6da98936af494dda94b",
+                "url": "https://api.github.com/repos/pear/Archive_Tar/zipball/e337c40bf467a1fcde6b770fce8ca6dc32dcc38f",
+                "reference": "e337c40bf467a1fcde6b770fce8ca6dc32dcc38f",
                 "shasum": ""
             },
             "require": {
@@ -451,6 +451,11 @@
                 "ext-zlib": "Gzip compression support."
             },
             "type": "library",
+            "extra": {
+                "branch-alias": {
+                    "dev-master": "1.4.x-dev"
+                }
+            },
             "autoload": {
                 "psr-0": {
                     "Archive_Tar": ""
@@ -483,20 +488,20 @@
                 "archive",
                 "tar"
             ],
-            "time": "2015-04-14 12:24:20"
+            "time": "2015-07-20 07:52:03"
         },
         {
             "name": "pear/console_getopt",
-            "version": "v1.4.0",
+            "version": "v1.4.1",
             "source": {
                 "type": "git",
                 "url": "https://github.com/pear/Console_Getopt.git",
-                "reference": "ff3eecbbc5d6e9a243f70f7cf51ca7554e4bb470"
+                "reference": "82f05cd1aa3edf34e19aa7c8ca312ce13a6a577f"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/pear/Console_Getopt/zipball/ff3eecbbc5d6e9a243f70f7cf51ca7554e4bb470",
-                "reference": "ff3eecbbc5d6e9a243f70f7cf51ca7554e4bb470",
+                "url": "https://api.github.com/repos/pear/Console_Getopt/zipball/82f05cd1aa3edf34e19aa7c8ca312ce13a6a577f",
+                "reference": "82f05cd1aa3edf34e19aa7c8ca312ce13a6a577f",
                 "shasum": ""
             },
             "type": "library",
@@ -530,7 +535,7 @@
                 }
             ],
             "description": "More info available on: http://pear.php.net/package/Console_Getopt",
-            "time": "2015-02-22 13:26:45"
+            "time": "2015-07-20 20:28:12"
         },
         {
             "name": "pear/pear-core-minimal",
@@ -633,16 +638,16 @@
         },
         {
             "name": "php-di/invoker",
-            "version": "1.0.0",
+            "version": "1.0.1",
             "source": {
                 "type": "git",
                 "url": "https://github.com/PHP-DI/Invoker.git",
-                "reference": "7ea703c62dbb29d64763fa85258826034ce3c97d"
+                "reference": "2eb8f3a9b44c1427865134ef585d986ca89bce36"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/PHP-DI/Invoker/zipball/7ea703c62dbb29d64763fa85258826034ce3c97d",
-                "reference": "7ea703c62dbb29d64763fa85258826034ce3c97d",
+                "url": "https://api.github.com/repos/PHP-DI/Invoker/zipball/2eb8f3a9b44c1427865134ef585d986ca89bce36",
+                "reference": "2eb8f3a9b44c1427865134ef585d986ca89bce36",
                 "shasum": ""
             },
             "require": {
@@ -672,7 +677,7 @@
                 "invoke",
                 "invoker"
             ],
-            "time": "2015-04-24 10:18:34"
+            "time": "2015-09-02 16:01:10"
         },
         {
             "name": "php-di/php-di",
@@ -992,17 +997,17 @@
         },
         {
             "name": "symfony/console",
-            "version": "v2.6.10",
+            "version": "v2.6.11",
             "target-dir": "Symfony/Component/Console",
             "source": {
                 "type": "git",
                 "url": "https://github.com/symfony/Console.git",
-                "reference": "042107bc202845086739414339e551fbe81293d7"
+                "reference": "0e5e18ae09d3f5c06367759be940e9ed3f568359"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/symfony/Console/zipball/042107bc202845086739414339e551fbe81293d7",
-                "reference": "042107bc202845086739414339e551fbe81293d7",
+                "url": "https://api.github.com/repos/symfony/Console/zipball/0e5e18ae09d3f5c06367759be940e9ed3f568359",
+                "reference": "0e5e18ae09d3f5c06367759be940e9ed3f568359",
                 "shasum": ""
             },
             "require": {
@@ -1046,11 +1051,11 @@
             ],
             "description": "Symfony Console Component",
             "homepage": "https://symfony.com",
-            "time": "2015-07-13 09:09:47"
+            "time": "2015-07-26 09:08:40"
         },
         {
             "name": "symfony/event-dispatcher",
-            "version": "v2.6.10",
+            "version": "v2.6.11",
             "target-dir": "Symfony/Component/EventDispatcher",
             "source": {
                 "type": "git",
@@ -1109,7 +1114,7 @@
         },
         {
             "name": "symfony/monolog-bridge",
-            "version": "v2.6.10",
+            "version": "v2.6.11",
             "target-dir": "Symfony/Bridge/Monolog",
             "source": {
                 "type": "git",
@@ -1168,16 +1173,16 @@
         },
         {
             "name": "tecnick.com/tcpdf",
-            "version": "6.2.9",
+            "version": "6.2.11",
             "source": {
                 "type": "git",
                 "url": "https://github.com/tecnickcom/TCPDF.git",
-                "reference": "fa6ab8a1e1fbabb9e6cfd2f807514fa1497240e4"
+                "reference": "354433a33946ae7497c3eab291eaaf814bccbfab"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/tecnickcom/TCPDF/zipball/fa6ab8a1e1fbabb9e6cfd2f807514fa1497240e4",
-                "reference": "fa6ab8a1e1fbabb9e6cfd2f807514fa1497240e4",
+                "url": "https://api.github.com/repos/tecnickcom/TCPDF/zipball/354433a33946ae7497c3eab291eaaf814bccbfab",
+                "reference": "354433a33946ae7497c3eab291eaaf814bccbfab",
                 "shasum": ""
             },
             "require": {
@@ -1227,7 +1232,7 @@
                 "pdf417",
                 "qrcode"
             ],
-            "time": "2015-06-18 09:12:38"
+            "time": "2015-08-02 12:30:27"
         },
         {
             "name": "tedivm/jshrink",
@@ -1272,25 +1277,29 @@
         },
         {
             "name": "twig/twig",
-            "version": "v1.18.2",
+            "version": "v1.21.1",
             "source": {
                 "type": "git",
                 "url": "https://github.com/twigphp/Twig.git",
-                "reference": "e8e6575abf6102af53ec283f7f14b89e304fa602"
+                "reference": "ca8d3aa90b6a01c82e07909fe815d6b443e75a23"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/twigphp/Twig/zipball/e8e6575abf6102af53ec283f7f14b89e304fa602",
-                "reference": "e8e6575abf6102af53ec283f7f14b89e304fa602",
+                "url": "https://api.github.com/repos/twigphp/Twig/zipball/ca8d3aa90b6a01c82e07909fe815d6b443e75a23",
+                "reference": "ca8d3aa90b6a01c82e07909fe815d6b443e75a23",
                 "shasum": ""
             },
             "require": {
                 "php": ">=5.2.7"
             },
+            "require-dev": {
+                "symfony/debug": "~2.7",
+                "symfony/phpunit-bridge": "~2.7"
+            },
             "type": "library",
             "extra": {
                 "branch-alias": {
-                    "dev-master": "1.18-dev"
+                    "dev-master": "1.21-dev"
                 }
             },
             "autoload": {
@@ -1325,7 +1334,7 @@
             "keywords": [
                 "templating"
             ],
-            "time": "2015-06-06 23:31:24"
+            "time": "2015-08-26 08:58:31"
         }
     ],
     "packages-dev": [
@@ -1477,7 +1486,7 @@
                 "performance",
                 "profiling"
             ],
-            "time": "2015-02-26 14:37:51"
+            "time": "2014-08-28 17:34:52"
         },
         {
             "name": "guzzle/guzzle",
@@ -1723,16 +1732,16 @@
         },
         {
             "name": "phpspec/prophecy",
-            "version": "v1.4.1",
+            "version": "v1.5.0",
             "source": {
                 "type": "git",
                 "url": "https://github.com/phpspec/prophecy.git",
-                "reference": "3132b1f44c7bf2ec4c7eb2d3cb78fdeca760d373"
+                "reference": "4745ded9307786b730d7a60df5cb5a6c43cf95f7"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/phpspec/prophecy/zipball/3132b1f44c7bf2ec4c7eb2d3cb78fdeca760d373",
-                "reference": "3132b1f44c7bf2ec4c7eb2d3cb78fdeca760d373",
+                "url": "https://api.github.com/repos/phpspec/prophecy/zipball/4745ded9307786b730d7a60df5cb5a6c43cf95f7",
+                "reference": "4745ded9307786b730d7a60df5cb5a6c43cf95f7",
                 "shasum": ""
             },
             "require": {
@@ -1779,20 +1788,20 @@
                 "spy",
                 "stub"
             ],
-            "time": "2015-04-27 22:15:08"
+            "time": "2015-08-13 10:07:40"
         },
         {
             "name": "phpunit/php-code-coverage",
-            "version": "2.1.8",
+            "version": "2.2.2",
             "source": {
                 "type": "git",
                 "url": "https://github.com/sebastianbergmann/php-code-coverage.git",
-                "reference": "6044546998c7627ab997501a3d0db972b3db9790"
+                "reference": "2d7c03c0e4e080901b8f33b2897b0577be18a13c"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/6044546998c7627ab997501a3d0db972b3db9790",
-                "reference": "6044546998c7627ab997501a3d0db972b3db9790",
+                "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/2d7c03c0e4e080901b8f33b2897b0577be18a13c",
+                "reference": "2d7c03c0e4e080901b8f33b2897b0577be18a13c",
                 "shasum": ""
             },
             "require": {
@@ -1800,7 +1809,7 @@
                 "phpunit/php-file-iterator": "~1.3",
                 "phpunit/php-text-template": "~1.2",
                 "phpunit/php-token-stream": "~1.3",
-                "sebastian/environment": "~1.0",
+                "sebastian/environment": "^1.3.2",
                 "sebastian/version": "~1.0"
             },
             "require-dev": {
@@ -1815,7 +1824,7 @@
             "type": "library",
             "extra": {
                 "branch-alias": {
-                    "dev-master": "2.1.x-dev"
+                    "dev-master": "2.2.x-dev"
                 }
             },
             "autoload": {
@@ -1841,20 +1850,20 @@
                 "testing",
                 "xunit"
             ],
-            "time": "2015-07-13 11:25:58"
+            "time": "2015-08-04 03:42:39"
         },
         {
             "name": "phpunit/php-file-iterator",
-            "version": "1.4.0",
+            "version": "1.4.1",
             "source": {
                 "type": "git",
                 "url": "https://github.com/sebastianbergmann/php-file-iterator.git",
-                "reference": "a923bb15680d0089e2316f7a4af8f437046e96bb"
+                "reference": "6150bf2c35d3fc379e50c7602b75caceaa39dbf0"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/a923bb15680d0089e2316f7a4af8f437046e96bb",
-                "reference": "a923bb15680d0089e2316f7a4af8f437046e96bb",
+                "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/6150bf2c35d3fc379e50c7602b75caceaa39dbf0",
+                "reference": "6150bf2c35d3fc379e50c7602b75caceaa39dbf0",
                 "shasum": ""
             },
             "require": {
@@ -1888,7 +1897,7 @@
                 "filesystem",
                 "iterator"
             ],
-            "time": "2015-04-02 05:19:05"
+            "time": "2015-06-21 13:08:43"
         },
         {
             "name": "phpunit/php-text-template",
@@ -1933,16 +1942,16 @@
         },
         {
             "name": "phpunit/php-timer",
-            "version": "1.0.6",
+            "version": "1.0.7",
             "source": {
                 "type": "git",
                 "url": "https://github.com/sebastianbergmann/php-timer.git",
-                "reference": "83fe1bdc5d47658b727595c14da140da92b3d66d"
+                "reference": "3e82f4e9fc92665fafd9157568e4dcb01d014e5b"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/83fe1bdc5d47658b727595c14da140da92b3d66d",
-                "reference": "83fe1bdc5d47658b727595c14da140da92b3d66d",
+                "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/3e82f4e9fc92665fafd9157568e4dcb01d014e5b",
+                "reference": "3e82f4e9fc92665fafd9157568e4dcb01d014e5b",
                 "shasum": ""
             },
             "require": {
@@ -1970,20 +1979,20 @@
             "keywords": [
                 "timer"
             ],
-            "time": "2015-06-13 07:35:30"
+            "time": "2015-06-21 08:01:12"
         },
         {
             "name": "phpunit/php-token-stream",
-            "version": "1.4.3",
+            "version": "1.4.6",
             "source": {
                 "type": "git",
                 "url": "https://github.com/sebastianbergmann/php-token-stream.git",
-                "reference": "7a9b0969488c3c54fd62b4d504b3ec758fd005d9"
+                "reference": "3ab72c62e550370a6cd5dc873e1a04ab57562f5b"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/7a9b0969488c3c54fd62b4d504b3ec758fd005d9",
-                "reference": "7a9b0969488c3c54fd62b4d504b3ec758fd005d9",
+                "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/3ab72c62e550370a6cd5dc873e1a04ab57562f5b",
+                "reference": "3ab72c62e550370a6cd5dc873e1a04ab57562f5b",
                 "shasum": ""
             },
             "require": {
@@ -2019,20 +2028,20 @@
             "keywords": [
                 "tokenizer"
             ],
-            "time": "2015-06-19 03:43:16"
+            "time": "2015-08-16 08:51:00"
         },
         {
             "name": "phpunit/phpunit",
-            "version": "4.7.7",
+            "version": "4.8.6",
             "source": {
                 "type": "git",
                 "url": "https://github.com/sebastianbergmann/phpunit.git",
-                "reference": "9b97f9d807b862c2de2a36e86690000801c85724"
+                "reference": "2246830f4a1a551c67933e4171bf2126dc29d357"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/9b97f9d807b862c2de2a36e86690000801c85724",
-                "reference": "9b97f9d807b862c2de2a36e86690000801c85724",
+                "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/2246830f4a1a551c67933e4171bf2126dc29d357",
+                "reference": "2246830f4a1a551c67933e4171bf2126dc29d357",
                 "shasum": ""
             },
             "require": {
@@ -2042,7 +2051,7 @@
                 "ext-reflection": "*",
                 "ext-spl": "*",
                 "php": ">=5.3.3",
-                "phpspec/prophecy": "~1.3,>=1.3.1",
+                "phpspec/prophecy": "^1.3.1",
                 "phpunit/php-code-coverage": "~2.1",
                 "phpunit/php-file-iterator": "~1.4",
                 "phpunit/php-text-template": "~1.2",
@@ -2050,7 +2059,7 @@
                 "phpunit/phpunit-mock-objects": "~2.3",
                 "sebastian/comparator": "~1.1",
                 "sebastian/diff": "~1.2",
-                "sebastian/environment": "~1.2",
+                "sebastian/environment": "~1.3",
                 "sebastian/exporter": "~1.2",
                 "sebastian/global-state": "~1.0",
                 "sebastian/version": "~1.0",
@@ -2065,7 +2074,7 @@
             "type": "library",
             "extra": {
                 "branch-alias": {
-                    "dev-master": "4.7.x-dev"
+                    "dev-master": "4.8.x-dev"
                 }
             },
             "autoload": {
@@ -2091,26 +2100,27 @@
                 "testing",
                 "xunit"
             ],
-            "time": "2015-07-13 11:28:34"
+            "time": "2015-08-24 04:09:38"
         },
         {
             "name": "phpunit/phpunit-mock-objects",
-            "version": "2.3.5",
+            "version": "2.3.7",
             "source": {
                 "type": "git",
                 "url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git",
-                "reference": "1c330b1b6e1ea8fd15f2fbea46770576e366855c"
+                "reference": "5e2645ad49d196e020b85598d7c97e482725786a"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/1c330b1b6e1ea8fd15f2fbea46770576e366855c",
-                "reference": "1c330b1b6e1ea8fd15f2fbea46770576e366855c",
+                "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/5e2645ad49d196e020b85598d7c97e482725786a",
+                "reference": "5e2645ad49d196e020b85598d7c97e482725786a",
                 "shasum": ""
             },
             "require": {
-                "doctrine/instantiator": "~1.0,>=1.0.2",
+                "doctrine/instantiator": "^1.0.2",
                 "php": ">=5.3.3",
-                "phpunit/php-text-template": "~1.2"
+                "phpunit/php-text-template": "~1.2",
+                "sebastian/exporter": "~1.2"
             },
             "require-dev": {
                 "phpunit/phpunit": "~4.4"
@@ -2146,20 +2156,20 @@
                 "mock",
                 "xunit"
             ],
-            "time": "2015-07-04 05:41:32"
+            "time": "2015-08-19 09:14:08"
         },
         {
             "name": "sebastian/comparator",
-            "version": "1.1.1",
+            "version": "1.2.0",
             "source": {
                 "type": "git",
                 "url": "https://github.com/sebastianbergmann/comparator.git",
-                "reference": "1dd8869519a225f7f2b9eb663e225298fade819e"
+                "reference": "937efb279bd37a375bcadf584dec0726f84dbf22"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/1dd8869519a225f7f2b9eb663e225298fade819e",
-                "reference": "1dd8869519a225f7f2b9eb663e225298fade819e",
+                "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/937efb279bd37a375bcadf584dec0726f84dbf22",
+                "reference": "937efb279bd37a375bcadf584dec0726f84dbf22",
                 "shasum": ""
             },
             "require": {
@@ -2173,7 +2183,7 @@
             "type": "library",
             "extra": {
                 "branch-alias": {
-                    "dev-master": "1.1.x-dev"
+                    "dev-master": "1.2.x-dev"
                 }
             },
             "autoload": {
@@ -2210,7 +2220,7 @@
                 "compare",
                 "equality"
             ],
-            "time": "2015-01-29 16:28:08"
+            "time": "2015-07-26 15:48:44"
         },
         {
             "name": "sebastian/diff",
@@ -2266,16 +2276,16 @@
         },
         {
             "name": "sebastian/environment",
-            "version": "1.2.2",
+            "version": "1.3.2",
             "source": {
                 "type": "git",
                 "url": "https://github.com/sebastianbergmann/environment.git",
-                "reference": "5a8c7d31914337b69923db26c4221b81ff5a196e"
+                "reference": "6324c907ce7a52478eeeaede764f48733ef5ae44"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/5a8c7d31914337b69923db26c4221b81ff5a196e",
-                "reference": "5a8c7d31914337b69923db26c4221b81ff5a196e",
+                "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/6324c907ce7a52478eeeaede764f48733ef5ae44",
+                "reference": "6324c907ce7a52478eeeaede764f48733ef5ae44",
                 "shasum": ""
             },
             "require": {
@@ -2312,20 +2322,20 @@
                 "environment",
                 "hhvm"
             ],
-            "time": "2015-01-01 10:01:08"
+            "time": "2015-08-03 06:14:51"
         },
         {
             "name": "sebastian/exporter",
-            "version": "1.2.0",
+            "version": "1.2.1",
             "source": {
                 "type": "git",
                 "url": "https://github.com/sebastianbergmann/exporter.git",
-                "reference": "84839970d05254c73cde183a721c7af13aede943"
+                "reference": "7ae5513327cb536431847bcc0c10edba2701064e"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/84839970d05254c73cde183a721c7af13aede943",
-                "reference": "84839970d05254c73cde183a721c7af13aede943",
+                "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/7ae5513327cb536431847bcc0c10edba2701064e",
+                "reference": "7ae5513327cb536431847bcc0c10edba2701064e",
                 "shasum": ""
             },
             "require": {
@@ -2378,7 +2388,7 @@
                 "export",
                 "exporter"
             ],
-            "time": "2015-01-27 07:23:06"
+            "time": "2015-06-21 07:55:53"
         },
         {
             "name": "sebastian/global-state",
@@ -2433,16 +2443,16 @@
         },
         {
             "name": "sebastian/recursion-context",
-            "version": "1.0.0",
+            "version": "1.0.1",
             "source": {
                 "type": "git",
                 "url": "https://github.com/sebastianbergmann/recursion-context.git",
-                "reference": "3989662bbb30a29d20d9faa04a846af79b276252"
+                "reference": "994d4a811bafe801fb06dccbee797863ba2792ba"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/3989662bbb30a29d20d9faa04a846af79b276252",
-                "reference": "3989662bbb30a29d20d9faa04a846af79b276252",
+                "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/994d4a811bafe801fb06dccbee797863ba2792ba",
+                "reference": "994d4a811bafe801fb06dccbee797863ba2792ba",
                 "shasum": ""
             },
             "require": {
@@ -2482,7 +2492,7 @@
             ],
             "description": "Provides functionality to recursively process PHP variables",
             "homepage": "http://www.github.com/sebastianbergmann/recursion-context",
-            "time": "2015-01-24 09:48:32"
+            "time": "2015-06-21 08:04:50"
         },
         {
             "name": "sebastian/version",
@@ -2521,7 +2531,7 @@
         },
         {
             "name": "symfony/var-dumper",
-            "version": "v2.6.10",
+            "version": "v2.6.11",
             "target-dir": "Symfony/Component/VarDumper",
             "source": {
                 "type": "git",
@@ -2581,17 +2591,17 @@
         },
         {
             "name": "symfony/yaml",
-            "version": "v2.6.10",
+            "version": "v2.6.11",
             "target-dir": "Symfony/Component/Yaml",
             "source": {
                 "type": "git",
                 "url": "https://github.com/symfony/Yaml.git",
-                "reference": "446353cc05339e676fb57e35232d2bfd055a47cd"
+                "reference": "c044d1744b8e91aaaa0d9bac683ab87ec7cbf359"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/symfony/Yaml/zipball/446353cc05339e676fb57e35232d2bfd055a47cd",
-                "reference": "446353cc05339e676fb57e35232d2bfd055a47cd",
+                "url": "https://api.github.com/repos/symfony/Yaml/zipball/c044d1744b8e91aaaa0d9bac683ab87ec7cbf359",
+                "reference": "c044d1744b8e91aaaa0d9bac683ab87ec7cbf359",
                 "shasum": ""
             },
             "require": {
@@ -2627,7 +2637,7 @@
             ],
             "description": "Symfony Yaml Component",
             "homepage": "https://symfony.com",
-            "time": "2015-06-30 16:10:16"
+            "time": "2015-07-26 08:59:42"
         }
     ],
     "aliases": [],
diff --git a/core/Composer/ScriptHandler.php b/core/Composer/ScriptHandler.php
index d4db6536b0..0595473f48 100644
--- a/core/Composer/ScriptHandler.php
+++ b/core/Composer/ScriptHandler.php
@@ -16,13 +16,21 @@ namespace Piwik\Composer;
  */
 class ScriptHandler
 {
+    private static function isPhp7orLater()
+    {
+        return version_compare('7.0.0-dev', PHP_VERSION) < 1;
+    }
+
     public static function cleanXhprof()
     {
         if (! is_dir('vendor/facebook/xhprof/extension')) {
             return;
         }
 
-        passthru('misc/composer/clean-xhprof.sh');
+        if (!self::isPhp7orLater()) {
+            // doesn't work with PHP 7 at the moment
+            passthru('misc/composer/clean-xhprof.sh');
+        }
     }
 
     public static function buildXhprof()
@@ -31,6 +39,9 @@ class ScriptHandler
             return;
         }
 
-        passthru('misc/composer/build-xhprof.sh');
+
+        if (!self::isPhp7orLater()) {
+            passthru('misc/composer/clean-xhprof.sh');
+        }
     }
 }
diff --git a/core/Db/Adapter.php b/core/Db/Adapter.php
index 4e245c84d3..bea69e1d04 100644
--- a/core/Db/Adapter.php
+++ b/core/Db/Adapter.php
@@ -39,7 +39,13 @@ class Adapter
 
         $className = self::getAdapterClassName($adapterName);
 
-        $adapter   = new $className($dbInfos);
+        // make sure not to pass any references otherwise they will modify $dbInfos
+        $infos = array();
+        foreach ($dbInfos as $key => $val) {
+            $infos[$key] = $val;
+        }
+
+        $adapter   = new $className($infos);
 
         if ($connect) {
             $adapter->getConnection();
diff --git a/core/ExceptionHandler.php b/core/ExceptionHandler.php
index aa20344dd1..b1a8a408db 100644
--- a/core/ExceptionHandler.php
+++ b/core/ExceptionHandler.php
@@ -24,7 +24,10 @@ class ExceptionHandler
         set_exception_handler(array('Piwik\ExceptionHandler', 'handleException'));
     }
 
-    public static function handleException(Exception $exception)
+    /**
+     * @param Exception $exception
+     */
+    public static function handleException($exception)
     {
         if (Common::isPhpCliMode()) {
             self::dieWithCliError($exception);
@@ -33,7 +36,10 @@ class ExceptionHandler
         self::dieWithHtmlErrorPage($exception);
     }
 
-    public static function dieWithCliError(Exception $exception)
+    /**
+     * @param Exception $exception
+     */
+    public static function dieWithCliError($exception)
     {
         $message = $exception->getMessage();
 
@@ -54,7 +60,10 @@ class ExceptionHandler
         exit(1);
     }
 
-    public static function dieWithHtmlErrorPage(Exception $exception)
+    /**
+     * @param Exception $exception
+     */
+    public static function dieWithHtmlErrorPage($exception)
     {
         Common::sendHeader('Content-Type: text/html; charset=utf-8');
 
@@ -63,7 +72,10 @@ class ExceptionHandler
         exit(1);
     }
 
-    private static function getErrorResponse(Exception $ex)
+    /**
+     * @param Exception $ex
+     */
+    private static function getErrorResponse($ex)
     {
         $debugTrace = $ex->getTraceAsString();
 
diff --git a/core/Plugin/Dimension/VisitDimension.php b/core/Plugin/Dimension/VisitDimension.php
index 48bcf70516..6932161d1b 100644
--- a/core/Plugin/Dimension/VisitDimension.php
+++ b/core/Plugin/Dimension/VisitDimension.php
@@ -309,7 +309,7 @@ abstract class VisitDimension extends Dimension
                 }
             }
 
-            usort($instances, array('self', 'sortByRequiredFields'));
+            $instances = self::sortDimensions($instances);
 
             $cache->save($cacheId, $instances);
         }
@@ -319,20 +319,53 @@ abstract class VisitDimension extends Dimension
 
     /**
      * @ignore
+     * @param VisitDimension[] $dimensions
      */
-    public static function sortByRequiredFields($a, $b)
+    public static function sortDimensions($dimensions)
     {
-        $fields = $a->getRequiredVisitFields();
+        $sorted = array();
+        $exists = array();
+
+        // we first handle all the once without dependency
+        foreach ($dimensions as $index => $dimension) {
+            $fields = $dimension->getRequiredVisitFields();
+            if (empty($fields)) {
+                $sorted[] = $dimension;
+                $exists[] = $dimension->getColumnName();
+                unset($dimensions[$index]);
+            }
+        }
 
-        if (empty($fields)) {
-            return -1;
+        // find circular references
+        // and remove dependencies whose column cannot be resolved because it is not installed / does not exist / is defined by core
+        $depenencies = array();
+        foreach ($dimensions as $dimension) {
+            $depenencies[$dimension->getColumnName()] = $dimension->getRequiredVisitFields();
         }
 
-        if (in_array($b->columnName, $fields)) {
-            return 1;
+        foreach ($depenencies as $column => $fields) {
+            foreach ($fields as $key => $field) {
+                if (empty($depenencies[$field]) && !in_array($field, $exists)) {
+                    // we cannot resolve that dependency as it does not exist
+                    unset($depenencies[$column][$key]);
+                } elseif (!empty($depenencies[$field]) && in_array($column, $depenencies[$field])) {
+                    throw new Exception("Circular reference detected for required field $field in dimension $column");
+                }
+            }
+        }
+
+        while (count($dimensions) > 0) {
+            foreach ($dimensions as $key => $dimension) {
+                $fields = $depenencies[$dimension->getColumnName()];
+                if (count(array_intersect($fields, $exists)) === count($fields)) {
+                    $sorted[] = $dimension;
+                    $exists[] = $dimension->getColumnName();
+                    unset($dimensions[$key]);
+                }
+            }
         }
 
-        return 0;
+        return $sorted;
     }
 
     /**
diff --git a/plugins/Diagnostics/Diagnostic/PhpSettingsCheck.php b/plugins/Diagnostics/Diagnostic/PhpSettingsCheck.php
index 533676e232..41142214f1 100644
--- a/plugins/Diagnostics/Diagnostic/PhpSettingsCheck.php
+++ b/plugins/Diagnostics/Diagnostic/PhpSettingsCheck.php
@@ -65,8 +65,9 @@ class PhpSettingsCheck implements Diagnostic
             'session.auto_start=0',
         );
 
-        if ($this->isPhpVersionAtLeast56() && ! defined("HHVM_VERSION")) {
+        if ($this->isPhpVersionAtLeast56() && ! defined("HHVM_VERSION") && !$this->isPhpVersionAtLeast70()) {
             // always_populate_raw_post_data must be -1
+            // removed in PHP 7
             $requiredSettings[] = 'always_populate_raw_post_data=-1';
         }
 
@@ -77,4 +78,9 @@ class PhpSettingsCheck implements Diagnostic
     {
         return version_compare(PHP_VERSION, '5.6', '>=');
     }
+
+    private function isPhpVersionAtLeast70()
+    {
+        return version_compare(PHP_VERSION, '7.0.0-dev', '>=');
+    }
 }
diff --git a/plugins/Insights/tests/Unit/FilterOrderByTest.php b/plugins/Insights/tests/Unit/FilterOrderByTest.php
index 8239204a2f..7c12164291 100644
--- a/plugins/Insights/tests/Unit/FilterOrderByTest.php
+++ b/plugins/Insights/tests/Unit/FilterOrderByTest.php
@@ -11,6 +11,7 @@ namespace Piwik\Plugins\Insights\tests;
 use Piwik\DataTable;
 use Piwik\DataTable\Row;
 use Piwik\Plugins\Insights\DataTable\Filter\OrderBy;
+use Piwik\Tests\Framework\TestCase\SystemTestCase;
 
 /**
  * @group Insights
@@ -43,7 +44,11 @@ class FilterOrderByTest extends BaseUnitTest
 
         $this->applyOrderByFilter();
 
-        $this->assertOrder(array('pos1', 'pos5', 'pos3', 'pos4', 'pos2', 'pos6', 'neg3', 'neg2', 'neg1', 'neg5', 'neg4'));
+        if (SystemTestCase::isPhp7orLater()) {
+            $this->assertOrder(array('pos1', 'pos3', 'pos5', 'pos4', 'pos2', 'pos6', 'neg3', 'neg2', 'neg1', 'neg5', 'neg4'));
+        } else {
+            $this->assertOrder(array('pos1', 'pos5', 'pos3', 'pos4', 'pos2', 'pos6', 'neg3', 'neg2', 'neg1', 'neg5', 'neg4'));
+        }
     }
 
     public function testOrderByShouldSortDependingOnNbVisitsIfColumnsHaveSameValue()
diff --git a/tests/PHPUnit/Framework/TestCase/SystemTestCase.php b/tests/PHPUnit/Framework/TestCase/SystemTestCase.php
index 40ee09eaae..b7b2f2f555 100755
--- a/tests/PHPUnit/Framework/TestCase/SystemTestCase.php
+++ b/tests/PHPUnit/Framework/TestCase/SystemTestCase.php
@@ -104,6 +104,11 @@ abstract class SystemTestCase extends PHPUnit_Framework_TestCase
         return strpos(PHP_VERSION, '5.3') === 0;
     }
 
+    public static function isPhp7orLater()
+    {
+        return version_compare('7.0.0-dev', PHP_VERSION) < 1;
+    }
+
     public static function isMysqli()
     {
         return getenv('MYSQL_ADAPTER') == 'MYSQLI';
diff --git a/tests/PHPUnit/Integration/PiwikTest.php b/tests/PHPUnit/Integration/PiwikTest.php
index 6839b66df3..aad756ee5e 100644
--- a/tests/PHPUnit/Integration/PiwikTest.php
+++ b/tests/PHPUnit/Integration/PiwikTest.php
@@ -29,8 +29,14 @@ class PiwikTest extends IntegrationTestCase
             (float)-1, (float)0, (float)1, (float)1.5, (float)-1.5, (float)21111, (float)89898, (float)99999999999, (float)-4565656,
             (int)-1, (int)0, (int)1, (int)1.5, (int)-1.5, (int)21111, (int)89898, (int)99999999999, (int)-4565656,
             '-1', '0', '1', '1.5', '-1.5', '21111', '89898', '99999999999', '-4565656',
-            '1e3', '0x123', "-1e-2",
+            '1e3', 0x123, "-1e-2",
         );
+
+        if (!self::isPhp7orLater()) {
+            // this seems to be no longer considered valid in PHP 7+
+            $value[] = '0x123';
+        }
+
         foreach ($valid as $key => $value) {
             $valid[$key] = array($value);
         }
diff --git a/tests/PHPUnit/Integration/Plugin/Dimension/VisitDimensionTest.php b/tests/PHPUnit/Integration/Plugin/Dimension/VisitDimensionTest.php
index 2f3d8149a6..505880b8a8 100644
--- a/tests/PHPUnit/Integration/Plugin/Dimension/VisitDimensionTest.php
+++ b/tests/PHPUnit/Integration/Plugin/Dimension/VisitDimensionTest.php
@@ -201,7 +201,7 @@ class VisitDimensionTest extends IntegrationTestCase
         $this->assertEquals(Segment::TYPE_METRIC, $segments[1]->getType());
     }
 
-    public function test_sortByRequiredFields_ShouldResolveDependencies()
+    public function test_sortDimensions_ShouldResolveDependencies()
     {
         $dimension1 = new FakeVisitDimension();
         $dimension1->set('columnName', 'column1');
@@ -221,7 +221,36 @@ class VisitDimensionTest extends IntegrationTestCase
 
         $instances = array($dimension1, $dimension2, $dimension3, $dimension4);
 
-        usort($instances, array('\Piwik\Plugin\Dimension\VisitDimension', 'sortByRequiredFields'));
+        $instances = VisitDimension::sortDimensions($instances);
+
+        $this->assertSame(array($dimension3, $dimension4, $dimension2, $dimension1), $instances);
+    }
+
+    /**
+     * @expectedException \Exception
+     * @expectedExceptionMessage  Circular reference detected for required field column4 in dimension column2
+     */
+    public function test_sortDimensions_ShouldThrowAnException_IfCircularReferenceDetected()
+    {
+        $dimension1 = new FakeVisitDimension();
+        $dimension1->set('columnName', 'column1');
+        $dimension1->requiredFields = array('column3');
+
+        $dimension2 = new FakeVisitDimension();
+        $dimension2->set('columnName', 'column2');
+        $dimension2->requiredFields = array('column3', 'column4');
+
+        $dimension3 = new FakeVisitDimension();
+        $dimension3->set('columnName', 'column3');
+        $dimension3->requiredFields = array();
+
+        $dimension4 = new FakeVisitDimension();
+        $dimension4->set('columnName', 'column4');
+        $dimension4->requiredFields = array('column2');
+
+        $instances = array($dimension1, $dimension2, $dimension3, $dimension4);
+
+        $instances = VisitDimension::sortDimensions($instances);
 
         $this->assertSame(array($dimension3, $dimension4, $dimension2, $dimension1), $instances);
     }
diff --git a/tests/PHPUnit/Unit/FilesystemTest.php b/tests/PHPUnit/Unit/FilesystemTest.php
index 166c13df1c..86894d13e1 100644
--- a/tests/PHPUnit/Unit/FilesystemTest.php
+++ b/tests/PHPUnit/Unit/FilesystemTest.php
@@ -10,6 +10,7 @@ namespace Piwik\Tests\Unit;
 
 use Piwik\Filesystem;
 use Piwik\Tests\Framework\Mock\File;
+use Piwik\Tests\Framework\TestCase\SystemTestCase;
 
 /**
  * @group Core
@@ -42,6 +43,11 @@ class FilesystemTest extends \PHPUnit_Framework_TestCase
     {
         $input  = array('xyz/1.gif', 'x/xyz.gif', 'xxyyzzgg');
         $result = Filesystem::sortFilesDescByPathLength($input);
+
+        if (SystemTestCase::isPhp7orLater()) {
+            $input = array('x/xyz.gif', 'xyz/1.gif', 'xxyyzzgg');
+        }
+
         $this->assertEquals($input, $result);
     }
 
diff --git a/tests/PHPUnit/Unit/Period/DayTest.php b/tests/PHPUnit/Unit/Period/DayTest.php
index c2b4a05a5b..7b1c4a6422 100644
--- a/tests/PHPUnit/Unit/Period/DayTest.php
+++ b/tests/PHPUnit/Unit/Period/DayTest.php
@@ -22,6 +22,8 @@ class DayTest extends BasePeriodTest
             new Day('Invalid Date');
         } catch (\Exception $e) {
             return;
+        } catch (\Throwable $e) {
+            return;
         }
         $this->fail('Expected Exception not raised');
     }
-- 
GitLab