Page 1 of 1

Namespaces

Posted: Tue Sep 17, 2013 10:38 pm
by holyfield
I have implemented based on version 1.9.7 the php namespaces for getID3()

It's not final yet. You are welcome to browse the code at BitBucket:
Also I have removed some globals into class constants to keep environment cleaner.

I will modify the code to get rid of dependency loader, that all classes are loaded automatically if needed.

Re: Namespaces

Posted: Tue Sep 17, 2013 10:51 pm
by James Heinrich
Thanks for your effort. I'll take a look and try porting your changes to Github.

I happend to glance at random at one of your changes and I'm not sure what it adds: you're explicitly checking for boolean, but only with loose equality (== or !=) rather than strict (=== or !==) so I'm not sure what it adds -- I can't think of an example where (expression) or ((expression)==true) or ((expression)!=false) wouldn't be identical. Can you give an example of what issue you're trying to address with this change?

Re: Namespaces

Posted: Thu Jun 09, 2016 7:25 am
by fred727
I think adding namespace is quite easy, because there is no use of php internal classes other than Exception.

These lines return no match :

Code: Select all

grep -F 'new ' getid3/*.php | grep -vi getID3 | grep -v Exception
grep -F '::' /getid3/*.php | grep -vi getID3 | grep -v Exception
So you just have to add these lines on the top of each files :

Code: Select all

namespace getID3;
use \Exception;
PS: for 'beauty' you could also replace every 'getID3_' occurences by nothing (case insensitive)

Re: Namespaces

Posted: Thu Jun 09, 2016 7:40 am
by fred727
fred727 wrote:These lines return no match :

Code: Select all

grep -F 'new ' getid3/*.php | grep -vi getID3 | grep -v Exception
grep -F '::' /getid3/*.php | grep -vi getID3 | grep -v Exception
Good code is :

Code: Select all

grep -Fh 'new ' getid3/*.php | grep -viF 'new getID3' | grep -vF 'new Exception'
grep -Fh '::'  getid3/*.php | grep -viF 'getid3' | grep -vF Exception |  grep -vF 'self::' | grep -vF 'parent::'
So there is 2 other php internal classes :
- SQLite3
- COM
namespace getID3;
use \Exception;
use \SQLite3;
use \COM;