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

Too few arguments to function #84

Open
djbacon opened this issue Aug 16, 2019 · 5 comments
Open

Too few arguments to function #84

djbacon opened this issue Aug 16, 2019 · 5 comments

Comments

@djbacon
Copy link

djbacon commented Aug 16, 2019

Hello!

When i run this php code...

require_once('vendor/autoload.php');
use Transmission\Client;
use Transmission\Transmission;

class metauri{
	private $instance_file = '/tmp/metauri.pid';
	private $files;

	private $transmission_host = '127.0.0.1';
	private $transmission_port = 9091;
	private $transmission_user = 'user';
	private $transmission_pass = 'pass';

	private $download_dir = '';

	function __construct(){
		$this->connect_to_transmission();
	}

	function connect_to_transmission(){
		$client = new Client();
		$client->authenticate($this->transmission_user, $this->transmission_pass);
		$transmission = new Transmission($this->transmission_host, $this->transmission_port);
		$session = $transmission->getSession();
		echo "TRANSMISSION SESSION: ".(!empty($session) ? 'Yes' : 'No')."\n";
		print_r($session);
		$session->setDownloadDir($this->download_dir);
	}

... i get this error.

PHP Fatal error: Uncaught ArgumentCountError: Too few arguments to function Buzz\Client\AbstractClient::__construct(), 0 passed in /mnt/data/projects/metauri/v2/vendor/kleiram/transmission-php/lib/Transmission/Client.php on line 76 and at least 1 expected in /mnt/data/projects/metauri/v2/vendor/kriswallsmith/buzz/lib/Client/AbstractClient.php:33
Stack trace:
#0 /mnt/data/projects/metauri/v2/vendor/kleiram/transmission-php/lib/Transmission/Client.php(76): Buzz\Client\AbstractClient->__construct()
#1 /mnt/data/projects/metauri/v2/metauri.php(52): Transmission\Client->__construct()
#2 /mnt/data/projects/metauri/v2/metauri.php(37): metauri->connect_to_transmission()
#3 /mnt/data/projects/metauri/v2/metauri.php(98): metauri->__construct()
#4 {main}
thrown in /mnt/data/projects/metauri/v2/vendor/kriswallsmith/buzz/lib/Client/AbstractClient.php on line 33

host: 127.0.0.1
postt: 9091
user and password also correct.
Transmission running (Ubuntu Mate 18.04 64bit).

it's fresh install.

P.S. i tried running this outside class and still the same.

@Pedroxam
Copy link

Yes i get this error:

Symfony\Component\Debug\Exception\FatalThrowableError
Too few arguments to function Buzz\Client\AbstractClient::__construct(), 0 passed in E:\xampp2\htdocs\seedbox\core\vendor\kleiram\transmission-php\lib\Transmission\Client.php on line 79 and at least 1 expected

@afk11
Copy link
Contributor

afk11 commented Oct 20, 2019

My guess is the packagist requirements for buzz are too flexible, and now we're unintentionally using too new a version.

@Pedroxam
Copy link

I can run this package without using any framework like laravel.

just try running with a simple php script.

this will not work on frameworks.

@afk11
Copy link
Contributor

afk11 commented Oct 20, 2019

@Pedroxam I don't think that's necessary - see this line for instance https://github.com/kleiram/transmission-php/blob/master/composer.json#L14 which allows everything after 0.9. This means if/when Buzz releases breaking changes in a new release (such as their 1.0.0 or 1.0.1 release that followed) transmission-php will no longer work because the dependencies have changed unexpectedly.

Try setting this in your composer.json to fix the exceptions being thrown.

 "kriswallsmith/buzz": "^0.9.0",

The above won't roll forward to 1.0.0, and transmission-php will work with your other code (since IIRC laravel doesn't have any concrete dependency on buzz)

@Pedroxam
Copy link

@afk11 Thanks. it most work.

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

No branches or pull requests

3 participants