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

[PHP] Cannot use "parent" when current class scope has no parent #12462

Open
WarriorXK opened this issue Sep 11, 2024 · 0 comments
Open

[PHP] Cannot use "parent" when current class scope has no parent #12462

WarriorXK opened this issue Sep 11, 2024 · 0 comments

Comments

@WarriorXK
Copy link

WarriorXK commented Sep 11, 2024

Description

When executing a request using PHP generated code I am getting the following error:
Cannot use "parent" when current class scope has no parent

This occurs (in my specific case) in the \Checkly\Client\Model\CheckList class with the listInvalidProperties method. The error is correct since the class does not extend another class since it is defined as following:
class CheckList implements ModelInterface, ArrayAccess

This is the generated method:

    public function listInvalidProperties()
    {
        $invalidProperties = parent::listInvalidProperties();

        return $invalidProperties;
    }

Full file can be found here:
CheckList.txt

Swagger-codegen version

I am using version 3

Swagger declaration file content or url

I use the following swagger file:
https://api.checklyhq.com/swagger.json

Command line used for generation

I use the following command to generate the code:

docker run --rm -v ".:/local/out" swaggerapi/swagger-codegen-cli-v3 generate \
    --invoker-package Checkly\\Client \
    -i https://api.checklyhq.com/swagger.json \
    -l php \
    -o /local/out/
Steps to reproduce

Generate the code, and execute a listing request.

Related issues/PRs
Suggest a fix/enhancement

Please note that I have no experience with mustache or this library, but i did notice the following which might be the cause:
In the modules/swagger-codegen/src/main/resources/php/model_generic.mustache file i noticed that everywhere the {{#parentSchema}} block was used except for in the listInvalidProperties method, there the {{#parent}} block is used instead.

akoziolsc added a commit to sitecrafting/gearlab-tools-php that referenced this issue Oct 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant