diff --git a/.travis.yml b/.travis.yml index 5c11c9126f..245b374876 100644 --- a/.travis.yml +++ b/.travis.yml @@ -36,6 +36,7 @@ cache: directories: - .phpunit - php-$MIN_PHP + - php-ext services: - memcached @@ -110,6 +111,23 @@ before_install: echo extension = mongo.so >> $INI fi + # tpecl is a helper to compile and cache php extensions + tpecl () { + local ext_name=$1 + local ext_so=$2 + local ext_dir=$(php -r "echo ini_get('extension_dir');") + local ext_cache=~/php-ext/$(basename $ext_dir)/$ext_name + + if [[ -e $ext_cache/$ext_so ]]; then + echo extension = $ext_cache/$ext_so >> $INI + else + mkdir -p $ext_cache + echo yes | pecl install -f $ext_name && + cp $ext_dir/$ext_so $ext_cache + fi + } + export -f tpecl + # Matrix lines for intermediate PHP versions are skipped for pull requests if [[ ! $deps && ! $PHP = ${MIN_PHP%.*} && ! $PHP = hhvm* && $TRAVIS_PULL_REQUEST != false ]]; then deps=skip @@ -128,11 +146,11 @@ before_install: - | # Install extra PHP extensions if [[ ! $skip && $PHP = 5.* ]]; then - ([[ $deps ]] || tfold ext.symfony_debug 'cd src/Symfony/Component/Debug/Resources/ext && phpize && ./configure && make && echo extension = $(pwd)/modules/symfony_debug.so >> '"$INI") && - tfold ext.apcu4 'echo yes | pecl install -f apcu-4.0.11' + ([[ $deps ]] || tfold ext.symfony_debug 'cd src/Symfony/Component/Debug/Resources/ext && phpize && ./configure && make && echo extension = $(pwd)/modules/symfony_debug.so >> '"$INI") + tfold ext.apcu tpecl apcu-4.0.11 apcu.so elif [[ ! $skip && $PHP = 7.* ]]; then - tfold ext.apcu5 'echo yes | pecl install -f apcu-5.1.6' - tfold ext.mongodb pecl install -f mongodb-1.4.0RC1 + tfold ext.apcu tpecl apcu-5.1.6 apcu.so + tfold ext.mongodb tpecl mongodb-1.4.0RC1 mongodb.so fi - | diff --git a/src/Symfony/Component/Routing/Matcher/Dumper/PhpMatcherDumper.php b/src/Symfony/Component/Routing/Matcher/Dumper/PhpMatcherDumper.php index e87a87fb49..b74ff8a9d7 100644 --- a/src/Symfony/Component/Routing/Matcher/Dumper/PhpMatcherDumper.php +++ b/src/Symfony/Component/Routing/Matcher/Dumper/PhpMatcherDumper.php @@ -104,7 +104,6 @@ EOF; \$context = \$this->context; \$request = \$this->request ?: \$this->createRequest(\$pathinfo); \$requestMethod = \$canonicalMethod = \$context->getMethod(); - \$scheme = \$context->getScheme(); if ('HEAD' === \$requestMethod) { \$canonicalMethod = 'GET'; @@ -362,7 +361,7 @@ EOF; $code .= <<context->getMethod(), array('HEAD', 'GET'))) { + } elseif ('GET' !== \$canonicalMethod) { goto $gotoname; } else { return array_replace(\$ret, \$this->redirect(\$rawPathinfo.'/', '$name')); @@ -379,7 +378,7 @@ EOF; $schemes = str_replace("\n", '', var_export(array_flip($schemes), true)); $code .= <<getScheme()])) { return array_replace(\$ret, \$this->redirect(\$rawPathinfo, '$name', key(\$requiredSchemes))); } diff --git a/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher0.php b/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher0.php index dd8bb98cf3..59253f0749 100644 --- a/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher0.php +++ b/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher0.php @@ -23,7 +23,6 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher $context = $this->context; $request = $this->request ?: $this->createRequest($pathinfo); $requestMethod = $canonicalMethod = $context->getMethod(); - $scheme = $context->getScheme(); if ('HEAD' === $requestMethod) { $canonicalMethod = 'GET'; diff --git a/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher1.php b/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher1.php index 783072886c..d1bb74ec1d 100644 --- a/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher1.php +++ b/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher1.php @@ -23,7 +23,6 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher $context = $this->context; $request = $this->request ?: $this->createRequest($pathinfo); $requestMethod = $canonicalMethod = $context->getMethod(); - $scheme = $context->getScheme(); if ('HEAD' === $requestMethod) { $canonicalMethod = 'GET'; diff --git a/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher2.php b/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher2.php index ac65f2957d..662c2cb9a7 100644 --- a/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher2.php +++ b/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher2.php @@ -23,7 +23,6 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec $context = $this->context; $request = $this->request ?: $this->createRequest($pathinfo); $requestMethod = $canonicalMethod = $context->getMethod(); - $scheme = $context->getScheme(); if ('HEAD' === $requestMethod) { $canonicalMethod = 'GET'; @@ -84,7 +83,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec $ret = array('_route' => 'baz3'); if ('/' === substr($pathinfo, -1)) { // no-op - } elseif (!in_array($this->context->getMethod(), array('HEAD', 'GET'))) { + } elseif ('GET' !== $canonicalMethod) { goto not_baz3; } else { return array_replace($ret, $this->redirect($rawPathinfo.'/', 'baz3')); @@ -101,7 +100,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec $ret = $this->mergeDefaults(array_replace($matches, array('_route' => 'baz4')), array ()); if ('/' === substr($pathinfo, -1)) { // no-op - } elseif (!in_array($this->context->getMethod(), array('HEAD', 'GET'))) { + } elseif ('GET' !== $canonicalMethod) { goto not_baz4; } else { return array_replace($ret, $this->redirect($rawPathinfo.'/', 'baz4')); @@ -190,7 +189,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec $ret = array('_route' => 'hey'); if ('/' === substr($pathinfo, -1)) { // no-op - } elseif (!in_array($this->context->getMethod(), array('HEAD', 'GET'))) { + } elseif ('GET' !== $canonicalMethod) { goto not_hey; } else { return array_replace($ret, $this->redirect($rawPathinfo.'/', 'hey')); @@ -340,7 +339,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec if ('/secure' === $pathinfo) { $ret = array('_route' => 'secure'); $requiredSchemes = array ( 'https' => 0,); - if (!isset($requiredSchemes[$scheme])) { + if (!isset($requiredSchemes[$context->getScheme()])) { return array_replace($ret, $this->redirect($rawPathinfo, 'secure', key($requiredSchemes))); } @@ -351,7 +350,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec if ('/nonsecure' === $pathinfo) { $ret = array('_route' => 'nonsecure'); $requiredSchemes = array ( 'http' => 0,); - if (!isset($requiredSchemes[$scheme])) { + if (!isset($requiredSchemes[$context->getScheme()])) { return array_replace($ret, $this->redirect($rawPathinfo, 'nonsecure', key($requiredSchemes))); } diff --git a/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher3.php b/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher3.php index 04f0770e50..40edb4386f 100644 --- a/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher3.php +++ b/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher3.php @@ -23,7 +23,6 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher $context = $this->context; $request = $this->request ?: $this->createRequest($pathinfo); $requestMethod = $canonicalMethod = $context->getMethod(); - $scheme = $context->getScheme(); if ('HEAD' === $requestMethod) { $canonicalMethod = 'GET'; diff --git a/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher4.php b/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher4.php index 4fede6240c..89f2b10e22 100644 --- a/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher4.php +++ b/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher4.php @@ -23,7 +23,6 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher $context = $this->context; $request = $this->request ?: $this->createRequest($pathinfo); $requestMethod = $canonicalMethod = $context->getMethod(); - $scheme = $context->getScheme(); if ('HEAD' === $requestMethod) { $canonicalMethod = 'GET'; diff --git a/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher5.php b/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher5.php index 56204a8566..f88ecaf15f 100644 --- a/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher5.php +++ b/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher5.php @@ -23,7 +23,6 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec $context = $this->context; $request = $this->request ?: $this->createRequest($pathinfo); $requestMethod = $canonicalMethod = $context->getMethod(); - $scheme = $context->getScheme(); if ('HEAD' === $requestMethod) { $canonicalMethod = 'GET'; @@ -58,7 +57,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec $ret = array('_route' => 'a_fourth'); if ('/' === substr($pathinfo, -1)) { // no-op - } elseif (!in_array($this->context->getMethod(), array('HEAD', 'GET'))) { + } elseif ('GET' !== $canonicalMethod) { goto not_a_fourth; } else { return array_replace($ret, $this->redirect($rawPathinfo.'/', 'a_fourth')); @@ -73,7 +72,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec $ret = array('_route' => 'a_fifth'); if ('/' === substr($pathinfo, -1)) { // no-op - } elseif (!in_array($this->context->getMethod(), array('HEAD', 'GET'))) { + } elseif ('GET' !== $canonicalMethod) { goto not_a_fifth; } else { return array_replace($ret, $this->redirect($rawPathinfo.'/', 'a_fifth')); @@ -88,7 +87,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec $ret = array('_route' => 'a_sixth'); if ('/' === substr($pathinfo, -1)) { // no-op - } elseif (!in_array($this->context->getMethod(), array('HEAD', 'GET'))) { + } elseif ('GET' !== $canonicalMethod) { goto not_a_sixth; } else { return array_replace($ret, $this->redirect($rawPathinfo.'/', 'a_sixth')); @@ -111,7 +110,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec $ret = array('_route' => 'nested_a'); if ('/' === substr($pathinfo, -1)) { // no-op - } elseif (!in_array($this->context->getMethod(), array('HEAD', 'GET'))) { + } elseif ('GET' !== $canonicalMethod) { goto not_nested_a; } else { return array_replace($ret, $this->redirect($rawPathinfo.'/', 'nested_a')); @@ -126,7 +125,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec $ret = array('_route' => 'nested_b'); if ('/' === substr($pathinfo, -1)) { // no-op - } elseif (!in_array($this->context->getMethod(), array('HEAD', 'GET'))) { + } elseif ('GET' !== $canonicalMethod) { goto not_nested_b; } else { return array_replace($ret, $this->redirect($rawPathinfo.'/', 'nested_b')); @@ -141,7 +140,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec $ret = array('_route' => 'nested_c'); if ('/' === substr($pathinfo, -1)) { // no-op - } elseif (!in_array($this->context->getMethod(), array('HEAD', 'GET'))) { + } elseif ('GET' !== $canonicalMethod) { goto not_nested_c; } else { return array_replace($ret, $this->redirect($rawPathinfo.'/', 'nested_c')); @@ -159,7 +158,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec $ret = array('_route' => 'slashed_a'); if ('/' === substr($pathinfo, -1)) { // no-op - } elseif (!in_array($this->context->getMethod(), array('HEAD', 'GET'))) { + } elseif ('GET' !== $canonicalMethod) { goto not_slashed_a; } else { return array_replace($ret, $this->redirect($rawPathinfo.'/', 'slashed_a')); @@ -174,7 +173,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec $ret = array('_route' => 'slashed_b'); if ('/' === substr($pathinfo, -1)) { // no-op - } elseif (!in_array($this->context->getMethod(), array('HEAD', 'GET'))) { + } elseif ('GET' !== $canonicalMethod) { goto not_slashed_b; } else { return array_replace($ret, $this->redirect($rawPathinfo.'/', 'slashed_b')); @@ -189,7 +188,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec $ret = array('_route' => 'slashed_c'); if ('/' === substr($pathinfo, -1)) { // no-op - } elseif (!in_array($this->context->getMethod(), array('HEAD', 'GET'))) { + } elseif ('GET' !== $canonicalMethod) { goto not_slashed_c; } else { return array_replace($ret, $this->redirect($rawPathinfo.'/', 'slashed_c')); diff --git a/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher6.php b/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher6.php index eb437a1d97..91079fcef7 100644 --- a/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher6.php +++ b/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher6.php @@ -23,7 +23,6 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher $context = $this->context; $request = $this->request ?: $this->createRequest($pathinfo); $requestMethod = $canonicalMethod = $context->getMethod(); - $scheme = $context->getScheme(); if ('HEAD' === $requestMethod) { $canonicalMethod = 'GET'; diff --git a/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher7.php b/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher7.php index 29d8ec66a6..a9c3fd2b5f 100644 --- a/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher7.php +++ b/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher7.php @@ -23,7 +23,6 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec $context = $this->context; $request = $this->request ?: $this->createRequest($pathinfo); $requestMethod = $canonicalMethod = $context->getMethod(); - $scheme = $context->getScheme(); if ('HEAD' === $requestMethod) { $canonicalMethod = 'GET'; @@ -35,7 +34,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec $ret = array('_route' => 'simple_trailing_slash_no_methods'); if ('/' === substr($pathinfo, -1)) { // no-op - } elseif (!in_array($this->context->getMethod(), array('HEAD', 'GET'))) { + } elseif ('GET' !== $canonicalMethod) { goto not_simple_trailing_slash_no_methods; } else { return array_replace($ret, $this->redirect($rawPathinfo.'/', 'simple_trailing_slash_no_methods')); @@ -55,7 +54,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec $ret = array('_route' => 'simple_trailing_slash_GET_method'); if ('/' === substr($pathinfo, -1)) { // no-op - } elseif (!in_array($this->context->getMethod(), array('HEAD', 'GET'))) { + } elseif ('GET' !== $canonicalMethod) { goto not_simple_trailing_slash_GET_method; } else { return array_replace($ret, $this->redirect($rawPathinfo.'/', 'simple_trailing_slash_GET_method')); @@ -75,7 +74,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec $ret = array('_route' => 'simple_trailing_slash_HEAD_method'); if ('/' === substr($pathinfo, -1)) { // no-op - } elseif (!in_array($this->context->getMethod(), array('HEAD', 'GET'))) { + } elseif ('GET' !== $canonicalMethod) { goto not_simple_trailing_slash_HEAD_method; } else { return array_replace($ret, $this->redirect($rawPathinfo.'/', 'simple_trailing_slash_HEAD_method')); @@ -104,7 +103,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec $ret = $this->mergeDefaults(array_replace($matches, array('_route' => 'regex_trailing_slash_no_methods')), array ()); if ('/' === substr($pathinfo, -1)) { // no-op - } elseif (!in_array($this->context->getMethod(), array('HEAD', 'GET'))) { + } elseif ('GET' !== $canonicalMethod) { goto not_regex_trailing_slash_no_methods; } else { return array_replace($ret, $this->redirect($rawPathinfo.'/', 'regex_trailing_slash_no_methods')); @@ -124,7 +123,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec $ret = $this->mergeDefaults(array_replace($matches, array('_route' => 'regex_trailing_slash_GET_method')), array ()); if ('/' === substr($pathinfo, -1)) { // no-op - } elseif (!in_array($this->context->getMethod(), array('HEAD', 'GET'))) { + } elseif ('GET' !== $canonicalMethod) { goto not_regex_trailing_slash_GET_method; } else { return array_replace($ret, $this->redirect($rawPathinfo.'/', 'regex_trailing_slash_GET_method')); @@ -144,7 +143,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec $ret = $this->mergeDefaults(array_replace($matches, array('_route' => 'regex_trailing_slash_HEAD_method')), array ()); if ('/' === substr($pathinfo, -1)) { // no-op - } elseif (!in_array($this->context->getMethod(), array('HEAD', 'GET'))) { + } elseif ('GET' !== $canonicalMethod) { goto not_regex_trailing_slash_HEAD_method; } else { return array_replace($ret, $this->redirect($rawPathinfo.'/', 'regex_trailing_slash_HEAD_method')); diff --git a/src/Symfony/Component/Routing/Tests/Matcher/UrlMatcherTest.php b/src/Symfony/Component/Routing/Tests/Matcher/UrlMatcherTest.php index b86c54f5ff..52e00f94e3 100644 --- a/src/Symfony/Component/Routing/Tests/Matcher/UrlMatcherTest.php +++ b/src/Symfony/Component/Routing/Tests/Matcher/UrlMatcherTest.php @@ -435,7 +435,7 @@ class UrlMatcherTest extends TestCase { $coll = new RouteCollection(); - $matcher = new UrlMatcher($coll, new RequestContext()); + $matcher = $this->getUrlMatcher($coll); $matcher->match('/'); }