Skip to content

Commit 3996d7a

Browse files
committed
Polish project capability PHPDocs
1 parent da2b36d commit 3996d7a

3 files changed

Lines changed: 45 additions & 26 deletions

File tree

src/Project/ProjectCapabilities.php

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,13 @@
2020
namespace FastForward\DevTools\Project;
2121

2222
/**
23-
* Describes the documentation, testing, and wiki surfaces exposed by the current repository.
23+
* Captures which documentation, testing, and wiki surfaces are available for the current repository.
2424
*/
2525
final readonly class ProjectCapabilities
2626
{
2727
/**
28+
* Creates a repository capability snapshot for reporting and documentation commands.
29+
*
2830
* @param list<string> $apiDirectories project-relative directories that contain autoloaded PHP API source
2931
* @param string|null $defaultPackageName the default package name derived from Composer namespaces when available
3032
* @param bool $hasGuideDirectory whether the configured guide directory exists
@@ -42,87 +44,87 @@ public function __construct(
4244
) {}
4345

4446
/**
45-
* @return list<string>
47+
* Returns the project-relative directories that expose autoloaded PHP API source.
4648
*/
4749
public function getApiDirectories(): array
4850
{
4951
return $this->apiDirectories;
5052
}
5153

5254
/**
53-
* @return string|null
55+
* Returns the default API package name when one can be derived from Composer namespaces.
5456
*/
5557
public function getDefaultPackageName(): ?string
5658
{
5759
return $this->defaultPackageName;
5860
}
5961

6062
/**
61-
* @return bool
63+
* Detects whether the configured guide directory exists.
6264
*/
6365
public function hasGuideDirectory(): bool
6466
{
6567
return $this->hasGuideDirectory;
6668
}
6769

6870
/**
69-
* @return bool
71+
* Detects whether the configured tests directory exists.
7072
*/
7173
public function hasTestsPath(): bool
7274
{
7375
return $this->hasTestsPath;
7476
}
7577

7678
/**
77-
* @return bool
79+
* Detects whether the configured wiki target exists.
7880
*/
7981
public function hasWikiTarget(): bool
8082
{
8183
return $this->hasWikiTarget;
8284
}
8385

8486
/**
85-
* @return bool
87+
* Detects whether the repository exposes PHP source files outside generated and vendor areas.
8688
*/
8789
public function hasPhpSourceFiles(): bool
8890
{
8991
return $this->hasPhpSourceFiles;
9092
}
9193

9294
/**
93-
* @return bool
95+
* Detects whether the repository exposes autoloaded PHP API source.
9496
*/
9597
public function canGenerateApiDocumentation(): bool
9698
{
9799
return [] !== $this->apiDirectories;
98100
}
99101

100102
/**
101-
* @return bool
103+
* Detects whether the repository can generate guides, API documentation, or both.
102104
*/
103105
public function canGenerateDocs(): bool
104106
{
105107
return $this->hasGuideDirectory || $this->canGenerateApiDocumentation();
106108
}
107109

108110
/**
109-
* @return bool
111+
* Detects whether metrics generation has PHP source or test inputs to analyse.
110112
*/
111113
public function canGenerateMetrics(): bool
112114
{
113115
return $this->hasTestsPath || $this->hasPhpSourceFiles;
114116
}
115117

116118
/**
117-
* @return bool
119+
* Detects whether wiki generation can render API documentation into the configured wiki target.
118120
*/
119121
public function canGenerateWiki(): bool
120122
{
121123
return $this->hasWikiTarget && $this->canGenerateApiDocumentation();
122124
}
123125

124126
/**
125-
* @return bool
127+
* Detects whether the repository has enough PHP surface to justify running tests.
126128
*/
127129
public function canRunTests(): bool
128130
{

src/Project/ProjectCapabilitiesResolver.php

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,20 +39,22 @@
3939
private const array API_AUTOLOAD_TYPES = ['psr-4', 'psr-0', 'classmap'];
4040

4141
/**
42-
* @param ComposerJsonInterface $composer
43-
* @param FilesystemInterface $filesystem
42+
* Creates a capability resolver backed by Composer autoload metadata and filesystem checks.
43+
*
44+
* @param ComposerJsonInterface $composer the composer.json accessor for autoload metadata
45+
* @param FilesystemInterface $filesystem the filesystem used to resolve project-relative paths
4446
*/
4547
public function __construct(
4648
private ComposerJsonInterface $composer,
4749
private FilesystemInterface $filesystem,
4850
) {}
4951

5052
/**
51-
* @param string $testsPath
52-
* @param string $guideDirectory
53-
* @param string $wikiTarget
53+
* Resolves which documentation, testing, and wiki surfaces are available for the current repository.
5454
*
55-
* @return ProjectCapabilities
55+
* @param string $testsPath the project-relative tests directory to inspect
56+
* @param string $guideDirectory the project-relative guide directory to inspect
57+
* @param string $wikiTarget the project-relative wiki output target to inspect
5658
*/
5759
public function resolve(
5860
string $testsPath = ProjectCapabilitiesResolverInterface::DEFAULT_TESTS_PATH,
@@ -72,7 +74,9 @@ public function resolve(
7274
}
7375

7476
/**
75-
* @param array<string, mixed> $psr4Autoload
77+
* Resolves the default API package name from the first PSR-4 namespace entry when available.
78+
*
79+
* @param array<string, mixed> $psr4Autoload the PSR-4 autoload map from composer.json
7680
*/
7781
private function resolveDefaultPackageName(array $psr4Autoload): ?string
7882
{
@@ -86,6 +90,8 @@ private function resolveDefaultPackageName(array $psr4Autoload): ?string
8690
}
8791

8892
/**
93+
* Resolves project-relative API directories exposed by Composer autoload configuration.
94+
*
8995
* @return list<string>
9096
*/
9197
private function resolveApiDirectories(): array
@@ -108,9 +114,9 @@ private function resolveApiDirectories(): array
108114
}
109115

110116
/**
111-
* @param string $path
117+
* Resolves a Composer autoload path into a project-relative API directory when it exists.
112118
*
113-
* @return string|null
119+
* @param string $path the Composer autoload path candidate
114120
*/
115121
private function resolveRelativeApiDirectory(string $path): ?string
116122
{
@@ -128,7 +134,9 @@ private function resolveRelativeApiDirectory(string $path): ?string
128134
}
129135

130136
/**
131-
* @param array<string, mixed> $autoload
137+
* Flattens Composer autoload path definitions into a normalized list of non-empty paths.
138+
*
139+
* @param array<string, mixed> $autoload the Composer autoload section to normalize
132140
*
133141
* @return list<string>
134142
*/

src/Project/ProjectCapabilitiesResolverInterface.php

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,27 @@
2424
*/
2525
interface ProjectCapabilitiesResolverInterface
2626
{
27+
/**
28+
* @var string the default project-relative test directory checked by repository capability discovery
29+
*/
2730
public const string DEFAULT_TESTS_PATH = './tests';
2831

32+
/**
33+
* @var string the default project-relative guide directory checked by repository capability discovery
34+
*/
2935
public const string DEFAULT_GUIDE_DIRECTORY = 'docs';
3036

37+
/**
38+
* @var string the default project-relative wiki target used for generated API wiki output
39+
*/
3140
public const string DEFAULT_WIKI_TARGET = '.github/wiki';
3241

3342
/**
34-
* @param string $testsPath
35-
* @param string $guideDirectory
36-
* @param string $wikiTarget
43+
* Resolves which documentation, testing, and wiki surfaces are available for the current repository.
3744
*
38-
* @return ProjectCapabilities
45+
* @param string $testsPath the project-relative tests directory to inspect
46+
* @param string $guideDirectory the project-relative guide directory to inspect
47+
* @param string $wikiTarget the project-relative wiki output target to inspect
3948
*/
4049
public function resolve(
4150
string $testsPath = self::DEFAULT_TESTS_PATH,

0 commit comments

Comments
 (0)