Edit report at https://bugs.php.net/bug.php?id=62455&edit=1

 ID:                 62455
 User updated by:    scout4u at ya dot ru
 Reported by:        scout4u at ya dot ru
 Summary:            last chance to work with __call by reference died
                     after removing call-time-&
 Status:             Wont fix
 Type:               Feature/Change Request
 Package:            *General Issues
 PHP Version:        5.4.4
 Block user comment: N
 Private report:     N

 New Comment:

You offer to work in artifishial maner and not in way:
$sm->letsGo($args);

Now we have decided to use construction:
$sm->need( 'funcName' );
sm_funcName( arg1,arg2 );
instead of
$sm->funcName( arg1,arg2 );

Alas I see nobody would revert references (by some mysterious reson).


Previous Comments:
------------------------------------------------------------------------
[2012-07-08 21:36:51] cataphr...@php.net

A full example:

<?php
class A {
function __call($func, $args) {
$args[0] = 3;
}
}
$a = new A;
call_user_func_array([$a, 'foo'], [&$a]);
var_dump($a); //int(3)

------------------------------------------------------------------------
[2012-07-08 21:29:07] cataphr...@php.net

Please see the documentation of call_user_func_array(). Unsurprisingly, it 
takes its arguments as an array. So you would have:

call_user_func_array(array($this,$n), array(&$val))

------------------------------------------------------------------------
[2012-07-02 14:55:57] scout4u at ya dot ru

«You can still pass by reference to __call using call_user_func_array().»

When I try to launch: call_user_func_array(array($this,$n), &$val);
I have:
 Call-time pass-by-reference has been removed in

When I try to launch: function __call($n, &$val)
I have:
 Method smTest::__call() cannot take arguments by reference

What do you mean by «refs are available for call_user_func_array()»?

------------------------------------------------------------------------
[2012-07-02 14:29:44] scout4u at ya dot ru

Dear catagraph, Sorry I can't catch you. What do you mean? Do you mean that we 
can 
work in maner I have submited before? But we can't.

------------------------------------------------------------------------
[2012-07-02 14:24:48] scout4u at ya dot ru

Well. Code stoped working. It's nice to hear that call_user_func_array can 
still 
process with references. But without ability to throw link call-time into 
__call 
we will have only COPY inside of that. And that's a great fail for PHP's 
functionality.

As I described our aproach to magical invocation of method we could work with 
refs even without permision to have ref right in: __call($name, &data)
Now to skip this breaking of functionality in PHP54 we do pre-loading by tech:

$sm->need('function1');
function1();

and then we work by reference this is an ugly way. So magical loading became 
impossible with working by reference. Sooo... maybe you will rise a question to 
revert these changins took place in 53-54? What have motivated author to refuse 
of refs in call-time? I hope that is not: «my granny don't like reference call-
time».

------------------------------------------------------------------------


The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at

    https://bugs.php.net/bug.php?id=62455


-- 
Edit this bug report at https://bugs.php.net/bug.php?id=62455&edit=1

Reply via email to