Skip to content

Commit

Permalink
Update for recent php7.2 aware magento versions
Browse files Browse the repository at this point in the history
  • Loading branch information
ajbonner committed Jan 9, 2019
1 parent 00376bf commit 93e3134
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 17 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
Magento Composer Autoload
=========================

Hack to make the magento autoloader composer vendor dir aware.

It's very likely you want to manage 3rd party libraries, or perhaps even Magento Extensions using composer. This can be difficult because composer uses its own class loading mechanism, typically creating a <application_root>/vendor/autoload.php file to initialise its environment.
Expand All @@ -12,3 +11,7 @@ If you have already overridden this file, or have installed another extension th
For example, this extension is not compatible with [Aoe_ClassPathCache](https://github.com/fbrnc/Aoe_ClassPathCache).

Any comments or questions can be directed to me on twitter [@ajbonner](http://twitter.com/ajbonner), or via email [[email protected]](mailto:[email protected]).

#### Requirements
- PHP 7.2+
- Magento CE 1.9.3.9+ (with PHP 7.2 Patch applied)
6 changes: 3 additions & 3 deletions app/code/community/Varien/Autoload.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
* versions in the future. If you wish to customize Magento for your
* needs please refer to http://www.magento.com for more information.
*
* @category Varien
* @package Varien_Autoload
* @category Varien
* @package Varien_Autoload
* @copyright Copyright (c) 2006-2018 Magento, Inc. (http://www.magento.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
Expand Down Expand Up @@ -134,7 +134,7 @@ public function autoload($class)
}
$classFile.= '.php';
//echo $classFile;die();
return include $classFile;
return @include $classFile;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
}
],
"require": {
"php": ">=5.3.0"
"php": ">=7.2.0"
}
}
1 change: 0 additions & 1 deletion phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
<phpunit backupGlobals="false"
backupStaticAttributes="false"
colors="true"
strict="true"
processIsolation="true"
verbose="true">
<testsuites>
Expand Down
20 changes: 10 additions & 10 deletions test/BootstrapTest.php
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
<?php

class BootstrapTest extends PHPUnit_Framework_TestCase
declare(strict_types=1);

use PHPUnit\Framework\TestCase;

class BootstrapTest extends TestCase
{
public function setUp()
{
require_once $this->varienAutoloaderClassPath();
}

public function testRequiresComposerAutoloaderWhenBasePathConstantsDefined()
public function testRequiresComposerAutoloaderWhenBasePathConstantsDefined(): void
{
define('BP', realpath(dirname(__FILE__) . '/../'));
define('BP', realpath(__DIR__ . '/../'));
$autoloader = new Varien_Autoload();
$this->assertTrue(COMPOSER_AUTOLOADER_LOADED);
}

public function testRequiresComposerAutoloaderWhenBasePathConstantsUndefined()
public function testRequiresComposerAutoloaderWhenBasePathConstantsUndefined(): void
{
$autoloader = new Varien_Autoload();
$this->assertTrue(COMPOSER_AUTOLOADER_LOADED);
}

/**
* @return string
*/
protected function varienAutoloaderClassPath()
protected function varienAutoloaderClassPath(): string
{
$ds = DIRECTORY_SEPARATOR;
return 'app' . $ds . 'code' . $ds . 'community' . $ds . 'Varien' . $ds . 'Autoload.php';
return implode(DIRECTORY_SEPARATOR, ['app', 'code', 'community', 'Varien', 'Autoload.php']);
}
}
6 changes: 5 additions & 1 deletion vendor/autoload.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
<?php

define('COMPOSER_AUTOLOADER_LOADED', true);
// autoload.php @generated by Composer

require_once __DIR__ . '/composer/autoload_real.php';

return ComposerAutoloaderInit912c46f9179f8bfb7e8293a18152dedf::getLoader();

0 comments on commit 93e3134

Please sign in to comment.