StoutLogic / acf-builder

An Advanced Custom Field Configuration Builder
GNU General Public License v2.0
792 stars 60 forks source link

Introduce phpstan and start fixing problems #105

Open szepeviktor opened 4 years ago

szepeviktor commented 4 years ago

Closes #93

@stevep It still needs fixing few errors.

szepeviktor commented 4 years ago

This is the current output. It reveals some wishful thinking: expecting proper input but checking whether it is rubbish.

Analysis gets exciting ✨ and useful on higher Levels.

viktor@mail:~/tmp/acf-builder$ vendor/bin/phpstan analyze
Note: Using configuration file /home/viktor/tmp/acf-builder/phpstan.neon.dist.
 24/24 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%

 ------ -------------------------------
  Line   FieldManager.php
 ------ -------------------------------
  74     Result of && is always false.
 ------ -------------------------------

 ------ --------------------------------------------------------------------------------------------------------------------------------------
  Line   FieldsBuilder.php
 ------ --------------------------------------------------------------------------------------------------------------------------------------
  120    Else branch is unreachable because ternary operator condition is always true.
  146    Method StoutLogic\AcfBuilder\FieldsBuilder::buildLocation() never returns StoutLogic\AcfBuilder\LocationBuilder so it can be removed
         from the return typehint.
  149    Else branch is unreachable because ternary operator condition is always true.
  693    If condition is always true.
  694    Call to an undefined method StoutLogic\AcfBuilder\Builder::setLocation().
  697    Unreachable statement - code above always terminates.
 ------ --------------------------------------------------------------------------------------------------------------------------------------

 ------ -------------------------------------------------------------------------------
  Line   FlexibleContentBuilder.php
 ------ -------------------------------------------------------------------------------
  51     Else branch is unreachable because ternary operator condition is always true.
 ------ -------------------------------------------------------------------------------

 ------ --------------------------------------------------------------------------------------------------------------------
  Line   GroupBuilder.php
 ------ --------------------------------------------------------------------------------------------------------------------
  58     Method StoutLogic\AcfBuilder\GroupBuilder::endGroup() should return StoutLogic\AcfBuilder\FieldBuilder but returns
         StoutLogic\AcfBuilder\Builder.
 ------ --------------------------------------------------------------------------------------------------------------------

 ------ -------------------------------------------------------
  Line   ParentDelegationBuilder.php
 ------ -------------------------------------------------------
  45     If condition is always true.
  52     Unreachable statement - code above always terminates.
  65     If condition is always true.
  69     Unreachable statement - code above always terminates.
 ------ -------------------------------------------------------

 ------ ------------------------------------------------------------------------------------------------------------------
  Line   RepeaterBuilder.php
 ------ ------------------------------------------------------------------------------------------------------------------
  62     Method StoutLogic\AcfBuilder\RepeaterBuilder::end() should return StoutLogic\AcfBuilder\FieldBuilder but returns
         StoutLogic\AcfBuilder\Builder.
 ------ ------------------------------------------------------------------------------------------------------------------
montchr commented 2 months ago

It would be great to have this merged. As an example, from what I can see based on the output in the screenshot, PHPStan would have prevented #166. Is there a particular reason this pull request has not been acknowledged?