I hereby claim:
- I am mikey179 on github.
- I am mikey179 (https://keybase.io/mikey179) on keybase.
- I have a public key ASAEbnyVKjsTeNqHonyCxi4UscVjxEf-wMcLX2IlAGOxgAo
To claim this, I am signing this object:
<?php | |
class SpecializedValidator extends AbstractValidator | |
{ | |
private $somethingToCheck; | |
public function __construct($somethingToCheck) | |
{ | |
parent::__construct([$this, 'validate']); // sic! | |
$this->somethingToCheck = $somethingToCheck; | |
} |
I hereby claim:
To claim this, I am signing this object:
#!/bin/bash | |
set -o nounset | |
set -o errexit | |
selfbase() { | |
local selfbase="" | |
if [ -f $0 -a ! -h $0 ]; then | |
selfbase="$(dirname $0)" | |
elif [ $(uname) = "Darwin" ]; then | |
selfbase="$(dirname $(readlink $0))" |
<?php | |
class MyStreamWrapper { | |
private $read = false; | |
public function stream_open($path , $mode , $options , &$opened_path) { | |
return true; | |
} | |
public function stream_stat() { | |
return []; |
<?php | |
function foo(callable $bar) | |
{ | |
$bar("nu?\n"); | |
} | |
foo(function($arg) { echo "Hello world!\n" . $arg;}); | |
function baz($arg) | |
{ |
If your application requires a build tool, there's something wrong with your application or the runtime environment of the application. For some that might be quite a controversial statement. What do I mean with it? In order to be able to run an application, the list of steps to fulfill should include just three steps. The first step is to get a checkout of the application from your source code management system (or download it to a local folder, this should require a single command line instruction only as well), and the last step is to start the application.
Now there is a single step left only. And this step should not be running a build tool which does hundreds of things in order to get a running application. Your application should be runnable right after checkout, the only thing that is allowed to miss are any dependencies the application is build on. So the second step should be fetching the dependencies. Nothing more. You don't need a build tool for that. A simple dependency manager is just enough to
In recent weeks I have come to the conclusion that private methods can be an indicator that a class needs to be refactored. The more lines a private method contains the stronger the indicator. Please be aware that I'm not arguing against private methods or that I consider them harmful, quite the contrary. A private method which encapsulates a condition to be used in another method of the class can be really helpful when it helps to keep the same level of abstraction in this other method.
However, such little methods seldom have more than 1 to 3 lines of code. When your private method starts to have five lines of code or more it becomes an indidator that it does things which shouldn't be done in this class in the first place. It should be done in one of the collaborators the class already has (i.e., one of its dependencies), either in a public method or as part of other operations in one of these collaborators. Alternatively, if it fits into none of those existing collaborators, it could give you a hint that
function convertToStringRepresentation1($value) | |
{ | |
$string = ''; | |
$lines = explode("\n", (string) $value); | |
foreach ($lines as $lineCounter => $line) { | |
if (empty($line)) { | |
continue; | |
} | |
if (0 != $lineCounter) { |
<?php | |
function with($var, \Closure $execute, \Closure $exit = null) | |
{ | |
try { | |
$result = $execute($var); | |
$exit($var); | |
} catch (\Exception $e) { | |
if (null == $exit) { | |
return null; | |
} |
<?php | |
# uses trac2mediawiki perl script from http://www.mediawiki.org/wiki/Extension:TracWiki2MediaWiki#Code | |
$dirit = new DirectoryIterator(getcwd()); | |
foreach ($dirit as $file) { | |
if (!$file->isFile() || substr($file->getFilename(), 0 , 1) == '.' || $file->getExtension() == '.md') { | |
continue; | |
} | |