[Koha-bugs] [Bug 19809] Koha::Objects::find calls do not need to be forbidden in list context

bugzilla-daemon at bugs.koha-community.org bugzilla-daemon at bugs.koha-community.org
Wed Nov 6 13:22:19 CET 2019


https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19809

--- Comment #18 from Marcel de Rooy <m.de.rooy at rijksmuseum.nl> ---
(In reply to Julian Maurice from comment #17)
> I don't know if it's perlish or not. To me it just feels natural to always
> get a value (even if that value is undef) when I call find. And when you
> think about it, that's what we get actually by being forced to put scalar in
> front of `find` calls.

https://metacpan.org/pod/Perl::Critic::Policy::Subroutines::ProhibitExplicitReturnUndef
Inspired by Damian's best practices.

Note that my $object; ... return $object; is almost the same.

But this is not an argument to not allow an exception from the rule ;)
The only thing we should not do is:
@array = Koha::Objects->find($x);
if( @array ) {
etc.
Because that condition would always be true. Similarly, foreach( ..->find )
would not work.

if( Koha::Objects->find($x) ) would be just fine however and probably what we
need most.

-- 
You are receiving this mail because:
You are watching all bug changes.


More information about the Koha-bugs mailing list