2017 © Pedro Peláez
 

library get-set-annotations

Helper for the GetSetTrait

image

angelxmoreno/get-set-annotations

Helper for the GetSetTrait

  • Friday, May 25, 2018
  • by angelxmoreno
  • Repository
  • 1 Watchers
  • 0 Stars
  • 103 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 5 Versions
  • 140 % Grown

The README.md

GetSet Methods Annotation

A CLI script for reporting missing getter/setter methods due to the use of magic methods., (*1)

License Total Downloads Latest Stable Version Build Status Codacy Badge Maintainability Test Coverage, (*2)

Why this project?

I really enjoy using the GetSetTrait provided by mikebarlow. One of the issues with using magic getters and setters is that most IDEs lose knowledge about the class methods available. This can easily be addressed by adding proper @method entries to the class doc blocks. This can sometimes prove to be time consuming and open to typos., (*3)

I created this CLI script to generate the @method entries for classes missing defined getters/setters. Thought it was created to support the GetSetTrait, it can be used for any implementation of magic getters and setters, (*4)

Installation

composer require --dev angelxmoreno/get-set-annotations

Usage

./bin/get-set-scan [directory]

This prints out a report similar to the following:, (*5)

Classname : Axm\GetSetAnnotations\ClassInfo
Path : /Users/amoreno/Projects/AmzRouter/get-set-methods-annotation/src/ClassInfo.php
DocBlock : 
* @method void setPath(string $path)
* @method void setFqn(string $fqn)
* @method void setProperties(PropertyInfo[] $properties)
* @method void setHasMissingMethods(bool $has_missing_methods)
* @method bool getHasMissingMethods()

Testing

tests can be run in two different ways; locally and using a docker container., (*6)

Locally

composer tests:check
composer tests:coverage

Using the built-in docker image

composer docker:tests:check
composer docker:tests:coverage

Current test coverage

Coverage Summary
----------------
                                                        Lines            %

 \                                                     45 / 71      63.38%
└── Axm\                                               45 / 71      63.38%
   └── GetSetAnnotations\                              45 / 71      63.38%
      ├── Analyser                                      7 /  7     100.00%
      │  ├── Analyser::buildClassInfosInPath()          6 /  6     100.00%
      │  └── Analyser::path()                           1 /  1     100.00%
      ├── CamelCase                                     2 /  3      66.67%
      │  └── CamelCase::convert()                       2 /  3      66.67%
      ├── ClassInfo                                    22 / 29      75.86%
      │  ├── ClassInfo::__construct()                   5 /  5     100.00%
      │  ├── ClassInfo::buildCurrentDocMethods()        2 /  2     100.00%
      │  ├── ClassInfo::buildMissingMethodsDoc()        0 /  7       0.00%
      │  ├── ClassInfo::buildPropertyInfoArray()       11 / 11     100.00%
      │  ├── ClassInfo::getFqn()                        1 /  1     100.00%
      │  ├── ClassInfo::getPath()                       1 /  1     100.00%
      │  ├── ClassInfo::getProperties()                 1 /  1     100.00%
      │  └── ClassInfo::hasMissingMethods()             1 /  1     100.00%
      ├── PropertyInfo                                 14 / 14     100.00%
      │  ├── PropertyInfo::__construct()                8 /  8     100.00%
      │  ├── PropertyInfo::getGetterFuncName()          1 /  1     100.00%
      │  ├── PropertyInfo::getName()                    1 /  1     100.00%
      │  ├── PropertyInfo::getSetterFuncName()          1 /  1     100.00%
      │  ├── PropertyInfo::getType()                    1 /  1     100.00%
      │  ├── PropertyInfo::isMissingGetterMethod()      1 /  1     100.00%
      │  └── PropertyInfo::isMissingSetterMethod()      1 /  1     100.00%
      └── Writer                                        0 / 18       0.00%
         ├── Writer::__construct()                      0 /  4       0.00%
         ├── Writer::outCli()                           0 /  3       0.00%
         ├── Writer::toCli()                            0 /  6       0.00%
         └── Writer::writeToFile()                      0 /  5       0.00%

Total: 63.38% (45/71)

Coverage collected in 0.069 seconds

License

Copyright 2022 Angel S. Moreno (angelxmoreno). All rights reserved., (*7)

Licensed under the MIT License. Redistributions of the source code included in this repository must retain the copyright notice found in each file., (*8)

The Versions