@@ -43,6 +43,7 @@ class Writer
4343 public static string $ outputDir ;
4444 /** @var array<class-string, string> */
4545 private static array $ stereotypes = [];
46+ public static bool $ silent = false ;
4647 public static DocBlockFactoryInterface $ docblock ;
4748 /** @var array<int, class-string> */
4849 private static array $ baseClasses = [
@@ -78,13 +79,11 @@ public static function generate(string $type, string $outputDir): void
7879 $ content = array_merge (
7980 match (self ::$ type ) {
8081 'mmd ' => Mermaid::$ header ,
81- 'md ' => Markdown::$ header ,
82- default => [],
82+ default => Markdown::$ header ,
8383 },
8484 match (self ::$ type ) {
8585 'mmd ' => Mermaid::namespaceBlocksGenerate ($ namespaceGroups , $ classMap , $ shortNameCount ),
86- 'md ' => Markdown::namespaceBlocksGenerate ($ namespaceGroups , $ classMap , $ shortNameCount ),
87- default => []
86+ default => Markdown::namespaceBlocksGenerate ($ namespaceGroups , $ classMap , $ shortNameCount )
8887 },
8988 self ::$ type === 'mmd ' ? self ::buildRelations ($ classMap , $ shortNameCount ) : []
9089 );
@@ -162,8 +161,7 @@ public static function buildClassBlock(array $entry, array $classMap, array $sho
162161 self ::displayNameGenerator ($ fullClass , $ classMap , $ shortNameCount ),
163162 self ::$ stereotypes [$ fullClass ] ?? null
164163 ),
165- 'md ' => Markdown::contentBlocksGenerate ($ classMap , $ entry ),
166- default => []
164+ default => Markdown::contentBlocksGenerate ($ classMap , $ entry )
167165 };
168166 }
169167
@@ -200,12 +198,9 @@ private static function buildRelations(array $classMap, array $shortNameCount):
200198 */
201199 private static function addInheritanceRelation (ReflectionClass $ ref , string $ name , array $ classMap , array $ shortNameCount ): string | null
202200 {
203- $ parent = $ ref ->getParentClass ();
204- if (!$ parent ) {
205- return null ;
206- }
201+ $ parent = $ ref ->getParentClass ();
207202 $ parentClassName = $ parent ->getName ();
208- if (in_array ($ parentClassName , self ::$ baseClasses , true ) || $ parent ->isAbstract () || !isset ($ classMap [$ parentClassName ])) {
203+ if (\ in_array ($ parentClassName , self ::$ baseClasses , true ) || $ parent ->isAbstract () || !isset ($ classMap [$ parentClassName ])) {
209204 return null ;
210205 }
211206 $ parentName = self ::displayNameGenerator ($ parentClassName , $ classMap , $ shortNameCount );
@@ -253,8 +248,7 @@ private static function collectProperties(ReflectionClass $ref): array
253248 continue ;
254249 }
255250 $ type = $ prop ->getType ();
256- $ typeStr = $ type ? (string ) $ type : 'mixed ' ;
257- $ typeStr = ltrim ($ typeStr , '? ' );
251+ $ typeStr = ltrim ((string ) $ type , '? ' );
258252 $ props [$ prop ->getName ()] = $ typeStr ;
259253 }
260254
@@ -330,7 +324,7 @@ private static function tryInstantiateClass(string $class): void
330324 ($ method = $ ref ->getMethod ('buildPropertyInheritanceChain ' ))->setAccessible (true ); // NOSONAR
331325 $ method ->invoke (null , $ ref ->newInstanceWithoutConstructor ()); // NOSONAR
332326 } catch (DefinitionException | Throwable $ e ) {
333- if ($ e instanceof DefinitionException) {
327+ if ($ e instanceof DefinitionException && ! self :: $ silent ) {
334328 fwrite (STDERR , "\033[33m[Skipped] $ class: {$ e ->getMessage ()}\033[0m \n" );
335329 }
336330 // Silently skip classes that cannot be instantiated
@@ -366,8 +360,8 @@ private static function parseFullClassName(string $path): ?string
366360 }
367361 [$ type , $ value ] = $ token ;
368362 match (true ) {
369- $ type === T_CLASS && $ prevTokenType !== T_DOUBLE_COLON => $ gettingClass = true ,
370- $ type === T_NAMESPACE => $ gettingNamespace = true ,
363+ $ type === T_CLASS && $ prevTokenType !== T_DOUBLE_COLON => $ gettingClass = true ,
364+ $ type === T_NAMESPACE => $ gettingNamespace = true ,
371365 $ gettingNamespace && ($ type === T_NAME_QUALIFIED || $ type === T_STRING ) => $ namespace [] = $ value ,
372366 default => null
373367 };
0 commit comments