引入 cs-fix , 格式化代码

pull/1/head
韩天峰 1 year ago
parent 228049c859
commit 5053797463
  1. 9
      composer.json
  2. 4059
      composer.lock
  3. 19
      src/Php/Encryptor.php
  4. 15
      src/Php/Translator.php

@ -2,6 +2,10 @@
"require": {
"nikic/php-parser": "^5.0"
},
"require-dev": {
"phpunit/phpunit": "^10.4",
"friendsofphp/php-cs-fixer": "^3.40"
},
"autoload": {
"psr-4": {
"PhpAot\\": "src"
@ -9,5 +13,10 @@
"files": [
"src/functions.php"
]
},
"scripts": {
"cs-fix": "php-cs-fixer fix $1",
"analyse": "phpstan analyse --memory-limit 512M -l 5 -c phpstan.neon",
"rector": "rector process --clear-cache"
}
}

4059
composer.lock generated

File diff suppressed because it is too large Load Diff

@ -20,7 +20,7 @@ class Encryptor extends \PhpAot\Core\Translator
protected array $decodeMap;
protected array $constants;
function __construct(array $stmts)
public function __construct(array $stmts)
{
$confDir = __DIR__ . '/../../config';
$this->stmts = $stmts;
@ -29,7 +29,7 @@ class Encryptor extends \PhpAot\Core\Translator
$this->constants = require $confDir . '/constants.php';
}
function parseHeaders(): string
public function parseHeaders(): string
{
$lines = [];
foreach ($this->headers as $header) {
@ -38,30 +38,30 @@ class Encryptor extends \PhpAot\Core\Translator
return implode(PHP_EOL, $lines) . PHP_EOL . PHP_EOL;
}
function setPhpxDir($dir): void
public function setPhpxDir($dir): void
{
$this->phpxDir = $dir;
}
function convert()
public function convert()
{
$this->parseStmts($this->stmts);
$prettyPrinter = new Standard;
$prettyPrinter = new Standard();
return $prettyPrinter->prettyPrintFile($this->stmts);
}
function save($code, $file)
public function save($code, $file)
{
file_put_contents($file, $code);
}
function getLine($node): int
public function getLine($node): int
{
return $node->getLine();
}
function getType($node): string
public function getType($node): string
{
return $node->getType();
}
@ -75,7 +75,7 @@ class Encryptor extends \PhpAot\Core\Translator
}
if ($v->returnType) {
$return =$this->parseIdentifier($v->returnType);
$return = $this->parseIdentifier($v->returnType);
} else {
$return = '';
}
@ -429,4 +429,3 @@ class Encryptor extends \PhpAot\Core\Translator
}
}
}

@ -16,12 +16,12 @@ class Translator extends \PhpAot\Core\Translator
'phpx.h',
];
function __construct(array $stmts)
public function __construct(array $stmts)
{
$this->stmts = $stmts;
}
function parseHeaders(): string
public function parseHeaders(): string
{
$lines = [];
foreach ($this->headers as $header) {
@ -30,12 +30,12 @@ class Translator extends \PhpAot\Core\Translator
return implode(PHP_EOL, $lines) . PHP_EOL . PHP_EOL;
}
function setPhpxDir($dir): void
public function setPhpxDir($dir): void
{
$this->phpxDir = $dir;
}
function convert()
public function convert()
{
$code = '';
$code .= $this->parseHeaders();
@ -44,18 +44,18 @@ class Translator extends \PhpAot\Core\Translator
return $code;
}
function save($code, $file)
public function save($code, $file)
{
file_put_contents($file, $code);
}
function getLine($node): int
public function getLine($node): int
{
return $node->getLine();
}
function getType($node): string
public function getType($node): string
{
return $node->getType();
}
@ -311,4 +311,3 @@ class Translator extends \PhpAot\Core\Translator
return $left . ' + ' . $right;
}
}

Loading…
Cancel
Save