Giter Club home page Giter Club logo

Comments (16)

ezyang avatar ezyang commented on August 15, 2024

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.

itbdw avatar itbdw commented on August 15, 2024

@ezyang Hi, this is PSR4. http://www.php-fig.org/psr/psr-4/

from htmlpurifier.

ezyang avatar ezyang commented on August 15, 2024

I guess #48 is related? The necessary change seems to be BC-incompatible.

from htmlpurifier.

alexweissman avatar alexweissman commented on August 15, 2024

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.

thisispiers avatar thisispiers commented on August 15, 2024

@ezyang Because PHP 5.3 is no longer actively supported, would you consider making the change to PSR-4?

from htmlpurifier.

lptn avatar lptn commented on August 15, 2024

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

image

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.

cnmade avatar cnmade commented on August 15, 2024

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.

ezyang avatar ezyang commented on August 15, 2024

we can drop PHP versions that are not in support window

from htmlpurifier.

bytestream avatar bytestream commented on August 15, 2024

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.

ezyang avatar ezyang commented on August 15, 2024

Yes, just to clarify: I'm OK to drop PHP support, but I'm NOT ok with egregious BC break.

from htmlpurifier.

lptn avatar lptn commented on August 15, 2024

@ezyang

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:

  1. drop unsupported PHP version support
  2. use a new PSR 4 namespace
  3. 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.

bytestream avatar bytestream commented on August 15, 2024

@lptn what is the motivation for psr-4 over psr-0

from htmlpurifier.

lptn avatar lptn commented on August 15, 2024

@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.

PatrickRose avatar PatrickRose commented on August 15, 2024

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 avatar bytestream commented on August 15, 2024

@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.

jhony1104 avatar jhony1104 commented on August 15, 2024

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.

See: https://github.com/twigphp/Twig/blob/872646a70ff83b3628d50c9bafa117af9f1da59e/src/Environment.php#L994

from htmlpurifier.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.