-
Notifications
You must be signed in to change notification settings - Fork 194
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
Not valid PHP namespaces #637
Comments
I don't have much experience with PHP — cc @markbook2 — any chance you could take a look at this one? Otherwise, @Ralle, can I ask you to add contribute some test into our test repo that clearly demonstrates the problem, or explain how to reproduce it? |
First of all, on this line: You need to check if As you cannot change namespace during a file, I think you have to make it so if You can reproduce it by putting a type in |
@Ralle Please provide the expected PHP code and fragment of the generated invalid PHP code. The 10-20 lines will be enough I think. Thanks. |
namespace \DosMz; should be namespace DosMz; |
@GreyCat namespace \Foo\Bar\Baz; should be replaced with: namespace Foo\Bar\Baz; It should be done only for the namespace definition. |
This is not true. Just open generated code of any passing PHP test with some subtypes (e.g. NestedTypes). It's absolutely possible to define multiple namespaces in the same PHP file, although it's illegal to mix namespaced code and non-namespaced when using "semicolon syntax". Actually, if you compile the NestedTypes format with no specified PHP namespace, it produces a code with this structure: class NestedTypes {}
namespace NestedTypes {
class SubtypeA {}
class SubtypeB {}
}
namespace NestedTypes\SubtypeA {
class SubtypeC {}
} The So I had to convert all namespace definitions to bracketed to make this work. I ran all tests locally for PHP, only had to fix enums declaration, but I think everything seems fine. Could you have a look, @GreyCat? |
I am getting a lot of errors from the PHP generated by kaitai.
On that line is this:
The first bug here is that the
namespace
construct always comes with an absolute namespace, so the \ does not make sense.When removing the \ you get this:
In PHP you want the namespace before everything else. Moving the
namespace
to the first line fixes it.The only problem now is that the main object,
FunctionInfo
is now in theFunctionInfo
namespace. So the fix here is to change all references to it (inside the same file to justFunctionInfo
instead of\FunctionInfo
.But in other files that refer to
FunctionInfo
, we want them to either have this in the top just after the namespace:or refer to it as \FunctionInfo\FunctionInfo unless they have the same namespace.
The text was updated successfully, but these errors were encountered: