{"record":{"id":"22eeb1dfefe8c8f9","repo":"phalcon/cphalcon","slug":"the-method-parameter-must-be-either-a-callable-o","errorCode":null,"errorMessage":"The 'method' parameter must be either a callable or NULL","messagePattern":"The 'method' parameter must be either a callable or NULL","errorType":"exception","errorClass":"Phalcon\\Autoload\\Exceptions\\LoaderMethodNotCallable","httpStatus":null,"severity":"error","filePath":"phalcon/Autoload/Loader.zep","lineNumber":410,"sourceCode":"     *\n     * // Do not check file existence.\n     * $loader->setFileCheckingCallback(null);\n     * ```\n     *\n     * @param callable|string|null $method\n     *\n     * @throws Exception\n     */\n    public function setFileCheckingCallback(var method = null) -> <static>\n    {\n        if (true === is_callable(method)) {\n            let this->fileCheckingCallback = method;\n        } elseif (null === method) {\n            let this->fileCheckingCallback = function (file) {\n                return true;\n            };\n        } else {\n            throw new LoaderMethodNotCallable();\n        }\n\n        return this;\n    }\n\n    /**\n     * Registers files that are \"non-classes\" hence need a \"require\". This is\n     * very useful for including files that only have functions\n     *\n     * @param autoload_strings $files\n     */\n    public function setFiles(array files, bool merge = false) -> <static>\n    {\n        return this->addToCollection(\n            files,\n            \"files\",\n            \"addFile\",\n            merge","sourceCodeStart":392,"sourceCodeEnd":428,"githubUrl":"https://github.com/phalcon/cphalcon/blob/b7419de9cd0a8a3f48441ead84c9f8415d463e25/phalcon/Autoload/Loader.zep#L392-L428","documentation":"Phalcon\\Autoload\\Loader::setFileCheckingCallback() accepts exactly two things: a callable that decides whether a file is loadable, or null to reset to the default that accepts every file. Any other value (a string that is not a callable function name, an array/object that is not callable, an integer...) throws LoaderMethodNotCallable before the callback is stored.","triggerScenarios":"$loader->setFileCheckingCallback('file_exists') (not callable as invoked - the documented values are 'is_file' or 'stream_resolve_include_path'); passing a method name of a non-existent function; passing 1/true/[] as a pseudo-truthy flag; passing an object without __invoke.","commonSituations":"Upgrading from old Phalcon versions where file-checking was a boolean (setFileCheckingCallback(true)) - the boolean API is gone and true now throws; passing a disabled/renamed function name; copy-pasting a callback name from outdated docs.","solutions":["Pass null to restore the default permissive behavior: $loader->setFileCheckingCallback(null)","Or pass one of the documented callables: $loader->setFileCheckingCallback('is_file') or 'stream_resolve_include_path'","Replace legacy boolean usage: old setFileCheckingCallback(true) becomes null; and make sure any custom value is a valid callable (Closure, ['Obj','method'], 'functionName')"],"exampleFix":"// before (legacy boolean style)\n$loader->setFileCheckingCallback(true);\n\n// after\n$loader->setFileCheckingCallback('is_file');\n// or simply omit it / pass null for the default","handlingStrategy":"type-guard","validationCode":"if ($callback !== null && !is_callable($callback)) {\n    throw new InvalidArgumentException('setFileCheckingCallback expects a callable or null');\n}","typeGuard":"function isValidFileCheckingCallback($value): bool\n{\n    return $value === null || is_callable($value);\n}","tryCatchPattern":null,"preventionTips":["Pass only 'is_file', 'stream_resolve_include_path', a Closure, or null","Replace legacy boolean arguments (true/false) from pre-migration code with null","Centralize loader setup in one bootstrap function so callback values are reviewed in one place"],"tags":["autoload","loader","callable","upgrade"],"backgroundTag":"invalid-callback-argument","analyzedSha":"b7419de9cd0a8a3f48441ead84c9f8415d463e25","analyzedAt":"2026-08-21T06:21:18.811Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}