zendframework / zend-inputfilter

InputFilter component from Zend Framework
BSD 3-Clause "New" or "Revised" License
64 stars 50 forks source link

Add file input compatibility with PSR-7 #172

Closed alextech closed 5 years ago

alextech commented 5 years ago

Fixes #145 - PSR-7 compatibility for validating and filtering forms with inputs.

This patch allows validating forms submitted via a PSR-7 payload, and, specifically file uploads.

Prerequisite PRs:

I could not separate PSR vs HTTP $_FilES into completely separate subclasses because current implementation is stateful, so cannot simply pass calls from current FileInput to appropriate implementation - private protected properties that hold values and options get lost. FileInput is hardcoded in other repositories, eg Zend\Form as a input specification so has to remain main entry point for forms to be used in both MVC and Expressive. Consequently, did decorator-ish style approach.

alextech commented 5 years ago

Looks like Travis does not like to pull from other repositories not having its own tokens. Can rerun the job after the 2 dependencies get accepted.

samsonasik commented 5 years ago

@alextech you can insert "no-api": true config inside each "repositories" config record in composer.json as follow:

    "repositories": [
        {
            "type": "vcs",
            "url": "https://github.com/alextech/zend-validator",
            "no-api": true
        },
        {
            "type": "vcs",
            "url": "https://github.com/alextech/zend-filter",
            "no-api": true
        }
    ],
weierophinney commented 5 years ago

@alextech I've rebased off of current develop, and done the following:

I think it should be ready to :ship: now.

alextech commented 5 years ago

I thought protected classifies as BC break too, because class open to extension will break if being extended and signature changes between upgrades.

вт, 18 дек. 2018 г., 2:39 Michał Bundyra notifications@github.com:

@webimpress commented on this pull request.

In src/FileInput.php https://github.com/zendframework/zend-inputfilter/pull/172#discussion_r242431647 :

  */
  • protected function injectUploadValidator()

This method is protected ;-) Only changes to public interface are considered as BC Break.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/zendframework/zend-inputfilter/pull/172#discussion_r242431647, or mute the thread https://github.com/notifications/unsubscribe-auth/ADpNHETXLNphWTnQ8Zx0tKt1WoXocb_Rks5u6JvEgaJpZM4WAsfF .

michalbundyra commented 5 years ago

@alextech As far as I know (if I am wrong please someone correct me) - in ZF rules for public interface are "public" methods and "protected" only when these are described as can be used in extension (for example in the documentation). I don't remember where I read about it, I can't find it now :(

weierophinney commented 5 years ago

@svycka @alextech and @webimpress —

Our policy since the ZF1 days has been to treat only public as part of the public API for BC purposes. We tend to scrutinize removals of protected methods a little closer, but, as @webimpress notes, unless it was documented as part of an internal API that users can rely on (e.g., how symfony/console documents configure and execute), we don't treat changes as BC issues.

In this particular case, there's little reason for extension, and the new changes make creating new strategies for file uploads easier.

svycka commented 5 years ago

@weierophinney I am ok with this change just maybe this should be noted in changelog. And good to know that protected can be removed or changed any time, will be more careful using them with ZF components

Slamdunk commented 5 years ago

Like https://github.com/zendframework/zend-filter/pull/70 this PR introduced a BC Break. Hope to isolate the issue and post a PR soon.