i suggest the passthru functionality to pass parameter to other method
without typing all parameters,like call_user_func_array.
foo(passthru()); = call_user_func_array('foo', func_get_args()
);
// case 1:
function a($a,$b,$c)
{
//...
}
function aa()
{
a(passthru()); // like call_user_func_array('a', func_get_args()
);
someOthers();
}
aa('foo','bar','baz');
//case 2:
class base
{
protected function insert(BaseType $object,$a,$b,$c)
{
}
}
class son extends base
{
public function insert(SonType $object) //type hinting differs from base
{
parent::insert(passthru()); // like call_user_func_array(array('parent',
'insert'), func_get_args()
);
}
}
$son = new son();
$sonType = new SonType();
$son->insert($sonType,'foo','bar','baz');
--
Mathias Grimm
Sun Certified Java Programmer 6.0 #SUN604760
Zend Certified Engineer #ZEND006756
Hi!
i suggest the passthru functionality to pass parameter to other method
without typing all parameters,like call_user_func_array.foo(passthru()); = call_user_func_array('foo',
func_get_args()
);
We already have function with this name: http://us.php.net/passthru
--
Stanislav Malyshev, Software Architect
SugarCrm: http://www.sugarcrm.com/
(408)454-6900 ext. 227
ok, sorry!
the name isn't important at this moment,can be anyone, can be pervade for
example.
i'm suggesting new feature, the name can be decided later
On Tue, May 18, 2010 at 8:13 PM, Stas Malyshev smalyshev@sugarcrm.comwrote:
We already have function with this name: http://us.php.net/passthru
--
Stanislav Malyshev, Software Architect
SugarCrm: http://www.sugarcrm.com/
(408)454-6900 ext. 227--
--
Mathias Grimm
Sun Certified Java Programmer 6.0 #SUN604760
Zend Certified Engineer #ZEND006756
php test source:
<?php
echo "TEST 1\n";
function a($a,$b,$c)
{
echo "$a $b $c\n";
}
function aa()
{
call_user_func_array('a',func_get_args());// a(pervade();
}
aa(1,2,3);
echo "TEST 2\n";
class BaseType{}
class SonType extends BaseType{}
class base
{
protected function insert(BaseType $o,$a,$b,$c)
{
print_r(func_get_args());
}
}
class son extends base
{
public function insert(SonType $o)
{
call_user_func_array(array('parent','insert'),func_get_args()); //
parent::insert(pervade());
}
}
$son = new son();
$son->insert(new SonType(),1,2,3);
php test result:
TEST 1
1 2 3
TEST 2
Array
(
[0] => SonType Object
(
)
[1] => 1
[2] => 2
[3] => 3
)
On Tue, May 18, 2010 at 8:50 PM, Mathias Grimm mathiasgrimm@gmail.comwrote:
ok, sorry!
the name isn't important at this moment,can be anyone, can be pervade for
example.i'm suggesting new feature, the name can be decided later
On Tue, May 18, 2010 at 8:13 PM, Stas Malyshev smalyshev@sugarcrm.comwrote:
We already have function with this name: http://us.php.net/passthru
--
Stanislav Malyshev, Software Architect
SugarCrm: http://www.sugarcrm.com/
(408)454-6900 ext. 227--
--
Mathias GrimmSun Certified Java Programmer 6.0 #SUN604760
Zend Certified Engineer #ZEND006756
--
Mathias Grimm
Sun Certified Java Programmer 6.0 #SUN604760
Zend Certified Engineer #ZEND006756
Mathias Grimm wrote:
call_user_func_array('a',func_get_args());// a(pervade();
Two things:
a) There is a way of doing it and although it is a bit cryptic I find it
appropriate since I don't consider this something which should be done
in regular code.
b) pervade() could not be a normal function but would have to be a
special language construct as far as I can see as the compiler needs to
know to call a() with multiple arguments. Not desirable IMHO.
If you want to have multiple dynamic arguments to pass on like this I'd
suggest you use one associative array as parameter instead.
Like
function a($p = array()) { ... }
function aa($p = array()) { a($p); }
aa(array("foo" => 42, "bar" => 17));
with the additional benefit of having named (and extensible) parameters
as an added bonus.
- Chris
On Wed, May 19, 2010 at 8:43 AM, Christian Schneider
cschneid@cschneid.comwrote:
If you want to have multiple dynamic arguments to pass on like this I'd
suggest you use one associative array as parameter instead.Like
function a($p = array()) { ... }
function aa($p = array()) { a($p); }
aa(array("foo" => 42, "bar" => 17));
with the additional benefit of having named (and extensible) parameters
as an added bonus.
- Chris
array cant be type hinting defined. i will need to do some extra work
checking type in the reciever function.
--
Mathias Grimm
Sun Certified Java Programmer 6.0 #SUN604760
Zend Certified Engineer #ZEND006756