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

Nullable parameters in PHP generated classes #40

Closed
ezimuel opened this issue Aug 17, 2023 · 1 comment
Closed

Nullable parameters in PHP generated classes #40

ezimuel opened this issue Aug 17, 2023 · 1 comment
Assignees
Labels
bug Something isn't working
Milestone

Comments

@ezimuel
Copy link
Contributor

ezimuel commented Aug 17, 2023

Some generated the Schema classes have the nullable option (?) in constructor but they don't have nullable in the property definition. For instance, the ExtractUrlIndexingResults in AppSearch\Schema :

namespace Elastic\EnterpriseSearch\AppSearch\Schema;

/**
 * @generated This file is generated, please do not edit
 */
class ExtractUrlIndexingResults
{
	public string $document_id;
	public object $document_fields;


	public function __construct(?string $document_id, ?object $document_fields)
	{
		$this->document_id = $document_id;
		$this->document_fields = $document_fields;
	}
}

In this example, the $document_id and the $document_fields properties will generate a FATAL error when set to null.
The FATAL error at runtime will be PHP Fatal error: Uncaught TypeError: Cannot assign null to property.
We need to fix this adding nullable also in the definition, as follows:

namespace Elastic\EnterpriseSearch\AppSearch\Schema;

/**
 * @generated This file is generated, please do not edit
 */
class ExtractUrlIndexingResults
{
	public ?string $document_id;
	public ?object $document_fields;


	public function __construct(?string $document_id, ?object $document_fields)
	{
		$this->document_id = $document_id;
		$this->document_fields = $document_fields;
	}
}
@ezimuel ezimuel added the bug Something isn't working label Aug 17, 2023
@ezimuel ezimuel self-assigned this Aug 17, 2023
@ezimuel ezimuel added this to the 8.9.0 milestone Aug 17, 2023
@ezimuel
Copy link
Contributor Author

ezimuel commented Aug 21, 2023

Fixed in version 8.9.0

@ezimuel ezimuel closed this as completed Aug 21, 2023
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

1 participant