Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
12 changes: 6 additions & 6 deletions autoload.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class Autoload
*
* @return bool
*/
public static function load($className)
public static function load(string $className)
{
// Include the composer autoloader if there is one, but re-register it
// so this autoloader runs before the composer one as we need to include
Expand Down Expand Up @@ -151,7 +151,7 @@ public static function load($className)
*
* @return string The fully qualified name of the class in the loaded file.
*/
public static function loadFile($path)
public static function loadFile(string $path)
{
if (strpos(__DIR__, 'phar://') !== 0) {
$path = realpath($path);
Expand Down Expand Up @@ -195,7 +195,7 @@ public static function loadFile($path)
*
* @return string The fully qualified name of the class in the loaded file.
*/
public static function determineLoadedClass($classesBeforeLoad, $classesAfterLoad)
public static function determineLoadedClass(array $classesBeforeLoad, array $classesAfterLoad)
{
$className = null;

Expand Down Expand Up @@ -256,7 +256,7 @@ static function ($remaining, $current) {
*
* @return void
*/
public static function addSearchPath($path, $nsPrefix='')
public static function addSearchPath(string $path, string $nsPrefix='')
{
self::$searchPaths[$path] = rtrim(trim((string) $nsPrefix), '\\');

Expand All @@ -283,7 +283,7 @@ public static function getSearchPaths()
* @throws \Exception If the file path has not been loaded.
* @return string
*/
public static function getLoadedClassName($path)
public static function getLoadedClassName(string $path)
{
if (isset(self::$loadedClasses[$path]) === false) {
throw new Exception("Cannot get class name for $path; file has not been included");
Expand All @@ -302,7 +302,7 @@ public static function getLoadedClassName($path)
* @throws \Exception If the class name has not been loaded.
* @return string
*/
public static function getLoadedFileName($className)
public static function getLoadedFileName(string $className)
{
if (isset(self::$loadedFiles[$className]) === false) {
throw new Exception("Cannot get file name for $className; class has not been included");
Expand Down
2 changes: 1 addition & 1 deletion scripts/build-phar.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
*
* @throws \PHP_CodeSniffer\Exceptions\RuntimeException When tokenizer errors are encountered.
*/
function stripWhitespaceAndComments($fullpath, $config)
function stripWhitespaceAndComments(string $fullpath, Config $config)
{
$contents = file_get_contents($fullpath);

Expand Down
36 changes: 18 additions & 18 deletions src/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ class Config
* @return mixed
* @throws \PHP_CodeSniffer\Exceptions\RuntimeException If the setting name is invalid.
*/
public function __get($name)
public function __get(string $name)
{
if (array_key_exists($name, $this->settings) === false) {
throw new RuntimeException("ERROR: unable to get value of property \"$name\"");
Expand Down Expand Up @@ -288,7 +288,7 @@ public function __get($name)
* @return void
* @throws \PHP_CodeSniffer\Exceptions\RuntimeException If the setting name is invalid.
*/
public function __set($name, $value)
public function __set(string $name, $value)
{
if (array_key_exists($name, $this->settings) === false) {
throw new RuntimeException("Can't __set() $name; setting doesn't exist");
Expand Down Expand Up @@ -359,7 +359,7 @@ public function __set($name, $value)
*
* @return bool
*/
public function __isset($name)
public function __isset(string $name)
{
return isset($this->settings[$name]);

Expand All @@ -373,7 +373,7 @@ public function __isset($name)
*
* @return void
*/
public function __unset($name)
public function __unset(string $name)
{
$this->settings[$name] = null;

Expand All @@ -399,7 +399,7 @@ public function getSettings()
*
* @return void
*/
public function setSettings($settings)
public function setSettings(array $settings)
{
$this->settings = $settings;

Expand All @@ -415,7 +415,7 @@ public function setSettings($settings)
*
* @return void
*/
public function __construct(array $cliArgs=[], $dieOnUnknownArg=true)
public function __construct(array $cliArgs=[], bool $dieOnUnknownArg=true)
{
if (defined('PHP_CODESNIFFER_IN_TESTS') === true) {
// Let everything through during testing so that we can
Expand Down Expand Up @@ -498,7 +498,7 @@ public function __construct(array $cliArgs=[], $dieOnUnknownArg=true)
*
* @return void
*/
public function setCommandLineValues($args)
public function setCommandLineValues(array $args)
{
$this->cliArgs = $args;
$numArgs = count($args);
Expand Down Expand Up @@ -675,7 +675,7 @@ public function restoreDefaults()
* @return void
* @throws \PHP_CodeSniffer\Exceptions\DeepExitException
*/
public function processShortArgument($arg, $pos)
public function processShortArgument(string $arg, int $pos)
{
switch ($arg) {
case 'h':
Expand Down Expand Up @@ -787,7 +787,7 @@ public function processShortArgument($arg, $pos)
* @return void
* @throws \PHP_CodeSniffer\Exceptions\DeepExitException
*/
public function processLongArgument($arg, $pos)
public function processLongArgument(string $arg, int $pos)
{
switch ($arg) {
case 'help':
Expand Down Expand Up @@ -1319,7 +1319,7 @@ public function processLongArgument($arg, $pos)
* @return array<string>
* @throws \PHP_CodeSniffer\Exceptions\DeepExitException When any of the provided codes are not valid as sniff codes.
*/
private function parseSniffCodes($input, $argument)
private function parseSniffCodes(string $input, string $argument)
{
$errors = [];
$sniffs = [];
Expand Down Expand Up @@ -1408,7 +1408,7 @@ static function ($carry, $item) {
* @return void
* @throws \PHP_CodeSniffer\Exceptions\DeepExitException
*/
public function processUnknownArgument($arg, $pos)
public function processUnknownArgument(string $arg, int $pos)
{
// We don't know about any additional switches; just files.
if ($arg[0] === '-') {
Expand All @@ -1434,7 +1434,7 @@ public function processUnknownArgument($arg, $pos)
* @return void
* @throws \PHP_CodeSniffer\Exceptions\DeepExitException
*/
public function processFilePath($path)
public function processFilePath(string $path)
{
// If we are processing STDIN, don't record any files to check.
if ($this->stdin === true) {
Expand Down Expand Up @@ -1490,7 +1490,7 @@ public function printUsage()
*
* @return string|void
*/
public function printShortUsage($returnOutput=false)
public function printShortUsage(bool $returnOutput=false)
{
if (PHP_CODESNIFFER_CBF === true) {
$usage = 'Run "phpcbf --help" for usage information';
Expand Down Expand Up @@ -1560,7 +1560,7 @@ public function printPHPCBFUsage()
* @see setConfigData()
* @see getAllConfigData()
*/
public static function getConfigData($key)
public static function getConfigData(string $key)
{
$phpCodeSnifferConfig = self::getAllConfigData();

Expand All @@ -1585,7 +1585,7 @@ public static function getConfigData($key)
* @return string|null
* @see getConfigData()
*/
public static function getExecutablePath($name)
public static function getExecutablePath(string $name)
{
$data = self::getConfigData($name.'_path');
if ($data !== null) {
Expand Down Expand Up @@ -1633,7 +1633,7 @@ public static function getExecutablePath($name)
* @see getConfigData()
* @throws \PHP_CodeSniffer\Exceptions\DeepExitException If the config file can not be written.
*/
public function setConfigData($key, $value, $temp=false)
public function setConfigData(string $key, ?string $value, bool $temp=false)
{
if (isset($this->overriddenDefaults['runtime-set']) === true
&& isset($this->overriddenDefaults['runtime-set'][$key]) === true
Expand Down Expand Up @@ -1749,7 +1749,7 @@ public static function getAllConfigData()
*
* @return string
*/
public function prepareConfigDataForDisplay($data)
public function prepareConfigDataForDisplay(array $data)
{
if (empty($data) === true) {
return '';
Expand Down Expand Up @@ -1786,7 +1786,7 @@ public function prepareConfigDataForDisplay($data)
*
* @return void
*/
public function printConfigData($data)
public function printConfigData(array $data)
{
echo $this->prepareConfigDataForDisplay($data);

Expand Down
12 changes: 9 additions & 3 deletions src/Files/DummyFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class DummyFile extends File
*
* @return void
*/
public function __construct($content, Ruleset $ruleset, Config $config)
public function __construct(string $content, Ruleset $ruleset, Config $config)
{
$this->setContent($content);

Expand Down Expand Up @@ -71,8 +71,14 @@ public function __construct($content, Ruleset $ruleset, Config $config)
*
* @return void
*/
public function setErrorCounts($errorCount, $warningCount, $fixableErrorCount, $fixableWarningCount, $fixedErrorCount, $fixedWarningCount)
{
public function setErrorCounts(
int $errorCount,
int $warningCount,
int $fixableErrorCount,
int $fixableWarningCount,
int $fixedErrorCount,
int $fixedWarningCount
) {
$this->errorCount = $errorCount;
$this->warningCount = $warningCount;
$this->fixableErrorCount = $fixableErrorCount;
Expand Down
Loading
Loading