File tree Expand file tree Collapse file tree 1 file changed +6
-10
lines changed
src/Symfony/Component/HttpFoundation Expand file tree Collapse file tree 1 file changed +6
-10
lines changed Original file line number Diff line number Diff line change @@ -520,20 +520,16 @@ public function overrideGlobals(): void
520
520
*
521
521
* You should only list the reverse proxies that you manage directly.
522
522
*
523
- * @param array $proxies A list of trusted proxies, the string 'REMOTE_ADDR' will be replaced with $_SERVER['REMOTE_ADDR']
524
- * @param int $trustedHeaderSet A bit field of Request::HEADER_*, to set which headers to trust from your proxies
523
+ * @param array $proxies A list of trusted proxies, the string 'REMOTE_ADDR' will be replaced with $_SERVER['REMOTE_ADDR']
524
+ * @param int-mask-of<Request::HEADER_*> $trustedHeaderSet A bit field to set which headers to trust from your proxies
525
525
*/
526
526
public static function setTrustedProxies (array $ proxies , int $ trustedHeaderSet ): void
527
527
{
528
- self ::$ trustedProxies = array_reduce ($ proxies , function ($ proxies , $ proxy ) {
529
- if ('REMOTE_ADDR ' !== $ proxy ) {
530
- $ proxies [] = $ proxy ;
531
- } elseif (isset ($ _SERVER ['REMOTE_ADDR ' ])) {
532
- $ proxies [] = $ _SERVER ['REMOTE_ADDR ' ];
533
- }
528
+ if (isset ($ _SERVER ['REMOTE_ADDR ' ]) && false !== $ i = array_search ('REMOTE_ADDR ' , $ proxies , true )) {
529
+ $ proxies [$ i ] = $ _SERVER ['REMOTE_ADDR ' ];
530
+ }
534
531
535
- return $ proxies ;
536
- }, []);
532
+ self ::$ trustedProxies = $ proxies ;
537
533
self ::$ trustedHeaderSet = $ trustedHeaderSet ;
538
534
}
539
535
You can’t perform that action at this time.
0 commit comments