File tree Expand file tree Collapse file tree 34 files changed +548
-44
lines changed Expand file tree Collapse file tree 34 files changed +548
-44
lines changed Original file line number Diff line number Diff line change @@ -71,7 +71,15 @@ public function getEmail() : string
71
71
*/
72
72
public function __toString () : string
73
73
{
74
- return $ this ->authorName . ($ this ->authorEmail !== '' ? ' < ' . $ this ->authorEmail . '> ' : '' );
74
+ if ($ this ->authorEmail ) {
75
+ $ authorEmail = '< ' . $ this ->authorEmail . '> ' ;
76
+ } else {
77
+ $ authorEmail = '' ;
78
+ }
79
+
80
+ $ authorName = (string ) $ this ->authorName ;
81
+
82
+ return $ authorName . ($ authorEmail !== '' ? ($ authorName !== '' ? ' ' : '' ) . $ authorEmail : '' );
75
83
}
76
84
77
85
/**
Original file line number Diff line number Diff line change @@ -72,6 +72,14 @@ public function getReference() : Fqsen
72
72
*/
73
73
public function __toString () : string
74
74
{
75
- return $ this ->refers . ($ this ->description ? ' ' . $ this ->description ->render () : '' );
75
+ if ($ this ->description ) {
76
+ $ description = $ this ->description ->render ();
77
+ } else {
78
+ $ description = '' ;
79
+ }
80
+
81
+ $ refers = (string ) $ this ->refers ;
82
+
83
+ return $ refers . ($ description !== '' ? ($ refers !== '' ? ' ' : '' ) . $ description : '' );
76
84
}
77
85
}
Original file line number Diff line number Diff line change @@ -95,6 +95,14 @@ public function getVersion() : ?string
95
95
*/
96
96
public function __toString () : string
97
97
{
98
- return ($ this ->version ?? '' ) . ($ this ->description ? ' ' . $ this ->description ->render () : '' );
98
+ if ($ this ->description ) {
99
+ $ description = $ this ->description ->render ();
100
+ } else {
101
+ $ description = '' ;
102
+ }
103
+
104
+ $ version = (string ) $ this ->version ;
105
+
106
+ return $ version . ($ description !== '' ? ($ version !== '' ? ' ' : '' ) . $ description : '' );
99
107
}
100
108
}
Original file line number Diff line number Diff line change @@ -142,7 +142,10 @@ public function getFilePath() : string
142
142
*/
143
143
public function __toString () : string
144
144
{
145
- return $ this ->filePath . ($ this ->content ? ' ' . $ this ->content : '' );
145
+ $ filePath = (string ) $ this ->filePath ;
146
+ $ content = (string ) $ this ->content ;
147
+
148
+ return $ filePath . ($ content !== '' ? ($ filePath !== '' ? ' ' : '' ) . $ content : '' );
146
149
}
147
150
148
151
/**
Original file line number Diff line number Diff line change @@ -64,7 +64,13 @@ public static function create(
64
64
*/
65
65
public function __toString () : string
66
66
{
67
- return $ this ->description ? $ this ->description ->render () : '' ;
67
+ if ($ this ->description ) {
68
+ $ description = $ this ->description ->render ();
69
+ } else {
70
+ $ description = '' ;
71
+ }
72
+
73
+ return $ description ;
68
74
}
69
75
70
76
/**
Original file line number Diff line number Diff line change @@ -65,6 +65,14 @@ public function getLink() : string
65
65
*/
66
66
public function __toString () : string
67
67
{
68
- return $ this ->link . ($ this ->description ? ' ' . $ this ->description ->render () : '' );
68
+ if ($ this ->description ) {
69
+ $ description = $ this ->description ->render ();
70
+ } else {
71
+ $ description = '' ;
72
+ }
73
+
74
+ $ link = (string ) $ this ->link ;
75
+
76
+ return $ link . ($ description !== '' ? ($ link !== '' ? ' ' : '' ) . $ description : '' );
69
77
}
70
78
}
Original file line number Diff line number Diff line change @@ -212,12 +212,25 @@ public function __toString() : string
212
212
foreach ($ this ->arguments as $ argument ) {
213
213
$ arguments [] = $ argument ['type ' ] . ' $ ' . $ argument ['name ' ];
214
214
}
215
+ $ argumentStr = '( ' . implode (', ' , $ arguments ) . ') ' ;
215
216
216
- return trim (($ this ->isStatic () ? 'static ' : '' )
217
- . (string ) $ this ->returnType . ' '
218
- . $ this ->methodName
219
- . '( ' . implode (', ' , $ arguments ) . ') '
220
- . ($ this ->description ? ' ' . $ this ->description ->render () : '' ));
217
+ if ($ this ->description ) {
218
+ $ description = $ this ->description ->render ();
219
+ } else {
220
+ $ description = '' ;
221
+ }
222
+
223
+ $ static = $ this ->isStatic ? 'static ' : '' ;
224
+
225
+ $ returnType = (string ) $ this ->returnType ;
226
+
227
+ $ methodName = (string ) $ this ->methodName ;
228
+
229
+ return $ static
230
+ . ($ returnType !== '' ? ($ static !== '' ? ' ' : '' ) . $ returnType : '' )
231
+ . ($ methodName !== '' ? ($ static !== '' || $ returnType !== '' ? ' ' : '' ) . $ methodName : '' )
232
+ . $ argumentStr
233
+ . ($ description !== '' ? ' ' . $ description : '' );
221
234
}
222
235
223
236
/**
Original file line number Diff line number Diff line change @@ -140,11 +140,23 @@ public function isReference() : bool
140
140
*/
141
141
public function __toString () : string
142
142
{
143
- return ($ this ->type ? $ this ->type . ($ this ->variableName ? ' ' : '' ) : '' )
144
- . ($ this ->isReference () ? '& ' : '' )
145
- . ($ this ->isVariadic () ? '... ' : '' )
146
- . ($ this ->variableName ? '$ ' . $ this ->variableName : '' )
147
- . (('' . $ this ->description ) ? ' ' . $ this ->description : '' );
143
+ if ($ this ->description ) {
144
+ $ description = $ this ->description ->render ();
145
+ } else {
146
+ $ description = '' ;
147
+ }
148
+
149
+ $ variableName = '' ;
150
+ if ($ this ->variableName ) {
151
+ $ variableName .= ($ this ->isReference ? '& ' : '' ) . ($ this ->isVariadic ? '... ' : '' );
152
+ $ variableName .= ($ this ->variableName ? '$ ' . $ this ->variableName : '' );
153
+ }
154
+
155
+ $ type = (string ) $ this ->type ;
156
+
157
+ return $ type
158
+ . ($ variableName !== '' ? ($ type !== '' ? ' ' : '' ) . $ variableName : '' )
159
+ . ($ description !== '' ? ($ type !== '' || $ variableName !== '' ? ' ' : '' ) . $ description : '' );
148
160
}
149
161
150
162
private static function strStartsWithVariable (string $ str ) : bool
Original file line number Diff line number Diff line change @@ -98,8 +98,22 @@ public function getVariableName() : ?string
98
98
*/
99
99
public function __toString () : string
100
100
{
101
- return ($ this ->type ? $ this ->type . ($ this ->variableName ? ' ' : '' ) : '' )
102
- . ($ this ->variableName ? '$ ' . $ this ->variableName : '' )
103
- . (('' . $ this ->description ) ? ' ' . $ this ->description : '' );
101
+ if ($ this ->description ) {
102
+ $ description = $ this ->description ->render ();
103
+ } else {
104
+ $ description = '' ;
105
+ }
106
+
107
+ if ($ this ->variableName ) {
108
+ $ variableName = ($ this ->variableName ? '$ ' . $ this ->variableName : '' );
109
+ } else {
110
+ $ variableName = '' ;
111
+ }
112
+
113
+ $ type = (string ) $ this ->type ;
114
+
115
+ return $ type
116
+ . ($ variableName !== '' ? ($ type !== '' ? ' ' : '' ) . $ variableName : '' )
117
+ . ($ description !== '' ? ($ type !== '' || $ variableName !== '' ? ' ' : '' ) . $ description : '' );
104
118
}
105
119
}
Original file line number Diff line number Diff line change @@ -98,8 +98,22 @@ public function getVariableName() : ?string
98
98
*/
99
99
public function __toString () : string
100
100
{
101
- return ($ this ->type ? $ this ->type . ($ this ->variableName ? ' ' : '' ) : '' )
102
- . ($ this ->variableName ? '$ ' . $ this ->variableName : '' )
103
- . (('' . $ this ->description ) ? ' ' . $ this ->description : '' );
101
+ if ($ this ->description ) {
102
+ $ description = $ this ->description ->render ();
103
+ } else {
104
+ $ description = '' ;
105
+ }
106
+
107
+ if ($ this ->variableName ) {
108
+ $ variableName = ($ this ->variableName ? '$ ' . $ this ->variableName : '' );
109
+ } else {
110
+ $ variableName = '' ;
111
+ }
112
+
113
+ $ type = (string ) $ this ->type ;
114
+
115
+ return $ type
116
+ . ($ variableName !== '' ? ($ type !== '' ? ' ' : '' ) . $ variableName : '' )
117
+ . ($ description !== '' ? ($ type !== '' || $ variableName !== '' ? ' ' : '' ) . $ description : '' );
104
118
}
105
119
}
Original file line number Diff line number Diff line change @@ -98,8 +98,22 @@ public function getVariableName() : ?string
98
98
*/
99
99
public function __toString () : string
100
100
{
101
- return ($ this ->type ? $ this ->type . ($ this ->variableName ? ' ' : '' ) : '' )
102
- . ($ this ->variableName ? '$ ' . $ this ->variableName : '' )
103
- . (('' . $ this ->description ) ? ' ' . $ this ->description : '' );
101
+ if ($ this ->description ) {
102
+ $ description = $ this ->description ->render ();
103
+ } else {
104
+ $ description = '' ;
105
+ }
106
+
107
+ if ($ this ->variableName ) {
108
+ $ variableName = ($ this ->variableName ? '$ ' . $ this ->variableName : '' );
109
+ } else {
110
+ $ variableName = '' ;
111
+ }
112
+
113
+ $ type = (string ) $ this ->type ;
114
+
115
+ return $ type
116
+ . ($ variableName !== '' ? ($ type !== '' ? ' ' : '' ) . $ variableName : '' )
117
+ . ($ description !== '' ? ($ type !== '' || $ variableName !== '' ? ' ' : '' ) . $ description : '' );
104
118
}
105
119
}
Original file line number Diff line number Diff line change @@ -51,6 +51,14 @@ public static function create(
51
51
52
52
public function __toString () : string
53
53
{
54
- return ($ this ->type ?: 'mixed ' ) . ' ' . (string ) $ this ->description ;
54
+ if ($ this ->description ) {
55
+ $ description = $ this ->description ->render ();
56
+ } else {
57
+ $ description = '' ;
58
+ }
59
+
60
+ $ type = $ this ->type ? '' . $ this ->type : 'mixed ' ;
61
+
62
+ return $ type . ($ description !== '' ? ($ type !== '' ? ' ' : '' ) . $ description : '' );
55
63
}
56
64
}
Original file line number Diff line number Diff line change @@ -77,6 +77,14 @@ public function getReference() : Reference
77
77
*/
78
78
public function __toString () : string
79
79
{
80
- return $ this ->refers . ($ this ->description ? ' ' . $ this ->description ->render () : '' );
80
+ if ($ this ->description ) {
81
+ $ description = $ this ->description ->render ();
82
+ } else {
83
+ $ description = '' ;
84
+ }
85
+
86
+ $ refers = (string ) $ this ->refers ;
87
+
88
+ return $ refers . ($ description !== '' ? ($ refers !== '' ? ' ' : '' ) . $ description : '' );
81
89
}
82
90
}
Original file line number Diff line number Diff line change @@ -89,6 +89,14 @@ public function getVersion() : ?string
89
89
*/
90
90
public function __toString () : string
91
91
{
92
- return (string ) $ this ->version . ($ this ->description ? ' ' . (string ) $ this ->description : '' );
92
+ if ($ this ->description ) {
93
+ $ description = $ this ->description ->render ();
94
+ } else {
95
+ $ description = '' ;
96
+ }
97
+
98
+ $ version = (string ) $ this ->version ;
99
+
100
+ return $ version . ($ description !== '' ? ($ version !== '' ? ' ' : '' ) . $ description : '' );
93
101
}
94
102
}
Original file line number Diff line number Diff line change @@ -96,8 +96,18 @@ public function getLineCount() : ?int
96
96
97
97
public function __toString () : string
98
98
{
99
- return $ this ->startingLine
100
- . ($ this ->lineCount !== null ? ' ' . $ this ->lineCount : '' )
101
- . ($ this ->description ? ' ' . (string ) $ this ->description : '' );
99
+ if ($ this ->description ) {
100
+ $ description = $ this ->description ->render ();
101
+ } else {
102
+ $ description = '' ;
103
+ }
104
+
105
+ $ startingLine = (string ) $ this ->startingLine ;
106
+
107
+ $ lineCount = $ this ->lineCount !== null ? '' . $ this ->lineCount : '' ;
108
+
109
+ return $ startingLine
110
+ . ($ lineCount !== '' ? ($ startingLine !== '' ? ' ' : '' ) . $ lineCount : '' )
111
+ . ($ description !== '' ? ($ startingLine !== '' || $ lineCount !== '' ? ' ' : '' ) . $ description : '' );
102
112
}
103
113
}
Original file line number Diff line number Diff line change @@ -51,6 +51,14 @@ public static function create(
51
51
52
52
public function __toString () : string
53
53
{
54
- return (string ) $ this ->type . ' ' . (string ) $ this ->description ;
54
+ if ($ this ->description ) {
55
+ $ description = $ this ->description ->render ();
56
+ } else {
57
+ $ description = '' ;
58
+ }
59
+
60
+ $ type = (string ) $ this ->type ;
61
+
62
+ return $ type . ($ description !== '' ? ($ type !== '' ? ' ' : '' ) . $ description : '' );
55
63
}
56
64
}
Original file line number Diff line number Diff line change @@ -71,6 +71,14 @@ public function getReference() : Fqsen
71
71
*/
72
72
public function __toString () : string
73
73
{
74
- return $ this ->refers . ' ' . (string ) $ this ->description ;
74
+ if ($ this ->description ) {
75
+ $ description = $ this ->description ->render ();
76
+ } else {
77
+ $ description = '' ;
78
+ }
79
+
80
+ $ refers = (string ) $ this ->refers ;
81
+
82
+ return $ refers . ($ description !== '' ? ($ refers !== '' ? ' ' : '' ) . $ description : '' );
75
83
}
76
84
}
Original file line number Diff line number Diff line change @@ -99,8 +99,22 @@ public function getVariableName() : ?string
99
99
*/
100
100
public function __toString () : string
101
101
{
102
- return ($ this ->type ? $ this ->type . ($ this ->variableName ? ' ' : '' ) : '' )
103
- . ($ this ->variableName ? '$ ' . $ this ->variableName : '' )
104
- . (('' . $ this ->description ) ? ' ' . $ this ->description : '' );
102
+ if ($ this ->description ) {
103
+ $ description = $ this ->description ->render ();
104
+ } else {
105
+ $ description = '' ;
106
+ }
107
+
108
+ if ($ this ->variableName ) {
109
+ $ variableName = ($ this ->variableName ? '$ ' . $ this ->variableName : '' );
110
+ } else {
111
+ $ variableName = '' ;
112
+ }
113
+
114
+ $ type = (string ) $ this ->type ;
115
+
116
+ return $ type
117
+ . ($ variableName !== '' ? ($ type !== '' ? ' ' : '' ) . $ variableName : '' )
118
+ . ($ description !== '' ? ($ type !== '' || $ variableName !== '' ? ' ' : '' ) . $ description : '' );
105
119
}
106
120
}
Original file line number Diff line number Diff line change @@ -92,7 +92,14 @@ public function getVersion() : ?string
92
92
*/
93
93
public function __toString () : string
94
94
{
95
- return ((string ) $ this ->version ) .
96
- ($ this ->description instanceof Description ? ' ' . $ this ->description ->render () : '' );
95
+ if ($ this ->description ) {
96
+ $ description = $ this ->description ->render ();
97
+ } else {
98
+ $ description = '' ;
99
+ }
100
+
101
+ $ version = (string ) $ this ->version ;
102
+
103
+ return $ version . ($ description !== '' ? ($ version !== '' ? ' ' : '' ) . $ description : '' );
97
104
}
98
105
}
Original file line number Diff line number Diff line change @@ -116,6 +116,23 @@ public function testStringRepresentationIsReturned() : void
116
116
$ fixture = new Author ('Mike van Riel ' , 'mike@phpdoc.org ' );
117
117
118
118
$ this ->assertSame ('Mike van Riel <mike@phpdoc.org> ' , (string ) $ fixture );
119
+
120
+ // ---
121
+
122
+ $ fixture = new Author ('0 ' , 'zero@foo.bar ' );
123
+
124
+ $ this ->assertSame ('0 <zero@foo.bar> ' , (string ) $ fixture );
125
+ }
126
+
127
+ /**
128
+ * @covers ::__construct
129
+ * @covers ::__toString
130
+ */
131
+ public function testStringRepresentationIsReturnedWithoutName () : void
132
+ {
133
+ $ fixture = new Author ('' , 'mike@phpdoc.org ' );
134
+
135
+ $ this ->assertSame ('<mike@phpdoc.org> ' , (string ) $ fixture );
119
136
}
120
137
121
138
/**
You can’t perform that action at this time.
0 commit comments