mirror of
https://codeberg.org/demostf/api.git
synced 2026-06-03 09:54:17 +02:00
add phan
This commit is contained in:
parent
6adcdc2362
commit
b3fbc1be3c
7 changed files with 91 additions and 10 deletions
13
.phan/config.php
Normal file
13
.phan/config.php
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
<?php
|
||||
|
||||
return [
|
||||
'directory_list' => [
|
||||
'src',
|
||||
'vendor',
|
||||
],
|
||||
'exclude_file_regex' => '@^vendor/.*/(tests|Tests)/@',
|
||||
"exclude_analysis_directory_list" => [
|
||||
'vendor/'
|
||||
],
|
||||
'dead_code_detection' => false,
|
||||
];
|
||||
|
|
@ -22,6 +22,7 @@ env:
|
|||
- DEMO_ROOT=/tmp/demos
|
||||
|
||||
install:
|
||||
- pecl install ast
|
||||
- composer install --no-interaction
|
||||
- npm install
|
||||
|
||||
|
|
@ -36,6 +37,8 @@ script:
|
|||
- phpunit --coverage-clover coverage.xml --configuration test/phpunit.xml
|
||||
- IFS=$'\n'; COMMIT_SCA_FILES=($(git diff --name-only --diff-filter=ACMRTUXB "${$TRAVIS_COMMIT_RANGE}")); unset IFS
|
||||
- vendor/bin/php-cs-fixer fix --config=.php_cs.dist -v --dry-run --allow-risky yes --stop-on-violation --using-cache=no --path-mode=intersection -- "${COMMIT_SCA_FILES[@]}"
|
||||
- phpenv config-rm xdebug.ini
|
||||
- vendor/bin/phan
|
||||
- node node_modules/.bin/mocha --recursive
|
||||
|
||||
after_success:
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@
|
|||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^6.0",
|
||||
"friendsofphp/php-cs-fixer": "^2.4"
|
||||
"friendsofphp/php-cs-fixer": "^2.4",
|
||||
"etsy/phan": "^0.9.3"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
55
composer.lock
generated
55
composer.lock
generated
|
|
@ -4,7 +4,7 @@
|
|||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "5790dd2b41f3548c5edd9287bfcd1c45",
|
||||
"content-hash": "c21dd50adbed335c87491af1a1b2cff6",
|
||||
"packages": [
|
||||
{
|
||||
"name": "doctrine/annotations",
|
||||
|
|
@ -1105,6 +1105,59 @@
|
|||
],
|
||||
"time": "2015-06-14T21:17:01+00:00"
|
||||
},
|
||||
{
|
||||
"name": "etsy/phan",
|
||||
"version": "0.9.3",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/etsy/phan.git",
|
||||
"reference": "e16ea3a01fdb4b38cd12d411200a1926ed56dd2a"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/etsy/phan/zipball/e16ea3a01fdb4b38cd12d411200a1926ed56dd2a",
|
||||
"reference": "e16ea3a01fdb4b38cd12d411200a1926ed56dd2a",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"ext-ast": "^0.1.4",
|
||||
"php": "~7.1.0",
|
||||
"symfony/console": "~2.3|~3.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^6.2.1"
|
||||
},
|
||||
"bin": [
|
||||
"phan",
|
||||
"phan_client",
|
||||
"tocheckstyle"
|
||||
],
|
||||
"type": "project",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Phan\\": "src/Phan"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Rasmus Lerdorf"
|
||||
},
|
||||
{
|
||||
"name": "Andrew S. Morrison"
|
||||
}
|
||||
],
|
||||
"description": "A static analyzer for PHP",
|
||||
"keywords": [
|
||||
"analyzer",
|
||||
"php",
|
||||
"static"
|
||||
],
|
||||
"time": "2017-07-11T15:55:24+00:00"
|
||||
},
|
||||
{
|
||||
"name": "firebase/php-jwt",
|
||||
"version": "v4.0.0",
|
||||
|
|
|
|||
|
|
@ -35,11 +35,11 @@ class Parser {
|
|||
|
||||
public function analyse(string $path): ParsedDemo {
|
||||
$data = $this->rawParser->parse($path);
|
||||
if (!is_array($data)) {
|
||||
if (is_array($data)) {
|
||||
return $this->handleData($data);
|
||||
} else {
|
||||
throw new \InvalidArgumentException('Error parsing demo');
|
||||
}
|
||||
|
||||
return $this->handleData($data);
|
||||
}
|
||||
|
||||
private function handleData(array $data): ParsedDemo {
|
||||
|
|
@ -60,7 +60,8 @@ class Parser {
|
|||
|
||||
foreach ($data['chat'] as $message) {
|
||||
if (isset($message['from'])) {
|
||||
$chat[] = new ChatMessage($message['from'], (int) floor(($message['tick'] - $data['startTick']) * $intervalPerTick), $message['text']);
|
||||
$chat[] = new ChatMessage($message['from'],
|
||||
(int)floor(($message['tick'] - $data['startTick']) * $intervalPerTick), $message['text']);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -79,13 +80,14 @@ class Parser {
|
|||
$player['userId'],
|
||||
$this->convertSteamIdToCommunityId($player['steamId']),
|
||||
$player['team'],
|
||||
$this->getClassName((int) $class)
|
||||
$this->getClassName((int)$class)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$kills = array_map(function (array $death) {
|
||||
return new ParsedKill($death['killer'] ?? 0, $death['assister'] ?? 0, $death['victim'] ?? 0, $death['weapon']);
|
||||
return new ParsedKill($death['killer'] ?? 0, $death['assister'] ?? 0, $death['victim'] ?? 0,
|
||||
$death['weapon']);
|
||||
}, $data['deaths']);
|
||||
|
||||
return new ParsedDemo(
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ declare(strict_types=1);
|
|||
namespace Demostf\API\Demo;
|
||||
|
||||
use GuzzleHttp\Client;
|
||||
use GuzzleHttp\Exception\GuzzleException;
|
||||
use GuzzleHttp\Exception\RequestException;
|
||||
|
||||
/**
|
||||
* Wrapper around demo.js parser.
|
||||
|
|
@ -32,7 +32,7 @@ class RawParser {
|
|||
} else {
|
||||
return $result;
|
||||
}
|
||||
} catch (GuzzleException $e) {
|
||||
} catch (RequestException $e) {
|
||||
if (strpos($e->getMessage(), 'cURL error 52') !== false) {
|
||||
throw new \Exception('Failed to parse demo, can\'t reach demo parser');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,6 +21,15 @@ class BaseProvider {
|
|||
*/
|
||||
protected $db;
|
||||
|
||||
/**
|
||||
* BaseProvider constructor.
|
||||
* @param Connection $connection
|
||||
*
|
||||
* The DBAL connection used will always be a PDO
|
||||
* but phan isn't aware of this.
|
||||
*
|
||||
* @suppress PhanTypeMismatchArgument
|
||||
*/
|
||||
public function __construct(Connection $connection) {
|
||||
$this->connection = $connection;
|
||||
$this->db = new Database($connection->getWrappedConnection());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue