swagger-codegen icon indicating copy to clipboard operation
swagger-codegen copied to clipboard

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

Open WarriorXK opened this issue 1 year ago • 0 comments

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.

WarriorXK avatar Sep 11 '24 05:09 WarriorXK