Skip to content
This repository has been archived by the owner on Jan 29, 2020. It is now read-only.

Deprecate FinalHandler and ErrorMiddlewareInterface #66

Commits on Sep 26, 2016

  1. Documented changes to error handling via a migration document

    In doing so, discovered that if we make `$out` required in v2, there's no need
    to introduce the `setFinalHandler()` argument, as it can be passed directly, or
    handled via `Zend\Diactoros\Server::listen()`.
    weierophinney committed Sep 26, 2016
    Configuration menu
    Copy the full SHA
    90d6281 View commit details
    Browse the repository at this point in the history
  2. Created NotFoundHandler and ErrorHandler middleware

    First step in the journey to remove the FinalHandler.
    
    - Bump minimum supported PHP version to 5.6 (allows calling callables without
      `call_user_func()`, and using `::class` notation).
    - `NotFoundHandler` returns a basic 404 response, always.
    - `ErrorHandler`:
      - creates a PHP error handler that will throw any errors not in the
        current error_handler mask as ErrorExceptions.
      - Does a try/catch around `$next()`
      - Raises a new exception, `MissingResponseException`, if `$next` did
        not return a response.
      - Casts all Throwable/Exception items to error responses:
        - If a boolean true flag is passed to the constructor, it will use
          the stack trace in the response.
        - Triggers listeners on the instance with the exception/throwable,
          request, and response, for reporting purposes.
    
    In order to return a response, each middleware type accepts a prototype
    `ResponseInterface` instance to the constructor; this is then used to generate
    the returned response in 404/error conditions.
    weierophinney committed Sep 26, 2016
    Configuration menu
    Copy the full SHA
    9fdb3fa View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    0c3ded4 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    024cbc5 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    3363133 View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    5b86130 View commit details
    Browse the repository at this point in the history
  7. Raise deprecation notice by MiddlewarePipe if $out is omitted

    We need to notify users that `$out` cannot be omitted starting with
    version 2.0.0.
    weierophinney committed Sep 26, 2016
    Configuration menu
    Copy the full SHA
    2aa080d View commit details
    Browse the repository at this point in the history
  8. Updated phpcs rules

    - Space around operators
    - Space after !
    weierophinney committed Sep 26, 2016
    Configuration menu
    Copy the full SHA
    4d8804f View commit details
    Browse the repository at this point in the history
  9. Configuration menu
    Copy the full SHA
    371e546 View commit details
    Browse the repository at this point in the history

Commits on Sep 27, 2016

  1. Provide extension points in the ErrorHandler implementation

    - Created a protected method, `createErrorResponse()`, for creating and
      returning the error response to use.
    - Made `$isDevelopmentMode` protected, to allow extending classes to
      query its value.
    weierophinney committed Sep 27, 2016
    Configuration menu
    Copy the full SHA
    8653c45 View commit details
    Browse the repository at this point in the history
  2. Compose an error generator, instead of require extension

    Per @vaclavvanik, this patch:
    
    - Moves the error generation aspects to a new class,
      `ErrorResponseGenerator`.
    - Updates the `ErrorHandler`:
      - to allow passing an optional, callable response generator via the
        constructor, instead of the `$isDevelopmentMode` flag.
      - to specify `ErrorResponseGenerator` in production mode if no
        generator is provided during instantiation.
      - to trigger the response generator from `handleThrowable()` in order
        to get an error response, passing the exception, request, and
        response prototype.
      - Marks the class final.
    
    This allows flexibility in generating error responses without requiring
    extension, by composing the generator in the handler itself.
    weierophinney committed Sep 27, 2016
    Configuration menu
    Copy the full SHA
    ac371ae View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    8499b23 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    8f00604 View commit details
    Browse the repository at this point in the history
  5. Fix typo in docs.

    Spotted by @vaclavvanik
    weierophinney committed Sep 27, 2016
    Configuration menu
    Copy the full SHA
    d413d5d View commit details
    Browse the repository at this point in the history