Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:101752 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 45105 invoked from network); 3 Feb 2018 12:19:12 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 3 Feb 2018 12:19:12 -0000 Authentication-Results: pb1.pair.com smtp.mail=ocramius@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=ocramius@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.128.181 as permitted sender) X-PHP-List-Original-Sender: ocramius@gmail.com X-Host-Fingerprint: 209.85.128.181 mail-wr0-f181.google.com Received: from [209.85.128.181] ([209.85.128.181:44765] helo=mail-wr0-f181.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 08/6B-33502-0C8A57A5 for ; Sat, 03 Feb 2018 07:19:12 -0500 Received: by mail-wr0-f181.google.com with SMTP id v31so25068079wrc.11 for ; Sat, 03 Feb 2018 04:19:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=CDHi2lycbE2Fw2mwtVYWNIjWzSQxrvyxcG7rGFP76Nc=; b=UX9Q7+0XnZQR33ZbgLz6uHgEkKHbYRTF0prZA7lkIYXIjq+9msOWUFXz8mPXHTd2ib +7gz9AnNKY5IuT62hG2+L6bwa9gbFKP3Wiolo67W7K8RMemyoqnexvWg5395Bvd3i3me xzr6HDGkeYqIz+JpLjBj4m0HH1r6aR3RcBmuUfZZND2IhFDckLQFVVGWXt6wKpLYniRC KXkwABtxlXBth30Uc7hYjGsk2m578/DK1MrAd0r2P3ygUBFhqFMzcR5/OIuSKzrFwD28 fiuVUIXcZ6XthWDz5pNmYrZdCOtkqYkGINBdDRALK+/v6YNJ4kL+gR3sy/KKZvv/IPxw tI2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=CDHi2lycbE2Fw2mwtVYWNIjWzSQxrvyxcG7rGFP76Nc=; b=JOSiruma0i4og84gqD9YrJPsXoI+LnmC8Oc1WPmLsn8FVwUkhN0KCw4ieaoxJtlRbQ tFAbR9ojTq9+MWmNV97Xme5r5pw7+ILRnyVZKMsOQ2FDPL9cVSep1eUYqTQicBcmZxxi iNwXlZBWzv5ZaMse9M2ydRh51hsxEWMbDki5DGSwin2VNrpGniRHqGc0wZ/89BJABMtB Tq+OnkVIYUypXUtPKoagr21v2D7/q37iGoyGO10gW1QBGiNUEBCBHpjNxI/orjw8EwWM ZDtB3G97mlsS9r9b7TUFJj7ebEpXCFwaigiwExWOZ/QUDILRtqA2IFbMZWMs4bjJC8Bh puuA== X-Gm-Message-State: AKwxytdux3+mqI3HhRQhQFl+ow2/Y+WB+HWfTbtkchnv4OH1gMK92/H7 2ltRdB2nfz87ZGpeSItahyv6FRvWbmXzSz1pJZe7yXPq X-Google-Smtp-Source: AH8x224BvnQR06/GhBjSDA6HUOOBlKtMsEMHuPUHUOu6DSJeQw/w07EjnPOJjF2PdXLKvGOTuOpJIG+iOv5acMvOcps= X-Received: by 10.223.190.141 with SMTP id i13mr19000352wrh.211.1517660349460; Sat, 03 Feb 2018 04:19:09 -0800 (PST) MIME-Version: 1.0 Received: by 10.223.135.61 with HTTP; Sat, 3 Feb 2018 04:18:48 -0800 (PST) In-Reply-To: References: Date: Sat, 3 Feb 2018 13:18:48 +0100 Message-ID: To: Wes Cc: Andreas Heigl , PHP Internals Content-Type: multipart/alternative; boundary="089e082f69c804f3f905644dd670" Subject: Re: [PHP-DEV] [RFC][DISCUSSION] Deprecation of fallback to root scope From: ocramius@gmail.com (Marco Pivetta) --089e082f69c804f3f905644dd670 Content-Type: text/plain; charset="UTF-8" On Sat, Feb 3, 2018 at 1:15 PM, Wes wrote: > question was: > > Do I get that right that it will then no longer be possible to mock > functions from the root namespace during tests? > > At least when the functions are "use"d or are explicitly namespaced... > > Being able to mock functions like "date" or "time" or "mt_rand" is > currently extremely helpful. > I think there's something quite broken with the current approach in mocking core functions, specifically because already having them hardcoded in your codebase means that the code relies on hidden shared global state. Can strongly suggest injecting a `Clock` object as is done in https://github.com/lcobucci/clock, for example. Same goes for sources of randomness. Marco Pivetta http://twitter.com/Ocramius http://ocramius.github.com/ --089e082f69c804f3f905644dd670--