Skip to content

Conversation

@loks0n
Copy link
Contributor

@loks0n loks0n commented Jan 6, 2026

Summary by CodeRabbit

  • Refactor

    • Updated core server dependencies to newer versions.
    • Refactored internal hook imports to align with updated dependencies.
  • Chores

    • Dependency management updates to support improved server infrastructure.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Jan 6, 2026

Walkthrough

This pull request migrates the codebase from the utopia-php/framework package to utopia-php/servers. The composer.json dependency is updated to require utopia-php/servers version 0.2.* instead of utopia-php/framework version 0.33.*. Corresponding namespace imports in two Queue-related files are updated to use Hook from the new package location (Utopia\Servers\Hook). A TODO comment is added in src/Queue/Server.php noting a potential compatibility issue regarding injections not existing on the new Hook class.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: removing the utopia-php/framework dependency and replacing it with utopia-php/servers.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Fix all issues with AI Agents
In @src/Queue/Job.php:
- Around line 5-7: The Hook subclass Job extends Utopia\Servers\Hook but the
Hook base no longer provides getInjections(), causing runtime failures; add a
getInjections() method to the Hook class (or to Job if preferred) that returns
the protected $injections property (matching the existing getter style alongside
getParams(), getAction(), getGroups(), setParamValue()), so Server code that
calls getInjections() can retrieve the injections array without error; ensure
the method is public and returns the same type/structure as $injections.

In @src/Queue/Server.php:
- Around line 365-368: The code calls the non-existent Hook::getInjections()
which causes a fatal error; update the loop in Server.php to safely handle the
new utopia-php/servers Hook API by first checking for the correct method or
falling back: inspect the Hook class in the new package to find the equivalent
method (e.g., a method that returns injection/parameter metadata) and replace
$hook->getInjections() with that method; if no equivalent exists, wrap the logic
with a method_exists($hook, 'getInjections') (or the discovered name) guard and
skip or log a warning and/or implement a fallback that resolves injections from
your own hook metadata store, ensuring you still populate
$arguments[$injection['order']] = $this->getResource($injection['name']) only
when valid injection info is available.
- Line 8: Add a public getter on the Hook class named getInjections() that
returns the protected $injections so the call in Server.php (getInjections())
compiles; implement it with the same return type as the injections container
(e.g., array or iterable) and proper visibility, or alternatively update the
Server.php usage to call the existing parent Injection class accessor if one
already exists (use Injection::getInjections() instead of
Hook::getInjections()).
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5cff95b and 76eb28e.

⛔ Files ignored due to path filters (1)
  • composer.lock is excluded by !**/*.lock
📒 Files selected for processing (3)
  • composer.json
  • src/Queue/Job.php
  • src/Queue/Server.php
🧰 Additional context used
🪛 GitHub Actions: CodeQL
src/Queue/Server.php

[error] 366-366: PHPStan error: Call to an undefined method Utopia\Servers\Hook::getInjections(). (src/Queue/Server.php:366). Command 'vendor/bin/phpstan analyse' exited with code 1.

🔇 Additional comments (1)
composer.json (1)

30-30: Update dependency version constraint to an available release.

The package utopia-php/servers version 0.2.* does not exist on Packagist. The latest available version is 0.1.1 (released 2024-09-06). Update the version constraint to "0.1.*" or wait for version 0.2 to be released, as this constraint will cause Composer to fail during installation.

Likely an incorrect or invalid review comment.

Comment on lines +5 to 7
use Utopia\Servers\Hook;

class Job extends Hook
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

find . -name "*.php" -type f | head -20

Repository: utopia-php/queue

Length of output: 641


🏁 Script executed:

# Search for Hook class definition in the current repository
rg -n "class Hook" --type php

Repository: utopia-php/queue

Length of output: 42


🏁 Script executed:

# Search for references to Utopia\Hook and Utopia\Servers\Hook
rg -n "Utopia.*Hook" --type php

Repository: utopia-php/queue

Length of output: 246


🏁 Script executed:

# Check Job.php to see current state and what methods are used
cat -n src/Queue/Job.php

Repository: utopia-php/queue

Length of output: 948


🏁 Script executed:

# Check Server.php mentioned in the review comment
fd "Server.php" --type f

Repository: utopia-php/queue

Length of output: 80


🏁 Script executed:

# Check Server.php around line 365 to see the TODO and actual usage
sed -n '360,375p' src/Queue/Server.php

Repository: utopia-php/queue

Length of output: 521


🏁 Script executed:

# Search for all method calls on Hook or usage patterns in Server.php
rg -n "getInjections|getParams|getAction|getGroups" src/Queue/Server.php

Repository: utopia-php/queue

Length of output: 1768


🏁 Script executed:

# Check if there's any composer.json to see which version of utopia-php/servers is being used
cat -n composer.json | head -50

Repository: utopia-php/queue

Length of output: 1867


🏁 Script executed:

# Check the full context of the getArguments method to see the issue
sed -n '350,375p' src/Queue/Server.php

Repository: utopia-php/queue

Length of output: 930


🏁 Script executed:

# Search for any interface or parent class of Hook in utopia-php/servers
# First, let's see if we can find any info about what Hook class looks like
rg -n "function (getInjections|getParams|getAction|getGroups|setParamValue)" --type php

Repository: utopia-php/queue

Length of output: 42


🏁 Script executed:

# Check if there's a vendor directory or composer.lock to see what version is installed
cat -n composer.lock | grep -A 10 "utopia-php/servers" | head -20

Repository: utopia-php/queue

Length of output: 1008


🌐 Web query:

utopia-php/servers Hook class 0.2.2 github

💡 Result:

I couldn't find a GitHub release or Hook class for utopia-php/servers version 0.2.2. Packagist shows the utopia-php/servers package with versions up to 0.1.1 and links to the repository. [1]

If you want, I can (a) look through the repository files on GitHub for a Hook class, or (b) search other forks or tags for a 0.2.2 release — which would you prefer?

Sources:
[1] Packagist — utopia-php/servers (package details). (packagist.org)

Citations:


🏁 Script executed:

# Look for vendor directory to check if Hook class is available
find . -path "*/vendor/utopia-php/servers/*" -name "*.php" -type f 2>/dev/null | head -20

Repository: utopia-php/queue

Length of output: 474


🏁 Script executed:

# If vendor is not available, check GitHub directly or look for any documentation
# Let's search for any Hook-related code in the current repo to understand the migration
rg -B5 -A10 "TODO.*getInjections" src/Queue/Server.php

Repository: utopia-php/queue

Length of output: 42


🏁 Script executed:

# Check all method calls on the Hook object to understand what API is expected
rg -n "\$hook\->" src/Queue/Server.php | head -30

Repository: utopia-php/queue

Length of output: 42


🏁 Script executed:

# Examine the Hook class in the vendor directory
cat -n ./vendor/utopia-php/servers/src/Servers/Hook.php

Repository: utopia-php/queue

Length of output: 6648


🏁 Script executed:

# Check the full extent of the Hook class to understand all available methods
wc -l ./vendor/utopia-php/servers/src/Servers/Hook.php

Repository: utopia-php/queue

Length of output: 112


🏁 Script executed:

# Check the parent class Injection to see if it has getInjections method
find ./vendor -path "*/utopia-php/di/*" -name "*.php" -type f 2>/dev/null

Repository: utopia-php/queue

Length of output: 239


🏁 Script executed:

# Search for getInjections method in the vendor directory
rg -n "getInjections|function.*Injections" ./vendor/utopia-php/di/ --type php

Repository: utopia-php/queue

Length of output: 42


🏁 Script executed:

# Check if Job class uses any of the potentially missing methods
rg -n "getInjections\|getParams\|getAction\|getGroups\|setParamValue" src/Queue/Job.php

Repository: utopia-php/queue

Length of output: 42


🏁 Script executed:

# Examine the Injection class to see all available methods
cat -n ./vendor/utopia-php/di/src/DI/Injection.php

Repository: utopia-php/queue

Length of output: 2232


🏁 Script executed:

# Search more broadly for "Injections" or "injections" in the DI package
rg -n "injections" ./vendor/utopia-php/di/src/DI/Injection.php -i

Repository: utopia-php/queue

Length of output: 42


The getInjections() method is missing from Utopia\Servers\Hook and will cause a runtime error.

The Hook class defined in utopia-php/servers 0.2.2 has a protected $injections property but no getInjections() method. Server.php calls this non-existent method at line 366, which will fail at runtime despite the TODO comment acknowledging the issue.

The new Hook class supports extension and provides getParams(), getAction(), getGroups(), and setParamValue(), but getInjections() must be added to complete the migration.

🤖 Prompt for AI Agents
In @src/Queue/Job.php around lines 5 - 7, The Hook subclass Job extends
Utopia\Servers\Hook but the Hook base no longer provides getInjections(),
causing runtime failures; add a getInjections() method to the Hook class (or to
Job if preferred) that returns the protected $injections property (matching the
existing getter style alongside getParams(), getAction(), getGroups(),
setParamValue()), so Server code that calls getInjections() can retrieve the
injections array without error; ensure the method is public and returns the same
type/structure as $injections.

use Throwable;
use Utopia\Console;
use Utopia\Hook;
use Utopia\Servers\Hook;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

cd /
find . -name "Server.php" -path "*/Queue/*" 2>/dev/null | head -5

Repository: utopia-php/queue

Length of output: 100


🏁 Script executed:

# First, let's check if the file exists and examine the area around line 366
if [ -f "src/Queue/Server.php" ]; then
  echo "=== Lines 360-370 of Server.php ==="
  sed -n '360,370p' src/Queue/Server.php
  echo ""
  echo "=== All method calls on Hook objects ==="
  rg -nP --type=php '\$\w+Hook->\w+\(' src/Queue/Server.php | head -20
fi

Repository: utopia-php/queue

Length of output: 555


🏁 Script executed:

# Search for the new Hook class definition
find . -path "*/Servers/Hook.php" -o -path "*/Hook.php" 2>/dev/null | grep -i hook | head -10

Repository: utopia-php/queue

Length of output: 158


🏁 Script executed:

# Check what Hook class is being used and look for getInjections method
rg -l "class Hook" --type=php 2>/dev/null | head -5

Repository: utopia-php/queue

Length of output: 42


🏁 Script executed:

cat -n ./vendor/utopia-php/servers/src/Servers/Hook.php

Repository: utopia-php/queue

Length of output: 6648


🏁 Script executed:

# Also check the old Hook implementation if it exists in the codebase
rg -l "getInjections" --type=php 2>/dev/null | head -10

Repository: utopia-php/queue

Length of output: 80


Critical API incompatibility: getInjections() method missing from Hook class.

The Utopia\Servers\Hook class does not have a getInjections() method, but the code calls it at line 366. The TODO comment at line 365 already flags this issue. The Hook class has the data (protected $injections property) but lacks the getter method. Either add getInjections() to the Hook class or refactor the code to access injections through the parent Injection class.

🤖 Prompt for AI Agents
In @src/Queue/Server.php at line 8, Add a public getter on the Hook class named
getInjections() that returns the protected $injections so the call in Server.php
(getInjections()) compiles; implement it with the same return type as the
injections container (e.g., array or iterable) and proper visibility, or
alternatively update the Server.php usage to call the existing parent Injection
class accessor if one already exists (use Injection::getInjections() instead of
Hook::getInjections()).

Comment on lines +365 to 368
// TODO: Get injections doesn't exist on Utopia\Servers\Hook
foreach ($hook->getInjections() as $key => $injection) {
$arguments[$injection['order']] = $this->getResource($injection['name']);
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

Critical: Calling non-existent method getInjections() - blocks PR merge.

The TODO comment acknowledges that getInjections() doesn't exist on Utopia\Servers\Hook, yet the code on line 366 still attempts to call this method. This is confirmed by the PHPStan pipeline failure and will cause a fatal error at runtime.

This makes the PR non-functional and blocks it from being merged. The migration to utopia-php/servers is incomplete.

Possible solutions
  1. Check if the new Hook class has an alternative method for accessing injections (e.g., different naming or API pattern)
  2. Refactor the injection mechanism to work with the new Hook API
  3. Request the feature be added to utopia-php/servers if it's missing
  4. Consider a different dependency injection approach compatible with the new package

Would you like me to help investigate the utopia-php/servers API to find the correct approach, or open an issue to track implementing the proper solution?

🧰 Tools
🪛 GitHub Actions: CodeQL

[error] 366-366: PHPStan error: Call to an undefined method Utopia\Servers\Hook::getInjections(). (src/Queue/Server.php:366). Command 'vendor/bin/phpstan analyse' exited with code 1.

🪛 PHPStan (2.1.33)

366-366: Call to an undefined method Utopia\Servers\Hook::getInjections().

(method.notFound)

🤖 Prompt for AI Agents
In @src/Queue/Server.php around lines 365 - 368, The code calls the non-existent
Hook::getInjections() which causes a fatal error; update the loop in Server.php
to safely handle the new utopia-php/servers Hook API by first checking for the
correct method or falling back: inspect the Hook class in the new package to
find the equivalent method (e.g., a method that returns injection/parameter
metadata) and replace $hook->getInjections() with that method; if no equivalent
exists, wrap the logic with a method_exists($hook, 'getInjections') (or the
discovered name) guard and skip or log a warning and/or implement a fallback
that resolves injections from your own hook metadata store, ensuring you still
populate $arguments[$injection['order']] =
$this->getResource($injection['name']) only when valid injection info is
available.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants