Skip to content

Commit

Permalink
fix: phpstan
Browse files Browse the repository at this point in the history
  • Loading branch information
DeepDiver1975 committed Feb 29, 2024
1 parent 1bbd274 commit edf185e
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 45 deletions.
2 changes: 1 addition & 1 deletion lib/Access.php
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ public function readAttribute($dn, $attr, $filter = 'objectClass=*') {
/**
* Runs an read operation against LDAP
*
* @param resource $cr the LDAP connection
* @param \LDAP\Connection $cr the LDAP connection
* @param string $dn
* @param string|array $attributes
* @param string $filter
Expand Down
4 changes: 2 additions & 2 deletions lib/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
*/
class Connection extends LDAPUtility {
/**
* @var resource|null
* @var \LDAP\Connection | null
*/
private $ldapConnectionRes;

Expand Down Expand Up @@ -201,7 +201,7 @@ public function setIgnoreValidation($state) {
/**
* Returns the LDAP handler
*
* @return resource | null
* @return \LDAP\Connection | null
*
* @throws \OC\ServerNotAvailableException
* @throws BindFailedException
Expand Down
34 changes: 17 additions & 17 deletions lib/ILDAPWrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ interface ILDAPWrapper {

/**
* Bind to LDAP directory
* @param resource $link LDAP link resource
* @param \LDAP\Connection $link LDAP link resource
* @param string $dn an RDN to log in with
* @param string $password the password
* @return bool true on success, false otherwise
Expand All @@ -59,7 +59,7 @@ public function connect($host, $port);

/**
* Send LDAP pagination control
* @param resource $link LDAP link resource
* @param \LDAP\Connection $link LDAP link resource
* @param int $pageSize number of results per page
* @param bool $isCritical Indicates whether the pagination is critical of not.
* @param string $cookie structure sent by LDAP server
Expand All @@ -69,8 +69,8 @@ public function controlPagedResult($link, $pageSize, $isCritical, $cookie);

/**
* Retrieve the LDAP pagination cookie
* @param resource $link LDAP link resource
* @param resource $result LDAP result resource
* @param \LDAP\Connection $link LDAP link resource
* @param \LDAP\Result $result LDAP result resource
* @param string $cookie structure sent by LDAP server
* @param int $estimated The estimated number of entries to retrieve.
* @return bool true on success, false otherwise
Expand All @@ -81,22 +81,22 @@ public function controlPagedResultResponse($link, $result, &$cookie = null, &$es

/**
* Count the number of entries in a search
* @param resource $link LDAP link resource
* @param \LDAP\Connection $link LDAP link resource
* @param resource $result LDAP result resource
* @return int|false number of results on success, false otherwise
*/
public function countEntries($link, $result);

/**
* Return the LDAP error number of the last LDAP command
* @param resource $link LDAP link resource
* @param \LDAP\Connection $link LDAP link resource
* @return string error message as string
*/
public function errno($link);

/**
* Return the LDAP error message of the last LDAP command
* @param resource $link LDAP link resource
* @param \LDAP\Connection $link LDAP link resource
* @return int error code as integer
*/
public function error($link);
Expand Down Expand Up @@ -124,47 +124,47 @@ public function explodeDN($dn, $withAttrib);

/**
* Return first result id
* @param resource $link LDAP link resource
* @param \LDAP\Connection $link LDAP link resource
* @param resource $result LDAP result resource
* @return Resource an LDAP search result resource
* */
public function firstEntry($link, $result);

/**
* Get attributes from a search result entry
* @param resource $link LDAP link resource
* @param \LDAP\Connection $link LDAP link resource
* @param resource $result LDAP result resource
* @return array containing the results, false on error
* */
public function getAttributes($link, $result);

/**
* Get the DN of a result entry
* @param resource $link LDAP link resource
* @param \LDAP\Connection $link LDAP link resource
* @param resource $result LDAP result resource
* @return string containing the DN, false on error
*/
public function getDN($link, $result);

/**
* Get all result entries
* @param resource $link LDAP link resource
* @param \LDAP\Connection $link LDAP link resource
* @param resource $result LDAP result resource
* @return array containing the results, false on error
*/
public function getEntries($link, $result);

/**
* Return next result id
* @param resource $link LDAP link resource
* @param \LDAP\Connection $link LDAP link resource
* @param resource $result LDAP entry result resource
* @return resource an LDAP search result resource
* */
public function nextEntry($link, $result);

/**
* Read an entry
* @param resource $link LDAP link resource
* @param \LDAP\Connection $link LDAP link resource
* @param string $baseDN The DN of the entry to read from
* @param string $filter An LDAP filter
* @param array $attr array of the attributes to read
Expand All @@ -187,7 +187,7 @@ public function search($link, $baseDN, $filter, $attr, $attrsOnly = 0, $limit =

/**
* Sets the value of the specified option to be $value
* @param resource $link LDAP link resource
* @param \LDAP\Connection $link LDAP link resource
* @param string $option a defined LDAP Server option
* @param int $value the new value for the option
* @return bool true on success, false otherwise
Expand All @@ -196,14 +196,14 @@ public function setOption($link, $option, $value);

/**
* establish Start TLS
* @param resource $link LDAP link resource
* @param \LDAP\Connection $link LDAP link resource
* @return bool true on success, false otherwise
*/
public function startTls($link);

/**
* Unbind from LDAP directory
* @param resource $link LDAP link resource
* @param \LDAP\Connection $link LDAP link resource
* @return bool true on success, false otherwise
*/
public function unbind($link);
Expand All @@ -224,7 +224,7 @@ public function hasPagedResultSupport();

/**
* Checks whether the submitted parameter is a resource
* @param resource $resource the resource variable to check
* @param \LDAP\Connection|resource $resource the resource variable to check
* @return bool true if it is a resource, false otherwise
*/
public function isResource($resource);
Expand Down
39 changes: 17 additions & 22 deletions lib/LDAP.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class LDAP implements ILDAPWrapper {
private array $pagedSearchControl;

/**
* @param resource $link
* @param \LDAP\Connection $link
* @param string $dn
* @param string $password
* @return bool|mixed
Expand Down Expand Up @@ -63,11 +63,11 @@ public function connect($host, $port) {
}

/**
* @param LDAP|resource $link
* @param LDAP|resource $result
* @param \LDAP\Connection $link
* @param \LDAP\Result $result
* @param string $cookie
* @param int $estimated $cookie
* @return bool|LDAP
* @return bool
*/
public function controlPagedResultResponse($link, $result, &$cookie = null, &$estimated = null) {
$ret = ldap_parse_result($link, $result, $errcode, $matcheddn, $errmsg, $referrals, $controls);
Expand All @@ -80,7 +80,7 @@ public function controlPagedResultResponse($link, $result, &$cookie = null, &$es
}

/**
* @param LDAP|resource $link
* @param \LDAP\Connection $link
* @param int $pageSize
* @param bool $isCritical
* @param string $cookie
Expand All @@ -92,7 +92,7 @@ public function controlPagedResult($link, $pageSize, $isCritical, $cookie) {
}

/**
* @param LDAP|resource $link
* @param \LDAP\Connection $link
* @param LDAP|resource $result
* @return mixed
*/
Expand All @@ -101,15 +101,15 @@ public function countEntries($link, $result) {
}

/**
* @param LDAP|resource $link
* @param \LDAP\Connection $link
* @return mixed|string
*/
public function errno($link) {
return $this->invokeLDAPMethod('errno', $link);
}

/**
* @param LDAP|resource $link
* @param \LDAP\Connection $link
* @return int|mixed
*/
public function error($link) {
Expand Down Expand Up @@ -142,7 +142,7 @@ public function explodeDN($dn, $withAttrib) {
}

/**
* @param LDAP|resource $link
* @param \LDAP\Connection $link
* @param LDAP|resource $result
* @return mixed
*/
Expand All @@ -151,7 +151,7 @@ public function firstEntry($link, $result) {
}

/**
* @param LDAP|resource $link
* @param \LDAP\Connection $link
* @param LDAP|resource $result
* @return array|mixed
*/
Expand All @@ -160,7 +160,7 @@ public function getAttributes($link, $result) {
}

/**
* @param LDAP|resource $link
* @param \LDAP\Connection $link
* @param LDAP|resource $result
* @return mixed|string
*/
Expand All @@ -169,7 +169,7 @@ public function getDN($link, $result) {
}

/**
* @param LDAP|resource $link
* @param \LDAP\Connection $link
* @param LDAP|resource $result
* @return array|mixed
*/
Expand All @@ -178,7 +178,7 @@ public function getEntries($link, $result) {
}

/**
* @param LDAP|resource $link
* @param \LDAP\Connection $link
* @param resource $result
* @return mixed
*/
Expand All @@ -187,7 +187,7 @@ public function nextEntry($link, $result) {
}

/**
* @param LDAP|resource $link
* @param \LDAP\Connection $link
* @param string $baseDN
* @param string $filter
* @param array $attr
Expand Down Expand Up @@ -217,7 +217,7 @@ public function search($link, $baseDN, $filter, $attr, $attrsOnly = 0, $limit =
}

/**
* @param LDAP|resource $link
* @param \LDAP\Connection $link
* @param string $option
* @param int $value
* @return bool|mixed
Expand All @@ -227,15 +227,15 @@ public function setOption($link, $option, $value) {
}

/**
* @param LDAP|resource $link
* @param \LDAP\Connection $link
* @return mixed|true
*/
public function startTls($link) {
return $this->invokeLDAPMethod('start_tls', $link);
}

/**
* @param resource $link
* @param \LDAP\Connection $link
* @return bool|mixed
*/
public function unbind($link) {
Expand All @@ -257,11 +257,6 @@ public function hasPagedResultSupport(): bool {
return true;
}

/**
* Checks whether the submitted parameter is a resource
* @param Resource $resource the resource variable to check
* @return bool true if it is a resource, false otherwise
*/
public function isResource($resource) {
if ($resource instanceof \LDAP\Connection) {
return true;
Expand Down
6 changes: 3 additions & 3 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ parameters:
- %currentWorkingDirectory%/appinfo/Migrations/*.php
ignoreErrors:
-
message: '!Parameter #1 \$link of method OCA\\User_LDAP\\ILDAPWrapper::bind\(\) expects resource, null given.!'
message: '!Parameter #1 \$link of method OCA\\User_LDAP\\ILDAPWrapper::bind\(\) expects LDAP\\Connection, null given.!'
path: lib/Connection.php
count: 2
-
message: '!Parameter #1 \$link of method OCA\\User_LDAP\\ILDAPWrapper::errno\(\) expects resource, null given.!'
message: '!Parameter #1 \$link of method OCA\\User_LDAP\\ILDAPWrapper::errno\(\) expects LDAP\\Connection, null given.!'
path: lib/Connection.php
count: 2
-
message: '!Parameter #1 \$link of method OCA\\User_LDAP\\ILDAPWrapper::error\(\) expects resource, null given.!'
message: '!Parameter #1 \$link of method OCA\\User_LDAP\\ILDAPWrapper::error\(\) expects LDAP\\Connection, null given.!'
path: lib/Connection.php
count: 2
-
Expand Down

0 comments on commit edf185e

Please sign in to comment.