transmission-php icon indicating copy to clipboard operation
transmission-php copied to clipboard

Too few arguments to function

Open djbacon opened this issue 4 years ago • 5 comments

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.

djbacon avatar Aug 16 '19 13:08 djbacon

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

Pedroxam avatar Oct 18 '19 18:10 Pedroxam

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

afk11 avatar Oct 20 '19 16:10 afk11

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.

Pedroxam avatar Oct 20 '19 16:10 Pedroxam

@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)

afk11 avatar Oct 20 '19 16:10 afk11

@afk11 Thanks. it most work.

Pedroxam avatar Oct 20 '19 18:10 Pedroxam