feat: Implement setNamespace method#65
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 94ee5d5fdb
ℹ️ 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".
Coverage Report for CI Build 25510203956Coverage increased (+0.06%) to 98.615%Details
Uncovered ChangesNo uncovered changes found. Coverage RegressionsNo coverage regressions found. Coverage Stats
💛 - Coveralls |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f34e2fb06a
ℹ️ 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".
| { | ||
| foreach ($nodes as $node) { | ||
| if ($node instanceof Namespace_) { | ||
| if ($node->name->toString() === $this->namespace) { |
There was a problem hiding this comment.
Handle anonymous namespace node before comparing names
Guard this comparison against Namespace_ nodes whose name is null (for example, files using namespace { ... } global blocks). In that case, calling toString() throws at runtime, so setNamespace() crashes instead of rewriting the file. This regression is input-dependent but affects valid PHP files that parse to anonymous namespace nodes.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Anonymous namespaces cannot be PSR-4 autoloaded, so this case is intentionally not supported.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b3631d2807
ℹ️ 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".
| if ($node instanceof Declare_) { | ||
| $declares[] = $node; | ||
|
|
||
| unset($nodes[$key]); |
There was a problem hiding this comment.
Restrict declare hoisting to leading strict_types
The new namespace insertion path hoists every top-level declare out of its original position before wrapping the rest of the file in namespace ...;. This changes runtime behavior for valid files that use non-strict_types declares (for example declare(ticks=1);) after some statements, because the directive is now applied from the top of the script. To avoid semantic changes, only preserve leading declare(strict_types=1) (or otherwise reject unsupported declare layouts) instead of relocating all Declare_ nodes.
Useful? React with 👍 / 👎.
No description provided.