Namespaces

Think you found a bug in getID3()? Post here with details.
Post Reply
holyfield
User
Posts: 2
Joined: Thu Sep 13, 2012 1:18 pm
Are you a spambot?: no

Namespaces

Post by holyfield » Tue Sep 17, 2013 10:38 pm

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.

James Heinrich
getID3() v1 developer
Posts: 1427
Joined: Fri May 04, 2001 4:00 pm
Are you a spambot?: no
Location: Northern Ontario, Canada
Contact:

Re: Namespaces

Post by James Heinrich » Tue Sep 17, 2013 10:51 pm

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?

fred727
User
Posts: 11
Joined: Wed Jun 08, 2016 6:20 pm
Are you a spambot?: no

Re: Namespaces

Post by fred727 » Thu Jun 09, 2016 7:25 am

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)

fred727
User
Posts: 11
Joined: Wed Jun 08, 2016 6:20 pm
Are you a spambot?: no

Re: Namespaces

Post by fred727 » Thu Jun 09, 2016 7:40 am

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;

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest