From 0582a27c29d66b89cc1fe0a86fd5ff62ef3e2031 Mon Sep 17 00:00:00 2001 From: phalcon Date: Wed, 2 Apr 2014 15:56:53 -0600 Subject: [PATCH] Now exceptions thrown shows the Zephir file where they were generated (2) --- Library/Statements/ThrowStatement.php | 2 +- Library/StaticCall.php | 2 +- ext/test/exceptions.c | 8 ++++---- ext/test/fortytwo.c | 2 +- ext/test/router.c | 14 +++++++------- ext/test/router/route.c | 4 ++-- ext/test/trytest.c | 24 ++++++++++++------------ 7 files changed, 28 insertions(+), 28 deletions(-) diff --git a/Library/Statements/ThrowStatement.php b/Library/Statements/ThrowStatement.php index b1e3a9164f..4d8a6b28db 100644 --- a/Library/Statements/ThrowStatement.php +++ b/Library/Statements/ThrowStatement.php @@ -55,7 +55,7 @@ public function compile(CompilationContext $compilationContext) if ($compilationContext->compiler->isClass($className)) { $classDefinition = $compilationContext->compiler->getClassDefinition($className); $message = $expr['parameters'][0]['parameter']['value']; - $codePrinter->output('ZEPHIR_THROW_EXCEPTION_DEBUG_STR(' . $classDefinition->getClassEntry() . ', "' . Utils::addSlashes($message) . '", "' . Compiler::getShortUserPath($statement['file']) . '", ' . $statement['line'] . ');'); + $codePrinter->output('ZEPHIR_THROW_EXCEPTION_DEBUG_STR(' . $classDefinition->getClassEntry() . ', "' . Utils::addSlashes($message) . '", "' . Compiler::getShortUserPath($statement['expr']['file']) . '", ' . $statement['expr']['line'] . ');'); $codePrinter->output('return;'); return; } else { diff --git a/Library/StaticCall.php b/Library/StaticCall.php index 58364f7174..39418ee6a9 100644 --- a/Library/StaticCall.php +++ b/Library/StaticCall.php @@ -574,7 +574,7 @@ public function compile(Expression $expr, CompilationContext $compilationContext } if ($callNumberParameters < $expectedNumberParameters) { - throw new CompilerException("Method '" . $classDefinition->getCompleteName() . "::" . $expression['name'] . "' called with a wrong number of parameters, the method has: " . $expectedNumberParameters . ", passed: " . $callNumberParameters, $expression); + throw new CompilerException("Method '" . $classDefinition->getCompleteName() . "::" . $expression['name'] . "' called with a wrong number of parameters, the method has: " . $expectedNumberParameters . ", passed: " . $callNumberParameters, $expression); } } else { diff --git a/ext/test/exceptions.c b/ext/test/exceptions.c index 1e6e745ac2..112f2e42e6 100644 --- a/ext/test/exceptions.c +++ b/ext/test/exceptions.c @@ -28,7 +28,7 @@ ZEPHIR_INIT_CLASS(Test_Exceptions) { PHP_METHOD(Test_Exceptions, testException1) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STRW(test_exception_ce, "hello1", "test/exceptions.zep", 9); + ZEPHIR_THROW_EXCEPTION_DEBUG_STRW(test_exception_ce, "hello1", "test/exceptions.zep", 8); return; } @@ -46,7 +46,7 @@ PHP_METHOD(Test_Exceptions, testException2) { object_init_ex(_0, test_exception_ce); ZEPHIR_CALL_METHOD(NULL, _0, "__construct", NULL, msg); zephir_check_call_status(); - zephir_throw_exception(_0 TSRMLS_CC); + zephir_throw_exception_debug(_0, "test/exceptions.zep", 15 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; @@ -65,7 +65,7 @@ PHP_METHOD(Test_Exceptions, testException3) { object_init_ex(ex, test_exception_ce); ZEPHIR_CALL_METHOD(NULL, ex, "__construct", NULL, msg); zephir_check_call_status(); - zephir_throw_exception(ex TSRMLS_CC); + zephir_throw_exception_debug(ex, "test/exceptions.zep", 23 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; @@ -97,7 +97,7 @@ PHP_METHOD(Test_Exceptions, testException4) { ZEPHIR_CALL_METHOD(&_0, this_ptr, "getexception", NULL); zephir_check_call_status(); - zephir_throw_exception(_0 TSRMLS_CC); + zephir_throw_exception_debug(_0, "test/exceptions.zep", 33 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; diff --git a/ext/test/fortytwo.c b/ext/test/fortytwo.c index 66ffa83fcc..4f73dd1e14 100644 --- a/ext/test/fortytwo.c +++ b/ext/test/fortytwo.c @@ -249,7 +249,7 @@ PHP_METHOD(Test_FortyTwo, proof) { } } if (j != 42) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(test_exception_ce, "not true", "test/fortytwo.zep", 30); + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(test_exception_ce, "not true", "test/fortytwo.zep", 29); return; } } diff --git a/ext/test/router.c b/ext/test/router.c index 179ba9757e..bf00470323 100644 --- a/ext/test/router.c +++ b/ext/test/router.c @@ -366,7 +366,7 @@ PHP_METHOD(Test_Router, setDefaults) { if (Z_TYPE_P(defaults) == IS_ARRAY) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STRW(test_router_exception_ce, "Defaults must be an array", "test/router.zep", 248); + ZEPHIR_THROW_EXCEPTION_DEBUG_STRW(test_router_exception_ce, "Defaults must be an array", "test/router.zep", 247); return; } if (zephir_array_isset_string_fetch(&namespaceName, defaults, SS("namespace"), 1 TSRMLS_CC)) { @@ -473,7 +473,7 @@ PHP_METHOD(Test_Router, handle) { _4 = zephir_fetch_nproperty_this(this_ptr, SL("_dependencyInjector"), PH_NOISY_CC); ZEPHIR_CPY_WRT(dependencyInjector, _4); if (Z_TYPE_P(dependencyInjector) != IS_OBJECT) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(test_router_exception_ce, "A dependency injection container is required to access the 'request' service", "test/router.zep", 344); + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(test_router_exception_ce, "A dependency injection container is required to access the 'request' service", "test/router.zep", 343); return; } ZEPHIR_INIT_NVAR(_5); @@ -495,7 +495,7 @@ PHP_METHOD(Test_Router, handle) { ZEPHIR_OBS_NVAR(dependencyInjector); zephir_read_property_this(&dependencyInjector, this_ptr, SL("_dependencyInjector"), PH_NOISY_CC); if (Z_TYPE_P(dependencyInjector) != IS_OBJECT) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(test_router_exception_ce, "A dependency injection container is required to access the 'request' service", "test/router.zep", 365); + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(test_router_exception_ce, "A dependency injection container is required to access the 'request' service", "test/router.zep", 364); return; } ZEPHIR_INIT_NVAR(_5); @@ -544,7 +544,7 @@ PHP_METHOD(Test_Router, handle) { zephir_check_call_status(); if (Z_TYPE_P(beforeMatch) != IS_NULL) { if (zephir_is_callable(beforeMatch TSRMLS_CC)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(test_router_exception_ce, "Before-Match callback is not callable in matched route", "test/router.zep", 415); + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(test_router_exception_ce, "Before-Match callback is not callable in matched route", "test/router.zep", 414); return; } } @@ -933,13 +933,13 @@ PHP_METHOD(Test_Router, mount) { if (Z_TYPE_P(group) != IS_OBJECT) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(test_router_exception_ce, "The group of routes is not valid", "test/router.zep", 679); + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(test_router_exception_ce, "The group of routes is not valid", "test/router.zep", 678); return; } ZEPHIR_CALL_METHOD(&groupRoutes, group, "getroutes", NULL); zephir_check_call_status(); if (!(zephir_fast_count_int(groupRoutes TSRMLS_CC))) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(test_router_exception_ce, "The group of routes does not contain any routes", "test/router.zep", 684); + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(test_router_exception_ce, "The group of routes does not contain any routes", "test/router.zep", 683); return; } ZEPHIR_CALL_METHOD(&beforeMatch, group, "getbeforematch", NULL); @@ -997,7 +997,7 @@ PHP_METHOD(Test_Router, notFound) { if (Z_TYPE_P(paths) != IS_ARRAY) { if (Z_TYPE_P(paths) != IS_STRING) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STRW(test_router_exception_ce, "The not-found paths must be an array or string", "test/router.zep", 726); + ZEPHIR_THROW_EXCEPTION_DEBUG_STRW(test_router_exception_ce, "The not-found paths must be an array or string", "test/router.zep", 725); return; } } diff --git a/ext/test/router/route.c b/ext/test/router/route.c index e1cce25b27..829e5799ce 100644 --- a/ext/test/router/route.c +++ b/ext/test/router/route.c @@ -420,7 +420,7 @@ PHP_METHOD(Test_Router_Route, reConfigure) { if (Z_TYPE_P(pattern) != IS_STRING) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(test_router_exception_ce, "The pattern must be string", "test/router/route.zep", 271); + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(test_router_exception_ce, "The pattern must be string", "test/router/route.zep", 270); return; } if (Z_TYPE_P(paths) != IS_NULL) { @@ -490,7 +490,7 @@ PHP_METHOD(Test_Router_Route, reConfigure) { array_init(routePaths); } if (Z_TYPE_P(routePaths) != IS_ARRAY) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(test_router_exception_ce, "The route contains invalid paths", "test/router/route.zep", 343); + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(test_router_exception_ce, "The route contains invalid paths", "test/router/route.zep", 342); return; } if (!(zephir_start_with_str(pattern, SL("#")))) { diff --git a/ext/test/trytest.c b/ext/test/trytest.c index 99a84ee448..3646d15aa7 100644 --- a/ext/test/trytest.c +++ b/ext/test/trytest.c @@ -48,7 +48,7 @@ PHP_METHOD(Test_TryTest, testThrow2) { object_init_ex(_0, zend_exception_get_default(TSRMLS_C)); ZEPHIR_CALL_METHOD(NULL, _0, "__construct", NULL, message); zephir_check_call_status(); - zephir_throw_exception(_0 TSRMLS_CC); + zephir_throw_exception_debug(_0, "test/trytest.zep", 16 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; @@ -84,7 +84,7 @@ PHP_METHOD(Test_TryTest, testTry2) { ZEPHIR_CALL_METHOD(NULL, _0, "__construct", NULL, _1); zephir_check_temp_parameter(_1); zephir_check_call_status_or_jump(try_end_1); - zephir_throw_exception(_0 TSRMLS_CC); + zephir_throw_exception_debug(_0, "test/trytest.zep", 27 TSRMLS_CC); goto try_end_1; @@ -112,7 +112,7 @@ PHP_METHOD(Test_TryTest, testTry3) { ZEPHIR_CALL_METHOD(NULL, _0, "__construct", NULL, _1); zephir_check_temp_parameter(_1); zephir_check_call_status_or_jump(try_end_1); - zephir_throw_exception(_0 TSRMLS_CC); + zephir_throw_exception_debug(_0, "test/trytest.zep", 34 TSRMLS_CC); goto try_end_1; @@ -151,7 +151,7 @@ PHP_METHOD(Test_TryTest, testTry4) { ZEPHIR_CALL_METHOD(NULL, _0, "__construct", NULL, _1); zephir_check_temp_parameter(_1); zephir_check_call_status_or_jump(try_end_1); - zephir_throw_exception(_0 TSRMLS_CC); + zephir_throw_exception_debug(_0, "test/trytest.zep", 46 TSRMLS_CC); goto try_end_1; } else { @@ -162,7 +162,7 @@ PHP_METHOD(Test_TryTest, testTry4) { ZEPHIR_CALL_METHOD(NULL, _0, "__construct", NULL, _1); zephir_check_temp_parameter(_1); zephir_check_call_status_or_jump(try_end_1); - zephir_throw_exception(_0 TSRMLS_CC); + zephir_throw_exception_debug(_0, "test/trytest.zep", 48 TSRMLS_CC); goto try_end_1; } @@ -208,7 +208,7 @@ PHP_METHOD(Test_TryTest, testTry5) { ZEPHIR_CALL_METHOD(NULL, _0, "__construct", NULL, _1); zephir_check_temp_parameter(_1); zephir_check_call_status_or_jump(try_end_1); - zephir_throw_exception(_0 TSRMLS_CC); + zephir_throw_exception_debug(_0, "test/trytest.zep", 63 TSRMLS_CC); goto try_end_1; } else { @@ -219,7 +219,7 @@ PHP_METHOD(Test_TryTest, testTry5) { ZEPHIR_CALL_METHOD(NULL, _0, "__construct", NULL, _1); zephir_check_temp_parameter(_1); zephir_check_call_status_or_jump(try_end_1); - zephir_throw_exception(_0 TSRMLS_CC); + zephir_throw_exception_debug(_0, "test/trytest.zep", 65 TSRMLS_CC); goto try_end_1; } @@ -263,7 +263,7 @@ PHP_METHOD(Test_TryTest, testTry6) { ZEPHIR_CALL_METHOD(NULL, _0, "__construct", NULL, _1); zephir_check_temp_parameter(_1); zephir_check_call_status_or_jump(try_end_1); - zephir_throw_exception(_0 TSRMLS_CC); + zephir_throw_exception_debug(_0, "test/trytest.zep", 80 TSRMLS_CC); goto try_end_1; } else { @@ -274,7 +274,7 @@ PHP_METHOD(Test_TryTest, testTry6) { ZEPHIR_CALL_METHOD(NULL, _0, "__construct", NULL, _1); zephir_check_temp_parameter(_1); zephir_check_call_status_or_jump(try_end_1); - zephir_throw_exception(_0 TSRMLS_CC); + zephir_throw_exception_debug(_0, "test/trytest.zep", 82 TSRMLS_CC); goto try_end_1; } @@ -318,7 +318,7 @@ PHP_METHOD(Test_TryTest, testTry7) { ZEPHIR_CALL_METHOD(NULL, _0, "__construct", NULL, _1); zephir_check_temp_parameter(_1); zephir_check_call_status_or_jump(try_end_1); - zephir_throw_exception(_0 TSRMLS_CC); + zephir_throw_exception_debug(_0, "test/trytest.zep", 99 TSRMLS_CC); goto try_end_1; } else { @@ -329,7 +329,7 @@ PHP_METHOD(Test_TryTest, testTry7) { ZEPHIR_CALL_METHOD(NULL, _0, "__construct", NULL, _1); zephir_check_temp_parameter(_1); zephir_check_call_status_or_jump(try_end_1); - zephir_throw_exception(_0 TSRMLS_CC); + zephir_throw_exception_debug(_0, "test/trytest.zep", 101 TSRMLS_CC); goto try_end_1; } @@ -366,7 +366,7 @@ PHP_METHOD(Test_TryTest, testTry8) { ZEPHIR_CALL_METHOD(NULL, _0, "__construct", NULL, _1); zephir_check_temp_parameter(_1); zephir_check_call_status_or_jump(try_end_1); - zephir_throw_exception(_0 TSRMLS_CC); + zephir_throw_exception_debug(_0, "test/trytest.zep", 111 TSRMLS_CC); goto try_end_1;