From 6a67d3370d35c791f06870dc7179ef483fddb848 Mon Sep 17 00:00:00 2001 From: Chad Sikorra Date: Sun, 24 May 2026 10:10:30 -0400 Subject: [PATCH 1/2] Fix the remaining implicit nullable param. --- src/FreeDSx/Snmp/Message/AbstractMessageV3.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/FreeDSx/Snmp/Message/AbstractMessageV3.php b/src/FreeDSx/Snmp/Message/AbstractMessageV3.php index 67ce0ee..6cfd686 100644 --- a/src/FreeDSx/Snmp/Message/AbstractMessageV3.php +++ b/src/FreeDSx/Snmp/Message/AbstractMessageV3.php @@ -85,7 +85,7 @@ abstract class AbstractMessageV3 implements PduInterface public function __construct( MessageHeader $header, ?ScopedPdu $scopedPdu, - string $encryptedPdu = null, + ?string $encryptedPdu = null, ?SecurityParametersInterface $securityParams = null ) { $this->header = $header; From 12e14a9f33614e76236a93b2c042ae0d0679b802 Mon Sep 17 00:00:00 2001 From: Chad Sikorra Date: Sun, 24 May 2026 10:53:25 -0400 Subject: [PATCH 2/2] Fix remaining issues on PHP 8.5 for the current code. A future update will bump the PHP version to address these properly. --- .github/workflows/build.yml | 2 +- composer.json | 10 +++++----- src/FreeDSx/Snmp/Module/Privacy/PrivacyTrait.php | 8 ++++++-- .../Module/SecurityModel/UserSecurityModelModule.php | 12 +++++++++--- src/FreeDSx/Snmp/Protocol/ClientProtocolHandler.php | 4 +++- src/FreeDSx/Snmp/Protocol/ProtocolTrait.php | 4 +++- 6 files changed, 27 insertions(+), 13 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ae447ba..c935449 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -38,7 +38,7 @@ jobs: fail-fast: false matrix: operating-system: [ubuntu-latest, windows-latest] - php-versions: ['7.1', '7.2', '7.3', '7.4', '8.0', '8.2'] + php-versions: ['7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4', '8.5'] name: Unit Tests for PHP ${{ matrix.php-versions }} on ${{ matrix.operating-system }} steps: - name: Checkout diff --git a/composer.json b/composer.json index 0e3bdce..cc64f44 100644 --- a/composer.json +++ b/composer.json @@ -18,11 +18,11 @@ "freedsx/socket": ">=0.3,<1.0" }, "require-dev": { - "friendsofphp/php-cs-fixer": "^2", - "phpspec/phpspec": "^5.1|^6.1|^7.1", - "phpstan/phpstan": "^0.11|^0.12", - "phpunit/phpunit": "^7.5|^8.5|^9.5", - "symfony/process": "^3|^4|^5" + "friendsofphp/php-cs-fixer": "^2.19 || ^3.0", + "phpspec/phpspec": "^5.1 || ^6.1 || ^7.1 || ^8.0", + "phpstan/phpstan": "^0.12.99 || ^1.12 || ^2.1", + "phpunit/phpunit": "^7.5 || ^8.5 || ^9.5", + "symfony/process": "^3.4 || ^4.4 || ^5.4 || ^6.4 || ^7.0" }, "suggest": { "ext-openssl": "For SNMP privacy encryption support.", diff --git a/src/FreeDSx/Snmp/Module/Privacy/PrivacyTrait.php b/src/FreeDSx/Snmp/Module/Privacy/PrivacyTrait.php index 1a92c8d..de8c86f 100644 --- a/src/FreeDSx/Snmp/Module/Privacy/PrivacyTrait.php +++ b/src/FreeDSx/Snmp/Module/Privacy/PrivacyTrait.php @@ -291,12 +291,16 @@ protected function setPduDataInMessage(AbstractMessageV3 $message, $encryptedDat if (!$encOnly) { $pduProperty = $requestObject->getProperty('scopedPdu'); - $pduProperty->setAccessible(true); + if (\PHP_VERSION_ID < 80100) { + $pduProperty->setAccessible(true); + } $pduProperty->setValue($message, $pdu); } $encryptedProperty = $requestObject->getProperty('encryptedPdu'); - $encryptedProperty->setAccessible(true); + if (\PHP_VERSION_ID < 80100) { + $encryptedProperty->setAccessible(true); + } $encryptedProperty->setValue($message, $encryptedData); } } diff --git a/src/FreeDSx/Snmp/Module/SecurityModel/UserSecurityModelModule.php b/src/FreeDSx/Snmp/Module/SecurityModel/UserSecurityModelModule.php index 16ef9a4..065623f 100644 --- a/src/FreeDSx/Snmp/Module/SecurityModel/UserSecurityModelModule.php +++ b/src/FreeDSx/Snmp/Module/SecurityModel/UserSecurityModelModule.php @@ -773,15 +773,21 @@ protected function setupOutgoingMessage( $scopedPduObject = new \ReflectionObject($scopedPdu); $secParamsProperty = $msgObject->getProperty('securityParams'); - $secParamsProperty->setAccessible(true); + if (\PHP_VERSION_ID < 80100) { + $secParamsProperty->setAccessible(true); + } $secParamsProperty->setValue($message, $secParams); $encryptedProperty = $msgObject->getProperty('encryptedPdu'); - $encryptedProperty->setAccessible(true); + if (\PHP_VERSION_ID < 80100) { + $encryptedProperty->setAccessible(true); + } $encryptedProperty->setValue($message, null); $contextEngineIdProperty = $scopedPduObject->getProperty('contextEngineId'); - $contextEngineIdProperty->setAccessible(true); + if (\PHP_VERSION_ID < 80100) { + $contextEngineIdProperty->setAccessible(true); + } $contextEngineIdProperty->setValue($message->getScopedPdu(), $secParams->getEngineId()); } diff --git a/src/FreeDSx/Snmp/Protocol/ClientProtocolHandler.php b/src/FreeDSx/Snmp/Protocol/ClientProtocolHandler.php index 940b0e2..ba9a51b 100644 --- a/src/FreeDSx/Snmp/Protocol/ClientProtocolHandler.php +++ b/src/FreeDSx/Snmp/Protocol/ClientProtocolHandler.php @@ -290,7 +290,9 @@ protected function setPduId(Pdu $request, int $id) : void } $requestObject = new \ReflectionObject($request); $idProperty = $requestObject->getProperty('id'); - $idProperty->setAccessible(true); + if (\PHP_VERSION_ID < 80100) { + $idProperty->setAccessible(true); + } $idProperty->setValue($request, $id); } diff --git a/src/FreeDSx/Snmp/Protocol/ProtocolTrait.php b/src/FreeDSx/Snmp/Protocol/ProtocolTrait.php index 47bbd7f..e63549e 100644 --- a/src/FreeDSx/Snmp/Protocol/ProtocolTrait.php +++ b/src/FreeDSx/Snmp/Protocol/ProtocolTrait.php @@ -123,7 +123,9 @@ protected function setPduId($pdu, int $id) : void } $requestObject = new \ReflectionObject($pdu); $idProperty = $requestObject->getProperty('id'); - $idProperty->setAccessible(true); + if (\PHP_VERSION_ID < 80100) { + $idProperty->setAccessible(true); + } $idProperty->setValue($pdu, $id); }