⚠️ [ABANDONED] Rinvex Subscribable is a flexible plans and subscription management system for Laravel, with the required tools to run your SAAS like services efficiently. It's simple architecture, accompanied by powerful underlying to afford solid platform for your business.
MIT License
727
stars
347
forks
source link
Fix feature validation when feature doesn't exist #171
Fix the exception caused by trying to access getKey() method on a null feature. This error occurs when you try to check a feature that does not exist in the subscription.
Error
Error occurs when you try to check a feature using canUseFeature() method. If the feature you try to check doesn't exist in the subscription, it gets this exception:
the problem is null coalescing operator ( ?? ) check if the previous variable is set or not null, trying to access a method on a null object(as in the code above) throw a exception that is not catch by the null coalescing operator.
Solutions
one posible solution is replace the null coalescing operator with a ternary operator:
Description
Fix the exception caused by trying to access getKey() method on a null feature. This error occurs when you try to check a feature that does not exist in the subscription.
Error
Error occurs when you try to check a feature using canUseFeature() method. If the feature you try to check doesn't exist in the subscription, it gets this exception:
The exception is caused by this line:
the problem is null coalescing operator ( ?? ) check if the previous variable is set or not null, trying to access a method on a null object(as in the code above) throw a exception that is not catch by the null coalescing operator.
Solutions
one posible solution is replace the null coalescing operator with a ternary operator:
This works as expected returning null in case no feature is found.