jayzeng / virustotal_apiwrapper

Virus Total Public API v2.0 PHP Wrapper
http://jayzeng.github.io/virustotal_apiwrapper/
MIT License
65 stars 18 forks source link

ApiBase constructor can't accept an existing Guzzle client due to namespacing #3

Closed bradJM closed 10 years ago

bradJM commented 10 years ago

If you try to pass in an existing Guzzle client to the ApiBase constructor, you get the following error:

"PHP Catchable fatal error: Argument 2 passed to VirusTotal\ApiBase::__construct() must be an instance of VirusTotal\ClientInterface, instance of Guzzle\Service\Client given"

jayzeng commented 10 years ago

@bradJM Thanks for reporting it, I will take a look when I get home.

In the meantime, can you post your code for me to reproduce?

jayzeng commented 10 years ago

Ah, it is a namespace issue. I will commit a fix tonight. Again, will be great if you can post your psudo code so I can verify the fix.

bradJM commented 10 years ago

Unfortunately not, it's work code. I can tell you that we're using the Silex Guzzle provider to store an instance of Guzzle\Service\Client in $app, then calling new VirusTotal\File() with our API key and the stored Guzzle client.

I suspect changing the typehint in ApiBase will fix it.

jayzeng commented 10 years ago

Yeah, the type hint needs to be fully namespaced. I have the fix and let me cook some tests and will release a minor fix soon.

bradJM commented 10 years ago

Great, thanks!

jayzeng commented 10 years ago

Also pushed a new release to: https://github.com/jayzeng/virustotal_apiwrapper/releases/tag/v0.1.2

It should be available through composer in few minutes, if not, please let me know.