You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
CI4: Missing return statement in get_category_name() function of Supplier model #3456
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?
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?
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.
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.
Activity
jekkos commentedon Apr 2, 2022
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?
objecttothis commentedon Apr 4, 2022
Currently the constants just represent an integer

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?objecttothis commentedon Apr 4, 2022
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.jekkos commentedon Apr 4, 2022
Indeed that was my idea. If there is a string missing then it will be directly clear.
objecttothis commentedon Apr 12, 2022
Fixed in #3271 but for now only in the en-US language.
Correct missing return type from #3456
Correct missing return type from #3456