Skip to content

Commit

Permalink
Fix boolean values handling in enum/const blocks (#44)
Browse files Browse the repository at this point in the history
  • Loading branch information
vearutop authored Apr 28, 2022
1 parent b3e41b0 commit f292798
Show file tree
Hide file tree
Showing 7 changed files with 214 additions and 296 deletions.
15 changes: 14 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,22 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.4.47] - 2022-01-02
## [0.4.49] - 2022-04-28

### Fixed

- Boolean values handling in enum/const block

## [0.4.48] - 2022-01-02

### Added
- Support for PHP 8.1

## [0.4.47] - 2022-01-02

### Fixed
- Code generation for AsyncAPI 2.1.0 schema

## [0.4.46] - 2021-08-29

### Fixed
Expand Down Expand Up @@ -277,6 +288,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed
- Removed unnecessary regexp dependency, #7.

[0.4.49]: https://github.com/swaggest/go-code-builder/compare/v0.4.48...v0.4.49
[0.4.48]: https://github.com/swaggest/go-code-builder/compare/v0.4.47...v0.4.48
[0.4.47]: https://github.com/swaggest/go-code-builder/compare/v0.4.46...v0.4.47
[0.4.46]: https://github.com/swaggest/go-code-builder/compare/v0.4.45...v0.4.46
[0.4.45]: https://github.com/swaggest/go-code-builder/compare/v0.4.44...v0.4.45
Expand Down
7 changes: 1 addition & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"swaggest/json-schema-maker": "^0.3.2"
},
"require-dev": {
"phpunit/phpunit": "4.8.36",
"phperf/phpunit": "4.8.37",
"victorjonsson/markdowndocs": "^1.3"
},
"autoload": {
Expand All @@ -40,10 +40,5 @@
"platform": {
"php": "5.6.1"
}
},
"scripts": {
"post-install-cmd": [
"patch -N -s -p0 < ./tests/phpunit.patch"
]
}
}
177 changes: 91 additions & 86 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion src/Templates/Constant/TypeConstBlock.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,13 @@ protected function toString()
if (!is_scalar($value)) {
continue;
}
$value = $this->escapeValue($value);
if ($value === true) {
$value = 'true';
} elseif ($value === false) {
$value = 'false';
} else {
$value = $this->escapeValue($value);
}

if (isset($this->comments[$name])) {
$result .= "\t//" . $name . ' ' . $this->comments[$name] . "\n";
Expand Down
Loading

0 comments on commit f292798

Please sign in to comment.