| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  * RoboFile.php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  * NOTICE OF LICENSE | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |  * This source file is subject to the Open Software License (OSL 3.0) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |  * that is available through the world-wide-web at this URL: | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |  * http://opensource.org/licenses/osl-3.0.php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |  * PHP version 5 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  |  * @author    Tim Wagner <[email protected]> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |  * @copyright 2016 TechDivision GmbH <[email protected]> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |  * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |  * @link      https://github.com/techdivision/import-category | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |  * @link      http://www.techdivision.com | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  | use Lurker\Event\FilesystemEvent; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  | use Symfony\Component\Finder\Finder; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |  * Defines the available build tasks. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |  * @author    Tim Wagner <[email protected]> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |  * @copyright 2016 TechDivision GmbH <[email protected]> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |  * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |  * @link      https://github.com/techdivision/import-category | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |  * @link      http://www.techdivision.com | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |  * @SuppressWarnings(PHPMD) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  | class RoboFile extends \Robo\Tasks | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |      * The build properties. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |      * @var array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |     protected $properties = array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |         'base.dir' => __DIR__, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |         'src.dir' => __DIR__ . '/src', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |         'dist.dir' => __DIR__ . '/dist', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |         'vendor.dir' => __DIR__ . '/vendor', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |         'target.dir' => __DIR__ . '/target' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |     ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |      * Run's the composer install command. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |      * @return \Robo\Result The result | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |     public function composerInstall() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |         // optimize autoloader with custom path | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |         return $this->taskComposerInstall() | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |              ->preferDist() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |              ->optimizeAutoloader() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |              ->run(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |      * Run's the composer update command. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |      * @return \Robo\Result The result | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |     public function composerUpdate() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |         // optimize autoloader with custom path | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  |         return $this->taskComposerUpdate() | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |              ->preferDist() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  |              ->optimizeAutoloader() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  |              ->run(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  |      * Clean up the environment for a new build. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  |      * @return \Robo\Result The result | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  |     public function clean() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  |         return $this->taskDeleteDir($this->properties['target.dir'])->run(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  |      * Prepare's the environment for a new build. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  |      * @return \Robo\Result The result | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  |     public function prepare() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  |         return $this->taskFileSystemStack() | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  |              ->mkdir($this->properties['dist.dir']) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  |              ->mkdir($this->properties['target.dir']) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  |              ->mkdir(sprintf('%s/reports', $this->properties['target.dir'])) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  |              ->run(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  |      * Run's the PHPMD. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  |      * @return \Robo\Result The result | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  |      */ | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 109 |  | View Code Duplication |     public function runMd() | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 |  |  |         // run the mess detector | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 |  |  |         return $this->_exec( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 |  |  |             sprintf( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 |  |  |                 '%s/bin/phpmd %s xml phpmd.xml --reportfile %s/reports/pmd.xml --ignore-violations-on-exit', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 116 |  |  |                 $this->properties['vendor.dir'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 117 |  |  |                 $this->properties['src.dir'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 118 |  |  |                 $this->properties['target.dir'] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 119 |  |  |             ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 120 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 121 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 122 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 123 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 124 |  |  |      * Run's the PHPCPD. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 125 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 126 |  |  |      * @return \Robo\Result The result | 
            
                                                                                                            
                            
            
                                    
            
            
                | 127 |  |  |      */ | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 128 |  | View Code Duplication |     public function runCpd() | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 129 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 130 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 131 |  |  |         // run the copy past detector | 
            
                                                                                                            
                            
            
                                    
            
            
                | 132 |  |  |         return $this->_exec( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 133 |  |  |             sprintf( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 134 |  |  |                 '%s/bin/phpcpd %s --log-pmd %s/reports/pmd-cpd.xml', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 135 |  |  |                 $this->properties['vendor.dir'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 136 |  |  |                 $this->properties['src.dir'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 137 |  |  |                 $this->properties['target.dir'] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 138 |  |  |             ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 139 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 140 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 141 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 142 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 143 |  |  |      * Run's the PHPCodeSniffer. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 144 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 145 |  |  |      * @return \Robo\Result The result | 
            
                                                                                                            
                            
            
                                    
            
            
                | 146 |  |  |      */ | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 147 |  | View Code Duplication |     public function runCs() | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 148 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 149 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 150 |  |  |         // run the code sniffer | 
            
                                                                                                            
                            
            
                                    
            
            
                | 151 |  |  |         return $this->_exec( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 152 |  |  |             sprintf( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 153 |  |  |                 '%s/bin/phpcs -n --report-full --extensions=php --standard=phpcs.xml --report-checkstyle=%s/reports/phpcs.xml %s', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 154 |  |  |                 $this->properties['vendor.dir'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 155 |  |  |                 $this->properties['target.dir'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 156 |  |  |                 $this->properties['src.dir'] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 157 |  |  |             ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 158 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 159 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 160 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 161 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 162 |  |  |      * Run's the PHPUnit tests. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 163 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 164 |  |  |      * @return \Robo\Result The result | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 165 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 166 |  |  |     public function runTests() | 
            
                                                                        
                            
            
                                    
            
            
                | 167 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 168 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 169 |  |  |         // run PHPUnit | 
            
                                                                        
                            
            
                                    
            
            
                | 170 |  |  |         return $this->taskPHPUnit(sprintf('%s/bin/phpunit', $this->properties['vendor.dir'])) | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 171 |  |  |              ->configFile('phpunit.xml') | 
            
                                                                        
                            
            
                                    
            
            
                | 172 |  |  |              ->run(); | 
            
                                                                        
                            
            
                                    
            
            
                | 173 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 174 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 175 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 176 |  |  |      * The complete build process. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 177 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 178 |  |  |      * @return void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 179 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 180 |  |  |     public function build() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 181 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 182 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 183 |  |  |         // stop the build on first failure of a task | 
            
                                                                                                            
                            
            
                                    
            
            
                | 184 |  |  |         $this->stopOnFail(true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 185 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 186 |  |  |         // process the build | 
            
                                                                                                            
                            
            
                                    
            
            
                | 187 |  |  |         $this->clean(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 188 |  |  |         $this->prepare(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 189 |  |  |         $this->runCs(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 190 |  |  |         $this->runCpd(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 191 |  |  |         $this->runMd(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 192 |  |  |         $this->runTests(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 193 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 194 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 195 |  |  |  | 
            
                        
It seems like the method you are trying to call exists only in some of the possible types.
Let’s take a look at an example:
Available Fixes
Add an additional type-check:
Only allow a single type to be passed if the variable comes from a parameter: