Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:94972 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 10655 invoked from network); 9 Aug 2016 17:33:56 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 9 Aug 2016 17:33:56 -0000 Authentication-Results: pb1.pair.com header.from=david.proweb@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=david.proweb@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.216.181 as permitted sender) X-PHP-List-Original-Sender: david.proweb@gmail.com X-Host-Fingerprint: 209.85.216.181 mail-qt0-f181.google.com Received: from [209.85.216.181] ([209.85.216.181:36858] helo=mail-qt0-f181.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 06/25-03404-4041AA75 for ; Tue, 09 Aug 2016 13:33:56 -0400 Received: by mail-qt0-f181.google.com with SMTP id 52so9124865qtq.3 for ; Tue, 09 Aug 2016 10:33:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:from:date:message-id:subject:to; bh=whK3REIBZtMKWA+U+wY7p1MRA/hT1jiCv2tuTn2XbQo=; b=X9yvBx90ne9G/TfA/TEdyCJou13G4JJ29vqmRp5uhsYXjmtHPva8q8lrGj2v4ZX7+Y iNMXvG+8hDZvZCcFLHBbScEtaMshAEn3oe7n/YvoUMKPo2kvXrMKrgDK3CGMHCoDpMWf WPf5CF3ZjCljwic1w68mDI3GlzIK9q6w7/82PdTiSoNKlFmig4ZUShtI24w1V9I+/VcI hQP/lFhxAbYvdoHwYkUM/UOVZmu+COGal9vpSlopnaQA9c4YYiC9WIP2y24rA5JIrqou n1KEAKMUDwD/W1dd8WAtOLnMt+SXFJebZs8hHhcd6eb/BMgs3BngIdDsrTNPi8/ED4lA jwsw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=whK3REIBZtMKWA+U+wY7p1MRA/hT1jiCv2tuTn2XbQo=; b=MyP5iuSukXgA3PxgrcdH+SFyMOjvdvb7sfSvQ788Quou7TjkLhSH0ModdSVNwQOCsi J/VORQ+rSDoa8Ih75FqSLGqs3vkVe2h65F35PWjr0HGwR3Lq49jkZ1C+Q9Ey3LhPnexD 6pwtwBLJ4qAVIoDvgD9D1L+Bb3hauzT7sNXy6vG+9ovuzks0TzdQMnJAwYnDdj2xE+Z/ cr+XGwDv4ij9cU6RIuxNzK25wdk1oD8jqRq2zDJgLCB12V3Em9iFSv917PGGFUGbUraG e53cCbyvpE1ymYE+dcS2q8T2q8RydmShglOWeQbOH430hfbCsLFAPYIXCroT1d5ImWXu wAvw== X-Gm-Message-State: AEkoousrIbFLTQIOetsVppQ8cyXb6TjUqRnl444GJT0j3T+SAwwxqa7cL919ruuEwHaTtV/g2H8GmD+wE0GeaQ== X-Received: by 10.200.55.91 with SMTP id p27mr35330934qtb.48.1470764033437; Tue, 09 Aug 2016 10:33:53 -0700 (PDT) MIME-Version: 1.0 Received: by 10.55.45.67 with HTTP; Tue, 9 Aug 2016 10:33:33 -0700 (PDT) Date: Tue, 9 Aug 2016 14:33:33 -0300 Message-ID: To: PHP Internals Content-Type: text/plain; charset=UTF-8 Subject: Method compare() From: david.proweb@gmail.com (David Rodrigues) Currently PHP has a method called "version_compare()". Should be great if we have the same function but to general usage. There are some implementations on web for that, but I guess that it could be done natively. > compare(mixed $a, mixed $b, string $operator): boolean Then I could do something like that: > compare(1, 2, '>') === false > compare('1', 1, '===') === false It should be very useful to libraries that expects that user pass an operator. For instance: > $collection->where('id', '>', 5) => compare($id, 5, '>') I guess that it could supports all PHP operators: ==, ===, !=, <>, !==, <, >, <= and >=. The spaceship operator does the works too for integers, but not should works if you expects than $a === $b, or when you expects than $a >= $b. -- David Rodrigues