Skip to content

S007 Edge Cases

IDScenarioExpected Behavior
S007-EC-001First path segment does not match any configured namespace root (e.g. src/Services/Foo.php with roots {'app' => 'App', 'tests' => 'Tests'})pathToFqcn() MUST apply the default fallback: ucfirst('src') = Src, returning Src\Services\Foo.
S007-EC-002Input path has a leading slash: /app/Services/Foo.phppathToFqcn() MUST strip the leading slash via ltrim($path, '/') before processing, producing the same result as app/Services/Foo.php.
S007-EC-003Input path uses Windows backslash separators: app\Services\Auth\LoginService.phppathToFqcn() MUST normalize all \ to / before processing. Result MUST be App\Services\Auth\LoginService. sourcePathToTestPath() MUST also normalize \ to / in all three parameters.
S007-EC-004Input path contains double or triple slashes: app//Services///Foo.phpnormalizeRelativePath() MUST collapse consecutive slashes to a single slash. pathToFqcn() does not itself collapse double slashes -- callers should normalize first.
S007-EC-005Source file sits directly in the source directory root with no subdirectory (e.g. app/Services/Helper.php with source base app/Services)sourcePathToTestPath() MUST return tests/Unit/Services/HelperTest.php with no intermediate directory. The dirname() result of . MUST produce an empty middle segment.
S007-EC-006Source path does not start with the provided source path base (e.g. lib/Utility.php passed with source base app/Services)sourcePathToTestPath() MUST fall back to testPathBase / basename(path, ext) + testSuffix + testExtension, yielding tests/Unit/Services/UtilityTest.php.
S007-EC-007file_map is present in the YAML but is an empty object {} or is not an arrayThe file_map MUST default to an empty array. No error MUST be thrown. The algorithmic derivation MUST be used for all files.
S007-EC-008Source and test base paths have trailing slashes: app/Services/ and tests/Unit/Services/sourcePathToTestPath() MUST rtrim() trailing slashes from both base paths before processing. The result MUST be identical to paths without trailing slashes.
S007-EC-009Namespace root uses a nested directory prefix (e.g. namespace_roots: { 'src/main' => 'Com\\App' })Current implementation only matches on the first path segment. A nested root like src/main will NOT match input src/main/Service.php because only src is compared. This is a known limitation. The first segment src would need its own root entry.
S007-EC-010Case mismatch between path segment and namespace root key (e.g. path APP/Services/Foo.php with root key app)pathToFqcn() MUST match using strtolower() comparison, so APP matches app. The namespace prefix MUST use the configured value (App), not the path casing.
S007-EC-011Input path to pathToFqcn() has no file extension (e.g. app/Services/Foo)pathToFqcn() MUST not strip anything (the str_ends_with check fails) and convert as-is, returning App\Services\Foo.
S007-EC-012Input path is a single segment with no directory (e.g. Foo.php)pathToFqcn() MUST treat the single segment (after stripping extension) as both the namespace root candidate and the class name. With default roots, Foo does not match app or tests, so the fallback applies: ucfirst('Foo') = Foo, and the remaining segments are empty, returning Foo\ (namespace separator appended to empty rest). This degenerate case produces an invalid FQCN with a trailing separator. Callers SHOULD validate input has at least two segments.