-
Notifications
You must be signed in to change notification settings - Fork 88
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
Encoding check and restructured file loading #122
Conversation
Also some minor refactoring.
On the PS remark, in edifact-generator I return the object (return $this) to allow method chaining. We could do it here as well? the current commit looks good |
If you want to break with that, I'd go one further and remove the The |
Ok let's try! Do you want to be added to the organization? |
…blic methods. Adjusted tests accordingly.
That made the constructor and resetUN*() methods useless.
I've changed the loading methods.
Not sure what you mean. Edit: I just noticed that |
It was required for the Reader::load() method anyway. This also dramatically reduced the memory requirement somehow. The tests wouldn't even complete with less than 5GB of RAM. Less than 1GB needed now.
Fixed that, too. This ok? |
@@ -326,7 +329,7 @@ public function load(string $location): self | |||
* @param string $txt | |||
* @return self | |||
*/ | |||
public function loadString(string &$txt): self | |||
public function loadString(string $txt): self |
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.
This reduced the required memory. Why was this passed by reference? The tests don't seem to care and it only needs 10MB to run them now instead of GBs.
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.
I think because I already had the string loaded in a variable? I don't remember :D
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.
Well, if it was for performance reasons, it's probably not necessary, maybe even harmful: http://schlueters.de/blog/archives/125-Do-not-use-PHP-references.html
Passing by reference disables the copy-on-write PHP default behaviour, which is probably why the memory requirement exploded.
Should parse() return $this? Btw tell me when you think it's complete to merge.. |
I don't really have an opinion on that. But I'm not certain how (if) to handle multiple calls to the loading methods. The This is really getting off-topic from the initial pull request though. :D |
I think I'm done here. I hope I didn't miss something in the process. P.S.: Thanks for the invite, but this account is really a catch-all one that multiple people have access to, and you probably don't want all of them in here. |
I've found a bit of a problem, if you pass the Reader a Parser that had loaded an array. I'll post about it soon. Just a heads up that the current state isn't quite stable. |
See https://www.gefeg.com/jswg/cl/v3/11b/cl1.htm Those are all that are supported in syntax version 3. In v4 there are more: https://www.gefeg.com/jswg/cl/v4x/40219/cl1.htm
As discussed in #82 here's my suggested solution.
I think the check for UNOA and UNOB isn't 100% correct, but it was the best I could find.
The
if(!isset(self::$charsets[$this->syntaxID]))
check might be better as an entry in theerrors
array instead of an exception, but then the actual check wouldn't make any sense, if a different syntaxID is used. Maybe anEdifactException
?Also some minor refactoring, like renaming private stuff to be closer to what they are actually called in EDI lingo.
P.S.: I wouldn't return anything from either
load()
,loadString()
orparse()
. I consider that leaking object state. Especially sinceget()
exists.