{"record":{"id":"5b2cce3a5d995da0","repo":"phar-io/manifest","slug":"invalidapplicationnameexception-invalidformat","errorCode":"InvalidApplicationNameException::InvalidFormat","errorMessage":"Format of name \"%s\" is not valid - expected: vendor/packagename","messagePattern":"Format of name \"(.+?)\" is not valid - expected: vendor/packagename","errorType":"validation","errorClass":"InvalidApplicationNameException","httpStatus":null,"severity":"error","filePath":"src/values/ApplicationName.php","lineNumber":35,"sourceCode":"    /** @var string */\n    private $name;\n\n    public function __construct(string $name) {\n        $this->ensureValidFormat($name);\n        $this->name = $name;\n    }\n\n    public function asString(): string {\n        return $this->name;\n    }\n\n    public function isEqual(ApplicationName $name): bool {\n        return $this->name === $name->name;\n    }\n\n    private function ensureValidFormat(string $name): void {\n        if (!preg_match('#\\w/\\w#', $name)) {\n            throw new InvalidApplicationNameException(\n                sprintf('Format of name \"%s\" is not valid - expected: vendor/packagename', $name),\n                InvalidApplicationNameException::InvalidFormat\n            );\n        }\n    }\n}\n","sourceCodeStart":17,"sourceCodeEnd":42,"githubUrl":"https://github.com/phar-io/manifest/blob/c581d4941e196459bf76c945a8ca922963a66708/src/values/ApplicationName.php#L17-L42","documentation":"ApplicationName::ensureValidFormat() requires the name to match the regex #\\w/\\w# (at least one word character, a slash, one word character) and throws InvalidApplicationNameException with code InvalidFormat otherwise. Application names must be written vendor/packagename.","triggerScenarios":"Constructing new ApplicationName('phpunit'), an empty string, 'vendor/', '/packagename', or a name with spaces — typically via <extension for=\"...\"> or <contains name=\"...\"> during mapping.","commonSituations":"Single-word extension targets like for=\"phpunit\" in manifests; missing vendor prefixes; copy-pasted names with whitespace.","solutions":["Rewrite the name as vendor/packagename, e.g. 'phpunit/phpunit'","Ensure a literal slash separates non-empty segments","Trim whitespace from names read from XML attributes"],"exampleFix":"// before\nnew ApplicationName('phpunit');\n// after\nnew ApplicationName('phpunit/phpunit');","handlingStrategy":"validation","validationCode":"if (!preg_match('#\\w/\\w#', $name)) {\n    throw new InvalidArgumentException(\"Application name '$name' must be vendor/packagename\");\n}","typeGuard":"function isValidApplicationName(string $name): bool {\n    return (bool) preg_match('#\\w/\\w#', $name);\n}","tryCatchPattern":"try {\n    $name = new ApplicationName($raw);\n} catch (InvalidApplicationNameException $e) {\n    // re-prompt or fix the <for> attribute to vendor/packagename\n}","preventionTips":["Always include a vendor prefix separated by a slash","Trim whitespace from names parsed from XML","Mirror composer package naming conventions"],"tags":["php","validation","naming","manifest"],"backgroundTag":"invalid-identifier-format","analyzedSha":"c581d4941e196459bf76c945a8ca922963a66708","analyzedAt":"2026-09-14T11:08:47.165Z","contentChangedAt":"2026-09-14T11:08:47.165Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}