Skip to content

Instantly share code, notes, and snippets.

View nikita2206's full-sized avatar

Nikita Nefedov nikita2206

  • Amsterdam, Netherlands
View GitHub Profile
diff --git a/hal/hal_com_phycfg.c b/hal/hal_com_phycfg.c
index 8bb2747..16a85bf 100644
--- a/hal/hal_com_phycfg.c
+++ b/hal/hal_com_phycfg.c
@@ -2575,7 +2575,7 @@ Hal_ChannelPlanToRegulation(
#ifdef CONFIG_LOAD_PHY_PARA_FROM_FILE
extern char *rtw_phy_file_path;
-char file_path[PATH_LENGTH_MAX];
+char rtw_file_path[PATH_LENGTH_MAX];

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.

diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c
index 19185df..a4440d9 100644
--- a/Zend/zend_compile.c
+++ b/Zend/zend_compile.c
@@ -4120,6 +4120,7 @@ static int zend_traits_copy_functions(zend_function *fn TSRMLS_DC, int num_args,
&& alias->trait_method->mname_len == fnname_len
&& (zend_binary_strcasecmp(alias->trait_method->method_name, alias->trait_method->mname_len, hash_key->arKey, fnname_len) == 0)) {
fn_copy = *fn;
+ fn_copy.common.function_name = alias->alias;
class ProductController {
protected $productFactory;
public function __construct(ProductFactory $productFactory)
{
$this->productFactory = $productFactory;
}
public function create($product_type)
@nikita2206
nikita2206 / gist:7354392
Created November 7, 2013 13:14
php-src patch for allowing array_unique to take callback as an argument for comparing elements...
diff --git a/ext/standard/array.c b/ext/standard/array.c
index 411e8de..1dcdf76 100644
--- a/ext/standard/array.c
+++ b/ext/standard/array.c
@@ -120,6 +120,7 @@ PHP_MINIT_FUNCTION(array) /* {{{ */
REGISTER_LONG_CONSTANT("SORT_LOCALE_STRING", PHP_SORT_LOCALE_STRING, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SORT_NATURAL", PHP_SORT_NATURAL, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SORT_FLAG_CASE", PHP_SORT_FLAG_CASE, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SORT_USERDEFINED", PHP_SORT_USERDEFINED, CONST_CS | CONST_PERSISTENT);
@nikita2206
nikita2206 / gist:5661776
Last active December 17, 2015 19:39
Script for resampling a whole directory of music files recursively. Depends on ffmpeg (better build it with soxr)
<?php
/* config section { */
$input = "F:\\Music";
$output = "F:\\ResampledMusic";
// it will convert all the files to flacs
$ffmpegExecutable = "C:\\users\\nikita\\bin\\ffmpeg";
$ffmpegOptions = "-af aresample=resampler=soxr -ar 44100";
<?php
class Foo
{
public bar()
{
echo "bar\n";
}
diff --git a/Zend/zend_language_parser.y b/Zend/zend_language_parser.y
index ccbc9b1..75b2431 100644
--- a/Zend/zend_language_parser.y
+++ b/Zend/zend_language_parser.y
@@ -588,7 +588,7 @@ class_statement:
variable_modifiers { CG(access_type) = Z_LVAL($1.u.constant); } class_variable_declaration ';'
| class_constant_declaration ';'
| trait_use_statement
- | method_modifiers function is_reference T_STRING { zend_do_begin_function_declaration(&$2, &$4, 1, $3.op_type, &$1 TSRMLS_CC); }
+ | method_modifiers method_definition is_reference T_STRING { zend_do_begin_function_declaration(&$2, &$4, 1, $3.op_type, &$1 TSRMLS_CC); }
phpinfo()
PHP Version => 5.4.9
System => Linux nikita2206-N56VJ 3.2.0-37-generic #58-Ubuntu SMP Thu Jan 24 15:28:10 UTC 2013 x86_64
Build Date => Feb 12 2013 17:13:16
Configure Command => './configure' '--enable-cli' '--enable-fpm' '--enable-intl' '--enable-pdo' '--with-pdo-pgsql' '--enable-sockets' '--with-curl' '--with-pgsql' '--with-openssl'
Server API => Command Line Interface
Virtual Directory Support => disabled
Configuration File (php.ini) Path => /usr/local/lib
Loaded Configuration File => /usr/local/lib/php.ini
@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;