From 619b78352f39ca1f03d1c9640cc5df3638e710fb Mon Sep 17 00:00:00 2001
From: Michael Beck
Date: Wed, 18 Nov 2026 18:23:10 -0500
Subject: [PATCH 1/2] fix(inspections): drop the deprecated PhpThrow and
Function.getReturnType() usages
---
CHANGELOG.md | 6 ++++++
.../inspections/XoopsResultSetGuardInspection.kt | 2 +-
src/main/kotlin/org/xoops/support/psi/Php.kt | 6 ++++--
src/main/resources/META-INF/plugin.xml | 4 ++--
src/test/kotlin/org/xoops/support/NeverBreakTest.kt | 2 +-
.../kotlin/org/xoops/support/XoopsQuickFixTest.kt | 7 +++++--
.../redundant/modules/demo/class/Redundant.php | 12 ++++++++++++
7 files changed, 31 insertions(+), 8 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index c4d20c6..42775e1 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -13,6 +13,12 @@ rebuild; it ships as **1.0.0 Alpha 4**, the successor of the 1.0.0 Alpha 3 relea
`HTTP/` line with PHP's built-in server). A file with a second status line, a setter, or a computed `header()`
argument is reported without a fix. The description states that the status code sent by the replacement is the
same.
+- No deprecated PHP plugin API is left (JetBrains Plugin Verifier, 2026.2 and 2026.3: "2 usages of deprecated API"):
+ the exit-guard check reads a `throw …;` statement through `PhpThrowExpression` instead of `PhpThrow`, and
+ **ResultSetGuard** reads a declared return type through `Function.getTypeDeclaration()` instead of
+ `getReturnType()`. A throw on one side of `||` or `??` is still no exit guard.
+- The plugin description says that install and update normally need no IDE restart; the IDE decides that per
+ install, and the verifier asks for a manual check.
## 1.0.0-alpha.5 — 1.0.0 Alpha 5 — Marketplace release 2026-10-26
diff --git a/src/main/kotlin/org/xoops/support/inspections/XoopsResultSetGuardInspection.kt b/src/main/kotlin/org/xoops/support/inspections/XoopsResultSetGuardInspection.kt
index 97e81fd..2a698d6 100644
--- a/src/main/kotlin/org/xoops/support/inspections/XoopsResultSetGuardInspection.kt
+++ b/src/main/kotlin/org/xoops/support/inspections/XoopsResultSetGuardInspection.kt
@@ -248,7 +248,7 @@ class XoopsResultSetGuardInspection : XoopsInspection() {
}
private fun plainReturn(fn: Function, element: PsiElement): String? {
- val declaredRaw = fn.returnType?.text?.replace(":", "")?.trim()?.lowercase()
+ val declaredRaw = fn.typeDeclaration?.text?.replace(":", "")?.trim()?.lowercase()
if (!declaredRaw.isNullOrBlank()) {
val nullable = declaredRaw.startsWith("?") || declaredRaw.split('|').any { it.trim() == "null" }
val declared = declaredRaw.removePrefix("?")
diff --git a/src/main/kotlin/org/xoops/support/psi/Php.kt b/src/main/kotlin/org/xoops/support/psi/Php.kt
index 29cedf8..4e204ce 100644
--- a/src/main/kotlin/org/xoops/support/psi/Php.kt
+++ b/src/main/kotlin/org/xoops/support/psi/Php.kt
@@ -24,7 +24,7 @@ import com.jetbrains.php.lang.psi.elements.PhpExit
import com.jetbrains.php.lang.psi.elements.PhpNamespace
import com.jetbrains.php.lang.psi.elements.PhpPsiElement
import com.jetbrains.php.lang.psi.elements.PhpReturn
-import com.jetbrains.php.lang.psi.elements.PhpThrow
+import com.jetbrains.php.lang.psi.elements.PhpThrowExpression
import com.jetbrains.php.lang.psi.elements.PhpUseList
import com.jetbrains.php.lang.psi.elements.Statement
import com.jetbrains.php.lang.psi.elements.StringLiteralExpression
@@ -268,7 +268,9 @@ object Php {
else -> body
}
if (last == null) return false
- if (last is PhpReturn || last is PhpThrow) return true
+ // A `throw …;` statement starts with its throw expression; `$x ?? throw …` and `$ok || throw …` do not,
+ // and they leave only on one side.
+ if (last is PhpReturn || last.firstChild is PhpThrowExpression) return true
if (PsiTreeUtil.findChildOfType(last, PhpExit::class.java, false) != null) return true
val firstCall = PsiTreeUtil.findChildOfType(last, FunctionReference::class.java, false) ?: return false
if (isCall(firstCall, "redirect_header")) return true
diff --git a/src/main/resources/META-INF/plugin.xml b/src/main/resources/META-INF/plugin.xml
index 947dd86..93ebca0 100644
--- a/src/main/resources/META-INF/plugin.xml
+++ b/src/main/resources/META-INF/plugin.xml
@@ -49,7 +49,7 @@
Getting started
Install the plugin and open a XOOPS project. Detection is automatic. You can set the Core Version and other
options under Settings → Languages & Frameworks → XOOPS Support, and the inspections are listed
- under Settings → Editor → Inspections → XOOPS. The plugin installs and updates without an IDE restart.
+ under Settings → Editor → Inspections → XOOPS. The plugin is dynamic: it normally installs and updates without an IDE restart.
Source, documentation and issues on GitHub
]]>
@@ -89,7 +89,7 @@
class/xoopsobject.php, xoopsmodule.php, xoopsuser.php and mimetypes.inc.php stubs moved to
kernel/ / include/; the eight deprecated xoops_load() short names ('cache' → 'xoopscache' …);
and a new inspection for $xoopsOption[…] inside a function without global $xoopsOption.
- Dynamic install and update without restart (language-constant cache is a project service).
+ Dynamic plugin: install and update normally need no restart (language-constant cache is a project service).
Settings page (Core Version override, auto-scan, startup balloon), New → XOOPS Module… scaffold with a legacy or hybrid layout (Helper, PSR-4 autoloader, Xmf admin side) whose output passes every inspection, Tools → XOOPS Support menu, and Ctrl+B / Find Usages on language constants used as strings or in Smarty templates - all carried over from Alpha 3 and rebuilt.
1.0.0 Alpha 3 (1.0.0-alpha.3)
diff --git a/src/test/kotlin/org/xoops/support/NeverBreakTest.kt b/src/test/kotlin/org/xoops/support/NeverBreakTest.kt
index 95ecec8..c937a0a 100644
--- a/src/test/kotlin/org/xoops/support/NeverBreakTest.kt
+++ b/src/test/kotlin/org/xoops/support/NeverBreakTest.kt
@@ -90,7 +90,7 @@ class NeverBreakTest : BasePlatformTestCase() {
fun testVoidFunctionGetsABareReturn() {
val text = fixEverything("adslight", "index.php")
val voidFunctions = PsiTreeUtil.findChildrenOfType(myFixture.file, Function::class.java)
- .filter { it.returnType?.text?.contains("void") == true }
+ .filter { it.typeDeclaration?.text?.contains("void") == true }
assertTrue("fixture lost its void functions", voidFunctions.isNotEmpty())
for (fn in voidFunctions) {
val valued = PsiTreeUtil.findChildrenOfType(fn, PhpReturn::class.java).filter { it.argument != null }
diff --git a/src/test/kotlin/org/xoops/support/XoopsQuickFixTest.kt b/src/test/kotlin/org/xoops/support/XoopsQuickFixTest.kt
index f8d2f02..498e303 100644
--- a/src/test/kotlin/org/xoops/support/XoopsQuickFixTest.kt
+++ b/src/test/kotlin/org/xoops/support/XoopsQuickFixTest.kt
@@ -926,9 +926,12 @@ class XoopsQuickFixTest : BasePlatformTestCase() {
fun testPathContainmentCanonicalisedAndDisplayPaths() =
check(XoopsPathContainmentInspection(), "PathContainment/canonical", "class/logger/Paths.php", 2)
- /** page_tablesfill.php: an isResultSet() exit above a `!$result` exit is no legacy guard. */
+ /**
+ * page_tablesfill.php: an isResultSet() exit above a `!$result` exit is no legacy guard. A `throw …;` statement
+ * is an exit, a throw on one side of `||` is not.
+ */
fun testResultSetGuardRedundantLegacyExitIsNotReported() =
- check(XoopsResultSetGuardInspection(), "ResultSetGuard/redundant", "modules/demo/class/Redundant.php", 1)
+ check(XoopsResultSetGuardInspection(), "ResultSetGuard/redundant", "modules/demo/class/Redundant.php", 2)
/** file_safety.php: the existence check in a previous try (every catch returns) dominates unlink(). */
fun testUnlinkCheckedInsidePreviousTry() =
diff --git a/src/test/resources/fixtures/ResultSetGuard/redundant/modules/demo/class/Redundant.php b/src/test/resources/fixtures/ResultSetGuard/redundant/modules/demo/class/Redundant.php
index cae01d2..8719e52 100644
--- a/src/test/resources/fixtures/ResultSetGuard/redundant/modules/demo/class/Redundant.php
+++ b/src/test/resources/fixtures/ResultSetGuard/redundant/modules/demo/class/Redundant.php
@@ -23,6 +23,18 @@ public function count()
return $count;
}
+ /** Reported: `$this->strict || throw …` leaves only when strict is off, so the block is no exit guard. */
+ public function conditionalThrow()
+ {
+ $result = $this->db->query('SELECT COUNT(*) FROM t');
+ if (!$this->db->isResultSet($result)) {
+ $this->strict || throw new \RuntimeException('query failed');
+ }
+ [$count] = $this->db->fetchRow($result);
+
+ return $count;
+ }
+
/** Reported: only the legacy exit guards the fetch. */
public function legacy()
{
From b89a41a0d6bf11e10296e44a6b15984dc0114917 Mon Sep 17 00:00:00 2001
From: Michael Beck
Date: Wed, 18 Nov 2026 19:55:29 -0500
Subject: [PATCH 2/2] test(inspections): assert the warning lines of the
ResultSetGuard redundant-exit fixture
---
src/test/kotlin/org/xoops/support/XoopsQuickFixTest.kt | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/src/test/kotlin/org/xoops/support/XoopsQuickFixTest.kt b/src/test/kotlin/org/xoops/support/XoopsQuickFixTest.kt
index 498e303..6e9d442 100644
--- a/src/test/kotlin/org/xoops/support/XoopsQuickFixTest.kt
+++ b/src/test/kotlin/org/xoops/support/XoopsQuickFixTest.kt
@@ -930,8 +930,12 @@ class XoopsQuickFixTest : BasePlatformTestCase() {
* page_tablesfill.php: an isResultSet() exit above a `!$result` exit is no legacy guard. A `throw …;` statement
* is an exit, a throw on one side of `||` is not.
*/
- fun testResultSetGuardRedundantLegacyExitIsNotReported() =
+ fun testResultSetGuardRedundantLegacyExitIsNotReported() {
check(XoopsResultSetGuardInspection(), "ResultSetGuard/redundant", "modules/demo/class/Redundant.php", 2)
+ val lines = myFixture.doHighlighting().filter { it.description?.startsWith("XOOPS:") == true }
+ .map { myFixture.editor.document.getLineNumber(it.startOffset) + 1 }.sorted()
+ assertEquals(listOf(33, 42), lines)
+ }
/** file_safety.php: the existence check in a previous try (every catch returns) dominates unlink(). */
fun testUnlinkCheckedInsidePreviousTry() =