[dev] components app converted to PSR-4 (mostly) - want feedback

Ralf Lang lang at b1-systems.de
Fri Oct 16 14:05:41 UTC 2020


https://github.com/horde/components/pull/4

Hi,

I updated the components app to PSR-4. Mostly I wanted to see if it
works out as desired and get feedback if anything is creating issues or
other devs don't like it. This had very limited testing and I expect to
find more oversights, but I think I have seen most types of conversion
issues by now. I'd like to merge this once I have fixed Horde_Test and
components' test suite.

see PR for details.



  *

    Converted to PSR-4 code

  *

    Dropped conductor from the code base as pear handling does not
    require it any more

  *

    Added capability to write psr-4 autoloader config into composer.json
    if horde yml asks for it

  *

    tested actions are qc, changed, composer, update

  *

    Unit tests have not yet been touched and most likely are broken.
    This needs a PSR-4 aware Horde_Test to make work.

This has only been tested with the composer based setup. Most likely a
git-tools based setup won't work with it. I am not sure if we find that
important at this point.

I think this should be improved until the qc command can run component's
own unit tests before merging.

Conversion strategy:

  * PSR-4 code lives in src/
  * Only few parameter type hints were added or fixed. This should be
    the focus of a second, separate refactoring pass
  * NULL changed to void
  * Some shim code for PSR-0 class names expected by by git-tools is
    provided in lib/
  * Injector registers both fully qualified name
    Horde\Components\Foo\Bar and shorthand Foo\Bar. The first is for
    autowiring, the second is for convenient use in injector->getInstance
  * I prefer explicitly calling un-namespaced classes as \Horde_Class
    rather than "use"ing them to import them into the namespace.
  * Where the actual class name is ambiguous or misleading, I have used
    the convention to just prepend the last part of the namespace, i.e.
    use Horde\Components\Pear\Environment as PearEnvironment. I did this
    without any thought if reversing the order might be more natural.
    Let's discuss and decide. Example:

use Horde\Components\Component\Factory as ComponentFactory;
use Horde\Components\Config;
use Horde\Components\Config\Bootstrap as ConfigBootstrap;
use Horde\Components\Dependencies;
use Horde\Components\Output;
use Horde\Components\Release\Tasks as ReleaseTasks;
use Horde\Components\Runner\Change as RunnerChange;
use Horde\Components\Runner\CiDistribute as RunnerDistribute;
use Horde\Components\Runner\CiPrebuild as RunnerCiPrebuild;
use Horde\Components\Runner\CiSetup as RunnerCiSetup;
use Horde\Components\Runner\Composer as RunnerComposer;
use Horde\Components\Runner\Dependencies as RunnerDependencies;
use Horde\Components\Runner\FetchDocs as RunnerFetchDocs;
use Horde\Components\Runner\Installer as RunnerInstaller;
use Horde\Components\Runner\Qc as RunnerQc;
use Horde\Components\Runner\Release as RunnerRelease;
use Horde\Components\Runner\Snapshot as RunnerSnapshot;
use Horde\Components\Runner\Update as RunnerUpdate;
use Horde\Components\Runner\WebDocs as RunnerWebDocs;

In most cases, I kept the directory structure and adopted it for
namespace and class names. In few cases, I opted put for obvious
reasons. No Trait should be named ...\Trait and the Components class is
Horde\Components\Components as PSR asks to have at least two levels
Vendor\PackageName\






See https://github.com/maintaina-com/components/tree/maintaina-bare-psr4
for a branch without updated metadata, easy for upstreaming, low chance
of conflict

See https://github.com/maintaina-com/components/tree/psr4-composerfixed
for a branch with updated metadata, composer.json, changelog,
package.xml, high chance of merge conflicts as soon as anybody does
anything upstream. Use the latter version to test against the
horde-deployment/composer based installation.


-- 
Ralf Lang
Linux Consultant / Developer
Tel.: +49-170-6381563
Mail: lang at b1-systems.de
B1 Systems GmbH
Osterfeldstraße 7 / 85088 Vohburg / http://www.b1-systems.de
GF: Ralph Dehner / Unternehmenssitz: Vohburg / AG: Ingolstadt,HRB 3537

-------------- next part --------------
A non-text attachment was scrubbed...
Name: pEpkey.asc
Type: application/pgp-keys
Size: 2688 bytes
Desc: not available
URL: <https://lists.horde.org/archives/dev/attachments/20201016/01336f27/attachment.key>


More information about the dev mailing list