Skip to content
This repository has been archived by the owner on Jun 19, 2019. It is now read-only.

minor updates for psr-2 #28

Merged
merged 1 commit into from
Feb 13, 2014
Merged

minor updates for psr-2 #28

merged 1 commit into from
Feb 13, 2014

Conversation

Gemorroj
Copy link
Contributor

Added newline at end of file (PSR-2 https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md#22-files ), remove ezcPhpGenerator from phpdocs, replace ?> to \r\n in method populateFile

…andards/blob/master/accepted/PSR-2-coding-style-guide.md#22-files ), remove ezcPhpGenerator from phpdocs, replace ?> to \r\n  in method populateFile
@mikaelcom
Copy link
Owner

Thanks for this update. Before validating it, I must update my IDE formatting rules for PHP for this project. What IDE to you use? I'm actually using Zend Studio and it would be great to be able to share the same configuration. if not, I'll learn the PSR-2 specs in order to take them as the formatting rules so it'll be easier to repect these new coding rules

@Gemorroj
Copy link
Contributor Author

@mikaelcom I use PHPStorm (http://www.jetbrains.com/phpstorm/)
It has predefined rules PSR.
phpstorm

@mikaelcom
Copy link
Owner

I would have argued that it would have been great to first ensure we follow the PSR-0 and PSR-1 but it seems the code respects these two first standards. As you seem to be more familiar that me with these standards, would you say that the generator classes/files respect these two first standards? At least, the generator classes/files should respect as much as possible the PSR-* standards.

Then the goal is also to make sure that the generated classes/files respect, as much as possible, these standards. However I must admit it may be more difficult to apply, dynamically, PSR-* standards on generated classes names and properties. Indeed, underscores and particular caracters can be used and pass through the normalizer or break the generated code. Si it can be hard to apply dynamically these standards, however the generator has worked pretty well since a while without having trouble to generate functional classes. What do you think about this last part? I had the idea to create a class that contains the PSR rules in order to generate the classes/files correctly. Maybe it does already exist? if not, maybe it would not be so hard to create it...

Enough of talking, let me know if you have ideas to implement these standards easily and beautifully.

@Gemorroj
Copy link
Contributor Author

@mikaelcom I saw some code formatters, but they did not work very well and very slowly.
I do not think that their application is advisable. The generated code does not quite correspond PSR, but I do not think that this is a problem.
Here is an example of how the IDE formatted getComment method in class WsdlToPhpFunction.
current
psr

The only thing that I find it uncomfortable - it newlines \r\n instead of \n and tabs instead of 4 spaces. PSR recommends using \n and 4 spaces.

@mikaelcom
Copy link
Owner

Reading coding standards on other projects makes me realize that standards can be modified and adapted depending on the project and the developers :).
For example, I would see no objection in using four spaces instead of tab but I'm not a fan of putting the opening braces in the same line of structure control meaning that I personally prefer:

if(true)
{
    // then do what you want
}
else
{
    // then do something else
}

instead of

if (true) {
    // then do what you want
} else {
    // then do something else
}

However, when you talk about using \n instead of \r\n, is it in the generated classes/files or in the generator classes/files? It's easy to update it in the populateFile method for the generated files but for the generator files, I don't see right now how I can to modify it in my IDE. Moreover, it might come from my OS, Windows, so hard to fix. Let me know anyway what your preferences about the newlines code.
The goal is to ease the comparison between modifications, as standards stands for, but without being frustrated when modifying the code and having to use rules that do not fit our usual coding manners.

@Gemorroj
Copy link
Contributor Author

@mikaelcom When upgrading wsdltophp I constantly receive information that some files are modified. In fact, I have not changed anything there. There is speculation that this may be due to line breaks.

composer_update

@mikaelcom
Copy link
Owner

Ok, I found how to modify line endings. I'll get your modifications later today, then I'll apply the configuration of my IDE to see if it fits your modifications.

More generally, I think you can also pass \r\n to \n in the generated files too, meaning in the populateFile method. Can you pull this request too? If it suits you.

Finally, concerning the whole PSR thing, I'll study what you've done and I'll let you know if I have modifications or questions about it. thx

mikaelcom added a commit that referenced this pull request Feb 13, 2014
[MERGE] minor updates for psr-2
@mikaelcom mikaelcom merged commit b8aa6bc into mikaelcom:master Feb 13, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
2 participants