Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zend-loader and autoloader overhaul - cont. #116

Merged
merged 3 commits into from
Oct 4, 2022

Commits on Oct 18, 2021

  1. zend-loader and autoloader overhaul - cont.

    - introduce `Zend_Loader::tryLoadClass()` to attempt loading a class but do not throw an exception when file is not found (but still throw when required class in the existing file is not defined)
    - did not go for suppressing loading classes with `@` suppressor by default, since regular warnings/errors coming from a loaded file should be visible, otherwise it might be very confusing for devs
    - introduce `Zend_Loader_Exception_FileNotFoundException` and `Zend_Loader_Exception_ClassNotFoundException`
      - instead of throwing `Zend_Exception` in `Zend_Loader::loadClass()` with a generic message `File \"$file\" does not exist or class \"$class\" was not found in the file`
      - `Zend_Loader_Exception_FileNotFoundException` will be thrown with message `File "$file" could not be found within configured include_path.` or
      - `Zend_Loader_Exception_ClassNotFoundException` with message `Class "$class" was not found in the file "$file".`, in their respective cases.
    - since composer autoloader takes precedence and `Zend_Autoloader` / `Zend_Loader` is only an extra helper, when necessary (when still needed and configured on legacy projects) - `Zend_Loader` should not emit warnings when checking for files, by default. Added `isReadable` check inside `loadFile` before `include`/`include_once`. There might be a performance hit, but it should be okay when most of the autoloading is handled by composer autoloader anyway.
    - Zend_Loader::loadClass returns boolean now
    - adjust combinations of `class_exists` + `Zend_Loader::loadClass` in remaining affected places (i.a. Translate or File_Transfer or Filter adapters)
    - unregister autoloader from spl_autoload when `Zend_Loader_Autoloader::resetInstance()` is called
    - added more tests for Zend_Loader and Zend_Autoloader
    - added tests for loading custom Zend_Translate adapter while having Zend_Autoloader enabled
    - adjusted existing tests which expected "file not found" php warning to be triggered by `Zend_Loader`
    
    ref: 76477fb
    falkenhawk committed Oct 18, 2021
    Configuration menu
    Copy the full SHA
    0bdfb60 View commit details
    Browse the repository at this point in the history
  2. zend-gdata: fix reading error message

    fixes the test failure on php 7.4 & 8.0:
    - Failed asserting that PHPUnit_Framework_Error_Notice Object (...) is an instance of class "Zend_Gdata_App_Exception".
    falkenhawk committed Oct 18, 2021
    Configuration menu
    Copy the full SHA
    198064f View commit details
    Browse the repository at this point in the history

Commits on Oct 19, 2021

  1. zend-loader: use stream_resolve_include_path

    in isReadable() - it should be more performant and the function is available since php 5.3.2
    falkenhawk committed Oct 19, 2021
    Configuration menu
    Copy the full SHA
    b54c84a View commit details
    Browse the repository at this point in the history