22
33namespace Bug14234 ;
44
5+ use function PHPStan \Testing \assertType ;
6+
57function getShortenedPath (string $ identifier ): string
68{
79 $ parts = explode ('/ ' , $ identifier );
10+ assertType ('non-empty-list<string> ' , $ parts );
811
912 for ($ i = 0 ; $ i < count ($ parts ) - 1 ; $ i ++) {
1013 $ parts [$ i ] = substr ($ parts [$ i ], 0 , 1 );
@@ -16,10 +19,34 @@ function getShortenedPath(string $identifier): string
1619function getShortenedPath2 (string $ identifier ): string
1720{
1821 $ parts = explode ('/ ' , $ identifier );
22+ assertType ('non-empty-list<string> ' , $ parts );
1923
2024 for ($ i = 0 ; $ i < count ($ parts ); $ i ++) {
2125 $ parts [$ i ] = substr ($ parts [$ i ], 0 , 1 );
2226 }
2327
2428 return implode ("/ " , $ parts );
2529}
30+
31+ function getShortenedPath3 (string $ identifier ): string
32+ {
33+ $ parts = explode ('/ ' , $ identifier );
34+ assertType ('non-empty-list<string> ' , $ parts );
35+
36+ for ($ i = 0 ; $ i < count ($ parts ) - 4 ; $ i ++) {
37+ $ parts [$ i ] = substr ($ parts [$ i ], 0 , 1 );
38+ }
39+
40+ return implode ("/ " , $ parts );
41+ }
42+
43+ function getShortenedPath4 (array $ parts ): string
44+ {
45+ assertType ('array ' , $ parts );
46+
47+ for ($ i = 0 ; $ i < count ($ parts ) - 4 ; $ i ++) {
48+ $ parts [$ i ] = substr ($ parts [$ i ], 0 , 1 );
49+ }
50+
51+ return implode ("/ " , $ parts );
52+ }
0 commit comments