Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
6 changes: 3 additions & 3 deletions .github/workflows/analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

- name: Install Composer Dependencies
run: composer install --no-progress --no-suggest --prefer-dist --optimize-autoloader
run: composer install --no-progress --prefer-dist --optimize-autoloader

- name: Cache Dependencies
uses: actions/cache@v3
Expand All @@ -43,11 +43,11 @@ jobs:
COMPOSER_ALLOW_SUPERUSER: 1
run: sudo composer run-script --timeout=0 test-coverage

- name: Upload Spec Coverage to Codecov
- name: Upload Unit Coverage to Codecov
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./coverage.xml
file: ./coverage-unit.xml
name: FreeDSx-LDAP-Unit

- name: Upload Integration Coverage to Codecov
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
fail-fast: false
matrix:
operating-system: [ubuntu-latest, windows-latest]
php-versions: ['8.1', '8.2']
php-versions: ['8.1', '8.2', '8.3', '8.4', '8.5']
name: PHP ${{ matrix.php-versions }} Test on ${{ matrix.operating-system }}
steps:
- name: Checkout
Expand All @@ -30,7 +30,7 @@ jobs:
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

- name: Install Composer dependencies
run: composer install --no-progress --no-suggest --prefer-dist --optimize-autoloader
run: composer install --no-progress --prefer-dist --optimize-autoloader

- name: Cache dependencies
uses: actions/cache@v3
Expand All @@ -39,8 +39,8 @@ jobs:
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-

- name: Run Specs
run: composer run-script test-spec
- name: Run Unit Tests
run: composer run-script test-unit

# Not ideal, but we run as root here because the LDAP server needs access to certs / keys system directories.
# For tests this seems fine, but in a real scenario this would be bad...
Expand Down
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
CHANGELOG
=========

1.0.0 (2023-xx-xx)
1.0.0 (202x-xx-xx)
------------------
* Updated the minimum version of PHP to version 8.1.
* All classes now use "strict_types=1". This internal change should not impact external usage.
Expand All @@ -10,6 +10,9 @@ CHANGELOG
* Added entry handler processing of searches. This allows immediate processing of entries via anonymous functions.
* Added the ability to cancel search or sync requests when using entry handler processing for searches.
* Added support for the SensitiveParameter attribute to mask bind related credentials from stack traces.
* Removed various deprecations for PHP >= 8.1 (implicit nullability, return type declarations, etc.).
* Added PHP 8.3, 8.4, and 8.5 to normal CI runs.
* Migrated all unit tests from PHPSpec to PHPUnit.

0.8.0 (2022-05-21)
------------------
Expand Down
29 changes: 15 additions & 14 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@
"psr/log": "^3"
},
"require-dev": {
"phpspec/phpspec": "^7.2",
"phpunit/phpunit": "^9.6",
"phpunit/phpunit": "^10.5",
"symplify/easy-coding-standard": "^9.4",
"friends-of-phpspec/phpspec-code-coverage": "^6.3",
"phpstan/phpstan": "^1.11",
"phpstan/phpstan": "^2.1",
"symfony/process": "^5.4",
"squizlabs/php_codesniffer": "^3.7",
"slevomat/coding-standard": "^7.2"
"slevomat/coding-standard": "^7.2",
"phpstan/phpstan-phpunit": "^2.0",
"phpstan/extension-installer": "^1.4"
},
"suggest": {
"ext-openssl": "For SSL/TLS support and some SASL mechanisms.",
Expand All @@ -40,31 +40,32 @@
},
"autoload-dev": {
"psr-4": {
"integration\\FreeDSx\\Ldap\\": "tests/integration/FreeDSx/Ldap",
"spec\\FreeDSx\\Ldap\\": "tests/spec/FreeDSx/Ldap"
"Tests\\Integration\\FreeDSx\\Ldap\\": "tests/integration",
"Tests\\Unit\\FreeDSx\\Ldap\\": "tests/unit"
}
},
"config": {
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true
"dealerdirect/phpcodesniffer-composer-installer": true,
"phpstan/extension-installer": true
}
},
"scripts": {
"test-coverage": [
"phpspec run --no-interaction -c phpspec.cov.yml",
"phpunit --coverage-clover=coverage-integration.xml"
"phpunit --testsuite unit --coverage-clover=coverage-unit.xml",
"phpunit --testsuite integration --coverage-clover=coverage-integration.xml"
],
"test-spec": [
"phpspec run --no-interaction"
"test-unit": [
"phpunit --testsuite unit"
],
"test-integration": [
"phpunit"
"phpunit --testsuite integration"
],
"analyse": [
"phpstan --memory-limit=-1 analyse"
],
"analyse-tests": [
"phpstan analyse -c phpstan.tests.neon"
"phpstan --memory-limit=-1 analyse -c phpstan.tests.neon"
],
"cs-fix": [
"phpcbf --standard=ruleset.xml --extensions=php --tab-width=4 -sp src",
Expand Down
13 changes: 0 additions & 13 deletions phpspec.cov.yml

This file was deleted.

5 changes: 0 additions & 5 deletions phpspec.yml

This file was deleted.

2 changes: 1 addition & 1 deletion phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
parameters:
level: max
level: 9
paths:
- %currentWorkingDirectory%/src
treatPhpDocTypesAsCertain: false
Expand Down
5 changes: 1 addition & 4 deletions phpstan.tests.neon
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
parameters:
level: 1
level: 3
paths:
- %currentWorkingDirectory%/tests
ignoreErrors:
# Does not seem to be a great extension for phpspec :(
- '#Call to an undefined (static )?method spec\\FreeDSx\\Ldap\\.*Spec::#'
34 changes: 27 additions & 7 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,14 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" backupStaticAttributes="false" colors="true" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" processIsolation="false" stopOnFailure="false" bootstrap="vendor/autoload.php" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage processUncoveredFiles="true">
<include>
<directory suffix=".php">src</directory>
</include>
</coverage>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
backupGlobals="false"
colors="true"
displayDetailsOnTestsThatTriggerDeprecations="true"
displayDetailsOnTestsThatTriggerErrors="true"
displayDetailsOnTestsThatTriggerNotices="true"
displayDetailsOnTestsThatTriggerWarnings="true"
displayDetailsOnPhpunitDeprecations="true"
processIsolation="false"
stopOnFailure="false"
bootstrap="vendor/autoload.php"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd"
>
<source>
<include>
<directory suffix=".php">./src</directory>
</include>
</source>
<coverage includeUncoveredFiles="true"
pathCoverage="false"
ignoreDeprecatedCodeUnits="true"
disableCodeCoverageIgnore="true">
</coverage>
<testsuites>
<testsuite name="FreeDSx LDAP Unit Tests">
<testsuite name="integration">
<directory>./tests/integration</directory>
</testsuite>
<testsuite name="unit">
<directory>./tests/unit</directory>
</testsuite>
</testsuites>
<php>
<env name="LDAP_SERVER" value="example.com"/>
Expand Down
2 changes: 1 addition & 1 deletion src/FreeDSx/Ldap/Control/Sync/SyncDoneControl.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public function toAsn1(): AbstractType
));
}
$this->controlValue->addChild(Asn1::boolean(
$this->refreshDeletes ?? false
$this->refreshDeletes
));

return parent::toAsn1();
Expand Down
2 changes: 1 addition & 1 deletion src/FreeDSx/Ldap/Control/Vlv/VlvControl.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public function getFilter(): ?GreaterThanOrEqualFilter
return $this->filter;
}

public function setFilter(GreaterThanOrEqualFilter $filter = null): self
public function setFilter(?GreaterThanOrEqualFilter $filter = null): self
{
$this->filter = $filter;

Expand Down
2 changes: 1 addition & 1 deletion src/FreeDSx/Ldap/Controls.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class Controls
public static function create(
string $oid,
bool $criticality = false,
ProtocolElementInterface|AbstractType $value = null
ProtocolElementInterface|AbstractType|null $value = null
): Control {
return new Control(
controlType: $oid,
Expand Down
2 changes: 1 addition & 1 deletion src/FreeDSx/Ldap/Exception/OperationException.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class OperationException extends Exception
public function __construct(
string $message = '',
int $code = ResultCode::OPERATIONS_ERROR,
Throwable $previous = null
?Throwable $previous = null
) {
$message = empty($message)
? $this->generateMessage($code)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class UnsolicitedNotificationException extends ProtocolException
public function __construct(
string $message = "",
int $code = 0,
Throwable $previous = null,
?Throwable $previous = null,
string $oid = ""
) {
$this->oid = $oid;
Expand Down
2 changes: 1 addition & 1 deletion src/FreeDSx/Ldap/LdapClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ public function vlv(
*/
public function dirSync(
?string $rootNc = null,
FilterInterface $filter = null,
?FilterInterface $filter = null,
Attribute|string ...$attributes
): DirSync {
return new DirSync(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class ClientExtendedOperationHandler extends ClientBasicHandler

public function __construct(
ClientQueue $queue,
ExtendedResponseFactory $extendedResponseFactory = null
?ExtendedResponseFactory $extendedResponseFactory = null
) {
$this->extendedResponseFactory = $extendedResponseFactory ?? new ExtendedResponseFactory();

Expand Down
2 changes: 1 addition & 1 deletion src/FreeDSx/Ldap/Protocol/LdapQueue.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class LdapQueue extends Asn1MessageQueue

public function __construct(
Socket $socket,
EncoderInterface $encoder = null
?EncoderInterface $encoder = null
) {
parent::__construct(
$socket,
Expand Down
2 changes: 1 addition & 1 deletion src/FreeDSx/Ldap/Protocol/Queue/ClientQueue.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class ClientQueue extends LdapQueue
*/
public function __construct(
private readonly SocketPool $socketPool,
EncoderInterface $encoder = null
?EncoderInterface $encoder = null
) {
parent::__construct(
$socketPool->connect(),
Expand Down
2 changes: 1 addition & 1 deletion src/FreeDSx/Ldap/Search/RangeRetrieval.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public function getAllRanged(Entry $entry): array
*/
public function hasRanged(
Entry $entry,
Attribute|string $attribute = null
Attribute|string|null $attribute = null
): bool {
return $attribute !== null
? (bool) $this->getRanged($entry, $attribute)
Expand Down
12 changes: 12 additions & 0 deletions src/FreeDSx/Ldap/Search/Vlv.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,18 @@ public function __construct(
: Controls::sort($sort);
}

/**
* Use a matching rule filter assertion to specify the target entry within a sorted LDAP result set.
*
* It is used as an alternative to specifying the target by a numerical offset.
*/
public function useFilter(?GreaterThanOrEqualFilter $filter): self
{
$this->filter = $filter;

return $this;
}

/**
* As a percentage the moveTo, moveForward, moveBackward, and position methods work with numbers 0 - 100 and should
* be interpreted as percentages.
Expand Down
10 changes: 9 additions & 1 deletion src/FreeDSx/Ldap/Server/RequestHistory.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ final class RequestHistory

private PagingRequests $pagingRequests;

public function __construct(PagingRequests $pagingRequests = null)
public function __construct(?PagingRequests $pagingRequests = null)
{
$this->pagingRequests = $pagingRequests ?? new PagingRequests();
}
Expand Down Expand Up @@ -59,4 +59,12 @@ public function pagingRequest(): PagingRequests
{
return $this->pagingRequests;
}

/**
* @return int[]
*/
public function getIds(): array
{
return $this->ids;
}
}
4 changes: 2 additions & 2 deletions src/FreeDSx/Ldap/Sync/SyncRepl.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ public function request(): SyncRequest
* **Note**: The LdapClient should be instantiated with no timeout via {@see ClientOptions::setTimeoutRead(-1)}.
* Otherwise, the listen operation will terminate due to a network timeout.
*/
public function listen(Closure $entryHandler = null): void
public function listen(?Closure $entryHandler = null): void
{
$this->sync(
mode: SyncRequestControl::MODE_REFRESH_AND_PERSIST,
Expand All @@ -170,7 +170,7 @@ public function listen(Closure $entryHandler = null): void
* If a cookie is provided, then it is a poll for content update. If no cookie is provided, then it is a poll for
* content update. To provide a cookie from a previous poll {@see self::useCookie()}.
*/
public function poll(Closure $entryHandler = null): void
public function poll(?Closure $entryHandler = null): void
{
$this->sync(
mode: SyncRequestControl::MODE_REFRESH_ONLY,
Expand Down
Loading
Loading