Skip to content

Support and test AST version 50 #13

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Sep 1, 2017
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
247 changes: 247 additions & 0 deletions .phan/config.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,247 @@
<?php

use \Phan\Issue;

/**
* This configuration will be read and overlayed on top of the
* default configuration. Command line arguments will be applied
* after this file is read.
*
* @see src/Phan/Config.php
* See Config for all configurable options.
*
* A Note About Paths
* ==================
*
* Files referenced from this file should be defined as
*
* ```
* Config::projectPath('relative_path/to/file')
* ```
*
* where the relative path is relative to the root of the
* project which is defined as either the working directory
* of the phan executable or a path passed in via the CLI
* '-d' flag.
*/
return [

// If true, missing properties will be created when
// they are first seen. If false, we'll report an
// error message.
"allow_missing_properties" => false,

// Allow null to be cast as any type and for any
// type to be cast to null.
"null_casts_as_any_type" => false,

// If enabled, scalars (int, float, bool, string, null)
// are treated as if they can cast to each other.
'scalar_implicit_cast' => false,

// If true, seemingly undeclared variables in the global
// scope will be ignored. This is useful for projects
// with complicated cross-file globals that you have no
// hope of fixing.
'ignore_undeclared_variables_in_global_scope' => false,

// Backwards Compatibility Checking
'backward_compatibility_checks' => false,

// If enabled, check all methods that override a
// parent method to make sure its signature is
// compatible with the parent's. This check
// can add quite a bit of time to the analysis.
'analyze_signature_compatibility' => true,

// Set to true in order to attempt to detect dead
// (unreferenced) code. Keep in mind that the
// results will only be a guess given that classes,
// properties, constants and methods can be referenced
// as variables (like `$class->$property` or
// `$class->$method()`) in ways that we're unable
// to make sense of.
'dead_code_detection' => false,

// Run a quick version of checks that takes less
// time
"quick_mode" => false,

// Enable or disable support for generic templated
// class types.
'generic_types_enabled' => true,

// By default, Phan will not analyze all node types
// in order to save time. If this config is set to true,
// Phan will dig deeper into the AST tree and do an
// analysis on all nodes, possibly finding more issues.
//
// See \Phan\Analysis::shouldVisit for the set of skipped
// nodes.
'should_visit_all_nodes' => true,

'runkit_superglobals' => ['_DATE', '_RK'],

'globals_type_map' => [
'_DATE' => '\\DateTime',
'_RK' => '\\RunkitGlobal',
],

// The minimum severity level to report on. This can be
// set to Issue::SEVERITY_LOW, Issue::SEVERITY_NORMAL or
// Issue::SEVERITY_CRITICAL.
'minimum_severity' => Issue::SEVERITY_LOW,

// Add any issue types (such as 'PhanUndeclaredMethod')
// here to inhibit them from being reported
'suppress_issue_types' => [
// 'PhanUndeclaredMethod',
],

// If empty, no filter against issues types will be applied.
// If non-empty, only issues within the list will be emitted
// by Phan.
'whitelist_issue_types' => [
// 'PhanAccessMethodPrivate',
// 'PhanAccessMethodProtected',
// 'PhanAccessNonStaticToStatic',
// 'PhanAccessPropertyPrivate',
// 'PhanAccessPropertyProtected',
// 'PhanAccessSignatureMismatch',
// 'PhanAccessSignatureMismatchInternal',
// 'PhanAccessStaticToNonStatic',
// 'PhanCompatibleExpressionPHP7',
// 'PhanCompatiblePHP7',
// 'PhanContextNotObject',
// 'PhanDeprecatedClass',
// 'PhanDeprecatedFunction',
// 'PhanDeprecatedProperty',
// 'PhanEmptyFile',
// 'PhanNonClassMethodCall',
// 'PhanNoopArray',
// 'PhanNoopClosure',
// 'PhanNoopConstant',
// 'PhanNoopProperty',
// 'PhanNoopVariable',
// 'PhanParamRedefined',
// 'PhanParamReqAfterOpt',
// 'PhanParamSignatureMismatch',
// 'PhanParamSignatureMismatchInternal',
// 'PhanParamSpecial1',
// 'PhanParamSpecial2',
// 'PhanParamSpecial3',
// 'PhanParamSpecial4',
// 'PhanParamTooFew',
// 'PhanParamTooFewInternal',
// 'PhanParamTooMany',
// 'PhanParamTooManyInternal',
// 'PhanParamTypeMismatch',
// 'PhanParentlessClass',
// 'PhanRedefineClass',
// 'PhanRedefineClassInternal',
// 'PhanRedefineFunction',
// 'PhanRedefineFunctionInternal',
// 'PhanStaticCallToNonStatic',
// 'PhanSyntaxError',
// 'PhanTraitParentReference',
// 'PhanTypeArrayOperator',
// 'PhanTypeArraySuspicious',
// 'PhanTypeComparisonFromArray',
// 'PhanTypeComparisonToArray',
// 'PhanTypeConversionFromArray',
// 'PhanTypeInstantiateAbstract',
// 'PhanTypeInstantiateInterface',
// 'PhanTypeInvalidLeftOperand',
// 'PhanTypeInvalidRightOperand',
// 'PhanTypeMismatchArgument',
// 'PhanTypeMismatchArgumentInternal',
// 'PhanTypeMismatchDefault',
// 'PhanTypeMismatchForeach',
// 'PhanTypeMismatchProperty',
// 'PhanTypeMismatchReturn',
// 'PhanTypeMissingReturn',
// 'PhanTypeNonVarPassByRef',
// 'PhanTypeParentConstructorCalled',
// 'PhanTypeVoidAssignment',
// 'PhanUnanalyzable',
// 'PhanUndeclaredClass',
// 'PhanUndeclaredClassCatch',
// 'PhanUndeclaredClassConstant',
// 'PhanUndeclaredClassInstanceof',
// 'PhanUndeclaredClassMethod',
// 'PhanUndeclaredClassReference',
// 'PhanUndeclaredConstant',
// 'PhanUndeclaredExtendedClass',
// 'PhanUndeclaredFunction',
// 'PhanUndeclaredInterface',
// 'PhanUndeclaredMethod',
// 'PhanUndeclaredProperty',
// 'PhanUndeclaredStaticMethod',
// 'PhanUndeclaredStaticProperty',
// 'PhanUndeclaredTrait',
// 'PhanUndeclaredTypeParameter',
// 'PhanUndeclaredTypeProperty',
// 'PhanUndeclaredVariable',
// 'PhanUnreferencedClass',
// 'PhanUnreferencedConstant',
// 'PhanUnreferencedMethod',
// 'PhanUnreferencedProperty',
// 'PhanVariableUseClause',
],

// A list of files to include in analysis
'file_list' => [
// 'vendor/phpunit/phpunit/src/Framework/TestCase.php',
],

// A file list that defines files that will be excluded
// from parsing and analysis and will not be read at all.
//
// This is useful for excluding hopelessly unanalyzable
// files that can't be removed for whatever reason.
'exclude_file_list' => [],

// The number of processes to fork off during the analysis
// phase.
'processes' => 1,

// A list of directories that should be parsed for class and
// method information. After excluding the directories
// defined in exclude_analysis_directory_list, the remaining
// files will be statically analyzed for errors.
//
// Thus, both first-party and third-party code being used by
// your application should be included in this list.
'directory_list' => [
'src',
'vendor/nikic/php-parser/lib',
],

// A directory list that defines files that will be excluded
// from static analysis, but whose class and method
// information should be included.
//
// Generally, you'll want to include the directories for
// third-party code (such as "vendor/") in this list.
//
// n.b.: If you'd like to parse but not analyze 3rd
// party code, directories containing that code
// should be added to the `directory_list` as
// to `exclude_analysis_directory_list`.
"exclude_analysis_directory_list" => [
'vendor/nikic/php-parser/lib',
],

// A list of plugin files to execute
'plugins' => [
// NOTE: src/Phan/Language/Internal/FunctionSignatureMap.php mixes value without key as return type with values having keys deliberately.
'vendor/etsy/phan/.phan/plugins/AlwaysReturnPlugin.php', // (TODO: make BlockExitStatus more reliable)
'vendor/etsy/phan/.phan/plugins/DollarDollarPlugin.php',
'vendor/etsy/phan/.phan/plugins/DuplicateArrayKeyPlugin.php',
'vendor/etsy/phan/.phan/plugins/UnreachableCodePlugin.php', // (TODO: make BlockExitStatus more reliable)
// NOTE: This plugin only produces correct results when
// Phan is run on a single core (-j1).
// '.phan/plugins/UnusedSuppressionPlugin.php',
],

];
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ install:
- composer --prefer-dist install

script:
- vendor/bin/phan
- ./test
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@ PHP-Parser to php-ast

[![Build Status](https://travis-ci.org/TysonAndre/php-parser-to-php-ast.svg?branch=master)](https://travis-ci.org/TysonAndre/php-parser-to-php-ast)

This converts ASTs(Abstract Syntax Trees) from [PHP-Parser](https://github.com/nikic/PHP-Parser) to [php-ast](https://github.com/nikic/php-ast/).
It can be used as a PHP-only implementation of php-ast.

Supported [php-ast AST versions](https://github.com/nikic/php-ast#version-changelog): 40, 50

Current Status
--------------

No tests are failing

- This is 90% done
Expand Down Expand Up @@ -31,7 +39,7 @@ Using it as an error-tolerant substitute for php-ast (e.g. for use in IDEs)
Running unit tests
------------------

To run unit tests, you must install [nikic/php-ast](https://github.com/nikic/php-ast)
To run unit tests, you must install [nikic/php-ast](https://github.com/nikic/php-ast). A version supporting AST versions 40 and/or 50 should be installed (`~0.1.5` is preferred)

- Then run `vendor/bin/phpunit`

Expand Down
11 changes: 6 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
{
"name": "tysonandre/php-parser",
"description": "A php-parser to php-ast converter written in php",
"name": "tysonandre/php-parser-to-php-ast",
"description": "A php-parser to php-ast converter written in php. Can be used to test out projects using php-ast without compiling php-ast.",
"require": {
"php": ">=7.1",
"nikic/PHP-Parser": "3.0.5"
"nikic/PHP-Parser": "~3.1.0"
},
"require-dev": {
"phpunit/phpunit": "^5.7"
"phpunit/phpunit": "^5.7",
"etsy/phan": "~0.9.4"
},
"suggest": {
"ext-ast": "~0.1.4"
"ext-ast": "~0.1.5"
},
"autoload": {
"psr-4": {"ASTConverter\\": "src/ASTConverter"}
Expand Down
Loading