Skip to content

Instantly share code, notes, and snippets.

View arcanisgk's full-sized avatar
🏦
looking for a job

Walter Nuñez arcanisgk

🏦
looking for a job
  • Icaros Net S.A
  • Panamá
View GitHub Profile
@arcanisgk
arcanisgk / anonymous-class-abuse.php
Last active February 24, 2021 14:51 — forked from requinix/anonymous-class-abuse.php
Global functions with (nearly) totally private shared data
<?php
/*
Can I write global functions in PHP that share data between them, without also making that data
accessible to everyone else?
Global functions have a particular utility that is handy, even in an OOP codebase: it doesn't
require a fully-qualified class name/use statement and when in the root namespace the function will
be automatically resolved from any other namespace automatically (though prepending that slash is
@arcanisgk
arcanisgk / highlight_string_ex.php
Last active February 24, 2021 14:51 — forked from requinix/highlight_string_ex.php
Quick PHP code highlighter
<?php
function highlight_string_ex($string) {
static $COLORS = [
"comment" => "\e[32m%s\e[0m", // green
"constant" => "\e[93m%s\e[0m", // yellow
"function" => "\e[97m%s\e[0m", // white
"keyword" => "\e[94m%s\e[0m", // blue
"magic" => "\e[93m%s\e[0m", // yellow
"string" => "\e[95m%s\e[0m", // magenta
@arcanisgk
arcanisgk / console-example.php
Created February 24, 2021 04:04 — forked from sallar/console-example.php
PHP Colored CLI Output Script.
<?php
// Output screenshot:
// http://cl.ly/NsqF
// -------------------------------------------------------
include_once 'console.php';
// ::log method usage
// -------------------------------------------------------
Console::log('Im Red!', 'red');
@arcanisgk
arcanisgk / php-style-guide.md
Created August 17, 2020 14:29 — forked from ryansechrest/php-style-guide.md
PHP style guide with coding standards and best practices.

PHP Style Guide

All rules and guidelines in this document apply to PHP files unless otherwise noted. References to PHP/HTML files can be interpreted as files that primarily contain HTML, but use PHP for templating purposes.

The keywords "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in RFC 2119.

Most sections are broken up into two parts:

  1. Overview of all rules with a quick example
  2. Each rule called out with examples of do's and don'ts