Created
July 2, 2012 15:51
-
-
Save luisartola/3033912 to your computer and use it in GitHub Desktop.
paranas php
This file contains 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
function doSomething(callable $x) { | |
return $x(); | |
} | |
doSomething(function () { }); | |
doSomething("function_name"); | |
doSomething(['class', 'staticMethodName']); | |
doSomething([$object, 'methodName']); | |
doSomething($invokableObject); |
This file contains 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
function doSomething(callable $x) { | |
return $x(); | |
} | |
doSomething(function () { }); | |
doSomething("function_name"); | |
doSomething(['class', 'staticMethodName']); | |
doSomething([$object, 'methodName']); | |
doSomething($invokableObject); |
This file contains 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
class foo { | |
function test() { | |
echo "Foo walks into a bar..."; | |
} | |
function anonFunc() { | |
return function() { $this->test(); }; | |
} } | |
class bar { | |
public function __construct(foo $o) { | |
$a = $o->anonFunc(); $a(); | |
} | |
} | |
new bar(new foo); // prints “Foo walks into a bar...” |
This file contains 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
..>bindTo |
This file contains 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
inyección php unclebob | |
Implementar el articulo de unclebob con pimple | |
<?php | |
class tralari { | |
public function soyTrait(){ | |
echo "puedo volar!"; | |
return $this; | |
} | |
} | |
$pruebas = new tralari(); | |
$pruebas->coco = "pepo"; | |
$pruebas->pepo = "coco"; | |
$pruebas->soyTrait(); | |
//print_r(array_filter((array)$pruebas, function($n) { return $n == "pepo";})); | |
class User extends ArrayObject{ | |
function filter(Closure $closure){ | |
var_dump($this->storage); | |
} | |
} | |
$user = new User(); | |
var_dump($user); | |
die(); | |
$user->filter(function(){}); | |
$user->coco = "pepo"; | |
$user[0] = "tralarelo"; | |
$popo = array_filter((array)$user, function($n) {return $n == "tralarelo";}); | |
var_dump($popo); | |
die(); | |
cuando haces esto te devuelve una stdclass!! | |
$row = $this->getAdapter()->fetchRow($sql); |
This file contains 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
esto funciona | |
$soyunstring{3} |
This file contains 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
$stdClass->method = function() {tralari tralara} | |
$stdClass->method(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment