Skip to content

Instantly share code, notes, and snippets.

View JarJak's full-sized avatar

Jarek Jakubowski JarJak

View GitHub Profile
@JarJak
JarJak / OptionalProperties.php
Created June 17, 2024 07:56
Optional properties php trait that distinguish from unset and null properties, useful tin DTOs
<?php
trait OptionalProperties
{
public static function fromArray(array $args = [], bool $strict = true): self
{
$obj = (new ReflectionClass(self::class))->newInstanceWithoutConstructor();
foreach ($args as $prop => $value) {
if (!property_exists($obj, $prop)) {
if ($strict) {
@JarJak
JarJak / .bashrc
Last active June 1, 2022 09:26
Useful GIT bash aliases
eval $(docker-machine env)
SSH_ENV=$HOME/.ssh/environment
force_color_prompt=yes
source /Library/Developer/CommandLineTools/usr/share/git-core/git-prompt.sh
PS1="\[\033[1;36m\]\u\[\033[1;35m\]@\[\033[1;34m\]#:\[\033[1;33m\]\w\[\033[1;32m\]\$(__git_ps1) \[\033[1;31m\]\$ \[\033[00m\]"
alias ls='ls --color=auto'
@JarJak
JarJak / lol.php
Last active March 15, 2017 21:02
php > if (!1 instanceof DumbClass) echo 'lolphp';
PHP Fatal error: instanceof expects an object instance, constant given in php shell code on line 1
php > $a = 1; if (!($a instanceof DumbClass)) echo 'lolphp'; // DumbClass has not been declared but not even a notice is thrown
lolphp