Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:96307 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 21668 invoked from network); 10 Oct 2016 19:22:25 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 10 Oct 2016 19:22:25 -0000 Authentication-Results: pb1.pair.com header.from=larry@garfieldtech.com; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=larry@garfieldtech.com; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain garfieldtech.com from 66.111.4.29 cause and error) X-PHP-List-Original-Sender: larry@garfieldtech.com X-Host-Fingerprint: 66.111.4.29 out5-smtp.messagingengine.com Received: from [66.111.4.29] ([66.111.4.29:35937] helo=out5-smtp.messagingengine.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 58/26-52150-E6AEBF75 for ; Mon, 10 Oct 2016 15:22:23 -0400 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id 5EC7A2084E for ; Mon, 10 Oct 2016 15:22:20 -0400 (EDT) Received: from frontend1 ([10.202.2.160]) by compute3.internal (MEProxy); Mon, 10 Oct 2016 15:22:20 -0400 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-sasl-enc:x-sasl-enc; s=smtpout; bh=LFSZUch4xPJmaD7 JlpoGv4x+wpA=; b=rGTYTd9ajNyzriKqesYoWKxnWD/TPmIZ3Kgozsow3l65UHx 8oprVArUlJq83RgXPtsRKy+D7EfQf+Qsvxg5/fKOmLlmydAdwaJZk12ggTZRfojj COdDQJMrqAFbdKEMPPgbpp5D/tPXyGSFKf4TUSZKRTgVu6nof+azO8VirkM4= X-Sasl-enc: NTsbXOviy/34uAU6IwmB5jtGFKcLuHHLG7eSjJwiH0yF 1476127340 Received: from [192.168.42.5] (c-50-178-40-84.hsd1.il.comcast.net [50.178.40.84]) by mail.messagingengine.com (Postfix) with ESMTPA id 1B843F2C78 for ; Mon, 10 Oct 2016 15:22:20 -0400 (EDT) To: internals@lists.php.net References: Message-ID: Date: Mon, 10 Oct 2016 14:22:19 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] [RFC] Bug #72811 - Replacing parse_url() From: larry@garfieldtech.com (Larry Garfield) On 10/07/2016 09:45 AM, David Walker wrote: >> I think an important part of this interface is that the URL is constructed >> using URL(url [, base]), where "base" is the base URL against which >> relative URLs are resolved. This base URL is required for parsing >> non-absolute URLs. To me this makes a lot of sense and I think it makes it >> much clearer how "incomplete" URLs are being treated. >> > If we go the route of making URL it's own object, and expose an > object-oriented interface, are we leading it to be more of a total URL > builder, of sorts? Like: > > $url = new URL(); > $url->setScheme('http'); > $url->setHost('example.org'); > $url->setPath('/test.php'); > var_dump($url->build()); // outputs: http://example.org/test.php > > OR, would it, at the end of the day be an object that takes a string, and > you just call getter's on it that would be akin to the current flags you > pass into parse_url()? > > On both accounts, if we're to go forward with the Object model of URL, > would this want to be broken into it's own ext/url module, like how date > exists? Or retain it in ext/standard? > > Cheers > -- > Dave Be aware that a user-space definition for a URL object already exists as part of PSR-7: http://www.php-fig.org/psr/psr-7/#3-5-psr-http-message-uriinterface A core-provided mutable and incompatible object would be problematic. What would be useful would be to have a C-level function (parse_url() or otherwise) that can generate a very well-known and standardized array structure (ie, better than parse_url()s now) that a UriInterface implementation could trivially wrap. Basically, a way to simplify this existing code: https://github.com/zendframework/zend-diactoros/blob/master/src/Uri.php#L435 And move the conditionals and filter*() sub-calls to C. (Right now they play games with regexes and hope.) --Larry Garfield