From 7036c5e780b76724e3975c04d86e7e1c53c4364b Mon Sep 17 00:00:00 2001
From: Tim van Dijen <tvdijen@gmail.com>
Date: Mon, 4 Feb 2019 10:56:51 +0100
Subject: [PATCH] Fixes for modules/ldap

---
 .../ldap/lib/Auth/Process/AttributeAddFromLDAP.php    |  3 ++-
 .../ldap/lib/Auth/Process/AttributeAddUsersGroups.php |  2 +-
 modules/ldap/lib/Auth/Process/BaseFilter.php          | 11 +++++------
 modules/ldap/lib/ConfigHelper.php                     |  9 ++++++++-
 4 files changed, 16 insertions(+), 9 deletions(-)

diff --git a/modules/ldap/lib/Auth/Process/AttributeAddFromLDAP.php b/modules/ldap/lib/Auth/Process/AttributeAddFromLDAP.php
index a1062376d..99ca6c0cc 100644
--- a/modules/ldap/lib/Auth/Process/AttributeAddFromLDAP.php
+++ b/modules/ldap/lib/Auth/Process/AttributeAddFromLDAP.php
@@ -34,7 +34,6 @@ namespace SimpleSAML\Module\ldap\Auth\Process;
  * @author Remy Blom <remy.blom@hku.nl>
  * @package SimpleSAMLphp
  */
-
 class AttributeAddFromLDAP extends BaseFilter
 {
     /**
@@ -60,6 +59,7 @@ class AttributeAddFromLDAP extends BaseFilter
      */
     protected $attr_policy;
 
+
     /**
      * Initialize this filter.
      *
@@ -136,6 +136,7 @@ class AttributeAddFromLDAP extends BaseFilter
      * Add attributes from an LDAP server.
      *
      * @param array &$request The current request
+     * @return void
      */
     public function process(&$request)
     {
diff --git a/modules/ldap/lib/Auth/Process/AttributeAddUsersGroups.php b/modules/ldap/lib/Auth/Process/AttributeAddUsersGroups.php
index fc66ec57f..ccf94067a 100644
--- a/modules/ldap/lib/Auth/Process/AttributeAddUsersGroups.php
+++ b/modules/ldap/lib/Auth/Process/AttributeAddUsersGroups.php
@@ -10,7 +10,6 @@ namespace SimpleSAML\Module\ldap\Auth\Process;
  * @author Ryan Panning <panman@traileyes.com>
  * @package SimpleSAMLphp
  */
-
 class AttributeAddUsersGroups extends BaseFilter
 {
     /**
@@ -21,6 +20,7 @@ class AttributeAddUsersGroups extends BaseFilter
      *
      * @throws \SimpleSAML\Error\Exception
      * @param $request
+     * @return void
      */
     public function process(&$request)
     {
diff --git a/modules/ldap/lib/Auth/Process/BaseFilter.php b/modules/ldap/lib/Auth/Process/BaseFilter.php
index f7de0656f..4c1d9d002 100644
--- a/modules/ldap/lib/Auth/Process/BaseFilter.php
+++ b/modules/ldap/lib/Auth/Process/BaseFilter.php
@@ -14,7 +14,6 @@ namespace SimpleSAML\Module\ldap\Auth\Process;
  * @author Remy Blom <remy.blom@hku.nl>
  * @package SimpleSAMLphp
  */
-
 abstract class BaseFilter extends \SimpleSAML\Auth\ProcessingFilter
 {
     /**
@@ -50,7 +49,7 @@ abstract class BaseFilter extends \SimpleSAML\Auth\ProcessingFilter
      * Instance, object of the ldap connection. Stored here to
      * be access later during processing.
      *
-     * @var \SimpleSAML\Auth\Ldap
+     * @var \SimpleSAML\Auth\LDAP
      */
     private $ldap;
 
@@ -90,8 +89,8 @@ abstract class BaseFilter extends \SimpleSAML\Auth\ProcessingFilter
      * instance/object and stores everything in class members.
      *
      * @throws \SimpleSAML\Error\Exception
-     * @param array $config
-     * @param $reserved
+     * @param array &$config
+     * @param mixed $reserved
      */
     public function __construct(&$config, $reserved)
     {
@@ -255,12 +254,12 @@ abstract class BaseFilter extends \SimpleSAML\Auth\ProcessingFilter
      * rather than setting in the constructor to avoid unnecessarily
      * connecting to LDAP when it might not be needed.
      *
-     * @return \SimpleSAML\Auth\Ldap
+     * @return \SimpleSAML\Auth\LDAP
      */
     protected function getLdap()
     {
         // Check if already connected
-        if ($this->ldap) {
+        if (isset($this->ldap)) {
             return $this->ldap;
         }
 
diff --git a/modules/ldap/lib/ConfigHelper.php b/modules/ldap/lib/ConfigHelper.php
index d4dcff33a..6d862c5a0 100644
--- a/modules/ldap/lib/ConfigHelper.php
+++ b/modules/ldap/lib/ConfigHelper.php
@@ -253,7 +253,7 @@ class ConfigHelper
      * @param bool $allowZeroHits
      * Determines if the method will throw an exception if no
      * hits are found. Defaults to FALSE.
-     * @return string
+     * @return string|null
      * The DN of the matching element, if found. If no element was
      * found and $allowZeroHits is set to FALSE, an exception will
      * be thrown; otherwise NULL will be returned.
@@ -295,6 +295,13 @@ class ConfigHelper
         );
     }
 
+
+    /**
+     * @param string $dn
+     * @param array|null $attributes
+     * @return array
+     * @throws \Exception
+     */
     public function getAttributes($dn, $attributes = null)
     {
         if ($attributes == null) {
-- 
GitLab