@@ -153,36 +153,33 @@ trait BaseDocumentTrait
153153 'image/heif ' ,
154154 ];
155155
156- #[
157- Serializer \Groups(['document_mount ' ]),
158- Serializer \SerializedName('mountPath ' ),
159- ]
156+ #[Serializer \Groups(['document_mount ' ]),
157+ Serializer \SerializedName('mountPath ' ),]
160158 public function getMountPath (): ?string
161159 {
162160 if (null === $ relativePath = $ this ->getRelativePath ()) {
163161 return null ;
164162 }
165163 if ($ this ->isPrivate ()) {
166164 return 'private:// ' .$ relativePath ;
167- } else {
168- return 'public:// ' .$ relativePath ;
169165 }
166+
167+ return 'public:// ' .$ relativePath ;
170168 }
171169
172170 /**
173171 * Get short type name for current document Mime type.
174172 */
175- #[
176- Serializer \Groups(['document ' , 'document_display ' , 'nodes_sources ' , 'tag ' , 'attribute ' ]),
177- Serializer \SerializedName('type ' ),
178- ]
173+ #[Serializer \Groups(['document ' , 'document_display ' , 'nodes_sources ' , 'tag ' , 'attribute ' ]),
174+ Serializer \SerializedName('type ' ),]
179175 public function getShortType (): string
180176 {
181- if (null !== $ this ->getMimeType () && isset (static ::$ mimeToIcon [$ this ->getMimeType ()])) {
182- return static ::$ mimeToIcon [$ this ->getMimeType ()];
183- } else {
184- return 'unknown ' ;
177+ $ mimeType = (string ) $ this ->getMimeType ();
178+ if ('' !== $ mimeType && isset (static ::$ mimeToIcon [$ mimeType ])) {
179+ return static ::$ mimeToIcon [$ mimeType ];
185180 }
181+
182+ return 'unknown ' ;
186183 }
187184
188185 /**
@@ -251,39 +248,36 @@ public function isWebp(): bool
251248 return 'image/webp ' === $ this ->getMimeType ();
252249 }
253250
254- #[
255- Serializer \Groups(['document ' , 'document_display ' , 'nodes_sources ' , 'tag ' , 'attribute ' ]),
256- Serializer \SerializedName('relativePath ' ),
257- ]
251+ #[Serializer \Groups(['document ' , 'document_display ' , 'nodes_sources ' , 'tag ' , 'attribute ' ]),
252+ Serializer \SerializedName('relativePath ' ),]
258253 public function getRelativePath (): ?string
259254 {
260255 return $ this ->isLocal () ? $ this ->getFolder ().'/ ' .$ this ->getFilename () : null ;
261256 }
262257
263- #[
264- Serializer \Groups(['document ' , 'document_display ' , 'nodes_sources ' , 'tag ' , 'attribute ' ]),
258+ #[Serializer \Groups(['document ' , 'document_display ' , 'nodes_sources ' , 'tag ' , 'attribute ' ]),
265259 Serializer \SerializedName('processable ' ),
266260 ApiProperty(
267261 description: 'Document can be processed as an image for resampling and other image operations. ' ,
268262 writable: false ,
269- )
270- ]
263+ )]
271264 public function isProcessable (): bool
272265 {
273266 return !$ this ->isPrivate () && $ this ->isImage () && in_array ($ this ->getMimeType (), static ::$ processableMimeTypes , true );
274267 }
275268
276- #[
277- Serializer \Groups(['document ' , 'document_display ' , 'nodes_sources ' , 'tag ' , 'attribute ' ]),
278- Serializer \SerializedName('alt ' ),
279- ]
269+ #[Serializer \Groups(['document ' , 'document_display ' , 'nodes_sources ' , 'tag ' , 'attribute ' ]),
270+ Serializer \SerializedName('alt ' ),]
280271 public function getAlternativeText (): ?string
281272 {
282273 return null ;
283274 }
284275
285276 /**
286277 * Return false if no local file is linked to document. i.e no filename, no folder.
278+ *
279+ * @phpstan-assert-if-true non-empty-string $this->getMountPath()
280+ * @phpstan-assert-if-true non-empty-string $this->getRelativePath()
287281 */
288282 #[Serializer \Ignore()]
289283 public function isLocal (): bool
0 commit comments