From 23acc24015debbeec33052d6b538d310a8b0933d Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 3 Feb 2014 10:40:25 +0100 Subject: [PATCH 1/3] [Debug] made order of suggestions predictable in error messages --- .../FatalErrorHandler/UndefinedFunctionFatalErrorHandler.php | 1 + .../FatalErrorHandler/UndefinedMethodFatalErrorHandler.php | 1 + .../FatalErrorHandler/UndefinedMethodFatalErrorHandlerTest.php | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/Debug/FatalErrorHandler/UndefinedFunctionFatalErrorHandler.php b/src/Symfony/Component/Debug/FatalErrorHandler/UndefinedFunctionFatalErrorHandler.php index 4b6fc905c9e25..f460c66f8e202 100644 --- a/src/Symfony/Component/Debug/FatalErrorHandler/UndefinedFunctionFatalErrorHandler.php +++ b/src/Symfony/Component/Debug/FatalErrorHandler/UndefinedFunctionFatalErrorHandler.php @@ -80,6 +80,7 @@ public function handleError(array $error, FatalErrorException $exception) } if ($candidates) { + sort($candidates); $message .= ' Did you mean to call: '.implode(', ', array_map(function ($val) { return '"'.$val.'"'; }, $candidates)).'?'; diff --git a/src/Symfony/Component/Debug/FatalErrorHandler/UndefinedMethodFatalErrorHandler.php b/src/Symfony/Component/Debug/FatalErrorHandler/UndefinedMethodFatalErrorHandler.php index ae385509bb08b..7cc55c6b06f5a 100644 --- a/src/Symfony/Component/Debug/FatalErrorHandler/UndefinedMethodFatalErrorHandler.php +++ b/src/Symfony/Component/Debug/FatalErrorHandler/UndefinedMethodFatalErrorHandler.php @@ -45,6 +45,7 @@ public function handleError(array $error, FatalErrorException $exception) } if ($candidates) { + sort($candidates); $message .= sprintf(' Did you mean to call: "%s"?', implode('", "', $candidates)); } diff --git a/src/Symfony/Component/Debug/Tests/FatalErrorHandler/UndefinedMethodFatalErrorHandlerTest.php b/src/Symfony/Component/Debug/Tests/FatalErrorHandler/UndefinedMethodFatalErrorHandlerTest.php index 3e3ee41fa969e..8e1893c15f07e 100644 --- a/src/Symfony/Component/Debug/Tests/FatalErrorHandler/UndefinedMethodFatalErrorHandlerTest.php +++ b/src/Symfony/Component/Debug/Tests/FatalErrorHandler/UndefinedMethodFatalErrorHandlerTest.php @@ -59,7 +59,7 @@ public function provideUndefinedMethodData() 'file' => 'foo.php', 'message' => 'Call to undefined method SplObjectStorage::offsetFet()', ), - 'Attempted to call method "offsetFet" on class "SplObjectStorage" in foo.php line 12. Did you mean to call: "offsetSet", "offsetUnset", "offsetGet"?', + 'Attempted to call method "offsetFet" on class "SplObjectStorage" in foo.php line 12. Did you mean to call: "offsetGet", "offsetSet", "offsetUnset"?', ), ); } From e22339596d81ce20152ed13f17dde08992f32786 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 3 Feb 2014 11:14:27 +0100 Subject: [PATCH 2/3] [Debug] fixed case differences between PHP and HHVM (classes are case-insensitive anyway in PHP) --- src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php | 3 ++- .../UndefinedFunctionFatalErrorHandlerTest.php | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php b/src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php index 0ffd0ab32ece3..c6e67e6da27fa 100644 --- a/src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php +++ b/src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php @@ -254,7 +254,8 @@ public function testFatalErrorHandlers($error, $class, $translatedMessage) $m->invoke($handler, $exceptionHandler, $error); $this->assertInstanceof($class, $exceptionHandler->e); - $this->assertSame($translatedMessage, $exceptionHandler->e->getMessage()); + // class names are case insensitive and PHP/HHVM do not return the same + $this->assertSame(strtolower($translatedMessage), strtolower($exceptionHandler->e->getMessage())); $this->assertSame($error['type'], $exceptionHandler->e->getSeverity()); $this->assertSame($error['file'], $exceptionHandler->e->getFile()); $this->assertSame($error['line'], $exceptionHandler->e->getLine()); diff --git a/src/Symfony/Component/Debug/Tests/FatalErrorHandler/UndefinedFunctionFatalErrorHandlerTest.php b/src/Symfony/Component/Debug/Tests/FatalErrorHandler/UndefinedFunctionFatalErrorHandlerTest.php index 511f2040543e8..27d50ff86f583 100644 --- a/src/Symfony/Component/Debug/Tests/FatalErrorHandler/UndefinedFunctionFatalErrorHandlerTest.php +++ b/src/Symfony/Component/Debug/Tests/FatalErrorHandler/UndefinedFunctionFatalErrorHandlerTest.php @@ -25,7 +25,8 @@ public function testUndefinedFunction($error, $translatedMessage) $exception = $handler->handleError($error, new FatalErrorException('', 0, $error['type'], $error['file'], $error['line'])); $this->assertInstanceof('Symfony\Component\Debug\Exception\UndefinedFunctionException', $exception); - $this->assertSame($translatedMessage, $exception->getMessage()); + // class names are case insensitive and PHP/HHVM do not return the same + $this->assertSame(strtolower($translatedMessage), strtolower($exception->getMessage())); $this->assertSame($error['type'], $exception->getSeverity()); $this->assertSame($error['file'], $exception->getFile()); $this->assertSame($error['line'], $exception->getLine()); From 12407586b2ddc034aea704c018722fde11ddaaa9 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 3 Feb 2014 12:24:19 +0100 Subject: [PATCH 3/3] [Routing] fixed CS --- .../Tests/Generator/Dumper/PhpGeneratorDumperTest.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Symfony/Component/Routing/Tests/Generator/Dumper/PhpGeneratorDumperTest.php b/src/Symfony/Component/Routing/Tests/Generator/Dumper/PhpGeneratorDumperTest.php index 78e3907fd56bf..4165741b06b0f 100644 --- a/src/Symfony/Component/Routing/Tests/Generator/Dumper/PhpGeneratorDumperTest.php +++ b/src/Symfony/Component/Routing/Tests/Generator/Dumper/PhpGeneratorDumperTest.php @@ -60,7 +60,7 @@ public function testDumpWithRoutes() $this->routeCollection->add('Test2', new Route('/testing2')); file_put_contents($this->testTmpFilepath, $this->generatorDumper->dump()); - include ($this->testTmpFilepath); + include $this->testTmpFilepath; $projectUrlGenerator = new \ProjectUrlGenerator(new RequestContext('/app.php')); @@ -81,7 +81,7 @@ public function testDumpWithRoutes() public function testDumpWithoutRoutes() { file_put_contents($this->testTmpFilepath, $this->generatorDumper->dump(array('class' => 'WithoutRoutesUrlGenerator'))); - include ($this->testTmpFilepath); + include $this->testTmpFilepath; $projectUrlGenerator = new \WithoutRoutesUrlGenerator(new RequestContext('/app.php')); @@ -96,7 +96,7 @@ public function testGenerateNonExistingRoute() $this->routeCollection->add('Test', new Route('/test')); file_put_contents($this->testTmpFilepath, $this->generatorDumper->dump(array('class' => 'NonExistingRoutesUrlGenerator'))); - include ($this->testTmpFilepath); + include $this->testTmpFilepath; $projectUrlGenerator = new \NonExistingRoutesUrlGenerator(new RequestContext()); $url = $projectUrlGenerator->generate('NonExisting', array()); @@ -107,7 +107,7 @@ public function testDumpForRouteWithDefaults() $this->routeCollection->add('Test', new Route('/testing/{foo}', array('foo' => 'bar'))); file_put_contents($this->testTmpFilepath, $this->generatorDumper->dump(array('class' => 'DefaultRoutesUrlGenerator'))); - include ($this->testTmpFilepath); + include $this->testTmpFilepath; $projectUrlGenerator = new \DefaultRoutesUrlGenerator(new RequestContext()); $url = $projectUrlGenerator->generate('Test', array()); @@ -121,7 +121,7 @@ public function testDumpWithSchemeRequirement() $this->routeCollection->add('Test2', new Route('/testing_bc', array(), array('_scheme' => 'https'))); // BC file_put_contents($this->testTmpFilepath, $this->generatorDumper->dump(array('class' => 'SchemeUrlGenerator'))); - include ($this->testTmpFilepath); + include $this->testTmpFilepath; $projectUrlGenerator = new \SchemeUrlGenerator(new RequestContext('/app.php'));