Skip to content

Instantly share code, notes, and snippets.

View drupol's full-sized avatar

Pol Dellaiera drupol

View GitHub Profile
@drupol
drupol / composer.php
Last active December 16, 2019 11:52
Composer dependency tree with PHPTree
<?php
declare(strict_types=1);
use drupol\launcher\Launcher;
use drupol\phptree\Exporter\Image;
use drupol\phptree\Importer\SimpleArray;
include './vendor/autoload.php';
@drupol
drupol / pi_approximation.php
Last active January 9, 2020 11:19
Approximate PI using Monte Carlo method
<?php
declare(strict_types=1);
include 'vendor/autoload.php';
use loophp\collection\Collection;
$monteCarloMethod = static function ($in = 0, $total = 1) {
$randomNumber1 = mt_rand() / mt_getrandmax();
@drupol
drupol / e.php
Last active January 6, 2020 09:19
Approximate the value of number e
<?php
declare(strict_types=1);
include 'vendor/autoload.php';
https://github.com/loophp/collection
use loophp\collection\Collection;
$multiplication = static function ($value1, $value2) {
@drupol
drupol / music-scale.php
Last active December 30, 2019 13:12
Pythagorian and harmonic music scales using functionnal PHP and a lazy collection
<?php
/**
* @file
* Example/demo file.
* @see https://github.com/drupol/collection
*/
declare(strict_types=1);
@drupol
drupol / primes.php
Last active August 27, 2020 21:07
Finding primes in PHP with a lazy collection library.
<?php
/**
* @file
* Example/demo file.
*
* @see https://github.com/loophp/collection
*/
declare(strict_types=1);
@drupol
drupol / Finder.svg
Last active February 29, 2020 10:29
loophp/phptree + nikic/php-parser = <3
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@drupol
drupol / test-advanced.php
Last active May 20, 2020 14:08
Advanced example of nikic/php-parser importer in loophp/phptree
<?php
declare(strict_types=1);
namespace EcPhp\Cart;
include __DIR__ . '/vendor/autoload.php';
use drupol\launcher\Launcher;
use loophp\phptree\Exporter\Image;
@drupol
drupol / test-simple.php
Last active May 10, 2021 13:34
Simple example of nikic/php-parser importer in loophp/phptree
<?php
declare(strict_types=1);
include __DIR__ . '/vendor/autoload.php';
use drupol\launcher\Launcher;
use loophp\phptree\Exporter\Image;
use PhpParser\ParserFactory;
use loophp\phptree\Importer\NikicPhpParserImporter;
final class Foo {}
final class Bar {
public function __construct(Foo $foo);
}