r107416 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r107415‎ | r107416 | r107417 >
Date:20:38, 27 December 2011
Author:reedy
Status:resolved (Comments)
Tags:
Comment:
Default to return '' at the bottom of the switch

Remove the redundant else statements for return false/array

-47 lines
Modified paths:
  • /trunk/extensions/LdapAuthentication/LdapAuthentication.php (modified) (history)

Diff [purge]

Index: trunk/extensions/LdapAuthentication/LdapAuthentication.php
@@ -280,9 +280,8 @@
281281 global $wgLDAPServerNames;
282282 if ( isset( $wgLDAPServerNames[$domain] ) ) {
283283 return $wgLDAPServerNames[$domain];
284 - } else {
285 - return array();
286284 }
 285+ return array();
287286 case 'UseLocal':
288287 global $wgLDAPUseLocal;
289288 return $wgLDAPUseLocal;
@@ -290,112 +289,86 @@
291290 global $wgLDAPEncryptionType;
292291 if ( isset( $wgLDAPEncryptionType[$domain] ) ) {
293292 return $wgLDAPEncryptionType[$domain];
294 - } else {
295 - return 'tls';
296293 }
 294+ return 'tls';
297295 case 'Options':
298296 global $wgLDAPOptions;
299297 if ( isset( $wgLDAPOptions[$domain] ) ) {
300298 return $wgLDAPOptions[$domain];
301 - } else {
302 - return array();
303299 }
 300+ return array();
304301 case 'Port':
305302 global $wgLDAPPort;
306303 if ( isset( $wgLDAPPort[$domain] ) ) {
307304 $this->printDebug( "Using non-standard port: " . $wgLDAPPort[$domain], SENSITIVE );
308305 return (string)$wgLDAPPort[$domain];
 306+ } elseif ( $this->getConf( 'EncryptionType' ) == 'ssl' ) {
 307+ return "636";
309308 } else {
310 - if ( $this->getConf( 'EncryptionType' ) == 'ssl' ) {
311 - return "636";
312 - } else {
313 - return "389";
314 - }
 309+ return "389";
315310 }
316311 case 'SearchString':
317312 global $wgLDAPSearchStrings;
318313 if ( isset( $wgLDAPSearchStrings[$domain] ) ) {
319314 return $wgLDAPSearchStrings[$domain];
320 - } else {
321 - return '';
322315 }
323316 case 'ProxyAgent':
324317 global $wgLDAPProxyAgent;
325318 if ( isset( $wgLDAPProxyAgent[$domain] ) ) {
326319 return $wgLDAPProxyAgent[$domain];
327 - } else {
328 - return '';
329320 }
330321 case 'ProxyAgentPassword':
331322 global $wgLDAPProxyAgentPassword;
332323 if ( isset( $wgLDAPProxyAgentPassword[$domain] ) ) {
333324 return $wgLDAPProxyAgentPassword[$domain];
334 - } else {
335 - return '';
336325 }
337326 case 'SearchAttribute':
338327 global $wgLDAPSearchAttributes;
339328 if ( isset( $wgLDAPSearchAttributes[$domain] ) ) {
340329 return $wgLDAPSearchAttributes[$domain];
341 - } else {
342 - return '';
343330 }
344331 case 'BaseDN':
345332 global $wgLDAPBaseDNs;
346333 if ( isset( $wgLDAPBaseDNs[$domain] ) ) {
347334 return $wgLDAPBaseDNs[$domain];
348 - } else {
349 - return '';
350335 }
351336 case 'GroupBaseDN':
352337 global $wgLDAPGroupBaseDNs;
353338 if ( isset( $wgLDAPGroupBaseDNs[$domain] ) ) {
354339 return $wgLDAPGroupBaseDNs[$domain];
355 - } else {
356 - return '';
357340 }
358341 case 'UserBaseDN':
359342 global $wgLDAPUserBaseDNs;
360343 if ( isset( $wgLDAPUserBaseDNs[$domain] ) ) {
361344 return $wgLDAPUserBaseDNs[$domain];
362 - } else {
363 - return '';
364345 }
365346 case 'WriterDN':
366347 global $wgLDAPWriterDN;
367348 if ( isset( $wgLDAPWriterDN[$domain] ) ) {
368349 return $wgLDAPWriterDN[$domain];
369 - } else {
370 - return '';
371350 }
372351 case 'WriterPassword':
373352 global $wgLDAPWriterPassword;
374353 if ( isset( $wgLDAPWriterPassword[$domain] ) ) {
375354 return $wgLDAPWriterPassword[$domain];
376 - } else {
377 - return '';
378355 }
379356 case 'WriteLocation':
380357 global $wgLDAPWriteLocation;
381358 if ( isset( $wgLDAPWriteLocation[$domain] ) ) {
382359 return $wgLDAPWriteLocation[$domain];
383 - } else {
384 - return '';
385360 }
386361 case 'AddLDAPUsers':
387362 global $wgLDAPAddLDAPUsers;
388363 if ( isset( $wgLDAPAddLDAPUsers[$domain] ) ) {
389364 return $wgLDAPAddLDAPUsers[$domain];
390 - } else {
391 - return false;
392365 }
 366+ return false;
393367 case 'UpdateLDAP':
394368 global $wgLDAPUpdateLDAP;
395369 if ( isset( $wgLDAPUpdateLDAP[$domain] ) ) {
396370 return $wgLDAPUpdateLDAP[$domain];
397 - } else {
398 - return false;
399371 }
 372+ return false;
400373 case 'PasswordHash':
401374 global $wgLDAPPasswordHash;
402375 if ( isset( $wgLDAPPasswordHash[$domain] ) ) {
@@ -407,38 +380,33 @@
408381 global $wgLDAPMailPassword;
409382 if ( isset( $wgLDAPMailPassword[$domain] ) ) {
410383 return $wgLDAPMailPassword[$domain];
411 - } else {
412 - return false;
413384 }
 385+ return false;
414386 case 'Preferences':
415387 global $wgLDAPPreferences;
416388 if ( isset( $wgLDAPPreferences[$domain] ) ) {
417389 return $wgLDAPPreferences[$domain];
418 - } else {
419 - return array();
420390 }
 391+ return array();
421392 case 'DisableAutoCreate':
422393 global $wgLDAPDisableAutoCreate;
423394 if ( isset( $wgLDAPDisableAutoCreate[$domain] ) ) {
424395 return $wgLDAPDisableAutoCreate[$domain];
425 - } else {
426 - return false;
427396 }
 397+ return false;
428398 case 'GroupUseFullDN':
429399 global $wgLDAPGroupUseFullDN;
430400 if ( isset( $wgLDAPGroupUseFullDN[$domain] ) ) {
431401 return $wgLDAPGroupUseFullDN[$domain];
432 - } else {
433 - return false;
434402 }
 403+ return false;
435404 case 'LowerCaseUsername':
436405 global $wgLDAPLowerCaseUsername;
437406 if ( isset( $wgLDAPLowerCaseUsername[$domain] ) ) {
438407 $this->printDebug( "Configuration set to lowercase username.", NONSENSITIVE );
439408 return $wgLDAPLowerCaseUsername[$domain];
440 - } else {
441 - return false;
442409 }
 410+ return false;
443411 case 'LowerCaseUsernameScheme':
444412 global $wgLDAPLowerCaseUsernameScheme;
445413 if ( isset( $wgLDAPLowerCaseUsernameScheme[$domain] ) ) {
@@ -452,85 +420,69 @@
453421 global $wgLDAPGroupUseRetrievedUsername;
454422 if ( isset( $wgLDAPGroupUseRetrievedUsername[$domain] ) ) {
455423 return $wgLDAPGroupUseRetrievedUsername[$domain];
456 - } else {
457 - return false;
458424 }
 425+ return false;
459426 case 'GroupObjectclass':
460427 global $wgLDAPGroupObjectclass;
461428 if ( isset( $wgLDAPGroupObjectclass[$domain] ) ) {
462429 return $wgLDAPGroupObjectclass[$domain];
463 - } else {
464 - return '';
465430 }
466431 case 'GroupAttribute':
467432 global $wgLDAPGroupAttribute;
468433 if ( isset( $wgLDAPGroupAttribute[$domain] ) ) {
469434 return $wgLDAPGroupAttribute[$domain];
470 - } else {
471 - return '';
472435 }
473436 case 'GroupNameAttribute':
474437 global $wgLDAPGroupNameAttribute;
475438 if ( isset( $wgLDAPGroupNameAttribute[$domain] ) ) {
476439 return $wgLDAPGroupNameAttribute[$domain];
477 - } else {
478 - return '';
479440 }
480441 case 'GroupsUseMemberOf':
481442 global $wgLDAPGroupsUseMemberOf;
482443 if ( isset( $wgLDAPGroupsUseMemberOf[$domain] ) ) {
483444 return $wgLDAPGroupsUseMemberOf[$domain];
484 - } else {
485 - return false;
486445 }
 446+ return false;
487447 case 'UseLDAPGroups':
488448 global $wgLDAPUseLDAPGroups;
489449 if ( isset( $wgLDAPUseLDAPGroups[$domain] ) ) {
490450 return $wgLDAPUseLDAPGroups[$domain];
491 - } else {
492 - return false;
493451 }
 452+ return false;
494453 case 'LocallyManagedGroups':
495454 global $wgLDAPLocallyManagedGroups;
496455 if ( isset( $wgLDAPLocallyManagedGroups[$domain] ) ) {
497456 return $wgLDAPLocallyManagedGroups[$domain];
498 - } else {
499 - return array();
500457 }
 458+ return array();
501459 case 'GroupsPrevail':
502460 global $wgLDAPGroupsPrevail;
503461 if ( isset( $wgLDAPGroupsPrevail[$domain] ) ) {
504462 return $wgLDAPGroupsPrevail[$domain];
505 - } else {
506 - return false;
507463 }
 464+ return false;
508465 case 'RequiredGroups':
509466 global $wgLDAPRequiredGroups;
510467 if ( isset( $wgLDAPRequiredGroups[$domain] ) ) {
511468 return $wgLDAPRequiredGroups[$domain];
512 - } else {
513 - return array();
514469 }
 470+ return array();
515471 case 'ExcludedGroups':
516472 global $wgLDAPExcludedGroups;
517473 if ( isset( $wgLDAPExcludedGroups[$domain] ) ) {
518474 return $wgLDAPExcludedGroups[$domain];
519 - } else {
520 - return array();
521475 }
 476+ return array();
522477 case 'GroupSearchNestedGroups':
523478 global $wgLDAPGroupSearchNestedGroups;
524479 if ( isset( $wgLDAPGroupSearchNestedGroups[$domain] ) ) {
525480 return $wgLDAPGroupSearchNestedGroups[$domain];
526 - } else {
527 - return false;
528481 }
 482+ return false;
529483 case 'AuthAttribute':
530484 global $wgLDAPAuthAttribute;
531485 if ( isset( $wgLDAPAuthAttribute[$domain] ) ) {
532486 return $wgLDAPAuthAttribute[$domain];
533 - } else {
534 - return '';
535487 }
536488 case 'AutoAuthUsername':
537489 global $wgLDAPAutoAuthUsername;
@@ -539,6 +491,7 @@
540492 global $wgLDAPAutoAuthDomain;
541493 return $wgLDAPAutoAuthDomain;
542494 }
 495+ return '';
543496 }
544497
545498 /**

Comments

#Comment by Ryan lane (talk | contribs)   20:42, 27 December 2011

There are no break statements in any of the cases. If return is moved to the bottom, then breaks need to be added to those cases.

#Comment by Reedy (talk | contribs)   20:46, 27 December 2011

Oh flip.. Yeah

Status & tagging log