packagist phan/phan 2.2.13
Release 2.2.13 supporting PHP 7.0-7.4 syntax

latest releases: v5.x-dev, dev-fix-4782, dev-MapReal-php81-82...
4 years ago

New features(CLI, Configs):

  • Always print 100% in --progress-bar after completing any phase of analysis.
    This is convenient for tools such as tool/phoogle that exit before starting the next phase.
  • Add GraphML output support to DependencyGraphPlugin.
    This allows tool/pdep output to be imported by Neo4j, Gephi and yEd
  • Add json output and import to tool/pdep
    For caching large graphs in order to generate multiple sub-graphs without re-scanning
  • Add setting infer_default_properties_in_construct.
    When this is enabled, infer that properties of $this are initialized to their default values at the start of __construct(). (#3213)
    (this is limited to instance properties which are declared in the current class (i.e. not inherited)).
    Off by default.
  • Add a config setting strict_object_checking. (#3262)
    When enabled, Phan will warn if some of the object types in the union type don't contain a property.
    Additionally, warn about definite non-object types when accessing properties.
    Also add --strict-object-checking to enable this setting.
  • Add CLI option --debug-emitted-issues={basic,verbose} to print the stack trace of when Phan emitted the issue to stderr.
    Useful for understanding why Phan emitted an issue.

New features(Analysis):

  • Disable simplify_ast by default.
    Phan's analysis of compound conditions and assignments/negations in conditions has improved enough that it should no longer be necessary.
  • Import more specific phpdoc/real array return types for internal global functions from opcache.
  • Emit PhanUndeclaredVariable and other warnings about arguments when there are too many parameters for methods. (#3245)
  • Infer real types of array/iterable keys and values in more cases.
  • Expose the last compilation warning seen when tokenizing or parsing with the native parser, if possible (#3263)
    New issue types: PhanSyntaxCompileWarning
    Additionally, expose the last compilation warning or deprecation notice seen when tokenizing in the polyfill.
  • Improve inference of when the real result of a binary operation is a float. (#3256)
  • Emit stricter warnings for more real type mismatches (#3256)
    (e.g. emit PhanTypeMismatchArgumentReal for float->int when strict_types=1, 'literal string'->int, etc.)
  • Consistently infer that variadic parameters are arrays with integer keys. (#3294)
  • Improve types inferred when the config setting enable_extended_internal_return_type_plugins is enabled.
  • Speed up sorting the list of parsed files, and avoid unnecessary work in --dump-parsed-file-list.
  • Emit PhanEmptyForeach and PhanEmptyYieldFrom when iterating over empty arrays.
  • Infer that properties of $this are initialized to their default values at the start of __construct(). (#3213)
    (this is limited to instance properties which are declared in the current class (i.e. not inherited)).
    To disable this, set infer_default_properties_in_construct to false.
  • Improve analysis of conditions on properties of $this, such as if (isset($this->prop['field1']['field2'])) (#3295)
  • Improve suggestions for PhanUndeclaredFunction.
    Properly suggest similar global functions for non-fully qualified calls in namespaces.
    Suggest new ClassName() as a suggestion for ClassName().
  • Improve suggestions for global constants (PhanUndeclaredConstant).
    Suggest similar constant names case-insensitively within the same namespace or the global namespace.
  • Suggest obvious getters and setters for instance properties in PhanAccessPropertyProtected and PhanAccessPropertyPrivate (#2540)
  • When strict_method_checking is enabled,
    warn if some of the object types in the union type don't contain that method. (#3262)
  • Make stronger assumptions about real types of global constants.
    Assume that constants defined with define(...) can have any non-object as its real type,
    to avoid false positives in redundant condition detection.
  • Properly infer that parameter defaults and global constants will resolve to null in some edge cases.
  • Emit PhanCompatibleDefaultEqualsNull when using a different constant that resolves to null as the default of a non-nullable parameter. (#3307)
  • Emit PhanPossiblyInfiniteRecursionSameParams when a function or method calls itself with the same parameter values it was declared with (in a branch). (#2893)
    (This requires unused variable detection to be enabled, when there are 1 or more parameters)
  • Analyze complex conditions such as switch (true), if (($x instanceof stdClass) == false), etc. (#3315)
  • Add a non-empty-array type, for arrays that have 1 or more elements.
    This gets inferred for checks such as if ($array), if (!empty($array)) (checks on count() are not supported yet)
    (non-empty-array<ValueT> and non-empty-array<KeyT, ValueT> can also be used in phpdoc)
  • Support checking if comparisons of types with more than one possible literal scalar are redundant/impossible.
    Previously, Phan would only warn if both sides had exactly one possible scalar value.
    (e.g. warn about 'string literal' >= $nullableBool)
  • Fix edge cases analyzing conditions on superglobals.
  • Be more consistent about when PhanTypeArraySuspiciousNullable is emitted, e.g. for ?mixed, array|null, etc.
  • Fix false positive impossible condition for casting mixed to an array.

Language Server/Daemon mode:

  • Fix logged Error when language server receives didChangeConfiguration events. (this is a no-op)

Plugins:

  • Fix failure to emit PhanPluginDescriptionlessComment* when a description
    would be automatically generated from the property or method's return type. (#3265)
  • Support checking for duplicate phpdoc descriptions of properties or methods within a class in HasPHPDocPlugin.
    Set 'plugin_config' => ['has_phpdoc_check_duplicates' => true] to enable these checks.
    (this skips deprecated methods/properties)
  • Implement LoopVariableReusePlugin, to detect reusing loop variables in nested loops. (#3045)
    (e.g. for ($i = 0; $i < 10; $i++) { /* various code ... */ foreach ($array as $i => $value) { ... } })

Maintenance:

  • Make \Phan\Library\None a singleton in internal uses.
  • Normalize folders in the config file generated by phan --init in the vendor autoload directories.
  • Update internal element types and documentation maps.

Bug fixes:

  • Consistently deduplicate the real type set of union types (fixes some false positives in redundant condition detection).

  • Fix \Phan\Debug's dumping representation of flags for ast\AST_DIM, ast\AST_ARRAY_ELEM,
    ast\AST_PARAM, ast\AST_ASSIGN_OP (??=), and ast\AST_CONDITIONAL.

    This affects some crash reporting and tools such as internal/dump_fallback_ast.php

  • Fix some infinite recursion edge cases caused parsing invalid recursive class inheritance. (#3264)

Don't miss a new phan release

NewReleases is sending notifications on new releases.