Use $this to refer to the current object. Use self to refer to the current class. In other words, use $this->member for non-static members, use self::$member for static members.
Source: When to use self vs this -stackoverflow
<?php | |
namespace App\Http\Middleware; | |
use Closure; | |
use Illuminate\Http\Request; | |
use Illuminate\Http\Response; | |
use Symfony\Component\DomCrawler\Crawler; | |
class PjaxMiddleware |
<?php | |
/* | |
|-------------------------------------------------------------------------- | |
| Follow this instructions: | |
|-------------------------------------------------------------------------- | |
| | |
| Laravel takes a dead simple approach to your application environments | |
| so you can just specify a machine name for the host that matches a | |
| given environment, then we will automatically detect it for you. |
# Running xdebug in the console, for debugging Laravel artisan commands. Useful as I keep forgetting this one... | |
php -dxdebug.remote_autostart artisan | |
#Running phpcs for 5.3: | |
phpcs -pv --standards= --runtime-set testVersion 5.3 --ignore=*/public/*,*.js,*.css,*/tests/*,*/views/training/* . |
Use $this to refer to the current object. Use self to refer to the current class. In other words, use $this->member for non-static members, use self::$member for static members.
Source: When to use self vs this -stackoverflow
class BaseModel extends \lithium\data\Model { | |
public static function create(array $data = array(), array $options = array()) { | |
$defaults = array('defaults' => true, 'class' => 'entity'); | |
$options += $defaults; | |
$model = get_called_class(); | |
if (isset($data['_type']) && $data['_type']) { | |
list($namespace, $name) = preg_split("/\\\[^\\\]*$/", $model); | |
$model = $namespace . '\\' . Inflector::humanize(Inflector::pluralize($data['_type'])); |
Attention: the list was moved to
https://github.com/dypsilon/frontend-dev-bookmarks
This page is not maintained anymore, please update your bookmarks.
<?php | |
// I have this in my bootstrap/cache.php file | |
Dispatcher::applyFilter('run', function ($self, $params, $chain) { | |
foreach (Connections::get() as $connection) { | |
$connection = Connections::get($connection); | |
$connection->applyFilter('describe', function($self, $params, $chain) { | |
if (!empty($params['fields'])) { | |
$fields = $params['fields']; | |
return $self->invokeMethod('_instance', array('schema', compact('fields'))); | |
} |
<?php | |
namespace app\tests\cases\controllers; | |
use app\controllers\UsersController; | |
use app\models\Users; | |
use lithium\action\Request; | |
use lithium\data\Connections; | |
class UsersControllerTest extends \lithium\test\Integration { |
<figure class="quote"> | |
<blockquote>It is the unofficial force—the Baker Street irregulars.</blockquote> | |
</figure> |
-server | |
-Xms2048m | |
-Xmx2048m | |
-XX:NewSize=512m | |
-XX:MaxNewSize=512m | |
-XX:PermSize=512m | |
-XX:MaxPermSize=512m | |
-XX:+UseParNewGC | |
-XX:ParallelGCThreads=4 | |
-XX:MaxTenuringThreshold=1 |