Conversation
📝 WalkthroughWalkthroughThis set of changes migrates utility and translation logic from local plugin files to a shared external library, refactors static utility calls to instance-based usage, and updates Composer configuration and autoloading. It also revises workflow automation and code style/static analysis exclusions, while enforcing stricter runtime checks for required constants. Changes
Sequence Diagram(s)sequenceDiagram
participant WebPage
participant CommonPHP
participant ComposerAutoloader
participant UtilsInstance
participant TranslatorInstance
WebPage->>CommonPHP: require common.php
CommonPHP->>ComposerAutoloader: require_once vendor/autoload.php
CommonPHP->>UtilsInstance: new Utils(PLUGIN_NAME)
UtilsInstance->>UtilsInstance: setPHPDebug()
WebPage->>UtilsInstance: $utils->logmsg(), $utils->run_command(), etc.
WebPage->>TranslatorInstance: new Translator(PLUGIN_ROOT)
WebPage->>TranslatorInstance: $tr->tr("message")
Possibly related PRs
Poem
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 7
♻️ Duplicate comments (2)
src/usr/local/emhttp/plugins/tailscale/include/Pages/Main.php (1)
10-12: Consistent runtime validation implementation.The runtime checks follow the same pattern as other files. Consider the error message improvement suggested in the daily.php review for consistency across all files.
src/usr/local/emhttp/plugins/tailscale/include/Pages/Info.php (1)
7-9: Duplicate runtime validation pattern.This follows the exact same runtime validation approach as the other files. The error message improvement suggestion from daily.php applies here as well.
🧹 Nitpick comments (8)
composer (1)
1-3: LGTM! Functional composer wrapper script.The script correctly sets the working directory and passes through all arguments. Consider ensuring the script has executable permissions.
You may want to verify the script is executable:
chmod +x composersrc/usr/local/emhttp/plugins/tailscale/daily.php (1)
9-11: Improve the error message specificity.While the runtime validation is good defensive programming, the error message could be more descriptive to help with debugging.
-if ( ! defined(__NAMESPACE__ . '\PLUGIN_ROOT') || ! defined(__NAMESPACE__ . '\PLUGIN_NAME')) { - throw new \RuntimeException("Common file not loaded."); -} +if ( ! defined(__NAMESPACE__ . '\PLUGIN_ROOT') || ! defined(__NAMESPACE__ . '\PLUGIN_NAME')) { + throw new \RuntimeException("Required constants PLUGIN_ROOT and/or PLUGIN_NAME not defined. Ensure common.php is properly loaded."); +}src/usr/local/emhttp/plugins/tailscale/include/tailscale-lock/disabled.php (1)
7-9: Consider improving error message consistency.The same generic error message pattern appears across multiple files. Consider creating a shared constant or function for this validation to ensure consistency and maintainability.
src/usr/local/emhttp/plugins/tailscale/include/Pages/Lock.php (1)
20-22: Remove duplicate constant check.There's a duplicate check for
PLUGIN_ROOTconstant - it's already checked at lines 7-9. The second check at lines 20-22 is redundant and should be removed.-if ( ! defined(__NAMESPACE__ . "\PLUGIN_ROOT")) { - throw new \RuntimeException("PLUGIN_ROOT not defined"); -}src/usr/local/emhttp/plugins/tailscale/include/common.php (1)
26-26: Consider making the autoloader path configurable.The hardcoded path
/usr/local/php/unraid-tailscale-utils/vendor/autoload.phpcould be brittle if the installation directory changes. Consider using a relative path or making it configurable.-// @phpstan-ignore requireOnce.fileNotFound -require_once "/usr/local/php/unraid-tailscale-utils/vendor/autoload.php"; +$autoloader_path = getenv('TAILSCALE_UTILS_PATH') ?: '/usr/local/php/unraid-tailscale-utils'; +require_once $autoloader_path . '/vendor/autoload.php';src/usr/local/php/unraid-tailscale-utils/composer.json (1)
1-33: Well-structured composer configuration with one concern about bin-dir path.The composer.json properly defines the package metadata, PSR-4 autoloading, and dependencies. The inclusion of development tools (php-cs-fixer, phpstan) and the VCS repository for unraid-utils are appropriate for the project setup.
However, the
bin-dirconfiguration path seems unusual:- "bin-dir": "../../../../../vendor/bin/" + "bin-dir": "vendor/bin/"The deep relative path (
../../../../../vendor/bin/) suggests an unusual project structure. Please verify this is intentional and won't cause issues with dependency management or deployment.src/usr/local/php/unraid-tailscale-utils/unraid-tailscale-utils/Utils.php (2)
75-104: Improve CIDR validation robustness.The
validateCidrmethod has good basic validation but could be more robust in handling edge cases.Consider these improvements:
public static function validateCidr(string $cidr): bool { + $cidr = trim($cidr); + if (empty($cidr)) { + return false; + } + $parts = explode('/', $cidr); if (count($parts) != 2) { return false; } - $ip = $parts[0]; - $netmask = $parts[1]; + $ip = trim($parts[0]); + $netmask = trim($parts[1]); + if (empty($ip) || empty($netmask)) { + return false; + } + if ( ! preg_match("/^\d+$/", $netmask)) { return false; } $netmask = intval($parts[1]); if ($netmask < 0) { return false; } if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) { return $netmask <= 32; } if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) { return $netmask <= 128; } return false; }
41-52: Consider IPv6 support for network membership check.The
ip4_in_networkmethod only handles IPv4 networks. Consider adding IPv6 support or renaming the method to be more explicit about its IPv4-only limitation.-public static function ip4_in_network(string $ip, string $network): bool +public static function ipInNetwork(string $ip, string $network): bool { + // Handle IPv6 + if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) { + // Add IPv6 network checking logic + return false; // Placeholder + } + + // IPv4 handling (existing logic) if (strpos($network, '/') === false) { return false; } // ... rest of existing IPv4 logic }Alternatively, keep the current method name to be explicit about IPv4-only support.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
src/usr/local/php/unraid-tailscale-utils/composer.lockis excluded by!**/*.lock
📒 Files selected for processing (35)
.github/workflows/lint.yml(1 hunks).github/workflows/release.yml(1 hunks).gitignore(1 hunks).php-cs-fixer.dist.php(1 hunks)composer(1 hunks)composer.json(0 hunks)phpstan.neon(1 hunks)src/usr/local/emhttp/plugins/tailscale/approve-nodes.php(1 hunks)src/usr/local/emhttp/plugins/tailscale/daily.php(1 hunks)src/usr/local/emhttp/plugins/tailscale/include/Pages/Dashboard.php(1 hunks)src/usr/local/emhttp/plugins/tailscale/include/Pages/Help.php(1 hunks)src/usr/local/emhttp/plugins/tailscale/include/Pages/Info.php(1 hunks)src/usr/local/emhttp/plugins/tailscale/include/Pages/Lock.php(1 hunks)src/usr/local/emhttp/plugins/tailscale/include/Pages/Log.php(1 hunks)src/usr/local/emhttp/plugins/tailscale/include/Pages/Main.php(1 hunks)src/usr/local/emhttp/plugins/tailscale/include/Pages/Settings.php(1 hunks)src/usr/local/emhttp/plugins/tailscale/include/Pages/Status.php(1 hunks)src/usr/local/emhttp/plugins/tailscale/include/Pages/Tailscale.php(1 hunks)src/usr/local/emhttp/plugins/tailscale/include/Tailscale/Translator.php(0 hunks)src/usr/local/emhttp/plugins/tailscale/include/Tailscale/Utils.php(0 hunks)src/usr/local/emhttp/plugins/tailscale/include/common.php(1 hunks)src/usr/local/emhttp/plugins/tailscale/include/data/Config.php(8 hunks)src/usr/local/emhttp/plugins/tailscale/include/data/Lock.php(1 hunks)src/usr/local/emhttp/plugins/tailscale/include/data/Status.php(2 hunks)src/usr/local/emhttp/plugins/tailscale/include/tailscale-lock/disabled.php(1 hunks)src/usr/local/emhttp/plugins/tailscale/include/tailscale-lock/locked.php(1 hunks)src/usr/local/emhttp/plugins/tailscale/include/tailscale-lock/signed.php(1 hunks)src/usr/local/emhttp/plugins/tailscale/include/tailscale-lock/signing.php(1 hunks)src/usr/local/emhttp/plugins/tailscale/pre-startup.php(1 hunks)src/usr/local/php/unraid-tailscale-utils/composer.json(1 hunks)src/usr/local/php/unraid-tailscale-utils/unraid-tailscale-utils/Info.php(1 hunks)src/usr/local/php/unraid-tailscale-utils/unraid-tailscale-utils/LocalAPI.php(2 hunks)src/usr/local/php/unraid-tailscale-utils/unraid-tailscale-utils/System.php(11 hunks)src/usr/local/php/unraid-tailscale-utils/unraid-tailscale-utils/Utils.php(1 hunks)src/usr/local/php/unraid-tailscale-utils/unraid-tailscale-utils/Watcher.php(3 hunks)
💤 Files with no reviewable changes (3)
- composer.json
- src/usr/local/emhttp/plugins/tailscale/include/Tailscale/Translator.php
- src/usr/local/emhttp/plugins/tailscale/include/Tailscale/Utils.php
🧰 Additional context used
🪛 PHPStan (2.1.15)
src/usr/local/emhttp/plugins/tailscale/include/Pages/Help.php
11-11: Instantiated class EDACerton\PluginUtils\Translator not found.
Learn more at https://phpstan.org/user-guide/discovering-symbols
(class.notFound)
src/usr/local/emhttp/plugins/tailscale/include/Pages/Status.php
11-11: Instantiated class EDACerton\PluginUtils\Translator not found.
Learn more at https://phpstan.org/user-guide/discovering-symbols
(class.notFound)
src/usr/local/emhttp/plugins/tailscale/daily.php
12-12: Class Tailscale\Utils does not have a constructor and must be instantiated without any parameters.
(new.noConstructor)
16-16: Call to an undefined method Tailscale\Utils::run_task().
(method.notFound)
17-17: Call to an undefined method Tailscale\Utils::run_task().
(method.notFound)
src/usr/local/emhttp/plugins/tailscale/include/Pages/Main.php
14-14: Instantiated class EDACerton\PluginUtils\Translator not found.
Learn more at https://phpstan.org/user-guide/discovering-symbols
(class.notFound)
src/usr/local/emhttp/plugins/tailscale/include/tailscale-lock/signing.php
11-11: Instantiated class EDACerton\PluginUtils\Translator not found.
Learn more at https://phpstan.org/user-guide/discovering-symbols
(class.notFound)
src/usr/local/emhttp/plugins/tailscale/include/common.php
28-28: Class Tailscale\Utils does not have a constructor and must be instantiated without any parameters.
(new.noConstructor)
src/usr/local/emhttp/plugins/tailscale/include/Pages/Tailscale.php
14-14: Instantiated class EDACerton\PluginUtils\Translator not found.
Learn more at https://phpstan.org/user-guide/discovering-symbols
(class.notFound)
src/usr/local/emhttp/plugins/tailscale/include/tailscale-lock/locked.php
11-11: Instantiated class EDACerton\PluginUtils\Translator not found.
Learn more at https://phpstan.org/user-guide/discovering-symbols
(class.notFound)
src/usr/local/emhttp/plugins/tailscale/include/Pages/Lock.php
11-11: Instantiated class EDACerton\PluginUtils\Translator not found.
Learn more at https://phpstan.org/user-guide/discovering-symbols
(class.notFound)
src/usr/local/emhttp/plugins/tailscale/include/Pages/Dashboard.php
11-11: Instantiated class EDACerton\PluginUtils\Translator not found.
Learn more at https://phpstan.org/user-guide/discovering-symbols
(class.notFound)
src/usr/local/emhttp/plugins/tailscale/include/Pages/Log.php
21-21: Instantiated class EDACerton\PluginUtils\Translator not found.
Learn more at https://phpstan.org/user-guide/discovering-symbols
(class.notFound)
src/usr/local/emhttp/plugins/tailscale/include/tailscale-lock/disabled.php
11-11: Instantiated class EDACerton\PluginUtils\Translator not found.
Learn more at https://phpstan.org/user-guide/discovering-symbols
(class.notFound)
src/usr/local/php/unraid-tailscale-utils/unraid-tailscale-utils/Watcher.php
24-24: Class Tailscale\Utils does not have a constructor and must be instantiated without any parameters.
(new.noConstructor)
26-26: Call to an undefined method Tailscale\Utils::logmsg().
(method.notFound)
47-47: Call to an undefined method Tailscale\Utils::logmsg().
(method.notFound)
54-54: Call to an undefined method Tailscale\Utils::run_task().
(method.notFound)
55-55: Call to an undefined method Tailscale\Utils::run_task().
(method.notFound)
56-56: Call to an undefined method Tailscale\Utils::run_task().
(method.notFound)
59-59: Call to an undefined method Tailscale\Utils::run_task().
(method.notFound)
60-60: Call to an undefined method Tailscale\Utils::run_task().
(method.notFound)
61-61: Call to an undefined method Tailscale\Utils::run_task().
(method.notFound)
70-70: Call to an undefined method Tailscale\Utils::logmsg().
(method.notFound)
73-73: Call to an undefined method Tailscale\Utils::run_task().
(method.notFound)
76-76: Call to an undefined method Tailscale\Utils::logmsg().
(method.notFound)
src/usr/local/emhttp/plugins/tailscale/pre-startup.php
12-12: Class Tailscale\Utils does not have a constructor and must be instantiated without any parameters.
(new.noConstructor)
16-16: Call to an undefined method Tailscale\Utils::run_task().
(method.notFound)
17-17: Call to an undefined method Tailscale\Utils::run_task().
(method.notFound)
18-18: Call to an undefined method Tailscale\Utils::run_task().
(method.notFound)
19-19: Call to an undefined method Tailscale\Utils::run_task().
(method.notFound)
22-22: Call to an undefined method Tailscale\Utils::run_command().
(method.notFound)
24-24: Call to an undefined method Tailscale\Utils::run_command().
(method.notFound)
25-25: Call to an undefined method Tailscale\Utils::run_command().
(method.notFound)
src/usr/local/emhttp/plugins/tailscale/include/data/Lock.php
14-14: Instantiated class EDACerton\PluginUtils\Translator not found.
Learn more at https://phpstan.org/user-guide/discovering-symbols
(class.notFound)
src/usr/local/emhttp/plugins/tailscale/include/data/Config.php
14-14: Instantiated class EDACerton\PluginUtils\Translator not found.
Learn more at https://phpstan.org/user-guide/discovering-symbols
(class.notFound)
15-15: Class Tailscale\Utils does not have a constructor and must be instantiated without any parameters.
(new.noConstructor)
src/usr/local/php/unraid-tailscale-utils/unraid-tailscale-utils/LocalAPI.php
22-22: Class Tailscale\Utils does not have a constructor and must be instantiated without any parameters.
(new.noConstructor)
49-49: Call to an undefined method Tailscale\Utils::logmsg().
(method.notFound)
56-56: Call to an undefined method Tailscale\Utils::logmsg().
(method.notFound)
src/usr/local/emhttp/plugins/tailscale/include/tailscale-lock/signed.php
11-11: Instantiated class EDACerton\PluginUtils\Translator not found.
Learn more at https://phpstan.org/user-guide/discovering-symbols
(class.notFound)
src/usr/local/emhttp/plugins/tailscale/include/data/Status.php
14-14: Instantiated class EDACerton\PluginUtils\Translator not found.
Learn more at https://phpstan.org/user-guide/discovering-symbols
(class.notFound)
15-15: Class Tailscale\Utils does not have a constructor and must be instantiated without any parameters.
(new.noConstructor)
src/usr/local/emhttp/plugins/tailscale/include/Pages/Settings.php
11-11: Instantiated class EDACerton\PluginUtils\Translator not found.
Learn more at https://phpstan.org/user-guide/discovering-symbols
(class.notFound)
src/usr/local/emhttp/plugins/tailscale/include/Pages/Info.php
11-11: Instantiated class EDACerton\PluginUtils\Translator not found.
Learn more at https://phpstan.org/user-guide/discovering-symbols
(class.notFound)
src/usr/local/php/unraid-tailscale-utils/unraid-tailscale-utils/Utils.php
5-5: Class Tailscale\Utils extends unknown class EDACerton\PluginUtils\Utils.
Learn more at https://phpstan.org/user-guide/discovering-symbols
(class.notFound)
12-12: Call to an undefined method Tailscale\Utils::logmsg().
(method.notFound)
59-59: Class Tailscale\Utils does not have a constructor and must be instantiated without any parameters.
(new.noConstructor)
60-60: Call to an undefined method Tailscale\Utils::logmsg().
(method.notFound)
71-71: Class Tailscale\Utils does not have a constructor and must be instantiated without any parameters.
(new.noConstructor)
72-72: Call to an undefined method Tailscale\Utils::run_command().
(method.notFound)
🔇 Additional comments (62)
src/usr/local/php/unraid-tailscale-utils/unraid-tailscale-utils/Info.php (1)
5-6: LGTM! Clean migration to external library.The import statement correctly references the external
Translatorclass fromEDACerton\PluginUtils. This aligns well with the existing dependency injection pattern in the constructor..php-cs-fixer.dist.php (1)
8-8: LGTM! Standard vendor directory exclusion.Excluding vendor directories from PHP-CS-Fixer is the correct approach to avoid reformatting third-party dependencies.
phpstan.neon (1)
8-9: LGTM! Standard vendor directory exclusion.Excluding vendor directories from PHPStan analysis is the correct approach. The
*/vendor/*pattern will appropriately exclude vendor directories at any level in the project structure..gitignore (1)
4-4: LGTM! Standard composer ignore pattern.Changing from
/vendortovendorcorrectly ignores vendor directories at any level in the repository, which is the standard practice for composer-managed PHP projects..github/workflows/release.yml (1)
12-16: LGTM! Proper dependency installation for release builds.The composer dependency installation step is correctly configured:
- Uses stable php-actions/composer@v6 action
- Properly excludes dev dependencies with
dev: no- Targets the correct working directory for the new library structure
- Positioned appropriately in the workflow sequence
src/usr/local/emhttp/plugins/tailscale/approve-nodes.php (2)
7-9: LGTM! Proper runtime validation.The runtime check ensures the
$utilsvariable is properly initialized before use, which is essential for the migration from static to instance-based utility usage.
14-14: LGTM! Consistent migration to instance-based utility calls.The change from static
Utils::logmsg()to instance$utils->logmsg()correctly implements the architectural shift described in the PR objectives.src/usr/local/emhttp/plugins/tailscale/include/Pages/Dashboard.php (2)
5-5: LGTM! Correct import for external library.The explicit import of
TranslatorfromEDACerton\PluginUtilsis correctly implemented for the migration to external dependencies.
7-9: LGTM! Essential runtime validation.The runtime check for
PLUGIN_ROOTandPLUGIN_NAMEconstants ensures proper initialization before proceeding, which is crucial for the new dependency structure.src/usr/local/emhttp/plugins/tailscale/daily.php (5)
16-17: LGTM! Instance method calls correctly replace static usage.The migration from static
Utils::run_task()calls to instance method$utils->run_task()calls is correctly implemented and aligns with the refactoring objectives.🧰 Tools
🪛 PHPStan (2.1.15)
16-16: Call to an undefined method Tailscale\Utils::run_task().
(method.notFound)
17-17: Call to an undefined method Tailscale\Utils::run_task().
(method.notFound)
12-12:Details
✅ Verification successful
Verify the external dependency is properly configured.
The static analysis indicates that the
Utilsclass constructor and methods are not found, suggesting theEDACerton\PluginUtilsdependency may not be available in the analysis environment.
🏁 Script executed:
#!/bin/bash # Description: Verify that the EDACerton\PluginUtils dependency is properly configured # Expected: Find composer.json with the dependency and autoloader setup # Check for composer.json and the dependency fd composer.json --exec cat {} \; # Check for autoloader usage in common.php rg -A 5 -B 5 "autoload" src/usr/local/emhttp/plugins/tailscale/include/common.phpLength of output: 1175
External dependency is properly configured
composer.jsonincludes
"require": { "edacerton/plugin-utils": "^1.0" }src/usr/local/emhttp/plugins/tailscale/include/common.phploads the Composer autoloader via
require_once "/usr/local/php/unraid-tailscale-utils/vendor/autoload.php";No further action needed.
🧰 Tools
🪛 PHPStan (2.1.15)
12-12: Class Tailscale\Utils does not have a constructor and must be instantiated without any parameters.
(new.noConstructor)
9-11: LGTM: Good defensive programming with runtime checks.The runtime validation ensures that required constants are properly defined before proceeding, which prevents runtime errors and makes debugging easier if the common file isn't loaded correctly.
12-12: Static analysis false positive - external library dependency.The PHPStan error about missing constructor is likely a false positive since this code is part of a refactor to use an external library (
EDACerton\PluginUtils\Utils). The static analysis environment probably doesn't have access to this external dependency.Ensure the Composer autoloader is properly configured to load the external library.
🧰 Tools
🪛 PHPStan (2.1.15)
12-12: Class Tailscale\Utils does not have a constructor and must be instantiated without any parameters.
(new.noConstructor)
16-17: LGTM: Good architectural change from static to instance methods.The migration from static
Utils::run_task()calls to instance$utils->run_task()calls is a solid architectural improvement that enables better dependency injection and testability.Note: The PHPStan errors about missing methods are likely false positives due to the external library not being available during static analysis.
🧰 Tools
🪛 PHPStan (2.1.15)
16-16: Call to an undefined method Tailscale\Utils::run_task().
(method.notFound)
17-17: Call to an undefined method Tailscale\Utils::run_task().
(method.notFound)
src/usr/local/emhttp/plugins/tailscale/include/tailscale-lock/disabled.php (5)
3-5: LGTM! Proper namespace and import declarations.The namespace declaration and explicit import of the external
Translatorclass are correctly implemented and consistent with the refactoring to use shared utilities.
11-11:Details
❓ Verification inconclusive
Verify Translator class constructor signature.
The static analysis indicates the
EDACerton\PluginUtils\Translatorclass is not found. Ensure this external dependency is properly available and the constructor accepts thePLUGIN_ROOTparameter.
🏁 Script executed:
#!/bin/bash # Description: Verify the Translator class usage and constructor signature # Expected: Find usage patterns and validate constructor parameters # Search for other Translator instantiations to verify pattern consistency rg -A 2 -B 2 "new Translator" src/usr/local/emhttp/plugins/tailscale/ # Check if there are any references to the old Tailscale\Translator class rg "Tailscale\\\\Translator" src/usr/local/emhttp/plugins/tailscale/Length of output: 7062
To verify the
Translatorclass and its constructor signature, let’s locate its definition in the codebase (including any vendor dependencies) and inspect the constructor:
🏁 Script executed:
#!/bin/bash # 1. Find where Translator is defined rg -n "class Translator" . # 2. If found, show the surrounding lines to inspect the constructor signature FOUND=$(rg -l "class Translator" .) if [ -n "$FOUND" ]; then rg -C 3 "function __construct" "$FOUND" fiLength of output: 83
Verify Translator class availability and constructor signature
I couldn’t locate any
class Translatordefinition in the repo (including vendor).Ensure that the external package providing
EDACerton\PluginUtils\Translatoris installed (e.g. via Composer undervendor/edacerton/plugin-utils) and autoloaded.Confirm you have the correct
use EDACerton\PluginUtils\Translator;import in these files.Check that
Translator::__construct()accepts a single parameter (i.e.public function __construct(string $pluginRoot)), matching every instantiation below:• src/usr/local/emhttp/plugins/tailscale/include/tailscale-lock/disabled.php
• src/usr/local/emhttp/plugins/tailscale/include/tailscale-lock/signing.php
• src/usr/local/emhttp/plugins/tailscale/include/tailscale-lock/signed.php
• src/usr/local/emhttp/plugins/tailscale/include/tailscale-lock/locked.php
• src/usr/local/emhttp/plugins/tailscale/include/data/Status.php
• src/usr/local/emhttp/plugins/tailscale/include/data/Lock.php
• src/usr/local/emhttp/plugins/tailscale/include/data/Config.php
• All instantiations in include/Pages/*Without a matching class and constructor signature, these
new Translator(PLUGIN_ROOT)calls will fail at runtime.🧰 Tools
🪛 PHPStan (2.1.15)
11-11: Instantiated class EDACerton\PluginUtils\Translator not found.
Learn more at https://phpstan.org/user-guide/discovering-symbols(class.notFound)
3-5: LGTM: Proper namespace and import declaration.The explicit import of
EDACerton\PluginUtils\Translatorfollows PHP best practices and makes dependencies clear.
7-9: LGTM: Consistent runtime validation pattern.The runtime check for required constants is implemented consistently across all files in this refactor, providing good error handling.
11-11: Static analysis false positive - verify external library availability.The PHPStan error about the missing
EDACerton\PluginUtils\Translatorclass is likely due to the external library not being available in the static analysis environment.Ensure the
EDACerton\PluginUtilspackage is properly included in your Composer dependencies and autoloader configuration.🧰 Tools
🪛 PHPStan (2.1.15)
11-11: Instantiated class EDACerton\PluginUtils\Translator not found.
Learn more at https://phpstan.org/user-guide/discovering-symbols(class.notFound)
src/usr/local/emhttp/plugins/tailscale/include/Pages/Main.php (5)
5-6: LGTM! Consistent import pattern.The explicit import of
EDACerton\PluginUtils\Translatormaintains consistency with the refactoring approach across all plugin files.
14-15: LGTM! Proper Translator instantiation with constructor parameter.The updated instantiation correctly passes
PLUGIN_ROOTto the Translator constructor, replacing the previous parameterless instantiation.🧰 Tools
🪛 PHPStan (2.1.15)
14-14: Instantiated class EDACerton\PluginUtils\Translator not found.
Learn more at https://phpstan.org/user-guide/discovering-symbols(class.notFound)
5-5: LGTM: Consistent external library import.The import follows the same pattern established across all files in this refactor.
10-12: LGTM: Consistent runtime validation implementation.The runtime check pattern is implemented identically across all refactored files, ensuring reliable error handling.
14-14: LGTM: Proper Translator instantiation with configuration.The change to pass
PLUGIN_ROOTas a constructor argument aligns with the external library's API requirements.Note: PHPStan error is likely a false positive due to missing external library in analysis environment.
🧰 Tools
🪛 PHPStan (2.1.15)
14-14: Instantiated class EDACerton\PluginUtils\Translator not found.
Learn more at https://phpstan.org/user-guide/discovering-symbols(class.notFound)
src/usr/local/emhttp/plugins/tailscale/include/Pages/Info.php (3)
5-6: LGTM! Consistent refactoring pattern maintained.The import statement maintains the same pattern established across all plugin files in this refactoring effort.
11-12: LGTM! Proper constructor parameter usage.The Translator instantiation correctly uses
PLUGIN_ROOTas a constructor argument, completing the migration from the old parameterless instantiation pattern.🧰 Tools
🪛 PHPStan (2.1.15)
11-11: Instantiated class EDACerton\PluginUtils\Translator not found.
Learn more at https://phpstan.org/user-guide/discovering-symbols(class.notFound)
5-11: LGTM: Excellent systematic refactoring implementation.This file follows the exact same pattern as the other three files in this refactor:
- Proper external library import
- Consistent runtime validation for required constants
- Correct Translator instantiation with configuration parameter
The systematic consistency across all files demonstrates a well-executed refactor that migrates from internal classes to external library dependencies while maintaining proper error handling.
🧰 Tools
🪛 PHPStan (2.1.15)
11-11: Instantiated class EDACerton\PluginUtils\Translator not found.
Learn more at https://phpstan.org/user-guide/discovering-symbols(class.notFound)
src/usr/local/emhttp/plugins/tailscale/include/tailscale-lock/locked.php (2)
7-9: Good defensive programming with runtime checks.The runtime validation ensures that required constants are defined before proceeding, which prevents undefined constant errors and provides clear error messaging.
11-11: Translator instantiation updated correctly.The change from
new Tailscale\Translatortonew Translator(PLUGIN_ROOT)aligns with the external library migration and provides the required plugin root path.🧰 Tools
🪛 PHPStan (2.1.15)
11-11: Instantiated class EDACerton\PluginUtils\Translator not found.
Learn more at https://phpstan.org/user-guide/discovering-symbols(class.notFound)
src/usr/local/emhttp/plugins/tailscale/pre-startup.php (2)
16-25: Instance method calls follow consistent refactoring pattern.The change from static calls like
Utils::run_task()to instance calls like$utils->run_task()is good for testability and dependency injection. Ensure the Utils class supports these methods.🧰 Tools
🪛 PHPStan (2.1.15)
16-16: Call to an undefined method Tailscale\Utils::run_task().
(method.notFound)
17-17: Call to an undefined method Tailscale\Utils::run_task().
(method.notFound)
18-18: Call to an undefined method Tailscale\Utils::run_task().
(method.notFound)
19-19: Call to an undefined method Tailscale\Utils::run_task().
(method.notFound)
22-22: Call to an undefined method Tailscale\Utils::run_command().
(method.notFound)
24-24: Call to an undefined method Tailscale\Utils::run_command().
(method.notFound)
25-25: Call to an undefined method Tailscale\Utils::run_command().
(method.notFound)
9-12:Details
❓ Verification inconclusive
Verify Utils class constructor and method signatures.
PHPStan reports that
Tailscale\Utilsdoesn't have a constructor but is being instantiated withPLUGIN_NAME, and that therun_taskandrun_commandmethods don't exist.
🏁 Script executed:
#!/bin/bash # Search for the Utils class definition in the Tailscale namespace ast-grep --pattern $'class Utils { $$$ }' # Look for the constructor definition ast-grep --pattern $'function __construct($$$) { $$$ }' # Search for run_task and run_command method definitions rg -A 5 "function run_task" rg -A 5 "function run_command"Length of output: 166
🏁 Script executed:
#!/bin/bash # Search for Utils class definitions anywhere in the repo rg -n "class Utils" . # Ensure the Tailscale namespace is applied to Utils rg -n "namespace\s\+Tailscale" -n . # Look for a constructor in any Utils implementation rg -n "function __construct" . # Search for run_task and run_command method definitions rg -n "function\s\+run_task" . rg -n "function\s\+run_command" .Length of output: 924
🏁 Script executed:
#!/bin/bash file="src/usr/local/php/unraid-tailscale-utils/unraid-tailscale-utils/Utils.php" echo "=== Namespace Declaration ===" rg -n "^namespace" "$file" || echo "(none found)" echo "=== Class Definition ===" rg -n "class Utils" -n "$file" echo "=== Constructor Signature ===" rg -n "function __construct" "$file" || echo "(no constructor)" echo "=== Public Methods ===" rg -n "public function" -n "$file"Length of output: 893
Verify
PluginUtils\UtilsParent InterfaceThe local
Tailscale\Utilsclass (src/usr/local/php/unraid-tailscale-utils/unraid-tailscale-utils/Utils.php) only declares one method (setPHPDebug) and no constructor of its own. It extends\EDACerton\PluginUtils\Utils, so you need to confirm that in that parent class:
- A constructor accepts the plugin name (i.e. a string parameter).
- Instance methods
run_task()andrun_command()are defined.Without those in the parent, instantiating
new Utils(PLUGIN_NAME)and calling$utils->run_task()/$utils->run_command()will fail. Please verify in theEDACerton\PluginUtils\Utilssource that these signatures exist.🧰 Tools
🪛 PHPStan (2.1.15)
12-12: Class Tailscale\Utils does not have a constructor and must be instantiated without any parameters.
(new.noConstructor)
src/usr/local/emhttp/plugins/tailscale/include/Pages/Tailscale.php (3)
5-5: External Translator import aligns with migration pattern.The import follows the consistent pattern across the codebase for migrating to the external plugin utilities library.
10-14: Runtime checks and initialization updated correctly.The defensive constant checks and updated Translator instantiation with
PLUGIN_ROOTare consistent with the refactoring pattern.🧰 Tools
🪛 PHPStan (2.1.15)
14-14: Instantiated class EDACerton\PluginUtils\Translator not found.
Learn more at https://phpstan.org/user-guide/discovering-symbols(class.notFound)
149-151:Details
❌ Incorrect review comment
Verify consistency with Utils refactoring pattern.
These lines still use static
Utils::formatWarning()calls while other files in this PR were refactored to use instance method calls. Confirm whether this is intentional or if these should also be updated.
🏁 Script executed:
#!/bin/bash # Check if formatWarning is a static method that should remain static ast-grep --pattern $'static function formatWarning($$$) { $$$ }' # Look for other static Utils calls in the codebase rg "Utils::" --type php -A 2 -B 2Length of output: 25172
I want to confirm where and how
formatWarningis declared. Let's locate theUtilsclass and anyformatWarningdefinitions/uses:
🏁 Script executed:
#!/bin/bash # Find any occurrence of 'formatWarning' (definition or reference) rg "formatWarning" -n . # Locate the Utils class declaration rg "class Utils" -n . # Find any files named Utils.php find . -type f -iname "Utils.php"Length of output: 869
No changes needed for formatWarning calls
The
formatWarningmethod is declared as apublic staticonUtils(see src/usr/local/php/unraid-tailscale-utils/unraid-tailscale-utils/Utils.php:32) and there is no instance‐method variant. All other pages continue to use staticUtils::…calls (e.g.printRow,make_option, etc.), so these lines are consistent with the existing utility API.Likely an incorrect or invalid review comment.
src/usr/local/emhttp/plugins/tailscale/include/Pages/Status.php (1)
5-11: Migration pattern implemented consistently.The external library import, runtime checks, and updated Translator instantiation follow the same reliable pattern established in other files.
🧰 Tools
🪛 PHPStan (2.1.15)
11-11: Instantiated class EDACerton\PluginUtils\Translator not found.
Learn more at https://phpstan.org/user-guide/discovering-symbols(class.notFound)
src/usr/local/php/unraid-tailscale-utils/unraid-tailscale-utils/Watcher.php (3)
26-26: Verify Utils class interface matches usage.The conversion from static to instance method calls looks correct, but PHPStan indicates the
logmsg()method is not found on the Utils class.Ensure the Utils class implements the expected interface with
logmsg()method.Also applies to: 47-47, 70-70, 76-76
🧰 Tools
🪛 PHPStan (2.1.15)
26-26: Call to an undefined method Tailscale\Utils::logmsg().
(method.notFound)
54-56: Verify Utils class has run_task method.The conversion from static to instance method calls for
run_task()looks correct, but PHPStan indicates this method is not found on the Utils class.Ensure the Utils class implements the
run_task()method as expected.Also applies to: 59-61, 73-73
🧰 Tools
🪛 PHPStan (2.1.15)
54-54: Call to an undefined method Tailscale\Utils::run_task().
(method.notFound)
55-55: Call to an undefined method Tailscale\Utils::run_task().
(method.notFound)
56-56: Call to an undefined method Tailscale\Utils::run_task().
(method.notFound)
21-25:Details
❓ Verification inconclusive
Good defensive programming with runtime checks.
The addition of runtime checks for required constants before instantiating the Utils class is excellent defensive programming. This ensures the plugin environment is properly initialized.
However, PHPStan indicates several issues with the Utils class:
🏁 Script executed:
#!/bin/bash # Verify the Utils class exists and has the expected interface ast-grep --pattern 'class Utils { $$$ }' # Check if the constructor accepts parameters ast-grep --pattern 'public function __construct($_) { $$$ }' # Verify logmsg and run_task methods exist ast-grep --pattern 'public function logmsg($_) { $$$ }' ast-grep --pattern 'public function run_task($_, $_) { $$$ }'Length of output: 235
Let’s locate and inspect the
Utilsclass and its methods directly:
🏁 Script executed:
#!/usr/bin/env bash # 1. Find the file defining Utils echo "Utils file path:" fd --hidden --max-depth 5 Utils.php # 2. Show the class declaration and nearby context rg -n '^\s*class\s+Utils\b' -C3 --color never # 3. Verify the constructor signature rg -n 'public function __construct' -C3 --color never # 4. Verify existence of logmsg() rg -n 'public function logmsg' -C3 --color never # 5. Verify existence of run_task() rg -n 'public function run_task' -C3 --color neverLength of output: 4773
Confirm inherited Utils interface
The
Utilsclass insrc/usr/local/php/unraid-tailscale-utils/unraid-tailscale-utils/Utils.phpextends\EDACerton\PluginUtils\Utilswithout overriding its constructor or methods. Before these instance-based calls ($utils = new Utils(PLUGIN_NAME); $utils->logmsg(...); $utils->run_task(...);) can be considered safe, please verify that in the parent class:
- The constructor accepts a single string parameter (the plugin name).
- A
public function logmsg(string $message): voidexists.- A
public function run_task(string $task, array $options)exists with the expected signature.Ensuring these definitions will resolve the PHPStan errors and confirm the refactoring is correct.
🧰 Tools
🪛 PHPStan (2.1.15)
24-24: Class Tailscale\Utils does not have a constructor and must be instantiated without any parameters.
(new.noConstructor)
.github/workflows/lint.yml (1)
26-30: Improved workflow structure for composer dependencies.The changes to run composer install and PHPStan from the specific subdirectory (
src/usr/local/php/unraid-tailscale-utils) align well with the new dependency structure. This ensures PHPStan has access to the external libraries.The workflow structure is logical: install dependencies first, then run analysis from the same directory.
src/usr/local/emhttp/plugins/tailscale/include/Pages/Lock.php (1)
5-11: Consistent migration pattern implemented correctly.The migration to external
EDACerton\PluginUtils\Translatorfollows the same consistent pattern as other files, with proper runtime checks for required constants.As with other files, PHPStan indicates the external class is not found, suggesting a dependency configuration issue that should be addressed across the project.
🧰 Tools
🪛 PHPStan (2.1.15)
11-11: Instantiated class EDACerton\PluginUtils\Translator not found.
Learn more at https://phpstan.org/user-guide/discovering-symbols(class.notFound)
src/usr/local/emhttp/plugins/tailscale/include/tailscale-lock/signed.php (2)
7-9: Excellent defensive programming with runtime checks.The runtime validation ensures that required constants are defined before proceeding, preventing potential runtime errors due to missing initialization.
11-11: Good migration to parameterized constructor.The updated translator instantiation with
PLUGIN_ROOTparameter aligns with the external library interface and makes dependencies explicit.🧰 Tools
🪛 PHPStan (2.1.15)
11-11: Instantiated class EDACerton\PluginUtils\Translator not found.
Learn more at https://phpstan.org/user-guide/discovering-symbols(class.notFound)
src/usr/local/emhttp/plugins/tailscale/include/data/Config.php (3)
10-12: Consistent runtime validation pattern.The defensive checks for required constants are properly implemented, matching the pattern used across other files in this refactor.
14-15: Good transition to instance-based dependencies.The migration from static utility usage to instance-based dependencies with explicit parameters improves testability and dependency injection.
🧰 Tools
🪛 PHPStan (2.1.15)
14-14: Instantiated class EDACerton\PluginUtils\Translator not found.
Learn more at https://phpstan.org/user-guide/discovering-symbols(class.notFound)
15-15: Class Tailscale\Utils does not have a constructor and must be instantiated without any parameters.
(new.noConstructor)
173-173: Consistent migration from static to instance method calls.All logging calls have been properly updated to use the instance method pattern
$utils->logmsg()instead of static calls, maintaining functionality while improving the architecture.Also applies to: 183-183, 198-198, 220-220, 236-236, 247-247, 260-260
src/usr/local/emhttp/plugins/tailscale/include/data/Status.php (3)
10-12: Consistent defensive programming pattern.The runtime validation for required constants follows the same pattern established across the refactor, ensuring proper initialization.
14-15: Proper instance-based dependency initialization.The updated instantiation pattern with explicit parameters improves dependency management and aligns with the external library interface.
🧰 Tools
🪛 PHPStan (2.1.15)
14-14: Instantiated class EDACerton\PluginUtils\Translator not found.
Learn more at https://phpstan.org/user-guide/discovering-symbols(class.notFound)
15-15: Class Tailscale\Utils does not have a constructor and must be instantiated without any parameters.
(new.noConstructor)
99-99: Correct migration to instance method.The change from static
Utils::run_command()to instance$utils->run_command()properly implements the new architecture while maintaining the same functionality for executing ping commands.src/usr/local/emhttp/plugins/tailscale/include/Pages/Help.php (2)
7-9: Consistent runtime safety pattern.The defensive validation for required constants maintains the same reliable pattern used throughout the refactor.
11-11: Proper migration to parameterized translator.The updated translator instantiation with
PLUGIN_ROOTparameter correctly aligns with the external library interface and makes dependencies explicit.🧰 Tools
🪛 PHPStan (2.1.15)
11-11: Instantiated class EDACerton\PluginUtils\Translator not found.
Learn more at https://phpstan.org/user-guide/discovering-symbols(class.notFound)
src/usr/local/emhttp/plugins/tailscale/include/tailscale-lock/signing.php (2)
3-5: LGTM! Consistent namespace and import pattern.The namespace declaration and import statement follow the refactoring pattern consistently applied across the codebase.
7-9: Good defensive programming with runtime checks.The runtime validation ensures that required constants are properly loaded before proceeding, which prevents silent failures and provides clear error messaging.
src/usr/local/emhttp/plugins/tailscale/include/common.php (1)
5-20: LGTM! Proper license header added.The GPLv3 license header is correctly formatted and provides clear licensing information.
src/usr/local/emhttp/plugins/tailscale/include/data/Lock.php (3)
5-5: LGTM! Consistent import pattern.The import statement follows the same pattern as other refactored files, maintaining consistency across the codebase.
10-12: LGTM! Consistent runtime validation.The runtime checks follow the same defensive programming pattern used throughout the refactored codebase.
14-14: LGTM! Proper translator initialization.The null coalescing operator prevents re-initialization while ensuring the translator is available with the required constructor argument.
🧰 Tools
🪛 PHPStan (2.1.15)
14-14: Instantiated class EDACerton\PluginUtils\Translator not found.
Learn more at https://phpstan.org/user-guide/discovering-symbols(class.notFound)
src/usr/local/php/unraid-tailscale-utils/unraid-tailscale-utils/System.php (2)
21-21: LGTM! Systematic method renaming completed.The refactoring consistently replaces:
Utils::run_command→Utils::runwrapUtils::logmsg→Utils::logwrapThis systematic change maintains the original logic while migrating to the new utility method names.
Also applies to: 29-30, 46-52, 74-75, 82-82, 86-86, 96-96, 103-103, 106-106, 117-117, 127-128, 131-131, 149-149, 163-163, 166-166, 184-184, 201-201, 203-203, 212-214, 216-216, 245-245, 248-248, 263-263, 271-271
21-21:Details
✅ Verification successful
Verify all utility method calls have been updated consistently.
Ensure that all instances of the old method names have been updated throughout the entire codebase to prevent runtime errors.
Also applies to: 29-30, 46-52, 74-75, 82-82, 86-86, 96-96, 103-103, 106-106, 117-117, 127-128, 131-131, 149-149, 163-163, 166-166, 184-184, 201-201, 203-203, 212-214, 216-216, 245-245, 248-248, 263-263, 271-271
🏁 Script executed:
#!/bin/bash # Description: Search for any remaining instances of old method names # Expected: Should find no instances of the old method names echo "Searching for remaining Utils::run_command calls:" rg "Utils::run_command" --type php || echo "✓ No remaining Utils::run_command calls found" echo -e "\nSearching for remaining Utils::logmsg calls:" rg "Utils::logmsg" --type php || echo "✓ No remaining Utils::logmsg calls found" echo -e "\nSearching for new method usage to verify consistency:" rg "Utils::(runwrap|logwrap)" --type php -c | head -10Length of output: 728
All utility method calls have been migrated
All instances of
Utils::run_commandandUtils::logmsghave been replaced withUtils::runwrap/Utils::logwrapacross the entire codebase. The verification script confirms:
- ✓ No remaining
Utils::run_commandcalls- ✓ No remaining
Utils::logmsgcalls- ✓ New
Utils::runwrap/Utils::logwrapusages present as expectedNo further changes required.
src/usr/local/php/unraid-tailscale-utils/unraid-tailscale-utils/LocalAPI.php (2)
49-49: Consistent migration from static to instance method calls.The conversion from
Utils::logmsgto$this->utils->logmsgis correctly implemented and follows the established refactoring pattern throughout the codebase.Also applies to: 56-56
🧰 Tools
🪛 PHPStan (2.1.15)
49-49: Call to an undefined method Tailscale\Utils::logmsg().
(method.notFound)
15-23:Details
❓ Verification inconclusive
LGTM: Well-implemented instance-based refactoring with proper validation.
The addition of the private
$utilsproperty and constructor with runtime validation of required constants follows a consistent pattern. The constructor properly ensures thatPLUGIN_ROOTandPLUGIN_NAMEconstants are available before proceeding.However, the static analysis hints suggest potential issues with the
Utilsclass constructor and methods. Please verify that theUtilsclass properly extends\EDACerton\PluginUtils\Utilsand that all required methods are available:
🏁 Script executed:
#!/bin/bash # Verify Utils class definition and constructor ast-grep --pattern $'class Utils extends $_ { $$$ }' # Check for logmsg method definition ast-grep --pattern $'logmsg($_) { $$$ }'Length of output: 11689
Verify Utils inheritance and instance methods
I’ve confirmed that
src/usr/local/php/unraid-tailscale-utils/unraid-tailscale-utils/Utils.phpdefinesclass Utils extends \EDACerton\PluginUtils\Utilswith no local
logmsg()override, so instance calls ($this->utils->logmsg(...)) will delegate to the parent’s method. The callnew Utils(PLUGIN_NAME)is valid assuming the base class constructor accepts the plugin name.Please verify in the external
\EDACerton\PluginUtils\Utilsclass that it provides:
public function __construct(string $pluginName)public function logmsg(string $message, bool $debug = false, bool $rateLimit = false): void🧰 Tools
🪛 PHPStan (2.1.15)
22-22: Class Tailscale\Utils does not have a constructor and must be instantiated without any parameters.
(new.noConstructor)
src/usr/local/emhttp/plugins/tailscale/include/Pages/Settings.php (1)
5-5: Proper import of external Translator class.The import statement correctly references the
Translatorclass from theEDACerton\PluginUtilsnamespace, aligning with the migration to the shared utility library.src/usr/local/php/unraid-tailscale-utils/unraid-tailscale-utils/Utils.php (1)
54-73: Good static wrapper pattern with proper constant validation.The
logwrapandrunwrapmethods provide a clean bridge between static and instance usage while properly validating thatPLUGIN_NAMEis defined. This pattern maintains backward compatibility while enforcing the new instance-based approach.🧰 Tools
🪛 PHPStan (2.1.15)
59-59: Class Tailscale\Utils does not have a constructor and must be instantiated without any parameters.
(new.noConstructor)
60-60: Call to an undefined method Tailscale\Utils::logmsg().
(method.notFound)
71-71: Class Tailscale\Utils does not have a constructor and must be instantiated without any parameters.
(new.noConstructor)
72-72: Call to an undefined method Tailscale\Utils::run_command().
(method.notFound)
| throw new \RuntimeException("Common file not loaded."); | ||
| } | ||
|
|
||
| $tr = $tr ?? new Translator(PLUGIN_ROOT); |
There was a problem hiding this comment.
💡 Verification agent
🧩 Analysis chain
Verify external dependency availability.
The translator initialization correctly uses PLUGIN_ROOT as a constructor argument. However, static analysis reports that EDACerton\PluginUtils\Translator class is not found, which suggests the external library may not be properly installed or available in the analysis environment.
Please verify that the EDACerton\PluginUtils package is properly defined and available:
🏁 Script executed:
#!/bin/bash
# Check if the external library is properly configured in composer.json
find . -name "composer.json" -exec echo "=== {} ===" \; -exec cat {} \;
# Check if autoload files exist
find . -name "autoload.php" -type f
# Look for the actual Translator class file
find . -name "Translator.php" -type fLength of output: 965
Ensure the EDACerton\PluginUtils\Translator class is actually installed and autoloaded
It looks like your composer.json does declare "edacerton/plugin-utils": "^1.0", but no vendor/autoload.php or Translator.php file was found in the repo scan—so the package isn’t installed or pulled into your plugin. Please:
- In your plugin’s root directory (e.g.
src/usr/local/emhttp/plugins/tailscale):- Add or verify a
composer.jsonthat requires"edacerton/plugin-utils": "^1.0". - Run
composer installto generatevendor/andvendor/autoload.php.
- Add or verify a
- Confirm that
vendor/edacerton/plugin-utils/src/Translator.phpexists. - Ensure your plugin bootstrap includes
require_once PLUGIN_ROOT . '/vendor/autoload.php';(or otherwise points to the correct autoloader).
Once the package is installed and autoloaded, the Translator class will be found and the static-analysis error will disappear.
🧰 Tools
🪛 PHPStan (2.1.15)
11-11: Instantiated class EDACerton\PluginUtils\Translator not found.
Learn more at https://phpstan.org/user-guide/discovering-symbols
(class.notFound)
🤖 Prompt for AI Agents
In src/usr/local/emhttp/plugins/tailscale/include/Pages/Dashboard.php at line
11, the Translator class from the EDACerton\PluginUtils package is not found
because the package is not installed or autoloaded. To fix this, ensure your
plugin's root directory has a composer.json requiring "edacerton/plugin-utils":
"^1.0", run composer install there to generate the vendor directory and autoload
files, verify that vendor/edacerton/plugin-utils/src/Translator.php exists, and
include require_once PLUGIN_ROOT . '/vendor/autoload.php'; in your plugin
bootstrap to load the package classes properly.
|
|
||
| namespace Tailscale; | ||
|
|
||
| use EDACerton\PluginUtils\Translator; |
There was a problem hiding this comment.
💡 Verification agent
🧩 Analysis chain
Verify external dependency availability.
The import of EDACerton\PluginUtils\Translator suggests this class should be available via Composer autoloader. The PHPStan warning indicates it's not found in the analysis environment.
🏁 Script executed:
#!/bin/bash
# Check if the external library is properly configured in composer.json
fd -e json composer.json --exec cat {} \; | jq '.require // empty'
# Look for any composer.lock files to verify dependencies are installed
fd composer.lock --exec ls -la {} \;
# Check if the plugin-utils library files exist in the codebase
fd -t d -g "*plugin*utils*" . | head -10Length of output: 302
Ensure the Translator class is actually autoloaded at runtime
The import of EDACerton\PluginUtils\Translator in locked.php assumes that the edacerton/plugin-utils library is installed and its autoloader has been required. I didn’t find any vendor directory or autoload.php inclusion in this plugin, so calling new Translator(...) will trigger a fatal “class not found” error.
• In src/usr/local/emhttp/plugins/tailscale/include/tailscale-lock/locked.php, add before using Translator:
require_once PLUGIN_ROOT . '/vendor/autoload.php';• Or vendor-bundle the edacerton/plugin-utils library into your plugin archive and ensure its autoloader is invoked.
This guarantees the external dependency is present and avoids runtime failures.
🤖 Prompt for AI Agents
In src/usr/local/emhttp/plugins/tailscale/include/tailscale-lock/locked.php at
line 5, the import of EDACerton\PluginUtils\Translator assumes the external
library is installed and autoloaded, but no autoloader is included. To fix this,
add a require_once statement for the Composer autoloader (e.g., require_once
PLUGIN_ROOT . '/vendor/autoload.php';) before using the Translator class to
ensure the dependency is loaded and prevent class not found errors at runtime.
| use EDACerton\PluginUtils\Translator; | ||
|
|
||
| if ( ! defined('Tailscale\PLUGIN_ROOT') || ! defined('Tailscale\PLUGIN_NAME')) { | ||
| throw new \RuntimeException("Common file not loaded."); | ||
| } | ||
|
|
||
| $tr = $tr ?? new Translator(Tailscale\PLUGIN_ROOT); |
There was a problem hiding this comment.
💡 Verification agent
🧩 Analysis chain
Consistent migration pattern to external library.
The migration from local Tailscale\Translator to external EDACerton\PluginUtils\Translator follows a consistent pattern with proper runtime checks for required constants.
However, PHPStan indicates the external class is not found, which suggests:
- The external dependency may not be properly installed
- PHPStan configuration may need updating to include the external library path
🏁 Script executed:
#!/bin/bash
# Check if composer dependencies are installed
ls -la src/usr/local/php/unraid-tailscale-utils/vendor/
# Verify the external Translator class exists
fd -name "Translator.php" src/usr/local/php/unraid-tailscale-utils/vendor/Length of output: 459
#!/bin/bash
Locate all vendor directories in the repo
fd -t d vendor
Search for any PHP file named Translator.php
fd -t f Translator.php
Check for a composer.json in the plugin root
fd -t f composer.json src/usr/local/emhttp/plugins/tailscale
🏁 Script executed:
#!/bin/bash
set -e
echo "Finding all vendor directories in the repo:"
fd --type d vendor
echo
echo "Locating any Translator.php files in the repo:"
fd --type f Translator.php
echo
echo "Searching for composer.json files in the repo:"
fd --type f composer.jsonLength of output: 460
Ensure external Translator dependency is installed and autoloaded by PHPStan
The migration to EDACerton\PluginUtils\Translator in src/usr/local/emhttp/plugins/tailscale/include/Pages/Log.php is correct and the runtime checks are in place. However, PHPStan errors indicate the external class isn’t found. Please:
- Install the Composer dependencies for the PluginUtils library:
cd src/usr/local/php/unraid-tailscale-utils composer install - Verify that
src/usr/local/php/unraid-tailscale-utils/vendor/autoload.phpexists. - Update your PHPStan configuration (e.g.
phpstan.neon) to include that autoload file or add the library’s directory toautoload_directories.
After these steps, re-run PHPStan to confirm the Translator class resolves without errors.
🧰 Tools
🪛 PHPStan (2.1.15)
21-21: Instantiated class EDACerton\PluginUtils\Translator not found.
Learn more at https://phpstan.org/user-guide/discovering-symbols
(class.notFound)
🤖 Prompt for AI Agents
In src/usr/local/emhttp/plugins/tailscale/include/Pages/Log.php lines 15 to 21,
PHPStan cannot find the external EDACerton\PluginUtils\Translator class due to
missing or unconfigured dependencies. Fix this by running composer install in
src/usr/local/php/unraid-tailscale-utils to install the PluginUtils library
dependencies, ensure the vendor/autoload.php file exists there, and then update
your PHPStan configuration (phpstan.neon) to include this autoload file or add
the library directory to autoload_directories. Finally, re-run PHPStan to verify
the class is correctly recognized.
| throw new \RuntimeException("Common file not loaded."); | ||
| } | ||
|
|
||
| $tr = $tr ?? new Translator(PLUGIN_ROOT); |
There was a problem hiding this comment.
💡 Verification agent
🧩 Analysis chain
Verify the Translator class is properly autoloaded.
The initialization looks correct, but the static analysis hints suggest the EDACerton\PluginUtils\Translator class might not be found. Ensure the Composer autoloader is working correctly.
🏁 Script executed:
#!/bin/bash
# Description: Check if the Composer autoloader contains the expected class
# Expected: The class should be listed in the autoloader's class map
find . -name "autoload.php" -path "*/vendor/*" -exec grep -l "EDACerton" {} \; 2>/dev/null || echo "No autoloader found with EDACerton namespace"
# Check if there are any composer.json files that might define this dependency
fd "composer.json" --exec cat {} \; | grep -A5 -B5 "EDACerton\|PluginUtils" || echo "No composer.json references found"Length of output: 235
To ensure the Translator class is actually defined and loaded by your plugin (rather than via Composer), let’s locate its declaration in the codebase:
🏁 Script executed:
#!/bin/bash
# Locate any declaration of the EDACerton\PluginUtils namespace
rg -n "namespace EDACerton\\\\PluginUtils" .
# Locate the Translator class definition
rg -n "class Translator" .Length of output: 73
Let’s locate where (and if) Translator is defined in the repo:
#!/usr/bin/env bash
# 1) Find any PHP file named Translator.php
fd -e php Translator.php
# 2) Search for class Translator declarations
rg -n "class Translator" .
# 3) Search for any references to Translator in code (to see import context)
rg -n "Translator" .Missing Translator class—autoload or include it
Our searches didn’t locate any EDACerton\PluginUtils\Translator definition or Composer autoload entry, so
$tr = $tr ?? new Translator(PLUGIN_ROOT); will fail at runtime. Please:
- Add
Translator.phpunder the proper path (e.g.include/tailscale-lock/Translator.php) with:<?php namespace EDACerton\PluginUtils; class Translator { … }
- Ensure your plugin’s
composer.jsondeclares PSR-4 autoloading, for example:"autoload": { "psr-4": { "EDACerton\\PluginUtils\\": "include/tailscale-lock/" } }
- Run
composer dump-autoload(or add arequire_once PLUGIN_ROOT.'include/tailscale-lock/Translator.php';before use)
File in question:
• src/usr/local/emhttp/plugins/tailscale/include/tailscale-lock/signing.php:11
🧰 Tools
🪛 PHPStan (2.1.15)
11-11: Instantiated class EDACerton\PluginUtils\Translator not found.
Learn more at https://phpstan.org/user-guide/discovering-symbols
(class.notFound)
🤖 Prompt for AI Agents
In src/usr/local/emhttp/plugins/tailscale/include/tailscale-lock/signing.php at
line 11, the Translator class is used but not found due to missing definition or
autoloading. To fix this, create a Translator.php file under
include/tailscale-lock/ with the namespace EDACerton\PluginUtils and the
Translator class defined inside. Then, update your plugin's composer.json to
include a PSR-4 autoload entry mapping EDACerton\PluginUtils\ to
include/tailscale-lock/, and run composer dump-autoload to regenerate the
autoloader. Alternatively, add a require_once statement for Translator.php
before its usage to ensure it is loaded.
| $utils = new Utils(PLUGIN_NAME); | ||
| $utils->setPHPDebug(); |
There was a problem hiding this comment.
Verify the Utils class constructor signature.
The static analysis indicates that Tailscale\Utils doesn't have a constructor, but the code is passing PLUGIN_NAME as a parameter. This suggests a mismatch between the class definition and usage.
#!/bin/bash
# Description: Find the Utils class definition and check its constructor
# Expected: Should find a constructor that accepts a parameter
# Search for the Utils class definition
ast-grep --pattern $'class Utils {
$$$
}'
# Search for Utils constructor specifically
ast-grep --pattern $'class Utils {
$$$
function __construct($_) {
$$$
}
$$$
}'
# Also check if it extends another class that might have the constructor
rg -A 10 "class Utils.*extends" || echo "No extending Utils class found"🧰 Tools
🪛 PHPStan (2.1.15)
28-28: Class Tailscale\Utils does not have a constructor and must be instantiated without any parameters.
(new.noConstructor)
🤖 Prompt for AI Agents
In src/usr/local/emhttp/plugins/tailscale/include/common.php at lines 28-29, the
Utils class is instantiated with PLUGIN_NAME as a constructor argument, but
static analysis shows Utils has no constructor accepting parameters. Verify the
Utils class definition to confirm if a constructor exists and accepts
parameters; if not, remove the argument PLUGIN_NAME from the instantiation to
match the class signature. Also check if Utils extends another class with a
constructor requiring parameters and adjust accordingly.
| if ( ! defined(__NAMESPACE__ . '\PLUGIN_ROOT') || ! defined(__NAMESPACE__ . '\PLUGIN_NAME')) { | ||
| throw new \RuntimeException("Common file not loaded."); | ||
| } | ||
|
|
||
| $tr = $tr ?? new Translator(PLUGIN_ROOT); |
There was a problem hiding this comment.
💡 Verification agent
🧩 Analysis chain
Excellent runtime validation and proper translator instantiation.
The runtime checks ensure that required constants are defined before proceeding, and the translator is properly instantiated with the PLUGIN_ROOT parameter. The null coalescing operator ensures the translator is only created if not already set.
However, static analysis indicates the Translator class may not be found. Please verify that the edacerton/plugin-utils dependency is properly installed:
🏁 Script executed:
#!/bin/bash
# Check if the dependency is properly defined in composer.json
find . -name "composer.json" -exec cat {} \; | jq '.require["edacerton/plugin-utils"]'
# Verify composer.lock exists and contains the dependency
if [ -f "composer.lock" ]; then
jq '.packages[] | select(.name == "edacerton/plugin-utils")' composer.lock
fiLength of output: 123
Install missing edacerton/plugin-utils dependency
- src/usr/local/emhttp/plugins/tailscale/include/Pages/Settings.php references
new Translator(PLUGIN_ROOT) - composer.json declares
"edacerton/plugin-utils": "^1.0", but composer.lock does not include that package
Please run composer update (or composer require edacerton/plugin-utils) to ensure the Translator class is available at runtime.
🧰 Tools
🪛 PHPStan (2.1.15)
11-11: Instantiated class EDACerton\PluginUtils\Translator not found.
Learn more at https://phpstan.org/user-guide/discovering-symbols
(class.notFound)
🤖 Prompt for AI Agents
In src/usr/local/emhttp/plugins/tailscale/include/Pages/Settings.php lines 7 to
11, the Translator class from the edacerton/plugin-utils package is used but the
package is missing from composer.lock, causing potential runtime errors. To fix
this, run `composer require edacerton/plugin-utils` or `composer update` to
install the missing dependency and ensure the Translator class is available at
runtime.
|
|
||
| namespace Tailscale; | ||
|
|
||
| class Utils extends \EDACerton\PluginUtils\Utils |
There was a problem hiding this comment.
💡 Verification agent
🧩 Analysis chain
Verify parent class availability.
The class extends \EDACerton\PluginUtils\Utils, but static analysis indicates this class may not be found. Ensure the dependency is properly installed and autoloaded.
🏁 Script executed:
#!/bin/bash
# Check if the parent class is available via composer
cd src/usr/local/php/unraid-tailscale-utils
composer show edacerton/plugin-utils
# Verify autoloading works
composer dump-autoloadLength of output: 960
Add missing edacerton/plugin-utils dependency
The parent class \EDACerton\PluginUtils\Utils isn’t available because the edacerton/plugin-utils package isn’t installed. You need to require it and regenerate your autoloader.
• In your project’s root composer.json, add:
{
"require": {
"edacerton/plugin-utils": "^1.0"
}
}• Run:
composer require edacerton/plugin-utils
composer dump-autoload• Verify that vendor/edacerton/plugin-utils/src/Utils.php exists and that Utils.php under
src/usr/local/php/unraid-tailscale-utils/unraid-tailscale-utils/Utils.php can find its parent class.
🧰 Tools
🪛 PHPStan (2.1.15)
5-5: Class Tailscale\Utils extends unknown class EDACerton\PluginUtils\Utils.
Learn more at https://phpstan.org/user-guide/discovering-symbols
(class.notFound)
🤖 Prompt for AI Agents
In src/usr/local/php/unraid-tailscale-utils/unraid-tailscale-utils/Utils.php at
line 5, the parent class \EDACerton\PluginUtils\Utils is missing because the
edacerton/plugin-utils package is not installed. Fix this by adding
"edacerton/plugin-utils": "^1.0" to the require section of your project's root
composer.json, then run composer require edacerton/plugin-utils and composer
dump-autoload to install the package and regenerate the autoloader. Finally,
verify that vendor/edacerton/plugin-utils/src/Utils.php exists and that your
Utils.php can properly extend the parent class.
|
@coderabbitai configuration |
CodeRabbit configurationlanguage: en-US
tone_instructions: ''
early_access: true
enable_free_tier: true
reviews:
profile: chill
request_changes_workflow: false
high_level_summary: true
high_level_summary_placeholder: '@coderabbitai summary'
high_level_summary_in_walkthrough: false
auto_title_placeholder: '@coderabbitai'
auto_title_instructions: ''
review_status: true
commit_status: true
fail_commit_status: false
collapse_walkthrough: true
changed_files_summary: true
sequence_diagrams: true
assess_linked_issues: true
related_issues: true
related_prs: true
suggested_labels: true
auto_apply_labels: true
suggested_reviewers: true
auto_assign_reviewers: true
poem: true
labeling_instructions: []
path_filters: []
path_instructions: []
abort_on_close: true
disable_cache: false
auto_review:
enabled: true
auto_incremental_review: true
ignore_title_keywords: []
labels: []
drafts: true
base_branches: []
finishing_touches:
docstrings:
enabled: true
unit_tests:
enabled: true
tools:
ast-grep:
rule_dirs: []
util_dirs: []
essential_rules: true
packages: []
shellcheck:
enabled: true
ruff:
enabled: true
markdownlint:
enabled: true
github-checks:
enabled: true
timeout_ms: 90000
languagetool:
enabled: true
enabled_rules: []
disabled_rules: []
enabled_categories: []
disabled_categories: []
enabled_only: false
level: default
biome:
enabled: true
hadolint:
enabled: true
swiftlint:
enabled: true
phpstan:
enabled: true
level: default
golangci-lint:
enabled: true
yamllint:
enabled: true
gitleaks:
enabled: true
checkov:
enabled: true
detekt:
enabled: true
eslint:
enabled: true
rubocop:
enabled: true
buf:
enabled: true
regal:
enabled: true
actionlint:
enabled: true
pmd:
enabled: true
cppcheck:
enabled: true
semgrep:
enabled: true
circleci:
enabled: true
clippy:
enabled: true
sqlfluff:
enabled: true
prismaLint:
enabled: true
pylint:
enabled: true
oxc:
enabled: true
shopifyThemeCheck:
enabled: true
luacheck:
enabled: true
brakeman:
enabled: true
chat:
auto_reply: true
integrations:
jira:
usage: auto
linear:
usage: auto
knowledge_base:
opt_out: false
web_search:
enabled: true
learnings:
scope: auto
issues:
scope: auto
jira:
usage: auto
project_keys: []
linear:
usage: auto
team_keys: []
pull_requests:
scope: auto
code_generation:
docstrings:
language: en-US
path_instructions: []
unit_tests:
path_instructions: []
|
Summary by CodeRabbit
New Features
Bug Fixes
Chores
.gitignorerules to better handle vendor directories at all levels.Refactor