Skip to content
This repository has been archived by the owner on Jul 18, 2018. It is now read-only.

Commit

Permalink
Adopt Microsoft/tolerant-php-parser (felixfbecker#357)
Browse files Browse the repository at this point in the history
  • Loading branch information
mousetraps authored and felixfbecker committed Jun 9, 2017
1 parent 08cf1a3 commit 7f427a1
Show file tree
Hide file tree
Showing 194 changed files with 6,450 additions and 1,483 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ vendor/
.phpls/
composer.lock
stubs
*.ast
27 changes: 27 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
[submodule "validation/frameworks/php-language-server"]
path = validation/frameworks/php-language-server
url = https://github.com/felixfbecker/php-language-server
[submodule "validation/frameworks/wordpress"]
path = validation/frameworks/wordpress
url = https://github.com/wordpress/wordpress
[submodule "validation/frameworks/drupal"]
path = validation/frameworks/drupal
url = https://github.com/drupal/drupal
[submodule "validation/frameworks/tolerant-php-parser"]
path = validation/frameworks/tolerant-php-parser
url = https://github.com/microsoft/tolerant-php-parser
[submodule "validation/frameworks/symfony"]
path = validation/frameworks/symfony
url = https://github.com/symfony/symfony
[submodule "validation/frameworks/math-php"]
path = validation/frameworks/math-php
url = https://github.com/markrogoyski/math-php
[submodule "validation/frameworks/codeigniter"]
path = validation/frameworks/codeigniter
url = https://github.com/bcit-ci/codeigniter
[submodule "validation/frameworks/cakephp"]
path = validation/frameworks/cakephp
url = https://github.com/cakephp/cakephp
[submodule "validation/frameworks/phpunit"]
path = validation/frameworks/phpunit
url = https://github.com/sebastianbergmann/phpunit
65 changes: 65 additions & 0 deletions Performance.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<?php

namespace LanguageServer\Tests;
require __DIR__ . '/vendor/autoload.php';

use Exception;
use LanguageServer\Index\Index;
use LanguageServer\PhpDocument;
use LanguageServer\DefinitionResolver;
use Microsoft\PhpParser;
use phpDocumentor\Reflection\DocBlockFactory;
use RecursiveDirectoryIterator;
use RecursiveIteratorIterator;

$totalSize = 0;

$frameworks = ["drupal", "wordpress", "php-language-server", "tolerant-php-parser", "math-php", "symfony", "CodeIgniter", "cakephp"];

foreach($frameworks as $framework) {
$iterator = new RecursiveDirectoryIterator(__DIR__ . "/validation/frameworks/$framework");
$testProviderArray = array();

foreach (new RecursiveIteratorIterator($iterator) as $file) {
if (strpos((string)$file, ".php") !== false) {
$totalSize += $file->getSize();
$testProviderArray[] = $file->getPathname();
}
}

if (count($testProviderArray) === 0) {
throw new Exception("ERROR: Validation testsuite frameworks not found - run `git submodule update --init --recursive` to download.");
}

$start = microtime(true);

foreach ($testProviderArray as $idx => $testCaseFile) {
if (filesize($testCaseFile) > 10000) {
continue;
}
if ($idx % 1000 === 0) {
echo "$idx\n";
}

$fileContents = file_get_contents($testCaseFile);

$docBlockFactory = DocBlockFactory::createInstance();
$index = new Index;
$maxRecursion = [];
$definitions = [];

$definitionResolver = new DefinitionResolver($index);
$parser = new PhpParser\Parser();

try {
$document = new PhpDocument($testCaseFile, $fileContents, $index, $parser, $docBlockFactory, $definitionResolver);
} catch (\Throwable $e) {
continue;
}
}

echo "------------------------------\n";

echo "Time [$framework]: " . (microtime(true) - $start) . PHP_EOL;
}

8 changes: 5 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
},
"require": {
"php": ">=7.0",
"nikic/php-parser": "^3.0.5",
"phpdocumentor/reflection-docblock": "^3.0",
"sabre/event": "^5.0",
"felixfbecker/advanced-json-rpc": "^2.0",
Expand All @@ -38,7 +37,8 @@
"webmozart/glob": "^4.1",
"sabre/uri": "^2.0",
"jetbrains/phpstorm-stubs": "dev-master",
"composer/composer": "^1.3"
"composer/composer": "^1.3",
"Microsoft/tolerant-php-parser": "^0.0.2"
},
"minimum-stability": "dev",
"prefer-stable": true,
Expand All @@ -47,7 +47,9 @@
"LanguageServer\\": "src/"
},
"files" : [
"src/utils.php"
"src/utils.php",
"src/FqnUtilities.php",
"src/ParserHelpers.php"
]
},
"autoload-dev": {
Expand Down
1 change: 1 addition & 0 deletions phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<ruleset name="PHP Language Server">
<file>src</file>
<file>tests</file>
<exclude-pattern>tests/Validation/cases</exclude-pattern>
<rule ref="PSR2">
<exclude name="PSR2.Namespaces.UseDeclaration.MultipleDeclarations"/>
<exclude name="PSR2.ControlStructures.ElseIfDeclaration.NotAllowed"/>
Expand Down
2 changes: 1 addition & 1 deletion phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@
</whitelist>
</filter>
<php>
<ini name="memory_limit" value="256M"/>
<ini name="memory_limit" value="1024M"/>
</php>
</phpunit>
Loading

0 comments on commit 7f427a1

Please sign in to comment.