Missing cleanup pattern (ARCH7082)
Esta página aún no está disponible en tu idioma.
Key php.performance.dispose-pattern · Severity info · Category performance
If a class holds a closeable resource as a field but offers no cleanup method to release it, owned resources are never freed. Add a close method.
Incorrect
Section titled “Incorrect”<?phpclass Logger{ private $fh; public function __construct(string $path) { $this->fh = fopen($path, 'a'); }}Correct
Section titled “Correct”<?phpclass Logger{ private $fh; public function __construct(string $path) { $this->fh = fopen($path, 'a'); } public function close(): void { fclose($this->fh); }}Give classes that hold closeable fields an explicit close() method (or __destruct) that releases those resources.