Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for configuration file #22

Closed
AlexanderAllen opened this issue Apr 19, 2024 · 3 comments
Closed

Support for configuration file #22

AlexanderAllen opened this issue Apr 19, 2024 · 3 comments
Assignees
Labels
unit test Unit test needs to be created or updated
Milestone

Comments

@AlexanderAllen
Copy link
Owner

Allow the type generation to be fine-tuned with default configuration placed in a file. It could be Nette Neon, it could be YAML. Who knows?

PHPStan uses neon, but some people might question that choice. The obvious alternative is Symfony YAML.

I haven't decided yet.

@AlexanderAllen AlexanderAllen added the unit test Unit test needs to be created or updated label Apr 19, 2024
@AlexanderAllen AlexanderAllen self-assigned this Apr 19, 2024
@AlexanderAllen AlexanderAllen added this to the 1.0.0-alpha milestone Apr 19, 2024
AlexanderAllen added a commit that referenced this issue Apr 28, 2024
* Keyword `not` completed in #5

* Capture additional todos and requirements in #20, #21.

* Captured comment in #21.

* Note todo for test case allOf, issue #19.

* Make TODOs for #15, #22, #23 in the code.

* Tag #15 re: anyOf.

* Issue #18: Initial boilerplate for file printer.

* Update PanDeAgua boilerplate.

* Promote all MediaNoche code except typematcher function.

* Set Setup as a shared fixture in SRC :/

Sadly, can't seem to be able to leave this fixture under tests.
PHPUnit does not see the namespaced class import, probably due to PHPUnit autoloading.

* OMG: Wrong namespace !

I have been using \Test instead of \Tests all this time?
composer.json autload is the source of thruth here.

* Move all schemas from fixture to schema dir.

* Demote Setup from src to tests where it belongs.

* Make test namespace singular in composer autoload.

* Make test directory consistent with namespace.

* Git ignore only current schema path, but not sub paths.

* Changed tests directory to singular test.

* Update test path for PHPStan.

* Initial print file implementation.

* Disable namespace resolution and specify output directory.

* Promote file printer to class.

* Initial pan de agua comments.

* Assert output file contains source class.

* Swap out default printer for PSR printer.

* Let the user decide both on nullable and readonly attributes.

* Only set default value if present in source schema.

* Address illegal characters for PHP symbols.

* Cleanup some namespaces.

* Update test paths on media noche.

* Change test target to public file.

* Update test path on Github Actions.

* Create tmp output dir on github pipeline.

* Create tmp output dir on github pipeline.
@AlexanderAllen
Copy link
Owner Author

Thought about TOML, just for fun. But...

  • Last release of the most popular package on Packagist was 6 years ago.
  • The domain linked by the creator of that package seems to have been seized by some sort of squatter.
  • There are plenty other parsers on Packagist, but not so sure how I feel going with something downloaded less than a million times. I know, being a bit picky and unfair maybe.

Fun consideration, but pass.

@AlexanderAllen
Copy link
Owner Author

I've gone ahead with PHP .ini files.
It's the most cost-efficient (short-term) option to implement.

Longer-term, a typed settings object is safer to pass around methods, and more efficient for writing tests, since typed objects have less edge cases than schema-less, free form arrays (PHP ini files).

I'll chalk this up in the not letting the perfect (typed settings using YAML) get in the way of the perfectly mediocre (free form arrays) column, somewhere near the iterative, progressive feature implementation column.

@AlexanderAllen
Copy link
Owner Author

Merged in #30.

AlexanderAllen added a commit that referenced this issue May 5, 2024
* PHPCS allow embedded enums in class files.

* Initial enumeration schema and test boilerplate.

* Initial handling for Enum properties.

- Initial enum type reference looks good.
- All tests green.
- Coverage still 99%.
- Now need to dump the actual enum type somewhere.

* Do not test for enums on the basic test cases.

* Add null value and type to enum test case.

* Register new enum method.

* Sidecar enum instances for eventual processing.

* Cleanup: issues #22 and #23 delivered in initial release.

* Dump non-property values into sidecar without breaking any test.

* Cleanup anyOf dead code/comment.

* Accept EnumType for printing in `printFile()`.

* Update the first media noche test `cebeToNetteObject`

* Finally allow EnumTypes in `sourceSchema` without breaking tests.

All tests green, baby. Let's go!

* Update nullable test.

* Reset sidecar on instantiation.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
unit test Unit test needs to be created or updated
Projects
None yet
Development

No branches or pull requests

1 participant