for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/*
* This file is part of Laravel Service Provider.
*
* (c) DraperStudio <[email protected]>
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace DraperStudio\ServiceProvider;
trait FilesTrait
{
/**
* @param $file
* @return string
protected function getFileName($file)
$file = basename($file);
if (!ends_with($file, '.php')) {
$file = $file.'.php';
}
return $file;
* Get the target destination path for the files.
* @param string $package
$package
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter $italy is not defined by the method finale(...).
$italy
finale(...)
/** * @param array $germany * @param array $island * @param array $italy */ function finale($germany, $island) { return "2:1"; }
The most likely cause is that the parameter was removed, but the annotation was not.
protected function getDestinationPath($type, $args)
return vsprintf($this->paths[$type]['dest'], $args);
paths
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
class MyClass { } $x = new MyClass(); $x->foo = true;
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:
class MyClass { public $foo; } $x = new MyClass(); $x->foo = true;
* @param $type
* @param $files
* @return array
protected function getSourceFiles($path)
$files = [];
foreach (glob($path.'/*.php') as $file) {
$files[] = $file;
return $files;
* @param $path
* @return mixed
protected function getClassFromFile($path)
$count = count($tokens = token_get_all(file_get_contents($path)));
for ($i = 2; $i < $count; ++$i) {
if ($tokens[$i - 2][0] == T_CLASS && $tokens[$i - 1][0] == T_WHITESPACE && $tokens[$i][0] == T_STRING) {
return $tokens[$i][1];
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italy
is not defined by the methodfinale(...)
.The most likely cause is that the parameter was removed, but the annotation was not.