Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ZEPHIR_CALL_METHOD() zephir_call_class_method_aparams() bug #1863

Closed
zhaoyanliang2 opened this issue May 18, 2019 · 1 comment
Closed

ZEPHIR_CALL_METHOD() zephir_call_class_method_aparams() bug #1863

zhaoyanliang2 opened this issue May 18, 2019 · 1 comment
Labels

Comments

@zhaoyanliang2
Copy link

https://github.com/phalcon/zephir/blob/df9c16e50788dc9631e7d291fc6f3c5c7f107380/kernels/ZendEngine3/fcall.c#L542
In php7, ce->name is zend_string*, We should wrap it with the ZSTR_VAL macro.
This is not the point


in "cphalcon/phalcon/mvc/controller.zep"

abstract class Controller extends Injectable implements ControllerInterface
{

	/**
	 * Phalcon\Mvc\Controller constructor
	 */
	public final function __construct()
	{
		if method_exists(this, "onConstruct") {
			this->{"onConstruct"}();
		}
	}
}

in php code

<?php
use Phalcon\Mvc\Controller;

class MyController extends Controller
{
	private function onConstruct()
	{

	}
}

$c = new MyController;

I incorrectly defined onConstruct as a private method, and I got an exception :

Fatal error: Uncaught RuntimeException: Call to undefined method MyController::onconstruct() in test.php:12
Stack trace:
#0 test.php(12): Phalcon\Mvc\Controller->__construct()
#1 {main}
thrown in test.php on line 12

This is a confusing error message.

<?php
class Controller
{
	public function __construct()
	{
		if ( method_exists($this, 'onConstruct') ) {
			$this->onConstruct();
		}
	}
}

class MyController extends Controller
{
	private function onConstruct()
	{

	}
}

$c = new MyController;

If we define the Controller in php code, we will get an exception:
PHP Fatal error: Call to private method MyController::onConstruct() from context 'Controller' in test.php on line 7

zephir_call_class_method_aparams() should handle this situation, keeping the error message consistent with php

@dreamsxin dreamsxin mentioned this issue May 23, 2019
3 tasks
@sergeyklay sergeyklay added the bug label Oct 2, 2019
@sergeyklay
Copy link
Contributor

sergeyklay commented Oct 2, 2019

Fixed in the 0.12.0 version (#1864). Feel free to open a new issue if the problem appears again. Thank you for contributing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants