-
Notifications
You must be signed in to change notification settings - Fork 180
Open
Labels
Milestone
Description
Declaring the classes in the Redmine\Api\ namespace as final will allow us to make more future changes without worrying to much about BC.
To achieve this in a FC way we could create new factory methods create(HttpClient $client): self in all API child classes.
class ProjectApi extends AbstractApi
{
final public static function create(HttpClient $client): self
{
return new self($client);
}
/**
* @param Client|HttpClient $client
*/
final public function __construct($client)
{
if (get_called_class() !== __CLASS__) {
@trigger_error('Extending ' . __CLASS__ . ' is deprecated since v2.x, it will become final in v3.0.0.');
}
if ($client instanceof Client) {
$this->client = $client;
}
// Handle HttpClient...
}
}Using the HttpClient in the API classes makes the AbstractApi obsolete and can be deprecated. Extending it should also trigger a deprecation.
abstract class AbstractApi
{
/**
* @param Client|HttpClient $client
*/
public function __construct($client)
{
@trigger_error(__CLASS__ . ' is deprecated since v2.x and will be removed in v3.0.0.');
// old code...
}
}Affected classes
Redmine\Api\AttachmentRedmine\Api\CustomFieldRedmine\Api\GroupRedmine\Api\IssueRedmine\Api\IssueCategoryRedmine\Api\IssuePriorityRedmine\Api\IssueRelationRedmine\Api\IssueStatusRedmine\Api\MembershipRedmine\Api\NewsRedmine\Api\ProjectRedmine\Api\QueryRedmine\Api\RoleRedmine\Api\SearchRedmine\Api\TimeEntryRedmine\Api\TimeEntryActivityRedmine\Api\TrackerRedmine\Api\UserRedmine\Api\VersionRedmine\Api\WikiRedmine\Api\AbstractApi