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

Incorrect native parameter type on nullable setters in mutable models #50

Open
dktapps opened this issue Oct 14, 2021 · 5 comments
Open
Assignees
Labels
bug Something isn't working

Comments

@dktapps
Copy link
Contributor

dktapps commented Oct 14, 2021

Describe the bug
Nullable field setters don't correctly account for null when generating typehints.
image

Again, found by PHPStan.

Expected behavior
setDisableBlockTicking() should accept null.

Schema

{
	"$schema": "http://json-schema.org/draft-04/schema#",
	"type": "object",
	"additionalProperties": false,
	"properties": {
		"disable-block-ticking": {
			"oneOf": [
				{
					"type": "array",
					"items": {
						"type": "integer"
					}
				},
				{
					"type": "null"
				}
			],
			"description": "IDs of blocks to disallow ticking.",
			"default": null
		}
	},
	"required": [
		"chunk-ticking"
	]
}

Config: https://github.com/pmmp/DataModels/blob/3f398d966d5180d68e33c8f4054ab592094ea54c/generate-schemas.php

Version:
0.21.5.

@dktapps
Copy link
Contributor Author

dktapps commented Oct 14, 2021

This seems to appear in a few other places where anyOf has been used in my schemas, like this one (both getters and setters are wrong in this case):
image

@wol-soft wol-soft added the bug Something isn't working label Oct 15, 2021
@wol-soft
Copy link
Owner

I've added fixes for this issue and issue #51 to the master branch and tagged version 0.21.6 which includes the fixes.

@wol-soft
Copy link
Owner

Hi @dktapps,

thanks for the report, again.
I'm currently working on a larger refactoring to support various JSON-Schema versions which also includes how types are evaluated to fix issues with composed types. This will fix the issue, when completed.

Cheers.

@dktapps
Copy link
Contributor Author

dktapps commented Nov 29, 2021

Alright, thanks for the update.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants