PrestaShop/PrestaShop — pull request #418 by e-gaulue (2013-05-02 08:59:39+00:00)
Title: [*] Project : improve the way module override are added and removed

# In short
Allow multiline properties overrides and is more syntax permissive than previous one. Don't put comments in override files.

# The long story
Overriding the $definition of the Address Class I got an error message each time I was reinitializating my module. At first, the solution I found was to remove the files in the override directory and then to install module again. Until I decided to look in the code.

* I understood it was due to the fact it didn't deal with multiline properties.
* Looking deeper, I also saw it couldn't handle this kind of code:

```
Class Address extends AddressCore {
function a
```
or
```
Class Address extends AddressCore

{
function a
```
because using $method->getEndLine() and $method->getStartLine() is dangerous.

* Finally, I found that my comments where not removed from the override files.

# The patch

First I tried to find a way to just allow multiline properties but it's really hard to find the last good ';' of the line. So I did a complete change but not so far than current one.

The idea is to add a mark through a comment at the beginning and at the end of all code coming from a module. This way it will be easy to remove this override code removing everything between those 2 marks.

So, once the methods and properties of the module override have been checked so it can be installed we:
1. Take the code
2. Remove all comments
3. Look for the first '{' and do the job
4. Look for the last '}' and do the job
5. Put the result in the override file

# Retro compatibility

We also need to handle overrides that have been installed with no marks (the previous way) to ensure compatibility. So if marks are not found, we remove the methods and properties the old way.