1313
1414namespace CodeIgniter \HTTP ;
1515
16- use CodeIgniter \Exceptions \BadMethodCallException ;
1716use CodeIgniter \Exceptions \ConfigException ;
1817use CodeIgniter \HTTP \Exceptions \HTTPException ;
1918use Config \App ;
@@ -43,37 +42,6 @@ class SiteURI extends URI
4342 */
4443 private readonly string $ indexPage ;
4544
46- /**
47- * List of URI segments in baseURL and indexPage.
48- *
49- * If the URI is "http://localhost:8888/ci431/public/index.php/test?a=b",
50- * and the baseURL is "http://localhost:8888/ci431/public/", then:
51- * $baseSegments = [
52- * 0 => 'ci431',
53- * 1 => 'public',
54- * 2 => 'index.php',
55- * ];
56- */
57- private array $ baseSegments ;
58-
59- /**
60- * List of URI segments after indexPage.
61- *
62- * The word "URI Segments" originally means only the URI path part relative
63- * to the baseURL.
64- *
65- * If the URI is "http://localhost:8888/ci431/public/index.php/test?a=b",
66- * and the baseURL is "http://localhost:8888/ci431/public/", then:
67- * $segments = [
68- * 0 => 'test',
69- * ];
70- *
71- * @var array<int, string>
72- *
73- * @deprecated This property will be private.
74- */
75- protected $ segments ;
76-
7745 /**
7846 * URI path relative to baseURL.
7947 *
@@ -147,16 +115,14 @@ private function determineBaseURL(
147115
148116 $ uri = new URI ($ baseURL );
149117
150- // Update scheme
151118 if ($ scheme !== null && $ scheme !== '' ) {
152- $ uri-> setScheme ($ scheme );
119+ $ uri = $ uri -> withScheme ($ scheme );
153120 } elseif ($ configApp ->forceGlobalSecureRequests ) {
154- $ uri-> setScheme ('https ' );
121+ $ uri = $ uri -> withScheme ('https ' );
155122 }
156123
157- // Update host
158124 if ($ host !== null ) {
159- $ uri ->setHost ($ host );
125+ $ uri = $ uri ->setHost ($ host );
160126 }
161127
162128 return $ uri ;
@@ -211,34 +177,12 @@ private function normalizeBaseURL(App $configApp): string
211177 private function setBasePath (): void
212178 {
213179 $ this ->basePathWithoutIndexPage = $ this ->baseURL ->getPath ();
214-
215- $ this ->baseSegments = $ this ->convertToSegments ($ this ->basePathWithoutIndexPage );
216-
217- if ($ this ->indexPage !== '' ) {
218- $ this ->baseSegments [] = $ this ->indexPage ;
219- }
220- }
221-
222- /**
223- * @deprecated
224- */
225- public function setBaseURL (string $ baseURL ): void
226- {
227- throw new BadMethodCallException ('Cannot use this method. ' );
228- }
229-
230- /**
231- * @deprecated
232- */
233- public function setURI (?string $ uri = null )
234- {
235- throw new BadMethodCallException ('Cannot use this method. ' );
236180 }
237181
238182 /**
239183 * Returns the baseURL.
240184 *
241- * @interal
185+ * @internal
242186 */
243187 public function getBaseURL (): string
244188 {
@@ -307,39 +251,18 @@ private function convertToSegments(string $path): array
307251 return ($ tempPath === '' ) ? [] : explode ('/ ' , $ tempPath );
308252 }
309253
310- /**
311- * Sets the path portion of the URI based on segments.
312- *
313- * @return $this
314- *
315- * @deprecated This method will be private.
316- */
317- public function refreshPath ()
318- {
319- $ allSegments = array_merge ($ this ->baseSegments , $ this ->segments );
320- $ this ->path = '/ ' . $ this ->filterPath (implode ('/ ' , $ allSegments ));
321-
322- if ($ this ->routePath === '/ ' && $ this ->path !== '/ ' ) {
323- $ this ->path .= '/ ' ;
324- }
325-
326- $ this ->routePath = $ this ->filterPath (implode ('/ ' , $ this ->segments ));
327-
328- return $ this ;
329- }
330-
331254 /**
332255 * Saves our parts from a parse_url() call.
333256 *
334257 * @param array{
335- * host?: string,
336- * user?: string,
337- * path?: string,
338- * query?: string,
339- * fragment?: string,
340- * scheme?: string,
341- * port?: int,
342- * pass?: string,
258+ * host?: string,
259+ * user?: string,
260+ * path?: string,
261+ * query?: string,
262+ * fragment?: string,
263+ * scheme?: string,
264+ * port?: int,
265+ * pass?: string,
343266 * } $parts
344267 */
345268 protected function applyParts (array $ parts ): void
@@ -364,11 +287,7 @@ protected function applyParts(array $parts): void
364287 $ this ->fragment = $ parts ['fragment ' ];
365288 }
366289
367- if (isset ($ parts ['scheme ' ])) {
368- $ this ->setScheme (rtrim ($ parts ['scheme ' ], ':/ ' ));
369- } else {
370- $ this ->setScheme ('http ' );
371- }
290+ $ this ->scheme = $ this ->withScheme (rtrim ($ parts ['scheme ' ] ?? 'http ' , ':/ ' ))->getScheme ();
372291
373292 if (isset ($ parts ['port ' ])) {
374293 // Valid port numbers are enforced by earlier parse_url or setPort()
0 commit comments