{"record":{"id":"78038d4c55124c88","repo":"rectorphp/rector","slug":"parameter-s-s-must-be-int-s-given-suse-c","errorCode":null,"errorMessage":"Parameter \"%s::%s\" must be int, \"%s\" given.%sUse constant from \"%s\" to provide it, e.g. \"%s::%s\"","messagePattern":"Parameter \"(.+?)::(.+?)\" must be int, \"(.+?)\" given\\.(.+?)Use constant from \"(.+?)\" to provide it, e\\.g\\. \"(.+?)::(.+?)\"","errorType":"validation","errorClass":"InvalidConfigurationException","httpStatus":null,"severity":"error","filePath":"src/Php/PhpVersionProvider.php","lineNumber":88,"sourceCode":"        if (in_array($phpVersionFeatures, $phpVersionReflectionClass->getConstants(), \\true)) {\n            return;\n        }\n        if (!is_int($phpVersionFeatures)) {\n            $this->throwInvalidTypeException($phpVersionFeatures);\n        }\n        if (StringUtils::isMatch((string) $phpVersionFeatures, self::VALID_PHP_VERSION_REGEX) && $phpVersionFeatures >= PhpVersion::PHP_53 - 1) {\n            return;\n        }\n        $this->throwInvalidTypeException($phpVersionFeatures);\n    }\n    /**\n     * @return never\n     * @param mixed $phpVersionFeatures\n     */\n    private function throwInvalidTypeException($phpVersionFeatures)\n    {\n        $errorMessage = sprintf('Parameter \"%s::%s\" must be int, \"%s\" given.%sUse constant from \"%s\" to provide it, e.g. \"%s::%s\"', Option::class, 'PHP_VERSION_FEATURES', (string) $phpVersionFeatures, \\PHP_EOL, PhpVersion::class, PhpVersion::class, 'PHP_80');\n        throw new InvalidConfigurationException($errorMessage);\n    }\n}\n","sourceCodeStart":70,"sourceCodeEnd":91,"githubUrl":"https://github.com/rectorphp/rector/blob/408fcb0ff1833e3d26cbc9b04c23a77565814a16/src/Php/PhpVersionProvider.php#L70-L91","documentation":"PhpVersionProvider validates the PHP_VERSION_FEATURES option (the --php-features CLI value / Option::PHP_VERSION_FEATURES parameter). The value must be an integer matching the version regex AND be at least PhpVersion::PHP_53 - 1; anything else (string versions, floats, out-of-range ints) is routed to throwInvalidTypeException(), which names the option, echoes the received value, and points at the PhpVersion constants.","triggerScenarios":"Passing '8.1' or 8.1 (string/float) to --php-features; passing an int below PHP_53 - 1 such as 42; constructing the option array with ['php_version_features' => '80100'] from untyped config.","commonSituations":"YAML/CLI config reading the version from an env var that arrives as a string; glue code mapping a composer constraint like '^8.1' directly to the option; copy-pasting 8010 (dropped digit).","solutions":["Pass a PhpVersion constant int: \\Rector\\ValueObject\\PhpVersion::PHP_81","If the value comes from config, cast/validate it first: is_int($v) && $v >= PhpVersion::PHP_53","Echo the received value shown in the message ('\"8.1\" given') to spot the type leak in your pipeline"],"exampleFix":"// before\n$parameters = [\n    Option::PHP_VERSION_FEATURES => '8.1',\n];\n\n// after\nuse Rector\\ValueObject\\PhpVersion;\n\n$parameters = [\n    Option::PHP_VERSION_FEATURES => PhpVersion::PHP_81,\n];","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"/** @param mixed $value */\nfunction isPhpVersionFeaturesValue($value): bool\n{\n    return is_int($value) && $value >= \\Rector\\ValueObject\\PhpVersion::PHP_53 - 1;\n}","tryCatchPattern":null,"preventionTips":["Only feed Option::PHP_VERSION_FEATURES from PhpVersion::PHP_* constants","When reading the version from env/YAML, coerce and assert is_int() before passing it on","Cover the option wiring with a unit test that passes a string version and expects InvalidConfigurationException"],"tags":["php","rector","parameter-type","php-version","validation"],"backgroundTag":"invalid-parameter-type","analyzedSha":"408fcb0ff1833e3d26cbc9b04c23a77565814a16","analyzedAt":"2026-08-21T05:11:02.643Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}