1
0
mirror of https://github.com/danog/psalm.git synced 2025-01-21 21:31:13 +01:00

Improve formatting

This commit is contained in:
Matthew Brown 2017-05-24 22:07:49 -04:00
parent 42b435e23f
commit 4fd46e1752
40 changed files with 128 additions and 99 deletions

View File

@ -7,7 +7,7 @@ use Psalm\StatementsSource;
class ClassChecker extends ClassLikeChecker
{
/**
* @var integer
* @var int
*/
protected static $anonymous_class_count = 0;

View File

@ -743,7 +743,7 @@ abstract class ClassLikeChecker extends SourceChecker implements StatementsSourc
* @param StatementsSource $source
* @param Context $class_context
* @param Context|null $global_context
* @param boolean $update_docblocks
* @param bool $update_docblocks
* @return MethodChecker|null
*/
private function analyzeClassMethod(
@ -1979,7 +1979,7 @@ abstract class ClassLikeChecker extends SourceChecker implements StatementsSourc
/**
* @param string $fq_class_name
* @return boolean
* @return bool
*/
public static function isUserDefined($fq_class_name)
{
@ -2000,7 +2000,7 @@ abstract class ClassLikeChecker extends SourceChecker implements StatementsSourc
}
/** @var array<string, array<string, string>> */
$property_map = require_once(__DIR__.'/../PropertyMap.php');
$property_map = require_once(__DIR__ . '/../PropertyMap.php');
self::$property_map = [];

View File

@ -399,7 +399,7 @@ class CommentChecker
$last = false;
} elseif ($last !== false) {
$old_last_line = $lines[$last];
$lines[$last] = rtrim($old_last_line) .' '. trim($line);
$lines[$last] = rtrim($old_last_line) . ' ' . trim($line);
if ($line_number) {
$old_line_number = $line_map[$old_last_line];

View File

@ -247,8 +247,8 @@ class FileChecker extends SourceChecker implements StatementsSource
}
/**
* @param boolean $update_docblocks
* @param boolean $preserve_checkers
* @param bool $update_docblocks
* @param bool $preserve_checkers
* @return void
*/
public function analyze($update_docblocks = false, $preserve_checkers = false)
@ -378,7 +378,7 @@ class FileChecker extends SourceChecker implements StatementsSource
/**
* @param Context|null $file_context
* @param boolean $update_docblocks
* @param bool $update_docblocks
* @return void
*/
public function visitAndAnalyzeMethods(Context $file_context = null, $update_docblocks = false)

View File

@ -48,7 +48,7 @@ class FunctionChecker extends FunctionLikeChecker
/**
* @param string $function_id
* @param string $file_path
* @return boolean
* @return bool
*/
public static function functionExists($function_id, $file_path)
{
@ -104,7 +104,7 @@ class FunctionChecker extends FunctionLikeChecker
/**
* @param string $function_id
* @param string $file_path
* @return boolean
* @return bool
*/
public static function isVariadic($function_id, $file_path)
{
@ -459,7 +459,7 @@ class FunctionChecker extends FunctionLikeChecker
$inner_type = $first_arg_array->type_params[1];
$key_type = clone $first_arg_array->type_params[0];
} else {
$inner_type = $first_arg_array->getGenericTypeParam();
$inner_type = $first_arg_array->getGenericTypeParam();
$key_type = Type::getString();
}
@ -529,6 +529,7 @@ class FunctionChecker extends FunctionLikeChecker
if ($call_map_key === 'array_map') {
$inner_type = clone $closure_return_type;
return new Type\Union([
new Type\Atomic\TArray([
$key_type,
@ -539,6 +540,7 @@ class FunctionChecker extends FunctionLikeChecker
if ($array_arg_type) {
$inner_type = clone $array_arg_type->type_params[1];
return new Type\Union([
new Type\Atomic\TArray([
$key_type,
@ -554,6 +556,7 @@ class FunctionChecker extends FunctionLikeChecker
if (isset($call_map[$mapped_function_id][0])) {
if ($call_map[$mapped_function_id][0]) {
$mapped_function_return = Type::parseString($call_map[$mapped_function_id][0]);
return new Type\Union([
new Type\Atomic\TArray([
Type::getInt(),
@ -585,7 +588,7 @@ class FunctionChecker extends FunctionLikeChecker
}
/** @var array<string, array<string, string>> */
$call_map = require_once(__DIR__.'/../CallMap.php');
$call_map = require_once(__DIR__ . '/../CallMap.php');
self::$call_map = [];

View File

@ -176,7 +176,7 @@ abstract class FunctionLikeChecker extends SourceChecker implements StatementsSo
$parent_method_id = MethodChecker::getCasedMethodId($implemented_method_id);
if (IssueBuffer::accepts(
new OverriddenMethodAccess(
'Method ' . $cased_method_id .' has different access level than ' . $parent_method_id,
'Method ' . $cased_method_id . ' has different access level than ' . $parent_method_id,
new CodeLocation($this, $this->function, true)
)
)) {
@ -194,7 +194,7 @@ abstract class FunctionLikeChecker extends SourceChecker implements StatementsSo
if (IssueBuffer::accepts(
new MethodSignatureMismatch(
'Method ' . $cased_method_id .' has fewer arguments than parent method ' .
'Method ' . $cased_method_id . ' has fewer arguments than parent method ' .
$parent_method_id,
new CodeLocation($this, $this->function, true)
)
@ -214,7 +214,7 @@ abstract class FunctionLikeChecker extends SourceChecker implements StatementsSo
if (IssueBuffer::accepts(
new MethodSignatureMismatch(
'Argument ' . ($i + 1) . ' of ' . $cased_method_id .' has wrong type \'' .
'Argument ' . ($i + 1) . ' of ' . $cased_method_id . ' has wrong type \'' .
$storage->params[$i]->signature_type . '\', expecting \'' .
$implemented_param->signature_type . '\' as defined by ' .
$parent_method_id,
@ -237,7 +237,7 @@ abstract class FunctionLikeChecker extends SourceChecker implements StatementsSo
if (IssueBuffer::accepts(
new MethodSignatureMismatch(
'Argument ' . ($i + 1) . ' of ' . $cased_method_id .' has wrong type \'' .
'Argument ' . ($i + 1) . ' of ' . $cased_method_id . ' has wrong type \'' .
$storage->params[$i]->type . '\', expecting \'' .
$implemented_param->type . '\' as defined by ' .
$parent_method_id,
@ -259,7 +259,7 @@ abstract class FunctionLikeChecker extends SourceChecker implements StatementsSo
if (IssueBuffer::accepts(
new MethodSignatureMismatch(
'Method ' . $cased_method_id .' has more arguments than parent method ' .
'Method ' . $cased_method_id . ' has more arguments than parent method ' .
$parent_method_id,
new CodeLocation($this, $this->function, true)
)
@ -1268,7 +1268,7 @@ abstract class FunctionLikeChecker extends SourceChecker implements StatementsSo
if (IssueBuffer::accepts(
new InvalidDocblock(
'Parameter $' . $param_name .' does not appear in the argument list for ' .
'Parameter $' . $param_name . ' does not appear in the argument list for ' .
$cased_method_id,
$code_location
)
@ -1325,7 +1325,7 @@ abstract class FunctionLikeChecker extends SourceChecker implements StatementsSo
$code_location->setCommentLine($line_number);
if (IssueBuffer::accepts(
new InvalidDocblock(
'Parameter $' . $param_name .' has wrong type \'' . $new_param_type . '\', should be \'' .
'Parameter $' . $param_name . ' has wrong type \'' . $new_param_type . '\', should be \'' .
$storage_param_type . '\'',
$code_location
)
@ -1361,7 +1361,7 @@ abstract class FunctionLikeChecker extends SourceChecker implements StatementsSo
) {
if (IssueBuffer::accepts(
new InvalidDocblock(
'Parameter $' . $function_signature_param->name .' does not appear in the docbock for ' .
'Parameter $' . $function_signature_param->name . ' does not appear in the docbock for ' .
$cased_method_id,
$function_signature_param->location
)
@ -1606,7 +1606,7 @@ abstract class FunctionLikeChecker extends SourceChecker implements StatementsSo
return self::getMatchingParamsFromCallMapOptions($function_param_options, $args, $file_checker);
}
/**
/**
* @param array<int, array<int, FunctionLikeParameter>> $function_param_options
* @param array<int, PhpParser\Node\Arg> $args
* @param FileChecker $file_checker
@ -1698,8 +1698,6 @@ abstract class FunctionLikeChecker extends SourceChecker implements StatementsSo
$this->suppressed_issues = array_merge($this->suppressed_issues, $suppressed_issues);
}
/**
* @return void
*/

View File

@ -41,7 +41,7 @@ class InterfaceChecker extends ClassLikeChecker
/**
* @param string $fq_interface_name
* @param FileChecker $file_checker
* @return boolean
* @return bool
*/
public static function interfaceExists($fq_interface_name, FileChecker $file_checker)
{
@ -59,7 +59,7 @@ class InterfaceChecker extends ClassLikeChecker
/**
* @param string $fq_interface_name
* @param FileChecker $file_checker
* @return boolean
* @return bool
*/
public static function hasCorrectCasing($fq_interface_name, FileChecker $file_checker)
{
@ -70,7 +70,7 @@ class InterfaceChecker extends ClassLikeChecker
* @param string $interface_name
* @param string $possible_parent
* @param FileChecker $file_checker
* @return boolean
* @return bool
*/
public static function interfaceExtends($interface_name, $possible_parent, FileChecker $file_checker)
{

View File

@ -48,7 +48,7 @@ class MethodChecker extends FunctionLikeChecker
/**
* @param string $method_id
* @return boolean
* @return bool
*/
public static function isVariadic($method_id)
{
@ -183,7 +183,6 @@ class MethodChecker extends FunctionLikeChecker
? ClassLikeChecker::VISIBILITY_PRIVATE
: ($method->isProtected() ? ClassLikeChecker::VISIBILITY_PROTECTED : ClassLikeChecker::VISIBILITY_PUBLIC);
$possible_params = FunctionChecker::getParamsFromCallMap($method_id);
if ($possible_params === null) {
@ -637,6 +636,6 @@ class MethodChecker extends FunctionLikeChecker
list($fq_class_name) = explode('::', $method_id);
return $fq_class_name . '::' .$storage->cased_name;
return $fq_class_name . '::' . $storage->cased_name;
}
}

View File

@ -33,14 +33,14 @@ class ProjectChecker
/**
* Whether or not to use colors in error output
*
* @var boolean
* @var bool
*/
public $use_color;
/**
* Whether or not to show informational messages
*
* @var boolean
* @var bool
*/
public $show_info;
@ -65,12 +65,12 @@ class ProjectChecker
public $debug_output = false;
/**
* @var boolean
* @var bool
*/
public $update_docblocks = false;
/**
* @var boolean
* @var bool
*/
public $cache = false;
@ -176,14 +176,14 @@ class ProjectChecker
public $fake_files = [];
/**
* @var boolean
* @var bool
*/
public $server_mode = false;
/**
* Whether to log functions just at the file level or globally (for stubs)
*
* @var boolean
* @var bool
*/
public $register_global_functions = false;
@ -192,9 +192,9 @@ class ProjectChecker
const TYPE_EMACS = 'emacs';
/**
* @param boolean $use_color
* @param boolean $show_info
* @param boolean $debug_output
* @param bool $use_color
* @param bool $show_info
* @param bool $debug_output
* @param string $output_format
* @param bool $update_docblocks
* @param bool $collect_references
@ -234,7 +234,7 @@ class ProjectChecker
/**
* @param string $base_dir
* @param boolean $is_diff
* @param bool $is_diff
* @return void
*/
public function check($base_dir, $is_diff = false)
@ -709,7 +709,7 @@ class ProjectChecker
}
if ($this->debug_output) {
echo (isset($this->visited_files[$file_path]) ? 'Rev' : 'V') . 'isiting ' . $file_path . PHP_EOL;
echo(isset($this->visited_files[$file_path]) ? 'Rev' : 'V') . 'isiting ' . $file_path . PHP_EOL;
}
$this->visited_files[$file_path] = true;
@ -724,7 +724,7 @@ class ProjectChecker
* for later checking
*
* @param string $fq_class_name
* @return boolean
* @return bool
* @psalm-suppress MixedMethodCall due to Reflection class weirdness
*/
public function fileExistsForClassLike($fq_class_name)
@ -745,6 +745,7 @@ class ProjectChecker
$this->visited_classes[$fq_class_name_ci] = true;
$reflected_class = new \ReflectionClass($fq_class_name);
ClassLikeChecker::registerReflectedClass($reflected_class->name, $reflected_class, $this);
return true;
}
@ -787,7 +788,7 @@ class ProjectChecker
/**
* @param string $fq_class_name
* @return boolean
* @return bool
* @psalm-suppress MixedMethodCall due to Reflection class weirdness
*/
public function visitFileForClassLike($fq_class_name)

View File

@ -12,10 +12,9 @@ use Psalm\Checker\StatementsChecker;
use Psalm\CodeLocation;
use Psalm\Context;
use Psalm\Issue\InvalidIterator;
use Psalm\IssueBuffer;
use Psalm\Issue\NullIterator;
use Psalm\Issue\NullReference;
use Psalm\Issue\PossiblyNullIterator;
use Psalm\IssueBuffer;
use Psalm\Type;
class ForeachChecker

View File

@ -232,6 +232,7 @@ class SwitchChecker
}
$context->vars_possibly_in_scope = array_merge($context->vars_possibly_in_scope, $new_vars_possibly_in_scope);
return null;
}
}

View File

@ -515,7 +515,7 @@ class AssertionFinder
* @param array<string> &$if_types
* @param string|null $this_class_name
* @param StatementsSource $source
* @param boolean $negate
* @param bool $negate
* @return void
*/
protected static function processFunctionCall(
@ -822,7 +822,7 @@ class AssertionFinder
{
if ($stmt->name instanceof PhpParser\Node\Name &&
($stmt->name->parts === ['is_int'] ||
$stmt->name->parts === ['is_integer']||
$stmt->name->parts === ['is_integer'] ||
$stmt->name->parts === ['is_long'])
) {
return true;

View File

@ -708,6 +708,7 @@ class AssignmentChecker
if ($var_id && count($class_property_types) === 1 && isset($class_property_types[0]->types['stdClass'])) {
$context->vars_in_scope[$var_id] = Type::getMixed();
return null;
}

View File

@ -1130,7 +1130,6 @@ class CallChecker
);
}
if (!$does_class_exist) {
return $does_class_exist;
}

View File

@ -88,6 +88,7 @@ class FetchChecker
if ($var_id && $context->hasVariable($var_id)) {
// we don't need to check anything
$stmt->inferredType = $context->vars_in_scope[$var_id];
return null;
}
@ -447,6 +448,7 @@ class FetchChecker
$statements_checker->getFileChecker()->containsUnEvaluatedClassLike($fq_class_name)
) {
$stmt->inferredType = Type::getString();
return null;
}
@ -462,12 +464,14 @@ class FetchChecker
if ($stmt->name === 'class') {
$stmt->inferredType = Type::getString();
return null;
}
// if we're ignoring that the class doesn't exist, exit anyway
if (!ClassLikeChecker::classOrInterfaceExists($fq_class_name, $statements_checker->getFileChecker())) {
$stmt->inferredType = Type::getMixed();
return null;
}
@ -618,6 +622,7 @@ class FetchChecker
if ($var_id && $context->hasVariable($var_id)) {
// we don't need to check anything
$stmt->inferredType = $context->vars_in_scope[$var_id];
return null;
}
@ -1234,6 +1239,7 @@ class FetchChecker
if ($type->type_params[1]->isEmpty()) {
$type->type_params[0] = $assignment_key_type;
$type->type_params[1] = $assignment_value_type;
return $type;
}

View File

@ -526,6 +526,7 @@ class ExpressionChecker
)
) {
$stmt->inferredType = Type::getArray();
return null;
}
@ -535,6 +536,7 @@ class ExpressionChecker
if ($passed_by_reference && $by_ref_type) {
self::assignByRefParam($statements_checker, $stmt, $by_ref_type, $context);
return null;
}
@ -575,7 +577,7 @@ class ExpressionChecker
if ($first_appearance) {
if (IssueBuffer::accepts(
new PossiblyUndefinedVariable(
'Possibly undefined variable ' . $var_name .', first seen on line ' .
'Possibly undefined variable ' . $var_name . ', first seen on line ' .
$first_appearance->getLineNumber(),
new CodeLocation($statements_checker->getSource(), $stmt)
),
@ -635,6 +637,7 @@ class ExpressionChecker
if ((string)$existing_type !== 'array<empty, empty>') {
$context->vars_in_scope[$var_id] = $by_ref_type;
$stmt->inferredType = $context->vars_in_scope[$var_id];
return;
}
}
@ -659,6 +662,7 @@ class ExpressionChecker
// if the array is empty, this special type allows us to match any other array type against it
if (empty($stmt->items)) {
$stmt->inferredType = Type::getEmptyArray();
return null;
}
@ -727,6 +731,7 @@ class ExpressionChecker
$can_create_objectlike
) {
$stmt->inferredType = new Type\Union([new Type\Atomic\ObjectLike($property_types)]);
return null;
}
@ -1113,6 +1118,7 @@ class ExpressionChecker
}
$result_type = Type::getMixed();
return;
}
@ -1142,6 +1148,7 @@ class ExpressionChecker
}
$result_type = Type::getArray();
return;
}
@ -1431,6 +1438,7 @@ class ExpressionChecker
if ($stmt instanceof PhpParser\Node\Expr\ArrayDimFetch && $nesting !== null) {
$nesting++;
return self::getVarId($stmt->var, $this_class_name, $source, $nesting);
}
@ -1552,6 +1560,7 @@ class ExpressionChecker
if (!$statements_checker->hasVariable($use_var_id)) {
$statements_checker->registerVariable($use_var_id, new CodeLocation($statements_checker, $use));
}
return;
}
@ -1860,6 +1869,7 @@ class ExpressionChecker
}
$stmt->inferredType = Type::getString();
return null;
}
@ -1959,7 +1969,7 @@ class ExpressionChecker
/**
* @param string $fq_class_name
* @return boolean
* @return bool
*/
public static function isMock($fq_class_name)
{

View File

@ -95,7 +95,6 @@ class StatementsChecker extends SourceChecker implements StatementsSource
}
}
if ($has_returned && !($stmt instanceof PhpParser\Node\Stmt\Nop) &&
!($stmt instanceof PhpParser\Node\Stmt\InlineHTML)
) {
@ -700,8 +699,6 @@ class StatementsChecker extends SourceChecker implements StatementsSource
$stmt->inferredType = Type::getVoid();
}
if ($this->source instanceof FunctionLikeChecker) {
$this->source->addReturnTypes($stmt->expr ? (string) $stmt->inferredType : '', $context);
}
@ -813,6 +810,7 @@ class StatementsChecker extends SourceChecker implements StatementsSource
$context->check_classes = false;
$context->check_variables = false;
$context->check_functions = false;
return null;
}
@ -871,6 +869,8 @@ class StatementsChecker extends SourceChecker implements StatementsSource
/**
* @return string|null
* @param mixed $file_name
* @param mixed $current_directory
*/
/**

View File

@ -87,7 +87,7 @@ class TraitChecker extends ClassLikeChecker
/**
* @param string $fq_trait_name
* @param FileChecker $file_checker
* @return boolean
* @return bool
*/
public static function traitExists($fq_trait_name, FileChecker $file_checker)
{
@ -101,7 +101,7 @@ class TraitChecker extends ClassLikeChecker
/**
* @param string $fq_trait_name
* @param FileChecker $file_checker
* @return boolean
* @return bool
*/
public static function hasCorrectCase($fq_trait_name, FileChecker $file_checker)
{

View File

@ -685,6 +685,7 @@ class TypeChecker
if ($all_types_contain) {
$to_string_cast = false;
return true;
}
@ -748,6 +749,7 @@ class TypeChecker
MethodChecker::methodExists($input_type_part->value . '::__toString', $file_checker)
) {
$to_string_cast = true;
return true;
}
}
@ -1041,7 +1043,7 @@ class TypeChecker
* @param Type\Union $declared_type
* @param Type\Union $inferred_type
* @param FileChecker $file_checker
* @return boolean
* @return bool
*/
public static function hasIdenticalTypes(
Type\Union $declared_type,

View File

@ -397,7 +397,6 @@ class Config
);
}
$config->plugins[] = $loaded_plugin;
}
}

View File

@ -8,7 +8,7 @@ class ErrorLevelFileFilter extends FileFilter
/**
* @var string
*/
private $error_level = "";
private $error_level = '';
/**
* @param SimpleXMLElement $e

View File

@ -73,7 +73,7 @@ class FileFilter
foreach ($globs as $glob_index => $directory_path) {
if (!$directory_path) {
die('Could not resolve config path to ' . $base_dir . DIRECTORY_SEPARATOR .
(string)$directory['name']. ':' . $glob_index);
(string)$directory['name'] . ':' . $glob_index);
}
$filter->addDirectory($directory_path);
}
@ -118,8 +118,8 @@ class FileFilter
/**
* @param string $file_name
* @param boolean $case_sensitive
* @return boolean
* @param bool $case_sensitive
* @return bool
*/
public function allows($file_name, $case_sensitive = false)
{

View File

@ -37,8 +37,8 @@ class ProjectFileFilter extends FileFilter
/**
* @param string $file_name
* @param boolean $case_sensitive
* @return boolean
* @param bool $case_sensitive
* @return bool
*/
public function allows($file_name, $case_sensitive = false)
{

View File

@ -248,8 +248,7 @@ class Context
*/
public function remove($remove_var_id)
{
unset($this->referenced_vars[$remove_var_id]);
unset($this->vars_possibly_in_scope[$remove_var_id]);
unset($this->referenced_vars[$remove_var_id], $this->vars_possibly_in_scope[$remove_var_id]);
if (isset($this->vars_in_scope[$remove_var_id])) {
$existing_type = $this->vars_in_scope[$remove_var_id];

View File

@ -54,6 +54,7 @@ class IssueBuffer
if (self::$recording_level > 0) {
self::$recorded_issues[self::$recording_level][] = $e;
return false;
}
@ -97,6 +98,7 @@ class IssueBuffer
break;
}
}
return false;
}
@ -107,7 +109,7 @@ class IssueBuffer
if (!self::alreadyEmitted($error_message)) {
switch ($project_checker->output_format) {
case ProjectChecker::TYPE_CONSOLE:
echo ($project_checker->use_color ? "\e[0;31mERROR\e[0m" : 'ERROR') .
echo($project_checker->use_color ? "\e[0;31mERROR\e[0m" : 'ERROR') .
': ' . $error_message . PHP_EOL;
echo self::getSnippet($e, $project_checker->use_color) . PHP_EOL . PHP_EOL;
@ -312,6 +314,7 @@ class IssueBuffer
{
if (self::$recording_level === 0) {
self::add($e);
return;
}

View File

@ -8,7 +8,7 @@ class FileProvider
{
/**
* @param string $file_path
* @return boolean
* @return bool
*/
public static function hasFileChanged($file_path)
{

View File

@ -190,6 +190,7 @@ class FileReferenceProvider
}
self::$file_references = $reference_cache;
return true;
}
}

View File

@ -70,7 +70,7 @@ interface Iterator extends Traversable {
/**
* Checks if current position is valid
* @link http://php.net/manual/en/iterator.valid.php
* @return boolean The return value will be casted to boolean and then evaluated.
* @return bool The return value will be casted to boolean and then evaluated.
* Returns true on success or false on failure.
* @since 5.0.0
*/
@ -100,7 +100,7 @@ interface ArrayAccess {
* @param TKey $offset <p>
* An offset to check for.
* </p>
* @return boolean true on success or false on failure.
* @return bool true on success or false on failure.
* </p>
* <p>
* The return value will be casted to boolean if non-boolean was returned.

View File

@ -121,6 +121,7 @@ abstract class Type
*/
function (ParseTree $child_tree) {
$tree_type = self::getTypeFromTree($child_tree);
return $tree_type instanceof Union ? $tree_type : new Union([$tree_type]);
},
$parse_tree->children
@ -243,6 +244,7 @@ abstract class Type
public static function convertSquareBrackets($type)
{
$class_chars = '[a-zA-Z0-9\<\>\\\\_]+';
return preg_replace_callback(
'/(' . $class_chars . '|' . '\((' . $class_chars . '(\|' . $class_chars . ')*' . ')\))((\[\])+)/',
/**

View File

@ -5,8 +5,8 @@ use Psalm\Checker\ClassChecker;
use Psalm\Checker\ClassLikeChecker;
use Psalm\Checker\FileChecker;
use Psalm\CodeLocation;
use Psalm\IssueBuffer;
use Psalm\Issue\ReservedWord;
use Psalm\IssueBuffer;
use Psalm\StatementsSource;
use Psalm\Type;
use Psalm\Type\Atomic\ObjectLike;
@ -36,14 +36,14 @@ abstract class Atomic
/**
* Whether or not the type has been checked yet
*
* @var boolean
* @var bool
*/
protected $checked = false;
/**
* Whether or not the type comes from a docblock
*
* @var boolean
* @var bool
*/
protected $from_docblock = false;

View File

@ -20,6 +20,7 @@ trait GenericTrait
foreach ($this->type_params as $type_param) {
$s .= $type_param . ', ';
}
return $this->value . '<' . substr($s, 0, -2) . '>';
}

View File

@ -1,7 +1,7 @@
<?php
namespace Psalm\Type\Atomic;
use \Psalm\Type\Atomic;
use Psalm\Type\Atomic;
class TNamedObject extends Atomic
{
@ -46,6 +46,7 @@ class TNamedObject extends Atomic
{
if ($this->value === $this_class) {
$class_parts = explode('\\', $this_class);
return array_pop($class_parts);
}

View File

@ -15,33 +15,33 @@ class Union
/**
* Whether the type originated in a docblock
*
* @var boolean
* @var bool
*/
public $from_docblock = false;
/**
* Whether the property that this type has been derived from has been initialized in a constructor
*
* @var boolean
* @var bool
*/
public $initialized = true;
/**
* Whether or not the type has been checked yet
*
* @var boolean
* @var bool
*/
protected $checked = false;
/**
* @var boolean
* @var bool
*/
public $failed_reconciliation = false;
/**
* Whether or not to ignore issues with possibly-null values
*
* @var boolean
* @var bool
*/
public $ignore_nullable_issues = false;
@ -72,6 +72,7 @@ class Union
foreach ($this->types as $type) {
$s .= $type . '|';
}
return substr($s, 0, -1);
}
@ -120,7 +121,7 @@ class Union
/**
* @param string $type_string
* @return boolean
* @return bool
*/
public function hasType($type_string)
{
@ -128,7 +129,7 @@ class Union
}
/**
* @return boolean
* @return bool
*/
public function hasGeneric()
{
@ -142,7 +143,7 @@ class Union
}
/**
* @return boolean
* @return bool
*/
public function hasArray()
{
@ -150,7 +151,7 @@ class Union
}
/**
* @return boolean
* @return bool
*/
public function hasObjectLike()
{
@ -158,7 +159,7 @@ class Union
}
/**
* @return boolean
* @return bool
*/
public function hasObjectType()
{
@ -172,7 +173,7 @@ class Union
}
/**
* @return boolean
* @return bool
*/
public function isNullable()
{
@ -180,7 +181,7 @@ class Union
}
/**
* @return boolean
* @return bool
*/
public function hasString()
{
@ -188,15 +189,15 @@ class Union
}
/**
* @return boolean
* @return bool
*/
public function hasInt()
{
return isset($this->types['int']);
}
/**
* @return boolean
/**
* @return bool
*/
public function hasFloat()
{
@ -204,7 +205,7 @@ class Union
}
/**
* @return boolean
* @return bool
*/
public function hasNumericType()
{
@ -228,7 +229,7 @@ class Union
}
/**
* @return boolean
* @return bool
*/
public function isMixed()
{
@ -236,7 +237,7 @@ class Union
}
/**
* @return boolean
* @return bool
*/
public function isNull()
{
@ -244,7 +245,7 @@ class Union
}
/**
* @return boolean
* @return bool
*/
public function isVoid()
{
@ -252,7 +253,7 @@ class Union
}
/**
* @return boolean
* @return bool
*/
public function isEmpty()
{
@ -330,7 +331,7 @@ class Union
}
/**
* @return boolean
* @return bool
*/
public function isSingle()
{

View File

@ -25,7 +25,7 @@ class FunctionCallTest extends TestCase
$this->assertEquals('array<string, int>', (string) $context->vars_in_scope['$d']);
$this->assertEquals('array<string, null|int>', (string) $context->vars_in_scope['$e']);
if (version_compare((string)phpversion(), '5.6.0', '>=')) {
if (version_compare((string)PHP_VERSION, '5.6.0', '>=')) {
$stmts = self::$parser->parse('<?php
$f = array_filter(["a" => 5, "b" => 12, "c" => null], function(?int $val, string $key) : bool {
return true;
@ -64,7 +64,7 @@ class FunctionCallTest extends TestCase
*/
public function testArrayFilterUseKey()
{
if (version_compare((string)phpversion(), '5.6.0', '>=')) {
if (version_compare((string)PHP_VERSION, '5.6.0', '>=')) {
$stmts = self::$parser->parse('<?php
$bar = "bar";

View File

@ -15,6 +15,7 @@ class MethodSignatureTest extends TestCase
{
if (class_exists('SoapClient') === false) {
$this->markTestSkipped('Cannot run test, base class "SoapClient" does not exist!');
return;
}
@ -55,6 +56,7 @@ class MethodSignatureTest extends TestCase
{
if (class_exists('SoapClient') === false) {
$this->markTestSkipped('Cannot run test, base class "SoapClient" does not exist!');
return;
}

View File

@ -16,7 +16,7 @@ class Php56Test extends TestCase
const ARR = ["a", "b"];
$a = ARR[0];',
'assertions' => [
['string' =>'$a']
['string' => '$a']
]
],
'constFeatures' => [

View File

@ -75,7 +75,7 @@ class Php70Test extends TestCase
$a = ANIMALS[1];',
'assertions' => [
['string' =>'$a']
['string' => '$a']
]
],
'anonymousClassLogger' => [

View File

@ -33,7 +33,7 @@ class Php71Test extends TestCase
$a = a();',
'assertions' => [
['null|string' =>'$a']
['null|string' => '$a']
]
],
'nullableArgument' => [

View File

@ -61,7 +61,7 @@ class TemplateTest extends TestCase
['Foo<A>' => '$afoo'],
['A' => '$afoo_bar'],
['Foo<B>' =>'$bfoo'],
['Foo<B>' => '$bfoo'],
['B' => '$bfoo_bar'],
['Foo<C>' => '$cfoo'],

View File

@ -26,6 +26,7 @@ trait FileCheckerValidCodeParseTestTrait
if (strpos($test_name, 'PHP7-') !== false) {
if (version_compare(PHP_VERSION, '7.0.0dev', '<')) {
$this->markTestSkipped('Test case requires PHP 7.');
return;
}
} elseif (strpos($test_name, 'SKIPPED-') !== false) {