-
Notifications
You must be signed in to change notification settings - Fork 3
chore: remove framework dependency #62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
WalkthroughThis pull request migrates the codebase from the Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ 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. Comment |
There was a problem hiding this 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
⛔ Files ignored due to path filters (1)
composer.lockis excluded by!**/*.lock
📒 Files selected for processing (3)
composer.jsonsrc/Queue/Job.phpsrc/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/serversversion 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.
| use Utopia\Servers\Hook; | ||
|
|
||
| class Job extends Hook |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
find . -name "*.php" -type f | head -20Repository: utopia-php/queue
Length of output: 641
🏁 Script executed:
# Search for Hook class definition in the current repository
rg -n "class Hook" --type phpRepository: utopia-php/queue
Length of output: 42
🏁 Script executed:
# Search for references to Utopia\Hook and Utopia\Servers\Hook
rg -n "Utopia.*Hook" --type phpRepository: 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.phpRepository: utopia-php/queue
Length of output: 948
🏁 Script executed:
# Check Server.php mentioned in the review comment
fd "Server.php" --type fRepository: 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.phpRepository: 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.phpRepository: 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 -50Repository: 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.phpRepository: 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 phpRepository: 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 -20Repository: 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 -20Repository: 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.phpRepository: 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 -30Repository: 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.phpRepository: 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.phpRepository: 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/nullRepository: 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 phpRepository: 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.phpRepository: 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.phpRepository: 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 -iRepository: 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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
cd /
find . -name "Server.php" -path "*/Queue/*" 2>/dev/null | head -5Repository: 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
fiRepository: 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 -10Repository: 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 -5Repository: utopia-php/queue
Length of output: 42
🏁 Script executed:
cat -n ./vendor/utopia-php/servers/src/Servers/Hook.phpRepository: 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 -10Repository: 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()).
| // TODO: Get injections doesn't exist on Utopia\Servers\Hook | ||
| foreach ($hook->getInjections() as $key => $injection) { | ||
| $arguments[$injection['order']] = $this->getResource($injection['name']); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
- Check if the new Hook class has an alternative method for accessing injections (e.g., different naming or API pattern)
- Refactor the injection mechanism to work with the new Hook API
- Request the feature be added to
utopia-php/serversif it's missing - 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.
Summary by CodeRabbit
Refactor
Chores
✏️ Tip: You can customize this high-level summary in your review settings.