From 3e2c559fd29d4963a8b89e6f4e54754ec55272f5 Mon Sep 17 00:00:00 2001 From: satakecode Date: Tue, 7 Mar 2017 20:08:35 +0000 Subject: [PATCH] PHP warning fix for the autoLoad() function This small alteration should fix this situation: https://forum.phalconphp.com/discussion/10339/strange-warning-probably-from-zephirfaststrreplace-or-something- If you have two classes: My\Class\Foo\Bar and My\Class\Foo When initializing Foo() the autoLoad will come to this line "let fileName = substr(className, strlen(nsPrefix . ns));" at the moment where className = "My\Class\Foo" and nsPrefix = "My\Class\Foo\Bar" At this point (could be a zephir bug) fileName is something that will make "let fileName = str_replace(ns, ds, fileName);" throw the following warning (Invalid arguments supplied for str_replace()). Either substr is returning something other than an empy string or str_replace is not allowing an empy string either way testing if fileName has any value before "let fileName = str_replace(ns, ds, fileName);" should mitigate this warning. --- phalcon/loader.zep | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/phalcon/loader.zep b/phalcon/loader.zep index c207ca78e2d..b5bf425dd24 100644 --- a/phalcon/loader.zep +++ b/phalcon/loader.zep @@ -337,11 +337,12 @@ class Loader implements EventsAwareInterface * Append the namespace separator to the prefix */ let fileName = substr(className, strlen(nsPrefix . ns)); - let fileName = str_replace(ns, ds, fileName); if !fileName { continue; } + + let fileName = str_replace(ns, ds, fileName); for directory in directories { /**