Skip to content

Commit

Permalink
fix: update composer autoload
Browse files Browse the repository at this point in the history
  • Loading branch information
evilebottnawi committed Jan 6, 2018
1 parent a7edf92 commit bff49cd
Show file tree
Hide file tree
Showing 10 changed files with 375 additions and 20 deletions.
2 changes: 1 addition & 1 deletion vendor/autoload.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@

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

return ComposerAutoloaderInit437ad47e064758a069eff5a4b7eef79f::getLoader();
return ComposerAutoloaderInitb076677c42f1a3b9647c849d14b74511::getLoader();
1 change: 0 additions & 1 deletion vendor/bin/sentry

This file was deleted.

92 changes: 92 additions & 0 deletions vendor/bin/sentry
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
#!/usr/bin/env php
<?php

// Maximize error reporting
error_reporting(E_ALL | E_STRICT);

// TODO: if we could get rid of this and have composer figure things out it'd make it
// a bit more sane
require(dirname(__file__) . '/../lib/Raven/Autoloader.php');
Raven_Autoloader::register();

function raven_cli_test($command, $args)
{
// Do something silly
try {
throw new Exception('This is a test exception sent from the Raven CLI.');
} catch (Exception $ex) {
return $ex;
}
}

function cmd_test($dsn)
{
// Parse DSN as a test
try {
if (empty(Raven_Client::parseDSN($dsn))) {
exit('ERROR: Missing DSN value');
}
} catch (InvalidArgumentException $ex) {
exit("ERROR: There was an error parsing your DSN:\n " . $ex->getMessage());
}

$client = new Raven_Client($dsn, array(
'trace' => true,
'curl_method' => 'sync',
'app_path' => realpath(__DIR__ . '/..'),
'base_path' => realpath(__DIR__ . '/..'),
));

$config = get_object_vars($client);
$required_keys = array('server', 'project', 'public_key', 'secret_key');

echo "Client configuration:\n";
foreach ($required_keys as $key) {
if (empty($config[$key])) {
exit("ERROR: Missing configuration for $key");
}
if (is_array($config[$key])) {
echo "-> $key: [".implode(", ", $config[$key])."]\n";
} else {
echo "-> $key: $config[$key]\n";
}

}
echo "\n";

echo "Sending a test event:\n";

$ex = raven_cli_test("command name", array("foo" => "bar"));
$event_id = $client->captureException($ex);

echo "-> event ID: $event_id\n";

$last_error = $client->getLastError();
if (!empty($last_error)) {
exit("ERROR: There was an error sending the test event:\n " . $last_error);
}

echo "\n";
echo "Done!";
}


function main() {
global $argv;

if (!isset($argv[1])) {
exit('Usage: sentry test <dsn>');
}

$cmd = $argv[1];

switch ($cmd) {
case 'test':
cmd_test(@$argv[2]);
break;
default:
exit('Usage: sentry test <dsn>');
}
}

main();
15 changes: 8 additions & 7 deletions vendor/composer/ClassLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@
class ClassLoader
{
// PSR-4
private $firstCharsPsr4 = array();
private $prefixLengthsPsr4 = array(); // For BC with legacy static maps
private $prefixLengthsPsr4 = array();
private $prefixDirsPsr4 = array();
private $fallbackDirsPsr4 = array();

Expand Down Expand Up @@ -171,10 +170,11 @@ public function addPsr4($prefix, $paths, $prepend = false)
}
} elseif (!isset($this->prefixDirsPsr4[$prefix])) {
// Register directories for a new namespace.
if ('\\' !== substr($prefix, -1)) {
$length = strlen($prefix);
if ('\\' !== $prefix[$length - 1]) {
throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
}
$this->firstCharsPsr4[$prefix[0]] = true;
$this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
$this->prefixDirsPsr4[$prefix] = (array) $paths;
} elseif ($prepend) {
// Prepend directories for an already registered namespace.
Expand Down Expand Up @@ -221,10 +221,11 @@ public function setPsr4($prefix, $paths)
if (!$prefix) {
$this->fallbackDirsPsr4 = (array) $paths;
} else {
if ('\\' !== substr($prefix, -1)) {
$length = strlen($prefix);
if ('\\' !== $prefix[$length - 1]) {
throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
}
$this->firstCharsPsr4[$prefix[0]] = true;
$this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
$this->prefixDirsPsr4[$prefix] = (array) $paths;
}
}
Expand Down Expand Up @@ -372,7 +373,7 @@ private function findFileWithExtension($class, $ext)
$logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext;

$first = $class[0];
if (isset($this->firstCharsPsr4[$first]) || isset($this->prefixLengthsPsr4[$first])) {
if (isset($this->prefixLengthsPsr4[$first])) {
$subPath = $class;
while (false !== $lastPos = strrpos($subPath, '\\')) {
$subPath = substr($subPath, 0, $lastPos);
Expand Down
8 changes: 4 additions & 4 deletions vendor/composer/autoload_real.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

// autoload_real.php @generated by Composer

class ComposerAutoloaderInit437ad47e064758a069eff5a4b7eef79f
class ComposerAutoloaderInitb076677c42f1a3b9647c849d14b74511
{
private static $loader;

Expand All @@ -19,15 +19,15 @@ public static function getLoader()
return self::$loader;
}

spl_autoload_register(array('ComposerAutoloaderInit437ad47e064758a069eff5a4b7eef79f', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInitb076677c42f1a3b9647c849d14b74511', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
spl_autoload_unregister(array('ComposerAutoloaderInit437ad47e064758a069eff5a4b7eef79f', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInitb076677c42f1a3b9647c849d14b74511', 'loadClassLoader'));

$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
if ($useStaticLoader) {
require_once __DIR__ . '/autoload_static.php';

call_user_func(\Composer\Autoload\ComposerStaticInit437ad47e064758a069eff5a4b7eef79f::getInitializer($loader));
call_user_func(\Composer\Autoload\ComposerStaticInitb076677c42f1a3b9647c849d14b74511::getInitializer($loader));
} else {
$map = require __DIR__ . '/autoload_namespaces.php';
foreach ($map as $namespace => $path) {
Expand Down
20 changes: 13 additions & 7 deletions vendor/composer/autoload_static.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,17 @@

namespace Composer\Autoload;

class ComposerStaticInit437ad47e064758a069eff5a4b7eef79f
class ComposerStaticInitb076677c42f1a3b9647c849d14b74511
{
public static $firstCharsPsr4 = array (
'I' => true,
'C' => true,
public static $prefixLengthsPsr4 = array (
'I' =>
array (
'Itgalaxy\\SentryIntegration\\' => 27,
),
'C' =>
array (
'Composer\\Installers\\' => 20,
),
);

public static $prefixDirsPsr4 = array (
Expand All @@ -35,9 +41,9 @@ class ComposerStaticInit437ad47e064758a069eff5a4b7eef79f
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->firstCharsPsr4 = ComposerStaticInit437ad47e064758a069eff5a4b7eef79f::$firstCharsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit437ad47e064758a069eff5a4b7eef79f::$prefixDirsPsr4;
$loader->prefixesPsr0 = ComposerStaticInit437ad47e064758a069eff5a4b7eef79f::$prefixesPsr0;
$loader->prefixLengthsPsr4 = ComposerStaticInitb076677c42f1a3b9647c849d14b74511::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInitb076677c42f1a3b9647c849d14b74511::$prefixDirsPsr4;
$loader->prefixesPsr0 = ComposerStaticInitb076677c42f1a3b9647c849d14b74511::$prefixesPsr0;

}, null, ClassLoader::class);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php
namespace Composer\Installers;

/**
* Plugin/theme installer for majima
* @author David Neustadt
*/
class MajimaInstaller extends BaseInstaller
{
protected $locations = array(
'plugin' => 'plugins/{$name}/',
);

/**
* Transforms the names
* @param array $vars
* @return array
*/
public function inflectPackageVars($vars)
{
return $this->correctPluginName($vars);
}

/**
* Change hyphenated names to camelcase
* @param array $vars
* @return array
*/
private function correctPluginName($vars)
{
$camelCasedName = preg_replace_callback('/(-[a-z])/', function ($matches) {
return strtoupper($matches[0][1]);
}, $vars['name']);
$vars['name'] = ucfirst($camelCasedName);
return $vars;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php
namespace Composer\Installers;

/**
* An installer to handle MODX specifics when installing packages.
*/
class ModxInstaller extends BaseInstaller
{
protected $locations = array(
'extra' => 'core/packages/{$name}/'
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?php
namespace Composer\Installers;

class PxcmsInstaller extends BaseInstaller
{
protected $locations = array(
'module' => 'app/Modules/{$name}/',
'theme' => 'themes/{$name}/',
);

/**
* Format package name.
*
* @param array $vars
*
* @return array
*/
public function inflectPackageVars($vars)
{
if ($vars['type'] === 'pxcms-module') {
return $this->inflectModuleVars($vars);
}

if ($vars['type'] === 'pxcms-theme') {
return $this->inflectThemeVars($vars);
}

return $vars;
}

/**
* For package type pxcms-module, cut off a trailing '-plugin' if present.
*
* return string
*/
protected function inflectModuleVars($vars)
{
$vars['name'] = str_replace('pxcms-', '', $vars['name']); // strip out pxcms- just incase (legacy)
$vars['name'] = str_replace('module-', '', $vars['name']); // strip out module-
$vars['name'] = preg_replace('/-module$/', '', $vars['name']); // strip out -module
$vars['name'] = str_replace('-', '_', $vars['name']); // make -'s be _'s
$vars['name'] = ucwords($vars['name']); // make module name camelcased

return $vars;
}


/**
* For package type pxcms-module, cut off a trailing '-plugin' if present.
*
* return string
*/
protected function inflectThemeVars($vars)
{
$vars['name'] = str_replace('pxcms-', '', $vars['name']); // strip out pxcms- just incase (legacy)
$vars['name'] = str_replace('theme-', '', $vars['name']); // strip out theme-
$vars['name'] = preg_replace('/-theme$/', '', $vars['name']); // strip out -theme
$vars['name'] = str_replace('-', '_', $vars['name']); // make -'s be _'s
$vars['name'] = ucwords($vars['name']); // make module name camelcased

return $vars;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

namespace Composer\Installers;

class SiteDirectInstaller extends BaseInstaller
{
protected $locations = array(
'module' => 'modules/{$vendor}/{$name}/',
'plugin' => 'plugins/{$vendor}/{$name}/'
);

public function inflectPackageVars($vars)
{
return $this->parseVars($vars);
}

protected function parseVars($vars)
{
$vars['vendor'] = strtolower($vars['vendor']) == 'sitedirect' ? 'SiteDirect' : $vars['vendor'];
$vars['name'] = str_replace(array('-', '_'), ' ', $vars['name']);
$vars['name'] = str_replace(' ', '', ucwords($vars['name']));

return $vars;
}
}
Loading

0 comments on commit bff49cd

Please sign in to comment.