Skip to content

Instantly share code, notes, and snippets.

View ManInTheBox's full-sized avatar

Zarko Stankovic ManInTheBox

View GitHub Profile
@ManInTheBox
ManInTheBox / static_inheritance.txt
Created March 30, 2017 11:40
Do not use static property inheritance. It's a class level inheritance, therefore "global".
Psy Shell v0.7.2 (PHP 7.1.0 — cli) by Justin Hileman
>>> class StaticParent
... {
... public static $catchAll = 'this is initial value';
... }
=> null
>>> class ChildOne extends StaticParent
... {}
=> null
>>> class ChildTwo extends StaticParent
zarko:unfinished/ (master) $ vagrant up [13:21:07]
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Box 'ubuntu/trusty64' could not be found. Attempting to find and install...
default: Box Provider: virtualbox
default: Box Version: >= 0
==> default: Loading metadata for box 'ubuntu/trusty64'
default: URL: https://atlas.hashicorp.com/ubuntu/trusty64
==> default: Adding box 'ubuntu/trusty64' (v20161121.0.0) for provider: virtualbox
default: Downloading: https://atlas.hashicorp.com/ubuntu/boxes/trusty64/versions/20161121.0.0/providers/virtualbox.box
==> default: Successfully added box 'ubuntu/trusty64' (v20161121.0.0) for 'virtualbox'!
@ManInTheBox
ManInTheBox / DateTimeImmutabilityExample.php
Created November 8, 2016 14:47
DateTime VS DateTimeImmutable example
<?php
class DateTimeImmutabilityExample
{
private $date;
/**
* Intentionaly no type hinting so you can test with both DateTime and DateTimeImmutable
*/
public function __construct($date)
@ManInTheBox
ManInTheBox / visitor.php
Last active August 22, 2016 21:52
Visitor pattern implementation in PHP
<?php
interface EntityInterface
{
/**
* @param VisitorInterface $visitor
*/
public function accept(VisitorInterface $visitor);
}
@ManInTheBox
ManInTheBox / setter.sublime-snippet
Created October 5, 2015 13:45
Sublime Text PHP setter snippet
<snippet>
<content><![CDATA[
public function set${1/(\w)/(\u$1)/}(\$$1)
{
\$this->$1 = \$$1;
return \$this;
}
]]></content>
<tabTrigger>setter</tabTrigger>
@ManInTheBox
ManInTheBox / getter.sublime-snippet
Created October 5, 2015 13:45
Sublime Text PHP getter snippet
<snippet>
<content><![CDATA[
public function get${1/(\w)/(\u$1)/}()
{
return \$this->$1;
}
]]></content>
<tabTrigger>getter</tabTrigger>
</snippet>
@ManInTheBox
ManInTheBox / instanceof.txt
Created July 1, 2014 09:28
PHP's instanceof operator.
$ php -r 'var_dump('test' instanceof \Exception);'
bool(false)
$ php -r 'var_dump(null instanceof \Exception);'
Fatal error: instanceof expects an object instance, constant given in Command line code on line 1
$ php -r 'var_dump(1234 instanceof \Exception);'
Fatal error: instanceof expects an object instance, constant given in Command line code on line 1
$ php -r 'var_dump(array() instanceof \Exception);'
bool(false)
➜ chess.com-master git:(ZS/fix-v3-v2-messages) whois belgradejs.org
Domain Name:BELGRADEJS.ORG
Domain ID: D169353928-LROR
Creation Date: 2013-08-03T09:21:01Z
Updated Date: 2013-10-03T03:45:50Z
Registry Expiry Date: 2014-08-03T09:21:01Z
Sponsoring Registrar:Domainclub.com, LLC (R1761-LROR)
Sponsoring Registrar IANA ID: 880
WHOIS Server:
Referral URL:
@ManInTheBox
ManInTheBox / syliusbundles.txt
Created November 4, 2013 00:23
Sylius bundles documentation and status
[docs] SyliusShippingBundle
SyliusWebBundle
[docs] SyliusVariableProductBundle
[docs] SyliusTaxonomiesBundle
[docs] SyliusTaxationBundle
[docs] SyliusSettingsBundle
[docs] SyliusOrderBundle
[docs] SyliusResourceBundle
SyliusPromotionsBundle
[docs] SyliusProductBundle
@ManInTheBox
ManInTheBox / curlinfo.txt
Created October 31, 2013 15:48
curl info
-w, --write-out <format>
Defines what to display on stdout after a completed and success-
ful operation. The format is a string that may contain plain
text mixed with any number of variables. The string can be spec-
ified as "string", to get read from a particular file you spec-
ify it "@filename" and to tell curl to read the format from
stdin you write "@-".
The variables present in the output format will be substituted
by the value or text that curl thinks fit, as described below.