Skip to content

Commit

Permalink
fix some error for parse json5 header
Browse files Browse the repository at this point in the history
  • Loading branch information
inhere committed Nov 12, 2021
1 parent 6412d38 commit aa91adc
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
5 changes: 3 additions & 2 deletions app/Console/Component/ContentsAutoReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,15 @@ public function read(string $source, array $opts = []): string
if (!$source) {
$this->srcType = self::TYPE_STDIN;
$print && Cli::info('try read contents from STDIN');
$str = Kite::cliApp()->getInput()->readAll();
$str = Kite::cliApp()->getInput()->readAll(false);
// $str = File::readStdinBody();

// is one line text
} elseif (!str_contains($source, "\n")) {
if (KiteUtil::isStdinAlias($source)) {
$this->srcType = self::TYPE_STDIN;
$print && Cli::info('try read contents from STDIN');
$str = Kite::cliApp()->getInput()->readAll();
$str = Kite::cliApp()->getInput()->readAll(false);
// $str = File::streamReadAll(STDIN);
// $str = File::readAll('php://stdin');
// vdump($str);
Expand Down
11 changes: 10 additions & 1 deletion app/Lib/Generate/Java/JavaType.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

namespace Inhere\Kite\Lib\Generate\Java;

use Toolkit\Stdlib\Type;
use function ucfirst;

/**
* class JavaType
*/
Expand All @@ -18,6 +21,12 @@ class JavaType
*/
public static function php2javaType(string $type): string
{
return $type;
if ($type === 'int') {
$type = Type::INTEGER;
} elseif ($type === Type::ARRAY) {
$type = Type::OBJECT;
}

return ucfirst($type);
}
}
2 changes: 1 addition & 1 deletion app/Lib/Generate/Json5Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function loadFrom(string $json): self
->setBeforeParseHeader(function (string $header) {
if ($pos = strpos($header, "//##\n")) {
$header = substr($header, $pos + 4);
$header = str_replace("\n//", '', $header);
$header = str_replace("\n//", "\n", $header);
}

return $header;
Expand Down

0 comments on commit aa91adc

Please sign in to comment.