{"record":{"id":"f8ad4789c0ad4c5f","repo":"Seldaek/monolog","slug":"a-stream-must-either-be-a-resource-or-a-string","errorCode":null,"errorMessage":"A stream must either be a resource or a string.","messagePattern":"A stream must either be a resource or a string\\.","errorType":"exception","errorClass":"InvalidArgumentException","httpStatus":null,"severity":"error","filePath":"src/Monolog/Handler/StreamHandler.php","lineNumber":75,"sourceCode":"                // use max 10% of allowed memory for the chunk size, and at least 100KB\n                $this->streamChunkSize = min(static::MAX_CHUNK_SIZE, max((int) ($phpMemoryLimit / 10), 100 * 1024));\n            } else {\n                // memory is unlimited, set to the default 10MB\n                $this->streamChunkSize = static::DEFAULT_CHUNK_SIZE;\n            }\n        } else {\n            // no memory limit information, set to the default 10MB\n            $this->streamChunkSize = static::DEFAULT_CHUNK_SIZE;\n        }\n\n        if (\\is_resource($stream)) {\n            $this->stream = $stream;\n\n            stream_set_chunk_size($this->stream, $this->streamChunkSize);\n        } elseif (\\is_string($stream)) {\n            $this->url = Utils::canonicalizePath($stream);\n        } else {\n            throw new \\InvalidArgumentException('A stream must either be a resource or a string.');\n        }\n\n        $this->fileOpenMode = $fileOpenMode;\n        $this->filePermission = $filePermission;\n        $this->useLocking = $useLocking;\n    }\n\n    /**\n     * @inheritDoc\n     */\n    public function reset(): void\n    {\n        parent::reset();\n\n        // auto-close on reset to make sure we periodically close the file in long running processes\n        // as long as they correctly call reset() between jobs\n        if ($this->url !== null && $this->url !== 'php://memory') {\n            $this->close();","sourceCodeStart":57,"sourceCodeEnd":93,"githubUrl":"https://github.com/Seldaek/monolog/blob/57eb1028342134e701e77c617565d51b6e5a2a53/src/Monolog/Handler/StreamHandler.php#L57-L93","documentation":"Error \"A stream must either be a resource or a string.\" thrown in Seldaek/monolog.","triggerScenarios":"Thrown at src/Monolog/Handler/StreamHandler.php:75 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"57eb1028342134e701e77c617565d51b6e5a2a53","analyzedAt":"2026-08-17T02:36:30.259Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}