php-the-right-way icon indicating copy to clipboard operation
php-the-right-way copied to clipboard

[suggestion] Code quality

Open ftwbzhao opened this issue 10 years ago • 3 comments

ftwbzhao avatar Nov 19 '15 02:11 ftwbzhao

Agreed. Will work on getting this started shortly.

codeguy avatar Jun 20 '18 12:06 codeguy

any update about this ? i think in modern PHP era we should use static analyzers for having a really better code quality. some of the great packagees in this section is :

https://github.com/phpstan/phpstan https://github.com/nunomaduro/larastan https://github.com/vimeo/psalm https://github.com/phan/phan

ariaieboy avatar Nov 26 '21 22:11 ariaieboy

Hi everybody, code quality is a very important topic. It contains so many more aspects than mentioned here before.

For me it starts with an IDE, which provides syntax highlighting. Many of you might not think that there are some people around, which still use an unmodified VIM or editor (windows) or textedit (mac os) without any hinting. But there are! Many! I do not know if you want to mention commercial products besides open source IDE. So I will not go into detail, which IDE I am using to not influence this discussion to one direction.

IDE usually allows plug-ins. They can provide so much more detailed checking than just syntax checking. The plug-in I really really recommend is PHP Inspections EA ( https://github.com/kalessil/phpinspectionsea ). Also PhpClean is on my list ( https://plugins.jetbrains.com/plugin/11272-phpclean ).

The problem with deep code inspection tools in IDE or static analyzers is that it provides good feedback for experienced developers. Beginners might enable all levels and try to fight all notices. By clearing issue by issue beginners might not solve the architectural mistakes behind it. Personally I am struggling with naming a static analyzer "a tool for everybody". They are easy to use - Yes. They provide helpful hints for everybody - Yes. But the conclusion of using a static analyzer cannot be to solve every displayed error without architectural changes.

Here is my recommendation for changes:

  • Add a section "Code Editors" to the chapter "Getting Started"
    • Name a few popular open source editors which provide tools for PHP
    • Name a few popular commercial source editors which are specialized for/in PHP
  • Add a chapter "Code Quality" between chapters "Errors and Exceptions" and "Security" (because code quality has an effect on security, it should appear before security)
    • Plug-ins for IDE, which provide a simple code inspection detecting obvious problems (like an enhanced syntax checker)
    • (Static) Metric analyzers for analyzing code quality and detecting mess
    • (Static) Code analyzers for detecting imperfect code

If you consider these or familiar changes, I would love to support you by writing a draft. What do you think?

JonisoftGermany avatar Jul 10 '22 10:07 JonisoftGermany