From a8d89c003a1af71a4231e8dd216372df6bd3de27 Mon Sep 17 00:00:00 2001 From: Hannes Papenberg Date: Fri, 13 Nov 2026 00:19:43 +0100 Subject: [PATCH] Deprecate the legacy Watching methods Watching::check(), watch() and unwatch() use the legacy /user/subscriptions/{owner}/{repo} routes and were only labelled LEGACY in their doc blocks. getSubscription(), setSubscription() and deleteSubscription() cover the same functions with the current routes. Deprecate the legacy methods with a runtime notice naming the replacement. Co-Authored-By: Claude Opus 5.5 --- Tests/Package/Activity/WatchingTest.php | 10 ++++++++++ composer.json | 3 ++- docs/overview.md | 6 ++++++ src/Package/Activity/Watching.php | 24 ++++++++++++++++++++++++ 4 files changed, 42 insertions(+), 1 deletion(-) diff --git a/Tests/Package/Activity/WatchingTest.php b/Tests/Package/Activity/WatchingTest.php index d7ce4b73..faf3ad40 100644 --- a/Tests/Package/Activity/WatchingTest.php +++ b/Tests/Package/Activity/WatchingTest.php @@ -9,6 +9,7 @@ use Joomla\Github\Package\Activity\Watching; use Joomla\Github\Tests\Stub\GitHubTestCase; +use PHPUnit\Framework\Attributes\IgnoreDeprecations; /** * Test class for the GitHub API package. @@ -165,8 +166,11 @@ public function testDeleteSubscription() * * @return void */ + #[IgnoreDeprecations] public function testCheck() { + $this->expectUserDeprecationMessageMatches('/' . preg_quote('Joomla\Github\Package\Activity\Watching::check() is deprecated and will be removed in 5.0', '/') . '/'); + $this->response = $this->getResponseObject('', 204); $this->client->expects($this->once()) @@ -224,8 +228,11 @@ public function testCheckUnexpected() * * @return void */ + #[IgnoreDeprecations] public function testWatch() { + $this->expectUserDeprecationMessageMatches('/' . preg_quote('Joomla\Github\Package\Activity\Watching::watch() is deprecated and will be removed in 5.0', '/') . '/'); + $this->response = $this->getResponseObject('', 204); $this->client->expects($this->once()) @@ -246,8 +253,11 @@ public function testWatch() * * @return void */ + #[IgnoreDeprecations] public function testUnwatch() { + $this->expectUserDeprecationMessageMatches('/' . preg_quote('Joomla\Github\Package\Activity\Watching::unwatch() is deprecated and will be removed in 5.0', '/') . '/'); + $this->response = $this->getResponseObject('', 204); $this->client->expects($this->once()) diff --git a/composer.json b/composer.json index 49ad2e0a..d44c9b57 100644 --- a/composer.json +++ b/composer.json @@ -9,7 +9,8 @@ "php": "^8.3.0", "joomla/http": "^4.0", "joomla/registry": "^4.0", - "joomla/uri": "^4.0" + "joomla/uri": "^4.0", + "symfony/deprecation-contracts": "^2|^3" }, "require-dev": { "phpunit/phpunit": "^12.2.7", diff --git a/docs/overview.md b/docs/overview.md index cfd53634..a0b12e68 100644 --- a/docs/overview.md +++ b/docs/overview.md @@ -1,3 +1,9 @@ # Github API package TODO + +## Watching repositories + +`$github->activity->watching->getSubscription()`, `setSubscription()` and `deleteSubscription()` manage the +subscription to a repository. `check()`, `watch()` and `unwatch()` use the legacy `/user/subscriptions` routes; they +are deprecated and will be removed in 5.0. diff --git a/src/Package/Activity/Watching.php b/src/Package/Activity/Watching.php index acf4c745..ee35acc8 100644 --- a/src/Package/Activity/Watching.php +++ b/src/Package/Activity/Watching.php @@ -143,9 +143,17 @@ public function deleteSubscription($owner, $repo) * * @since 1.0 * @throws \UnexpectedValueException + * @deprecated 5.0 GitHub has replaced the legacy /user/subscriptions routes. Use getSubscription() instead. */ public function check($owner, $repo) { + trigger_deprecation( + 'joomla/github', + '__DEPLOY_VERSION__', + '%s() is deprecated and will be removed in 5.0, use getSubscription() instead.', + __METHOD__ + ); + // Build the request path. $path = '/user/subscriptions/' . $owner . '/' . $repo; @@ -175,9 +183,17 @@ public function check($owner, $repo) * @return object * * @since 1.0 + * @deprecated 5.0 GitHub has replaced the legacy /user/subscriptions routes. Use setSubscription() instead. */ public function watch($owner, $repo) { + trigger_deprecation( + 'joomla/github', + '__DEPLOY_VERSION__', + '%s() is deprecated and will be removed in 5.0, use setSubscription() instead.', + __METHOD__ + ); + // Build the request path. $path = '/user/subscriptions/' . $owner . '/' . $repo; @@ -198,9 +214,17 @@ public function watch($owner, $repo) * @return object * * @since 1.0 + * @deprecated 5.0 GitHub has replaced the legacy /user/subscriptions routes. Use deleteSubscription() instead. */ public function unwatch($owner, $repo) { + trigger_deprecation( + 'joomla/github', + '__DEPLOY_VERSION__', + '%s() is deprecated and will be removed in 5.0, use deleteSubscription() instead.', + __METHOD__ + ); + // Build the request path. $path = '/user/subscriptions/' . $owner . '/' . $repo;