Description
Currently, I'm getting a bunch of deprecations about methods having optional parameters declared before required ones ( see https://github.com/console-helpers/jira-api-restclient/actions/runs/12379854881/job/34554938237 ).
Related to ClientInterface
itself and classes implementing it
- PHP Deprecated: Optional parameter $data declared before required parameter $credential is implicitly treated as a required parameter in .../src/Jira/Api/Client/ClientInterface.php on line 53
// ClientInterface interface
public function sendRequest(
$method,
$url,
$data = array(),
$endpoint,
AuthenticationInterface $credential,
$is_file = false,
$debug = false
);
- PHP Deprecated: Optional parameter $data declared before required parameter $credential is implicitly treated as a required parameter in .../src/Jira/Api/Client/CurlClient.php on line 62
// CurlClient class
public function sendRequest(
$method,
$url,
$data = array(),
$endpoint,
AuthenticationInterface $credential,
$is_file = false,
$debug = false
) {
- PHP Deprecated: Optional parameter $data declared before required parameter $credential is implicitly treated as a required parameter in .../src/Jira/Api/Client/PHPClient.php on line 95
// PHPClient class
public function sendRequest(
$method,
$url,
$data = array(),
$endpoint,
AuthenticationInterface $credential,
$is_file = false,
$debug = false
) {
Related to the Api
class
- PHP Deprecated: Optional parameter $method declared before required parameter $url is implicitly treated as a required parameter in .../src/Jira/Api.php on line 711
// Api class
public function api(
$method = self::REQUEST_GET,
$url,
$data = array(),
$return_as_array = false,
$is_file = false,
$debug = false
) {
The @royarisse suggested some interesting ideas (see #205) about fixing:
- remove the default value for the
ClientInterface::sendRequest
method's$data
parameter - remove the default value for the
Api::api
method's$method
parameter
I completely agree with 1st item (interface change) and I dare to remove default values from all parameters in the ClientInterface::sendRequest
method signature, because:
- when the
Api
class calls the class implementing theClientInterface
interface it will provide all parameters in each call - we're breaking BC anyway with the 2.0.0 release
I also agree with 2nd item, because the current library users (who use the master
branch) are forced to specify the request method anyway.
Metadata
Metadata
Assignees
Labels
No labels