Support for namespaces and PHP 7.X?

43 views
Skip to first unread message

Bruce Wells

unread,
Nov 5, 2019, 10:50:06 PM11/5/19
to htmlpurifier
I would be happy to do a port to PHP 7.X and namespaces.  Since name spaces are in 5.3, we would have to bump to at least 5.3.

But considering 7.1 support will die at the end of the month, we should think about 7.2 support.  I don't really see any need to change the code except to add name spaces and make sure it all runs under 7.2.

Also not sure what the unit testing is for this project. PHPUnit is pretty much the standard, but I don't see that.  Happy to port the unit tests to PHPUnit, but not sure where they are.

Any interest?  Not going to do a pull request if this is not of interest.

Keith Davis

unread,
Nov 5, 2019, 11:38:33 PM11/5/19
to htmlpurifier
+1

Chris J. Zähller

unread,
Nov 6, 2019, 11:29:04 AM11/6/19
to htmlpurifier
+1

On Tuesday, November 5, 2019 at 9:50:06 PM UTC-6, Bruce Wells wrote:

Edward Z. Yang

unread,
Jan 16, 2020, 8:53:04 AM1/16/20
to Bruce Wells, htmlpurifier
Hi Bruce, sorry about the delayed response.

My main concern with a change to use namespaces is backwards
compatibility. If you have a good story for this I'm amenable to
accepting the patch.

I think porting from SimpleTest to PHPUnit would be a lot of work
(we actually have quite a lot of stuff) probably not worth
the payoff.

Edward

Excerpts from Bruce Wells's message of 2019-11-05 19:50:05 -0800:

Bruce Wells

unread,
Jan 16, 2020, 10:13:55 AM1/16/20
to Edward Z. Yang, htmlpurifier
Ed,

Thanks for the reply.  Here is what I found.

To port an existing app, you would just replace the Class_Name_With_Underscores to Class\Name\With\Underscores, so the port for users is not that big a deal.  Another thing one could do would be to write a PHP Script to mod the source code to do the port.  This would render porting a much easier task for most people.

Yes, the change was/is a lot of work to do. I actually was able to automate most of it, but ran into issues with the unit testing.  There is a lot of unit testing, so I think even a bigger issue is porting the testing to PHPUnit. 

The reason to change to namespaces is simply to bring it up to modern standards.  PHPOffice went through the same thing a while back, and is better for it.  I think you have a good package, so wanted to help.  My personal reason is that I use my own autoloader (fast as hell, zero memory footprint, and does not include unused classes like the include everything system requires), but it needs a logical namespace to file mapping, which most modern packages use.  Composer will work with the package is it currently is obviously, but I don't use the Composer autoloader.  Also, keeping the package modern is the only viable thing, as eventually it will become unusable due to PHP changing underneath it. 

So at this point, I found another library to clean HTML (not as nice as yours), but it works for me.

I would be happy to submit my work so far, but I don't feel it is ready for release, primarily since it does not pass unit testing.  I also had to make some minor namespace changes.  Let me know if you want to see it.

Bruce

Edward Z. Yang

unread,
Feb 5, 2020, 8:35:27 PM2/5/20
to Bruce Wells, htmlpurifier
If you are willing to drive the process, I can work with you to get
it merged. Better compatibility with autoloaders is a good reason.

Edward

Excerpts from Bruce Wells's message of 2020-01-16 10:12:32 -0500:

Bruce Wells

unread,
Feb 5, 2020, 9:04:45 PM2/5/20
to Edward Z. Yang, htmlpurifier
Turns out the bigger issue is unit testing.  I have the code fairly well converted over.  There were a few issues where I had to make changes to accommodate modern PHP. But Simple Test threw me for a loop. Maybe we could write some type of conversion script to bring it into PHPUnit?  Or maybe leave it as is, but convert it to modern autoloading. My first exposure to Simple Test.

Let me see where my branch is and I can push what I have.  You can take a look, and we can decide from there.  But yes, would be nice to push the project forward, as I think it has value.

Bruce

Bruce Wells

unread,
Feb 5, 2020, 10:06:05 PM2/5/20
to Edward Z. Yang, htmlpurifier
OK, pushed my latest stuff to https://github.com/phpfui/htmlpurifier

If we can get the tests to work, then I think this is a fairly good first wack.

Bruce

Reply all
Reply to author
Forward
0 new messages