Skip to content

Commit ce092b5

Browse files
authored
Merge pull request #36 from madewithlove/feature/banner
General maintenance
2 parents 7434247 + aa96e41 commit ce092b5

38 files changed

+1348
-1024
lines changed

.bowerrc

-3
This file was deleted.

.editorconfig

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
root = true
2+
3+
[**]
4+
indent_style = space
5+
indent_size = 4
6+
end_of_line = lf
7+
insert_final_newline = true
8+
charset = utf-8
9+
trim_trailing_whitespace = true
10+
11+
[composer.json]
12+
indent_style = tab
13+
14+
[*.yml]
15+
indent_style = space
16+
17+
[package.json]
18+
indent_style = space
19+
indent_size = 2

.php_cs

+37-21
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,41 @@
11
<?php
2-
use Symfony\CS\Config\Config;
3-
use Symfony\CS\Finder\DefaultFinder;
4-
use Symfony\CS\FixerInterface;
2+
use PhpCsFixer\Config;
3+
use PhpCsFixer\Finder;
54

6-
$finder = DefaultFinder::create()->in(['app', 'tests/unit/Semver']);
5+
require 'vendor/autoload.php';
6+
7+
$finder = Finder::create()->in([
8+
'app',
9+
'tests',
10+
]);
711

812
return Config::create()
9-
->level(FixerInterface::SYMFONY_LEVEL)
10-
->fixers([
11-
'ereg_to_preg',
12-
'multiline_spaces_before_semicolon',
13-
'newline_after_open_tag',
14-
'no_blank_lines_before_namespace',
15-
'ordered_use',
16-
'php4_constructor',
17-
'phpdoc_order',
18-
'-phpdoc_params',
19-
'short_array_syntax',
20-
'short_echo_tag',
21-
'strict',
22-
'strict_param',
23-
])
24-
->setUsingCache(true)
25-
->finder($finder);
13+
->setRiskyAllowed(true)
14+
->setRules([
15+
'@Symfony' => true,
16+
'align_double_arrow' => false,
17+
'align_equals' => false,
18+
'concat_with_spaces' => false,
19+
'ereg_to_preg' => true,
20+
'header_comment' => false,
21+
'linebreak_after_opening_tag' => true,
22+
'long_array_syntax' => false,
23+
'no_blank_lines_before_namespace' => false,
24+
'no_multiline_whitespace_before_semicolons' => true,
25+
'no_php4_constructor' => true,
26+
'no_short_echo_tag' => true,
27+
'no_useless_return' => true,
28+
'not_operator_with_space' => false,
29+
'not_operator_with_successor_space' => false,
30+
'ordered_imports' => true,
31+
'php_unit_construct' => true,
32+
'php_unit_strict' => false,
33+
'phpdoc_order' => true,
34+
'phpdoc_property' => true,
35+
'phpdoc_var_to_type' => false,
36+
'psr0' => true,
37+
'short_array_syntax' => true,
38+
'strict_comparison' => true,
39+
'strict_param' => true,
40+
])
41+
->finder($finder);

app/Semver/Application.php

+21-15
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
11
<?php
2+
23
namespace Semver;
34

4-
use League\Container\ContainerInterface;
5-
use League\Container\ServiceProvider;
5+
use League\Container\Container;
6+
use League\Container\ReflectionContainer;
7+
use League\Container\ServiceProvider\AbstractServiceProvider;
68
use League\Route\Dispatcher;
79
use League\Route\RouteCollection;
8-
use Symfony\Component\HttpFoundation\Request;
10+
use Psr\Http\Message\ServerRequestInterface;
11+
use Zend\Diactoros\Response;
12+
use Zend\Diactoros\Response\SapiEmitter;
913

1014
class Application
1115
{
1216
/**
13-
* @var ContainerInterface
17+
* @var Container
1418
*/
1519
private $container;
1620

@@ -29,11 +33,12 @@ class Application
2933
];
3034

3135
/**
32-
* @param ContainerInterface $container
36+
* @param Container $container
3337
*/
34-
public function __construct(ContainerInterface $container)
38+
public function __construct(Container $container)
3539
{
3640
$this->container = $container;
41+
$this->container->delegate(new ReflectionContainer());
3742

3843
$this->setupProviders();
3944
}
@@ -43,14 +48,15 @@ public function __construct(ContainerInterface $container)
4348
*/
4449
public function run()
4550
{
46-
/** @var Dispatcher $dispatcher */
47-
/* @type Request $request */
48-
$dispatcher = $this->container->get(RouteCollection::class)->getDispatcher();
49-
$request = $this->container->get(Request::class);
51+
/* @var Dispatcher $dispatcher */
52+
/* @type ServerRequestInterface $request */
53+
$request = $this->container->get(ServerRequestInterface::class);
54+
$response = new Response();
55+
$dispatcher = $this->container->get(RouteCollection::class);
5056

51-
$response = $dispatcher->dispatch($request->getMethod(), $request->getPathInfo());
57+
$response = $dispatcher->dispatch($request, $response);
5258

53-
$response->send();
59+
(new SapiEmitter())->emit($response);
5460
}
5561

5662
/**
@@ -59,18 +65,18 @@ public function run()
5965
private function setupProviders()
6066
{
6167
foreach ($this->serviceProviders as &$serviceProvider) {
62-
/** @var ServiceProvider $serviceProvider */
68+
/** @var AbstractServiceProvider $serviceProvider */
6369
$serviceProvider = new $serviceProvider();
6470
$serviceProvider->setContainer($this->container);
6571
}
6672

6773
// Register the service providers.
68-
array_walk($this->serviceProviders, function (ServiceProvider $serviceProvider) {
74+
array_walk($this->serviceProviders, function (AbstractServiceProvider $serviceProvider) {
6975
$this->container->addServiceProvider($serviceProvider);
7076
});
7177

7278
// Call the boot methods.
73-
array_walk($this->serviceProviders, function (ServiceProvider $serviceProvider) {
79+
array_walk($this->serviceProviders, function (AbstractServiceProvider $serviceProvider) {
7480
if (method_exists($serviceProvider, 'boot')) {
7581
$this->container->call([$serviceProvider, 'boot']);
7682
}

app/Semver/Contracts/Repositories/PackageVersionsRepository.php

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
namespace Semver\Contracts\Repositories;
34

45
use Packagist\Api\Result\Package\Version;

app/Semver/Http/Controllers/HomeController.php

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
namespace Semver\Http\Controllers;
34

45
use League\Plates\Engine;

app/Semver/Http/Controllers/PackageController.php

+12-11
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,30 @@
11
<?php
2+
23
namespace Semver\Http\Controllers;
34

45
use Composer\Package\BasePackage;
6+
use Psr\Http\Message\ServerRequestInterface;
57
use Semver\Services\Packagist\Packagist;
6-
use Symfony\Component\HttpFoundation\JsonResponse;
7-
use Symfony\Component\HttpFoundation\Request;
88
use UnexpectedValueException;
9+
use Zend\Diactoros\Response\JsonResponse;
910

1011
class PackageController
1112
{
1213
/**
13-
* @var Request
14+
* @var Packagist
1415
*/
15-
private $request;
16+
private $packagist;
1617

1718
/**
18-
* @var Packagist
19+
* @var ServerRequestInterface
1920
*/
20-
private $packagist;
21+
private $request;
2122

2223
/**
23-
* @param Packagist $packagist
24-
* @param Request $request
24+
* @param Packagist $packagist
25+
* @param ServerRequestInterface $request
2526
*/
26-
public function __construct(Packagist $packagist, Request $request)
27+
public function __construct(Packagist $packagist, ServerRequestInterface $request)
2728
{
2829
$this->packagist = $packagist;
2930
$this->request = $request;
@@ -55,7 +56,7 @@ public function matchVersions($vendor, $package)
5556
{
5657
$this->configureMinimumStability();
5758

58-
$constraint = $this->request->get('constraint', '*');
59+
$constraint = $this->request->getAttribute('constraint', '*');
5960
$versions = $this->packagist->getMatchingVersions($vendor, $package, $constraint);
6061

6162
return new JsonResponse($versions);
@@ -66,7 +67,7 @@ public function matchVersions($vendor, $package)
6667
*/
6768
protected function configureMinimumStability()
6869
{
69-
$minimumStability = $this->request->get('minimum-stability', 'stable');
70+
$minimumStability = $this->request->getAttribute('minimum-stability', 'stable');
7071
if (!in_array($minimumStability, array_keys(BasePackage::$stabilities), true)) {
7172
throw new UnexpectedValueException(sprintf('Unsupported value for minimum-stability: %s', $minimumStability));
7273
}
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
<?php
2+
23
namespace Semver\Http\Support;
34

4-
use League\Container\ServiceProvider;
5-
use Symfony\Component\HttpFoundation\Request;
5+
use League\Container\ServiceProvider\AbstractServiceProvider;
6+
use Psr\Http\Message\ServerRequestInterface;
7+
use Zend\Diactoros\ServerRequestFactory;
68

7-
class RequestServiceProvider extends ServiceProvider
9+
class RequestServiceProvider extends AbstractServiceProvider
810
{
911
/**
1012
* @var array
1113
*/
1214
protected $provides = [
13-
Request::class,
15+
ServerRequestInterface::class,
1416
];
1517

1618
/**
@@ -19,8 +21,8 @@ class RequestServiceProvider extends ServiceProvider
1921
public function register()
2022
{
2123
// Bind the Symfony request to the container.
22-
$this->container->singleton(Request::class, function () {
23-
return Request::createFromGlobals();
24+
$this->container->share(ServerRequestInterface::class, function () {
25+
return ServerRequestFactory::fromGlobals();
2426
});
2527
}
2628
}
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
<?php
2+
23
namespace Semver\Http\Support;
34

4-
use League\Container\ServiceProvider;
5+
use League\Container\ServiceProvider\AbstractServiceProvider;
56
use League\Route\RouteCollection;
6-
use League\Route\Strategy\UriStrategy;
7+
use League\Route\Strategy\ParamStrategy;
78

8-
class RoutesServiceProvider extends ServiceProvider
9+
class RoutesServiceProvider extends AbstractServiceProvider
910
{
1011
/**
1112
* @var array
@@ -15,14 +16,6 @@ class RoutesServiceProvider extends ServiceProvider
1516
'routes.file',
1617
];
1718

18-
/**
19-
* @param RouteCollection $router
20-
*/
21-
public function boot(RouteCollection $router)
22-
{
23-
include $this->container->get('routes.file');
24-
}
25-
2619
/**
2720
* Register method,.
2821
*/
@@ -33,11 +26,22 @@ public function register()
3326
});
3427

3528
// Bind a route collection to the container.
36-
$this->container->singleton(RouteCollection::class, function () {
29+
$this->container->share(RouteCollection::class, function () {
30+
$strategy = new ParamStrategy();
31+
$strategy->setContainer($this->container);
32+
3733
$routes = new RouteCollection($this->container);
38-
$routes->setStrategy(new UriStrategy());
34+
$routes->setStrategy($strategy);
3935

4036
return $routes;
4137
});
4238
}
39+
40+
/**
41+
* {@inheritdoc}
42+
*/
43+
public function boot(RouteCollection $router)
44+
{
45+
include $this->container->get('routes.file');
46+
}
4347
}

app/Semver/Services/Cache/ServiceProvider.php

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
<?php
2+
23
namespace Semver\Services\Cache;
34

45
use Illuminate\Cache\FileStore;
56
use Illuminate\Cache\Repository as IlluminateCache;
67
use Illuminate\Contracts\Cache\Repository;
78
use Illuminate\Filesystem\Filesystem;
8-
use League\Container\ServiceProvider as BaseServiceProvider;
9+
use League\Container\ServiceProvider\AbstractServiceProvider as BaseServiceProvider;
910

1011
class ServiceProvider extends BaseServiceProvider
1112
{
@@ -23,7 +24,7 @@ class ServiceProvider extends BaseServiceProvider
2324
*/
2425
public function register()
2526
{
26-
$this->container->singleton(Repository::class, function () {
27+
$this->container->share(Repository::class, function () {
2728
$store = new FileStore(new Filesystem(), $this->container->get('paths.cache'));
2829

2930
return new IlluminateCache($store);

app/Semver/Services/Error/ServiceProvider.php

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
<?php
2+
23
namespace Semver\Services\Error;
34

45
use ErrorException;
56
use Exception;
6-
use League\Container\ServiceProvider as BaseServiceProvider;
7+
use League\Container\ServiceProvider\AbstractServiceProvider as BaseServiceProvider;
8+
use League\Container\ServiceProvider\BootableServiceProviderInterface;
79
use Whoops\Handler\PrettyPageHandler;
810
use Whoops\Run;
911

10-
class ServiceProvider extends BaseServiceProvider
12+
class ServiceProvider extends BaseServiceProvider implements BootableServiceProviderInterface
1113
{
1214
/**
1315
* @var array

0 commit comments

Comments
 (0)