Repository navigation
Version 4.0.0
Release v4.0.0
Project structure & namespaces:
- Modernized project to PSR-4 standard — source files moved from
NNTP/tosrc/ - Added PHP namespaces:
Net\NNTP,Net\NNTP\Protocol - Renamed classes from PEAR underscore style to namespaced short names:
Net_NNTP_Client→Net\NNTP\ClientNet_NNTP_Error→Net\NNTP\ErrorNet_NNTP_Protocol_Client→Net\NNTP\Protocol\Client
- Updated
composer.jsonautoload from classmap to PSR-4 ("Net\\NNTP\\": "src/") - Added
filesautoload entry forResponsecode.phpglobal constants - Removed all
require_onceincludes from source files (now handled by Composer autoload) - Removed old
NNTP/directory
PEAR removal:
- Removed all PEAR dependencies, code, and references
- Removed
PEAR_LOG_DEBUGconstant and all_isMasked()calls fromProtocol\Client - Replaced all
PEAR::isError()calls with\Net\NNTP\Error::isError()throughout - Removed
require_once "Log.php"andrequire_once "PEAR.php"from demo files - Removed
grabPearErrors()/PEAR::setErrorHandling()from demo - Removed
PEAR_Errorreferences fromErrorclass - Updated
X-postermail header: removedPEAR::prefix - Replaced all
@link http://pear.php.net/package/Net_NNTPwith GitHub URL
PSR-3 logging:
- Added
psr/logas a dependency — the library now accepts any PSR-3 compatible logger - Type-hinted
$_loggerproperty andsetLogger()parameter withPsr\Log\LoggerInterface - Made
setLogger()public (wasprotected) - Removed deprecated
setDebug()method fromProtocol\Client - Updated demo
Loggerclass to extendPsr\Log\AbstractLogger
Configuration:
- Added
vlucas/phpdotenvas a dependency for demo configuration - Replaced hardcoded
config.inc.phpwith.env-based configuration using phpdotenv - Added
.env.examplewith all available settings and documented defaults - Added
.envto.gitignore
Test suite:
- Added comprehensive PHPUnit 13 test suite (117 tests, 253 assertions):
tests/Unit/ErrorTest.php— Error class construction, isError(), toStringtests/Unit/ClientTest.php— Client instantiation, PSR-3 logger, public API surfacetests/Unit/ProtocolClientTest.php— Protocol layer, throwError, _isConnected, _clearOpensslErrorstests/Unit/ResponsecodeTest.php— All 48 NNTP response code constantstests/Unit/AutoloadTest.php— PSR-4 autoloading, namespaces, dependency wiringtests/Unit/ConfigTest.php—.env.examplecompleteness, phpdotenv integrationtests/Integration/ServerConnectionTest.php— Live server: connect, groups, articles, overview, disconnect
- Updated
phpunit.xmlwith separate Unit and Integration test suites - Updated demo and phpdoc examples to use namespaced classes
Enums & code optimization:
- Created
Net\NNTP\Protocol\ResponseCodeint-backed enum with all 53 NNTP response codes- Each case includes a
description()method returning the RFC description - Supports
ResponseCode::from(int)andResponseCode::tryFrom(int)natively - Added 6 new codes not previously defined:
DisconnectingRequested(205),DisconnectingForced(400),TlsContinue(382),TlsRefused(580),XgtitleFollows(282),XgtitleUnavailable(481)
- Each case includes a
- Converted
Responsecode.phpto a backwards-compatible shim — alldefine()constants now delegate toResponseCode::CASE->value - Replaced all
NET_NNTP_PROTOCOL_RESPONSECODE_*references inProtocol\ClientwithResponseCode::CASE->value - Replaced all bare integer response codes (205, 382, 400, 502, 503, etc.) with enum references
- Converted all
switchblocks tomatchexpressions throughoutProtocol\ClientandClient - Removed all unreachable
breakstatements afterreturn(~50+ instances) - Removed dead code:
if (false) { ... }block,die()calls, unused namespace-level constants - Removed all vim modelines,
{{{ }}}fold markers, and "Local variables" blocks from all source files - Added
declare(strict_types=1)to all source files - Applied constructor property promotion with
readonlytoErrorclass - Refactored duplicated parsing logic in
Protocol\Clientinto private helper methods:
_parseGroupSelected(),_parseArticlePointer(),_fetchTextAndLog(),_parseGroupLines(),
_parseOverviewResponse(),_parseKeyValueResponse(),_parseOverviewFormat(),
_parseNewsgroupDescriptions(),_logAndReturn(),_handleTlsNegotiation() - Extracted
_resolveTimestamp()helper inClientto deduplicate time parsing - Used
str_ends_with()/str_starts_with()instead ofsubstr()comparisons - Used null coalescing assignment (
??=) throughout - Used nullsafe operator (
?->) consistently for logger calls - Used union types for
_sendArticle(string|array)parameter - Expanded test suite to 335 tests / 526 assertions (was 117 / 253):
- Added enum tests: case values,
from(),tryFrom(),description(), int-backed verification - Added legacy constant shim verification
- Added
ResponseCodeautoload and namespace tests
- Added enum tests: case values,
Static analysis:
- Added PHPStan (
phpstan/phpstan) as a dev dependency - Created
phpstan.neonconfiguration at level 8 (strict) - All source files pass PHPStan level 8 with zero errors
- Added proper type annotations (PHPDoc
@return,@param) to all methods throughoutProtocol\ClientandClient - Typed all deprecated method parameters and return types (
getArticleRaw(),getHeaderRaw(), etc.) - Changed
getArticle(),getHeader(),getBody()$implodeparameter frombooltomixedfor v1.1 API backward compatibility - Added
@varPHPDoc annotations to all class properties - Added
.phpstan-cache/to.gitignore - Added
composer scripts:composer analyse,composer test,composer check