for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* Copyright MediaCT. All rights reserved.
* https://www.mediact.nl
*/
namespace Mediact\CodingStandard;
use PHP_CodeSniffer\Files\File;
trait FunctionTrait
{
* Get a function name.
*
* @param File $file
* @param int $functionIndex
* @return bool|string
protected function getFunctionName(File $file, $functionIndex)
$index = $this->findFunctionNameIndex($file, $functionIndex);
return $index
? $file->getTokens()[$index]['content']
: false;
}
* Find the function name index.
* @return bool|int
protected function findFunctionNameIndex(File $file, $functionIndex)
return $file->findNext([T_STRING], $functionIndex);
* Find the start of a function body.
protected function findFunctionBodyStartIndex(File $file, $functionIndex)
return $file->findNext([T_SEMICOLON, T_OPEN_CURLY_BRACKET], $functionIndex);