Skip to content

CI4: Missing return statement in get_category_name() function of Supplier model #3456

Closed

Description

@objecttothis

Issue / Bug / Question / New Feature

Here is a bug in the code that PHP is complaining about and I need to resolve it to move forward with the CI4 conversion. The problem is that the code has a path that doesn't return anything. Seems like either switching the elseif to an else statement or switching the entire block to a switch statement and adding a default would be the logical options. Alternately if we wanted to go the route of throwing an exception we could do that as well, but it means wrapping the calling code in try/catch blocks and handling the exception. Thoughts?

#3271
158175891-f5c7f9e8-4aa6-40a0-af58-7dc562758767

Activity

  1. jekkos commented on Apr 2, 2022

    @jekkos
    Member

    Maybe we can build the language key based on the constant value, so if a new one is added for some reason it will be rendererd as the key instead?

  2. objecttothis commented on Apr 4, 2022

    @objecttothis
    MemberAuthor

    Currently the constants just represent an integer
    image

    I think you mean changing the code to read something like: return lang('Suppliers.' . $id); and probably refactor $id to something like $supplier_type, then in the language change the names from 'goods' => 'Goods Supplier', to '1' => 'Goods Supplier',? Can you confirm?

  3. objecttothis commented on Apr 4, 2022

    @objecttothis
    MemberAuthor

    We might also be able to get away with GOODS_SUPPLIER => 'Goods Supplier', but I'm not sure if we'd have to cast that to a string or it would be fine as an integer and therefore a mixed associative array.

  4. jekkos commented on Apr 4, 2022

    @jekkos
    Member

    I think you mean changing the code to read something like: return lang('Suppliers.' . $id); and probably refactor $id to something like $supplier_type, then in the language change the names from 'goods' => 'Goods Supplier', to '1' => 'Goods Supplier',? Can you confirm?

    Indeed that was my idea. If there is a string missing then it will be directly clear.

  5. objecttothis commented on Apr 12, 2022

    @objecttothis
    MemberAuthor

    Fixed in #3271 but for now only in the en-US language.

  6. added this to the 3.4.0 milestone on Dec 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions