# bit of an odd bug

- Thread: https://externals.io/message/14268
- Original archive: https://news-web.php.net/php.internals/14268
- Started by Gareth Ardron on 2005-01-04T02:59:22+00:00
- Messages: 8
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · RFCs at https://externals.io/rfc.md · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #14268 — Gareth Ardron — 2005-01-04T02:59:22+00:00

URL: https://externals.io/message/14268#14268

Ok, I'm in need of a sanity check here.

step one:
$input = "foo";
$scanning_class = "clamav";
$result = $scanning_class::scanBuffer($input);
now this fails with a "Parse error: parse error, unexpected 
T_PAAMAYIM_NEKUDOTAYIM"

So ok, you can't put variables at the front on a class call like that. 
Minor bug I'm thinking at this point, but I wonder if I can work round 
it. So, onto step two:
$input = "foo";
$scanning_class = "clamav";
$func = $scanning_class."::scanBuffer";
$result = $func($input);
Which fails with a "Fatal error: Call to undefined function 
clamav::scanBuffer()"

Just doing:
$result = clamav::scanBuffer($input);
of course works absolutly fine.

Somebody just tell me that this isn't exactly expected behaviour and 
it's a minor bug

this is all on 5.0.3 btw.

Cheers.

-- 
Gareth Ardron

---

## #14269 — nicobn@gmail.com — 2005-01-04T03:09:03+00:00

URL: https://externals.io/message/14268#14269 · In reply to: #14268

Hi,

This looks a lot more like a limitation of the Zend engine to me. The
second observation you made is correct, at least, from my point of
view. You are literally calling a function named clamav::scanBuffer(),
not the member function of the class clamav.

Hope this helps,
Nicolas Bérard Nault.


> Ok, I'm in need of a sanity check here.
> 
> step one:
> $input = "foo";
> $scanning_class = "clamav";
> $result = $scanning_class::scanBuffer($input);
> now this fails with a "Parse error: parse error, unexpected
> T_PAAMAYIM_NEKUDOTAYIM"
> 
> So ok, you can't put variables at the front on a class call like that.
> Minor bug I'm thinking at this point, but I wonder if I can work round
> it. So, onto step two:
> $input = "foo";
> $scanning_class = "clamav";
> $func = $scanning_class."::scanBuffer";
> $result = $func($input);
> Which fails with a "Fatal error: Call to undefined function
> clamav::scanBuffer()"
> 
> Just doing:
> $result = clamav::scanBuffer($input);
> of course works absolutly fine.
> 
> Somebody just tell me that this isn't exactly expected behaviour and
> it's a minor bug
> 
> this is all on 5.0.3 btw.
> 
> Cheers.
> 
> --
> Gareth Ardron

---

## #14270 — Adam Maccabee Trachtenberg — 2005-01-04T03:24:18+00:00

URL: https://externals.io/message/14268#14270 · In reply to: #14268

> Somebody just tell me that this isn't exactly expected behaviour and
> it's a minor bug

This is a known limitation. I suggest using the reflection classes to
work around this.

class foo {
  static function bar() {
    print "static method!\n";
  }
}

$class = 'foo';
$method = 'bar';
$x = new ReflectionMethod($class, $method);
$x->invoke(NULL);

-adam

-- 
adam@trachtenberg.com | http://www.trachtenberg.com
author of o'reilly's "upgrading to php 5" and "php cookbook"
avoid the holiday rush, buy your copies today!

---

## #14271 — Chris — 2005-01-04T04:35:18+00:00

URL: https://externals.io/message/14268#14271 · In reply to: #14268

That, I'm afraid, is expected behavior, though I believe you can use:

call_user_func(array($scanning_class,'scanBuffer'));

http://www.php.net/call_user_func

I *could* be wrong though

Chris


Gareth Ardron wrote:

> Ok, I'm in need of a sanity check here.
>
> step one:
> $input = "foo";
> $scanning_class = "clamav";
> $result = $scanning_class::scanBuffer($input);
> now this fails with a "Parse error: parse error, unexpected 
> T_PAAMAYIM_NEKUDOTAYIM"
>
> So ok, you can't put variables at the front on a class call like that. 
> Minor bug I'm thinking at this point, but I wonder if I can work round 
> it. So, onto step two:
> $input = "foo";
> $scanning_class = "clamav";
> $func = $scanning_class."::scanBuffer";
> $result = $func($input);
> Which fails with a "Fatal error: Call to undefined function 
> clamav::scanBuffer()"
>
> Just doing:
> $result = clamav::scanBuffer($input);
> of course works absolutly fine.
>
> Somebody just tell me that this isn't exactly expected behaviour and 
> it's a minor bug
>
> this is all on 5.0.3 btw.
>
> Cheers.

---

## #14274 — Jason Sweat — 2005-01-04T11:42:20+00:00

URL: https://externals.io/message/14268#14274 · In reply to: #14268

> Ok, I'm in need of a sanity check here.
> 
> step one:
> $input = "foo";
> $scanning_class = "clamav";
> $result = $scanning_class::scanBuffer($input);
> now this fails with a "Parse error: parse error, unexpected
> T_PAAMAYIM_NEKUDOTAYIM"
> 
> So ok, you can't put variables at the front on a class call like that.
> Minor bug I'm thinking at this point, but I wonder if I can work round
> it. So, onto step two:
> $input = "foo";
> $scanning_class = "clamav";
> $func = $scanning_class."::scanBuffer";
> $result = $func($input);
> Which fails with a "Fatal error: Call to undefined function
> clamav::scanBuffer()"
> 
> Just doing:
> $result = clamav::scanBuffer($input);
> of course works absolutly fine.
> 
> Somebody just tell me that this isn't exactly expected behaviour and
> it's a minor bug
> 
> this is all on 5.0.3 btw.

Hi Gareth,

In addition to the other options people have mentioned, you could also
use the old standby of:
eval("\$result = $scanning_class::scanBuffer(\$input);");

Regards,
Jason
http://blog.casey-sweat.us/

---

## #14276 — Gareth Ardron — 2005-01-04T15:01:32+00:00

URL: https://externals.io/message/14268#14276 · In reply to: #14274

Jason Sweat wrote:

>Hi Gareth,
>
>In addition to the other options people have mentioned, you could also
>use the old standby of:
>eval("\$result = $scanning_class::scanBuffer(\$input);");
>  
>
Cheers for all the replies, people. I may have a bit of a prod at the 
internals this evening though, as this is a bloody annoying thing when 
you're trying to build up a highly modularised system - and I'd like the 
code as clean as possible really, not jumping through hoops like use 
reflection API to do this as it has to be maintained by people who 
haven't yet encountered that type of thing.

Cheers,

-- 
Gareth Ardron

---

## #14278 — Wez Furlong — 2005-01-04T17:15:41+00:00

URL: https://externals.io/message/14268#14278 · In reply to: #14276

If you want to do this kind of thing, why not do it properly?

$foo = new $scanning_class;
$foo->scanBuffer($input);

that is, after all, what "extends" is all about.

--Wez



> Jason Sweat wrote:
> 
> > […]
> Cheers for all the replies, people. I may have a bit of a prod at the
> internals this evening though, as this is a bloody annoying thing when
> you're trying to build up a highly modularised system - and I'd like the
> code as clean as possible really, not jumping through hoops like use
> reflection API to do this as it has to be maintained by people who
> haven't yet encountered that type of thing.
> 
> Cheers,
> 
> --
> Gareth Ardron

---

## #14279 — Jochem Maas — 2005-01-04T18:16:20+00:00

URL: https://externals.io/message/14268#14279 · In reply to: #14278

Wez Furlong wrote:
> If you want to do this kind of thing, why not do it properly?
> 
> $foo = new $scanning_class;
> $foo->scanBuffer($input);
> 
> that is, after all, what "extends" is all about.
> 
> --Wez

hihi, that why Wez get the 'King' prefix and everyone doesn't :-)

...
