Skip to content

Commit

Permalink
First working version
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejmirtes committed Jan 4, 2016
1 parent 3c169b3 commit 1cb3904
Show file tree
Hide file tree
Showing 117 changed files with 5,243 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/tests export-ignore
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/composer.lock
/conf/config.local.yml
/vendor
/.idea
18 changes: 18 additions & 0 deletions bin/phpstan
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env php
<?php declare(strict_types=1);

use PHPStan\Command\AnalyseCommand;

gc_disable(); // performance boost

$composerAutoloadFile = __DIR__ . '/../vendor/autoload.php';
if (!is_file($composerAutoloadFile)) {
$composerAutoloadFile = __DIR__ . '/../../../autoload.php';
}

require_once($composerAutoloadFile);

$application = new \Symfony\Component\Console\Application('PHPStan - PHP Static Analysis Tool');
$application->setCatchExceptions(false);
$application->add(new AnalyseCommand());
$application->run();
99 changes: 99 additions & 0 deletions build.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
<?xml version="1.0" encoding="utf-8"?>
<project name="PHPStan" default="check">

<target name="check" depends="
composer,
lint,
cs,
tests,
phpstan
"/>

<target name="composer">
<exec
executable="composer"
logoutput="true"
passthru="true"
checkreturn="true"
>
<arg value="install"/>
</exec>
</target>

<target name="lint">
<exec
executable="vendor/bin/parallel-lint"
logoutput="true"
passthru="true"
checkreturn="true"
>
<arg value="--exclude"/>
<arg path="tests/PHPStan/Analyser/data"/>
<arg path="src" />
<arg path="tests" />
</exec>
</target>

<target name="cs">
<exec
executable="vendor/bin/phpcs"
logoutput="true"
passthru="true"
checkreturn="true"
>
<arg value="--standard=ruleset.xml"/>
<arg value="--extensions=php"/>
<arg value="--encoding=utf-8"/>
<arg value="--tab-width=4"/>
<arg value="--ignore=tests/*/data"/>
<arg value="-sp"/>
<arg path="src"/>
<arg path="tests"/>
</exec>
</target>

<target name="cs-fix">
<exec
executable="vendor/bin/phpcbf"
logoutput="true"
passthru="true"
checkreturn="true"
>
<arg value="--standard=ruleset.xml"/>
<arg value="--extensions=php"/>
<arg value="--encoding=utf-8"/>
<arg value="--tab-width=4"/>
<arg value="--ignore=tests/*/data"/>
<arg value="-sp"/>
<arg path="src"/>
<arg path="tests"/>
</exec>
</target>

<target name="tests">
<exec
executable="vendor/bin/phpunit"
logoutput="true"
passthru="true"
checkreturn="true"
>
<arg value="-c"/>
<arg value="tests/phpunit.xml"/>
<arg path="tests"/>
</exec>
</target>

<target name="phpstan">
<exec
executable="bin/phpstan"
logoutput="true"
passthru="true"
checkreturn="true"
>
<arg value="analyse"/>
<arg path="src"/>
<arg path="tests"/>
</exec>
</target>

</project>
28 changes: 27 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,31 @@
{
"name": "phpstan/phpstan",
"description": "PHPStan - PHP Static Analysis Tool",
"license": ["MIT"]
"license": ["MIT"],
"minimum-stability": "dev",
"prefer-stable": true,
"bin": [
"bin/phpstan"
],
"require": {
"php": "~7.0",
"nette/bootstrap": "~2.3",
"nette/robot-loader": "~2.3",
"nikic/php-parser": "~2.0",
"symfony/console": "~3.0",
"symfony/finder": "~3.0",
"tracy/tracy": "~2.3"
},
"require-dev": {
"consistence/coding-standard": "~0.10.0",
"phing/phing": "~2.13.0",
"phpunit/phpunit": "~5.0",
"slevomat/coding-standard": "1.0.4"
},
"autoload": {
"psr-4": {"PHPStan\\": "src/"}
},
"autoload-dev": {
"classmap": ["tests/"]
}
}
128 changes: 128 additions & 0 deletions conf/config.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
parameters:
debug_cli_browser:
excludes_analyse:
- %rootDir%/tests/*/data/* # todo přes konfigurák při spouštění binárky
autoload_directories: []
autoload_files: []
lookForFuncGetArgs: false # 'true' looks for func_get_args and evaluates functions and methods as variadic, greatly decreases performance

services:
-
class: PhpParser\Lexer

-
class: PhpParser\NodeTraverser
setup:
- addVisitor(@PhpParser\NodeVisitor\NameResolver)

-
class: PhpParser\NodeVisitor\NameResolver

-
class: PhpParser\Parser\Php7

-
class: PHPStan\Analyser\Analyser
arguments:
analyseExcludes: %excludes_analyse%

-
class: PHPStan\Command\AnalyseApplication

-
class: PHPStan\Parser\CachedParser
arguments:
originalParser: @directParser

-
class: PHPStan\Parser\FunctionCallStatementFinder

-
implement: PHPStan\Reflection\FunctionReflectionFactory
arguments:
lookForFuncGetArgs: %lookForFuncGetArgs%

-
class: PHPStan\Reflection\Php\PhpClassReflectionExtension

-
implement: PHPStan\Reflection\Php\PhpMethodReflectionFactory
arguments:
lookForFuncGetArgs: %lookForFuncGetArgs%

-
class: PHPStan\Rules\FunctionCallParametersCheck

-
class: PHPStan\Rules\FunctionDefinitionCheck

-
class: PHPStan\Rules\Classes\AccessOwnPropertiesRule

-
class: PHPStan\Rules\Classes\AccessStaticPropertiesRule

-
class: PHPStan\Rules\Classes\ClassConstantRule

-
class: PHPStan\Rules\Classes\ExistingClassInInstanceOfRule

-
class: PHPStan\Rules\Classes\InstantiationRule

-
class: PHPStan\Rules\Classes\RequireParentConstructCallRule

-
class: PHPStan\Rules\Exceptions\CatchedExceptionExistenceRule

-
class: PHPStan\Rules\Functions\CallToFunctionParametersRule

-
class: PHPStan\Rules\Functions\CallToNonExistentFunctionRule

-
class: PHPStan\Rules\Functions\ExistingClassesInTypehintsRule

-
class: PHPStan\Rules\Functions\PrintfParametersRule

-
class: PHPStan\Rules\Methods\CallOwnMethodsRule

-
class: PHPStan\Rules\Methods\CallStaticMethodsRule

-
class: PHPStan\Rules\Methods\ExistingClassesInTypehintsRule

-
class: PHPStan\Rules\Registry
setup:
- register(@PHPStan\Rules\Classes\AccessOwnPropertiesRule)
- register(@PHPStan\Rules\Classes\AccessStaticPropertiesRule)
- register(@PHPStan\Rules\Classes\ClassConstantRule)
- register(@PHPStan\Rules\Classes\ExistingClassInInstanceOfRule)
- register(@PHPStan\Rules\Classes\InstantiationRule)
- register(@PHPStan\Rules\Classes\RequireParentConstructCallRule)
- register(@PHPStan\Rules\Exceptions\CatchedExceptionExistenceRule)
- register(@PHPStan\Rules\Functions\CallToNonExistentFunctionRule)
- register(@PHPStan\Rules\Functions\CallToFunctionParametersRule)
- register(@PHPStan\Rules\Functions\ExistingClassesInTypehintsRule)
- register(@PHPStan\Rules\Functions\PrintfParametersRule)
- register(@PHPStan\Rules\Methods\CallOwnMethodsRule)
- register(@PHPStan\Rules\Methods\CallStaticMethodsRule)
- register(@PHPStan\Rules\Methods\ExistingClassesInTypehintsRule)

broker:
class: PHPStan\Broker\Broker
arguments:
classReflectionExtensions:
- @PHPStan\Reflection\Php\PhpClassReflectionExtension

directParser:
class: PHPStan\Parser\DirectParser
autowired: no

12 changes: 12 additions & 0 deletions ruleset.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0"?>
<ruleset name="PHPStan">
<rule ref="vendor/slevomat/coding-standard/SlevomatCodingStandard/ruleset.xml">
<exclude name="SlevomatCodingStandard.Files.TypeNameMatchesFileName"/>
<exclude name="SlevomatCodingStandard.Namespaces.FullyQualifiedClassNameAfterKeyword"/>
<exclude name="SlevomatCodingStandard.Namespaces.UseOnlyWhitelistedNamespaces"/>
<exclude name="SlevomatCodingStandard.Namespaces.ReferenceUsedNamesOnly"/>
</rule>
<rule ref="Squiz.PHP.InnerFunctions.NotAllowed">
<exclude-pattern>tests/PHPStan/Rules/AbstractRuleTest.php</exclude-pattern>
</rule>
</ruleset>
8 changes: 8 additions & 0 deletions src/AnalysedCodeException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php declare(strict_types = 1);

namespace PHPStan;

abstract class AnalysedCodeException extends \Exception
{

}
Loading

0 comments on commit 1cb3904

Please sign in to comment.