Comments (16)
Hello @netroby, I must profess complete ignorance with regards to this issue. What is PSR 4 autoloader style? How do I change HTML Purifier to it? Are there backwards compatibility concerns?
from htmlpurifier.
@ezyang Hi, this is PSR4. http://www.php-fig.org/psr/psr-4/
from htmlpurifier.
I guess #48 is related? The necessary change seems to be BC-incompatible.
from htmlpurifier.
This may be difficult if @ezyang wants to maintain compatibility with PHP 5.2. PSR-4 relies on namespaces, which weren't introduced until PHP 5.3.
from htmlpurifier.
@ezyang Because PHP 5.3 is no longer actively supported, would you consider making the change to PSR-4?
from htmlpurifier.
sorry for posting on closed issue, but I think it's important.
The oldies supported PHP version (for security fixes only) is 7.4: https://www.php.net/supported-versions.php
How about dropping supporting old PHP versions and only support a new ones (7.4+)? Will you approve such PR?
This way the package can support PSR-4.
This package created for security reasons, but on other hand it's not secure to support unsupported PHP version, as package maintainers, we should force devs to use new PHP versions (however it also has a downside that I'm aware of).
from htmlpurifier.
I guess no anyone want to use php any more, this issue open by me in 2015 year.
then 8 year past.(or 7)
Things changes a lot.
from htmlpurifier.
we can drop PHP versions that are not in support window
from htmlpurifier.
What's the motivation for psr-4? To me it just unnecessarily introduces a huge BC break, is a lot of work to change and has minimal benefit.
As for bumping PHP versions, it's largely unnecessary unless there is good reason. Pretty much everything can be done in PHP 5.3.
from htmlpurifier.
Yes, just to clarify: I'm OK to drop PHP support, but I'm NOT ok with egregious BC break.
from htmlpurifier.
Yes, just to clarify: I'm OK to drop PHP support, but I'm NOT ok with egregious BC break.
Does it mean we can use PSR 4 (means use \Ezyang\HTMLPurifier
namespace instead \HTMLPurifier
)?
I can create a PR that will:
- drop unsupported PHP version support
- use a new PSR 4 namespace
- use latest PHP version functionality (upgrade using https://github.com/rectorphp/rector)
I can optionally implement only 1 and 2 steps if you want to have as less changes as possible
from htmlpurifier.
@lptn what is the motivation for psr-4 over psr-0
from htmlpurifier.
@bytestream
this packages uses class prefixes to avoid conflicts with other classes from other packages or project's classes. This is an approach used before 5.3.0, where namespaces where introduced. More reasons why PSR-4 introduced you can find here: https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-4-autoloader-meta.md
Another point, more subjective, modern PHP devs used to use PSR-4 and nowadays it looks weird to import long classnames with underscores and prefixes (but again, it's subjective [developers likes consistency, right?]).
from htmlpurifier.
Replacing everything to use namespaces would be a major BC break, so if that's something that is going to happen it might as well be linked with a major library change - I don't keep massively up to date with what's happening with this library but I don't believe one of those is in progress (?)
Yes, all modern PHP code should use namespaces but updating old code to use namespaces if you aren't doing any other work to that code is a bit much, especially for all the consumers of this library.
If you want to have that PSR-4 style syntax of HTMLPurifier in your code then just do use HTMLPurifier_ClassName as ClassName
at the top of your file.
EDIT Though there is a BC compatible way, which is to add class_alias(NewClassName, OldClassName)
. Still, what's the value if you're not doing a major round of updates anyway?
from htmlpurifier.
@bytestream this packages uses class prefixes to avoid conflicts with other classes from other packages or project's classes. This is an approach used before 5.3.0, where namespaces where introduced. More reasons why PSR-4 introduced you can find here: https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-4-autoloader-meta.md
Another point, more subjective, modern PHP devs used to use PSR-4 and nowadays it looks weird to import long classnames with underscores and prefixes (but again, it's subjective [developers likes consistency, right?]).
Thanks. I'm aware of what PSR-0 and PSR-4 are. In my opinion, the arguments above don't provide sufficient justification to warrant such a huge BC break. My view is that it's a lot of work for someone to implement, a lot of work for end users / plugin developers and achieves absolutely nothing except compliance with a newer PSR standard.
from htmlpurifier.
A change like this does not have to be a BC break.
Class aliases can be used to ensure previous names are still working. This was done in twig 2.
from htmlpurifier.
Related Issues (20)
- Remove supporting under PHP 5.2 version autoloader HOT 1
- Some csstidy declaration are not handle properly in ExtractStyleBlocks HOT 1
- Element 'button' is not supported (for information on implementing this, see the support forums HOT 1
- Content will be cut with multiple body tags HOT 1
- Typed property DOMAttr::$name must not be accessed before initialization HOT 1
- Wrong output when Core.CollectError is disabled HOT 1
- Is it possible to put a div inside an anchor tag? HOT 2
- javascript in a href if set with : HOT 2
- Cache.DefinitionImpl / Cache.SerializerPath ignored HOT 1
- Absolute worst security advice HOT 1
- Adding additional protocol handlers to URI.AllowedSchemes HOT 6
- New release HOT 1
- `HTMLPurifier_ConfigSchema::makeFromSerial()` fails because `service.ser` is missing
- Deprecated __autoload() method is used in HtmlPurifier.autoload.php
- URI schemas with dashes HOT 2
- Support for conditional HTML commenting e.g. `<!--[if mso]>` HOT 6
- Getting Error: Request exceeds maximum allowed text size of 50 KB HOT 2
- How to remove JavaScript & hyperlinks from HTML?
- Deprecations for preg_match, preg_replace_callback and null argument
- Unchecked input in HTMLPurifier_UnitConverter round() function HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from htmlpurifier.