This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$distance = new Meter(3); | |
$cm = $distance->in(Centimeter::class); | |
ecoh $distance; // 3m | |
echo $cm; // 300cm | |
$distance == Decimeter(30); // True | |
$distance === Decimeter(30); // False |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use Jasny\DB\Option\Functions as opts; | |
use Jasny\HttpAttributes\Request\Accept; | |
use Jasny\HttpAttributes\Request\ParsedBody; | |
use Jasny\HttpAttributes\Request\PathParam; | |
use Jasny\HttpAttributes\Response\ContentType; | |
use Jasny\HttpAttributes\Route\Delete; | |
use Jasny\HttpAttributes\Route\Get; | |
use Jasny\HttpAttributes\Route\Post; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
## -*-sh-*- | |
#set -x | |
# BEGIN of icu-config-top | |
# Copyright (C) 2016 and later: Unicode, Inc. and others. | |
# License & terms of use: http://www.unicode.org/copyright.html | |
#****************************************************************************** | |
# Copyright (C) 1999-2013, International Business Machines | |
# Corporation and others. All Rights Reserved. | |
#****************************************************************************** |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* `a > b > c > a` should always result in false. | |
*/ | |
function all_greater($a, $b, $c) | |
{ | |
return ($a > $b) && ($b > $c) && ($c > $a); | |
} | |
// Fails due to type juggling. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require 'vendor/autoload.php'; | |
// This is a sample test API key. Sign in to see examples pre-filled with your key. | |
\Stripe\Stripe::setApiKey('sk_test_4eC39HqLyjWDarjtT1zdp7dc'); | |
# retrieve JSON from POST body | |
header('Content-Type: application/json'); | |
$json_str = file_get_contents('php://input'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
declare(strict_types=1); | |
use Jasny\Auth; | |
use Jasny\Auth\Confirmation\InvalidTokenException; | |
use Jasny\Persist\Gateway; | |
use Jasny\Session; | |
use Psr\Http\Message\ResponseInterface as Response; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cmake_minimum_required(VERSION 3.8) | |
project(php C) | |
# 32bit or 64bit | |
set(BITNESS 32) | |
if(CMAKE_SIZEOF_VOID_P EQUAL 8) | |
set(BITNESS 64) | |
endif() | |
# Global definitions |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Set the properties (including protected and private) of an object. | |
* This should only be called by the object itself. | |
*/ | |
function object_init(object $object, array $values): void | |
{ | |
$init = function ($values) { | |
foreach ($values as $prop => $value) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Generate package.xml for pecl extensions. | |
* Works for new and existing extensions. | |
* | |
* Add it to `Makefile.frag` | |
* package.xml: php_$(PHP_PECL_EXTENSION).h | |
* $(PHP_EXECUTABLE) build-packagexml.php | |
* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Render and send e-mail | |
*/ | |
class Email extends PHPMailer | |
{ | |
/** | |
* @var Twig_Environment | |
*/ |