Skip to content

feat: ability print array in multiline format#76

Open
AZabolotnikov wants to merge 3 commits into
add-midlewares-prepend-groupfrom
73-array-formating
Open

feat: ability print array in multiline format#76
AZabolotnikov wants to merge 3 commits into
add-midlewares-prepend-groupfrom
73-array-formating

Conversation

@AZabolotnikov

Copy link
Copy Markdown
Contributor

refs: #73

@AZabolotnikov AZabolotnikov self-assigned this Jun 24, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8fc6e25ea5

ℹ️ 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 findMiddlewareGroupIndex(array $stmts): ?int
{
return array_find_key($stmts, function (Expression $stmt) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Skip non-expression statements while scanning groups

For bootstraps whose withMiddleware closure contains any non-expression statement, such as an if block for environment-specific middleware or another Nop comment/placeholder that remains after the first statement, array_find_key() passes that Stmt into this callback and PHP throws a TypeError because it is typed as Expression. This prevents addMiddlewarePrependToGroup() from saving otherwise valid bootstrap files; mirror shouldInsertNode() by accepting generic statements and skipping anything that is not an Expression.

Useful? React with 👍 / 👎.

{
$middlewareList = $this->getMiddlewareList();

$methodCall = new MethodCall(new Variable('middleware'), new Identifier($this->targetMethod), [

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Use the closure's middleware parameter name

When the existing withMiddleware closure uses a parameter name other than $middleware and the target group does not already have a prependToGroup call, this inserts $middleware->prependToGroup(...) even though that variable is undefined in the generated closure. This makes the resulting bootstrap fail at runtime for valid Laravel code like function (Middleware $m): void { ... }; build the call from the closure parameter variable instead of hard-coding $middleware.

Useful? React with 👍 / 👎.

@AZabolotnikov AZabolotnikov changed the base branch from master to add-midlewares-prepend-group June 24, 2026 15:29
@chatgpt-codex-connector

Copy link
Copy Markdown

💡 Codex Review

$this->traverser->addVisitor(new AddMiddlewarePrependToGroup($group, $middlewares, $position));

P2 Badge Preserve chained middleware order

When callers chain multiple default addMiddlewarePrependToGroup() calls for the same group, each call registers a separate order-sensitive visitor here, but NodeTraverser::traverse() reverses visitor execution (src/NodeTraverser.php:12). For example, adding 'a' and then 'b' to an empty api group with the default End position produces ['b', 'a'], which changes middleware execution order from the order requested by the builder chain.


return $originalName === $newMiddleware
|| $originalName === class_basename($newMiddleware);

P2 Badge Avoid de-duplicating different classes by basename

If an existing group contains an imported short class such as Authenticate::class and the caller adds a different FQCN with the same basename, this basename comparison treats them as the same middleware and filters the new one out. Middleware classes from different namespaces can share basenames, so this can silently omit the requested middleware while addMiddlewarePrependToGroup() still queues an import for it.

ℹ️ 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".

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.

1 participant