PHP 8 and new documentation
A lot of time has passed since the v0.2.0 (v0.3.0 was minor) release, so the list of changes is very long.
The goal of this release is to start a new development phase with scheduled releases and respecting backward compatibility.
Big features
- PHP 8 and PHP 8.1
- 40+ new checkers
- New CLI
- New documentation
Checkers
New checkers
paramClobber
printf
offBy1
argsOrder
callSimplify
discardVar
strictCmp
dupCatch
catchOrder
indexingSyntax
trailingComma
emptyStmt
stripTags
nestedTernary
intNeedle
angDeprecated
emptyStringCheck
oldStyleConstructor
returnAssign
strangeCast
classMembersOrder
badTraitUse
varShadow
invalidNew
countUse
unaryRepeat
forLoop
alwaysNull
selfAssign
errorSilence
switchDefault
switchSimplify
switchEmpty
implicitModifier
invalidExtendClass
methodSignatureMismatch
argsReverse
constCase
reverseAssign
concatenationPrecedence
Improved checkers
- Improved
dupBranchBody
checker, added handling switch cases - Improved message for
dupCond
checkers for switch cases - Improved
strangeCast
checker
New checks in existing checkers
- Added check for nullable syntax
- Added precedence rules for
??
- Added check for incorrect case of class names in type hints
- Added a check for casting to the
real
type and using theis_real
function - Added a check for calling
array_key_exists
with an object - Added check for calls to the
random_int
function - Added cases to
callSimplify
andternarySimplify
checkers - Added
finally
return check forunreachable
checker - Added a check for
array
type hint - Added check for
parent
typehint intypeHint
checker - Added check for repeated nullable
- Added a check for using
void
type in the type union or@param
annotation - Added check for class name case in const fetch
- Added a check that the return type is defined for the
callable(...)
annotation
Linter
Added
- Added type inferring for callback param type of
array_map
-like funcs - Added multi-pattern rules support via "any" blocks
- Added handling of assignment operators (
+=
,-=
,*=
,.=
) - Added
.=
<<=
>>=` assignments type inference - Added type inference for magic constants
- Added name case checking for
self
,static
andparent
- Added type inference for the null coalesce operator
- Added support for magic constants in constant folding
- Added arrow functions processing in linter
- Added support for
@mixin
annotation - Added support for
use [function] namespace\{A, B}
syntax - Added check for deprecated for static methods
- Added the ability to define a checker both in the code and in dynamic rules
- Added detection of suspicious PHPDoc comments
- Added support for
@noinspection PhpUnreachableStatementInspection
- Added behavior when vendor folder is added to indexing list by default
- Added display of the number of non-critical errors
- Added check that
null
is assigned to not nullable property - Added type inference for
callable
from PHPDoc - Added handling of unknown
types-with-dashes
annotations in PHPDoc - For
iterable<T>
now will be assume typearray<T>
- Added handling of the case when a static method was called through a variable
- Added support for mixing key and non-key types in
array{}
- Added initial support of complex
instanceof
forif
/else
and ternary operator - Added support when no variable is specified for
@var
- Added
--strict-mixed
flag
Changed
- Assume
int|string
array key types inforeach
stmt - Treat
trigger_error($msg, E_USER_ERROR)
asexit()
- Renamed
nameCase
tonameMismatch
--rules
flag can now accept folders, in which case all files from it will be added to the rules- For embedded dynamic rules, all messages are capitalized
- For messages with variables, added
$
before the variable name - For messages related to an unused variable added mention of the
--unused-var-regex
flag - Custom types are now taken into account when getting closures
Fixed
- Fixed
--allow-checks
filtering of rules - Fixed bug where assign null coalesce gave
discardExpr
warning - Fixed type inference for callback arguments if they have type hint
- Fixed a panic in git mode for binary files
- Fixed incorrect type inference for a tuple containing
static
,self
or$this
- Fixed false positive of
parentConstructor
- Fixed processing of variables in
try-catch
- Fixed a bug with a tuple containing an array
- Fixed collisions for the late static binding
- Fixed panic when used
parent
typehint in class without parents - Fixed suggest of
--fix
flag when the flag is already provided - Fixed panic if file cannot be parsed
- Fixed a bug with
@see CONSTANT_NAME
- Fixed error when calling the
define
function with a slash at the beginning - Fixed bug in array quick fix
- Fixed bug with quick fix, now if the check is not enabled, quickfixes will not be applied for it
- Fixed bug with quick fix for autogenerated files, now for autogen files, quick fixes will not be applied if the flag
--check-auto-generated
is not provided - Fixed bug, when typecast to an array does overwrite existing types
- Fixed autofix for
langDeprecated.define
rule - Fixed PHPDoc for class with modifiers
- Fixed a bug, if the function starts with a backslash, then the type was incorrectly inferred based on meta information from phpstorm-stubs
- Fixed arrow function handling in custom walkers
Improved
- Improved
assignOp
tests - Improved
list(...) = $a
type inference for arrays - Improved checking for duplicate cases
- Improved type inference for multidimensional arrays when adding elements to them
- Improved closure and shape handling
- Improved context line in PHPDoc warnings
- Improved message for
argCount
checker
Removed
- Removed the deprecated way to run NoVerify, now, when run without commands, help will be displayed
- Removed langserver
Documentation
- Added a page with all checks
- Added Getting started document
- Added Configuration document
- Updated Install document
- Updated README
- Added documentation for baseline mode
- Added missing information to dynamic rules documentation
Improves in CLI
- Added the
version
command to replace the--version
flag for thecheck
command - Added a new field for version, now the
version
command will also show the NoVerify version number - Build time will now be shown with delimiters
- Added groups for flags
- Improved
checkers
command - Fixed output if the flag is not found
Build from source
- Added
build
command to Makefile - Splited the
check
command intotest
andlint
commands - Renamed
build-release
command withrelease
KPHP
- Interpret
any
type asmixed
- Added itype inferring for
instance_deserialize
- Added type inferring for
instance_cast
- Replaced
array_first_element
witharray_first_value
- Added type inferring for
array_filter_by_key
andinstance_cache_fetch
- Added type inferring for
not_null
,not_false
andcreate_vector