Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:105684 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 8522 invoked from network); 13 May 2019 12:54:53 -0000 Received: from unknown (HELO mail-it1-f169.google.com) (209.85.166.169) by pb1.pair.com with SMTP; 13 May 2019 12:54:53 -0000 Received: by mail-it1-f169.google.com with SMTP id m141so17909828ita.3 for ; Mon, 13 May 2019 03:00:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=nqnO5LZDrpdkC5u5jpmvf9C7t7rNZOfKDZ2Gmdzey3w=; b=gY9F+vhKiTVY8a38kgVJIzjFz2ogWLGB3FeyhZiE4ndaAGjvWNho3xmMBTnBjjBXZj PZjflhQ7UPNt1wRCCrKdYlI6tyH85AxiqVqrBINKci50Mdslb6PnXj42Tl8AHPXfcrGw RDDZN7opOjTf9FiYfmsqYtok5uh2TG0h6qbS98G8gmgpuhv+PV256Owr+ZxicujIdUDC SQmCagiRG+lSEOjO97bEbQnkKCcfsSP65M/inLga6QWxPn9XSTQDdksWstj1hrk/kBZF LpIfTJMB2h+TExQWJey7RRqkNM+v7chSiy2u53V5LRvvTMPinIIddnXEZm3Ic+CjZCYW V8UA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=nqnO5LZDrpdkC5u5jpmvf9C7t7rNZOfKDZ2Gmdzey3w=; b=pobEoW0BrL6fQFc57dnR/ESjBQnq/bWsbjq/DtYDHnXUGBaUCHDJDPAx1teg5bsH0q RPvWPmgXiMuhzuXYyclNC+GzKZPYrzlDZo6UHMiIYwHjy+KufHz6VpB7AlMlT8z/4yMW Z669wHTDF33iVj3Va3kNb17LA/7ncuGUmvLIduwo5lFt/KBRU3c40GQhAGdmF4OzBAz/ eEQOiVun9nN9CdnTeN34Gw4aN02RMbwCbAMtBgfmtebBXp85vb3bkF2NtLFfzyaNamsQ w1JaWFxg+H9y4/9KAip/comA0oTP+u6Fb5LVS42FGVf+eAtJXDo7AdYxTMjqbefMKWY1 kycw== X-Gm-Message-State: APjAAAVvaEOqqfn99b54WtuQ+xA/6nE36eYJ47Cy+2EQol9TmLREyLuV cSrySPF9dbp0DEzCs/FmWkdqhNMdkZ6U1Qpzf8E= X-Google-Smtp-Source: APXvYqyMWqp+xUaw7wSGYlZMsUzWMqWx+0gCpgKaMoD9eokIS5+PwyNqwF1fTnENXv1ZeJQ+dv9KBJBZIVwW+IbA4YU= X-Received: by 2002:a24:edc6:: with SMTP id r189mr19667169ith.158.1557741615138; Mon, 13 May 2019 03:00:15 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Mon, 13 May 2019 11:59:49 +0200 Message-ID: To: Niklas Keller Cc: Dustin Wheeler , PHP internals Content-Type: multipart/alternative; boundary="0000000000009f4bae0588c1fbd0" Subject: Re: [PHP-DEV] PHP header files, restrict to declaring code only From: kjarli@gmail.com (Lynn) --0000000000009f4bae0588c1fbd0 Content-Type: text/plain; charset="UTF-8" > Instead of introducing a declare option or special open tag, how about > another "include" construct, that only allows side-effect free (apart > from class loading) operations? > > e.g. "require_noexec 'foobar.php'" > > Regards, Niklas > Hi Niklas, That's indeed a very interesting alternative! I've given it some thought in regards in the context of no side-effects and I really like the idea as it sounds easier to implement. With an alternative as such, I see one major roadblock, perhaps it can be solved? These days I personally hardly ever write require/include statements, composer does this for me with autoloading. For composer it would probably mean an "all or nothing" when it comes to picking the keyword to "require" or "require without side-effects". This makes it hard, if not impossible, to trigger deprecations from deprecated interfaces, unless you use something too hook into autoloading and check if there were `@deprecated` annotations on the class, interface, etc. This means that a feature that worked by default, would be broken and risk potential issues when upgrading. Following this strategy, it would put the responsibility of loading the files at the developer that consumes the (public) API, rather than the developer that (public) API. I believe the public API should define whether or not it can, or must be, be loaded without side effects without any worries for the developer consuming that public API. This is why I initially tried to come up with a strategy that allows you to define it in the file (one way or another). Note that my example with composer is tailored around my specific use-case and that a new function, keyword or statement might be more suitable for developers that explicitly load their code without autoloading. Regards, Lynn van der Berg --0000000000009f4bae0588c1fbd0--