feat: Add method to manage withRouting options#61
Conversation
# Conflicts: # src/Visitors/PropertyVisitors/AbstractPropertyVisitor.php
…rate-withSchedule
…rate-withSchedule # Conflicts: # src/Visitors/AppBootstrapVisitors/AbstractAppBootstrapVisitor.php
There was a problem hiding this comment.
💡 Codex Review
The generic parent-node rewrite path still runs on any method named withExceptions/withSchedule/withRouting, even when that call is not part of an Application::configure(...)->...->create() chain. In bootstrap/app.php files that contain another object with a same-named method (for example helper builders or factories), this visitor will mutate the unrelated call as well, which can silently alter behavior and produce incorrect generated code. Add the same bootstrap-chain guard used in the create branch before calling insertNode() on existing parent calls.
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2e17f0f21d
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
…te-addRoutingOption-method
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c80678846b
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| public string $method, | ||
| public array $arguments = [], | ||
| ) { | ||
| $this->validateMethod($this->method); |
There was a problem hiding this comment.
Validate ScheduleOption argument arity during construction
ScheduleOption currently validates only method names, so options with required parameters can be constructed with empty arguments (e.g., new ScheduleOption('dailyAt') or new ScheduleOption('between')). The generator then emits calls like ->dailyAt() that are syntactically valid but fail with ArgumentCountError when Laravel evaluates the schedule callback. Adding required-parameter validation here would prevent generating broken bootstrap code.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
The library is responsible for generating syntactically valid code, not for enforcing Laravel's runtime contracts. Ensuring correct arguments is the caller's responsibility, just as with any code generation tool.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0609ce7fbf
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f90a7991f2
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5d9abb8a46
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
When the bootstrap file contains any other fluent call named withRouting, withSchedule, or withExceptions, this branch still updates that unrelated call because only the create() insertion path is guarded by isApplicationBootstrapChain(). For example, addRoutingOption('health', ...) will rewrite an $other->withRouting(...) call in the same file before/alongside the real Application::configure(...)->create() chain. Please apply the same chain check before calling insertNode() so unrelated builders are not mutated.
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 043fac8155
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
|
||
| protected function parsePHPCode(string $code): array | ||
| { | ||
| $nodes = new ParserFactory()->createForHostVersion()->parse("<?php\n{$code};"); |
There was a problem hiding this comment.
Preserve InvalidPHPCodeException for bad snippets
When a caller passes invalid preformatted code, for example an invalid renderBody to addExceptionsRender(), this shared parser now lets PhpParser\Error escape instead of translating it to the package's InvalidPHPCodeException as PreformattedCode did before. That breaks the public error contract and the existing invalid-body test/callers that catch InvalidPHPCodeException; wrap this parse in the same catch before returning the nodes.
Useful? React with 👍 / 👎.
| ); | ||
|
|
||
| foreach ($this->options as $option) { | ||
| $arguments = array_map(fn ($argument) => new Arg(NodeValueFactory::make($argument)->node), $option->arguments); |
There was a problem hiding this comment.
Emit callback option arguments as expressions
Fresh evidence beyond the earlier thread is that this version maps every schedule option argument through NodeValueFactory::make(), whose string branch builds a string literal, so raw snippets are not inserted as raw code. With new ScheduleOption('when', ['fn () => User::count() > 0']), the generated bootstrap contains ->when('fn () => User::count() > 0'); callback-based scheduler options such as when/skip then receive a non-callable string instead of the closure expression when the schedule is evaluated.
Useful? React with 👍 / 👎.
refs: #62