Skip to content

Instantly share code, notes, and snippets.

View nikita2206's full-sized avatar

Nikita Nefedov nikita2206

  • Amsterdam, Netherlands
View GitHub Profile

Hi,

I've been going through some bug reports, and have found there are several bad behaviours related to class constructors that ought to be corrected, but could only be done at a major version. The bad behaviours are:

Constructors returning null

Several classes in PHP return null when there is a problem in the parameters passed to their constructor e.g.

@nikita2206
nikita2206 / gist:3035134
Created July 2, 2012 19:26 — forked from withremote/gist:3034778
If String Contains
<?php
if(!function_exists('if_string_contains'))
{
function if_string_contains($needle,$haystack) {
if (is_array($needle)) {
foreach ($needle as $n) {
if (strpos($haystack, $n) !== false) {
return true;