Skip to content

Commit

Permalink
Merge pull request #251 from koriym/php7
Browse files Browse the repository at this point in the history
Drop php 5.6 and hhvm support
  • Loading branch information
koriym committed Aug 21, 2017
2 parents 96c2eaa + b7677cc commit 85445b5
Show file tree
Hide file tree
Showing 17 changed files with 46 additions and 392 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
@@ -1,9 +1,9 @@
language: php
sudo: false
php:
- 5.6
- 7
- 7.0
- 7.1
- 7.2
cache:
directories:
- vendor
Expand Down
166 changes: 0 additions & 166 deletions build.xml

This file was deleted.

13 changes: 5 additions & 8 deletions composer.json
Expand Up @@ -16,18 +16,15 @@
}
],
"require": {
"php": ">=5.6.0",
"php": ">=7.0.0",
"aura/cli": "^2.2",
"bear/app-meta": "^1.1",
"bear/query-repository": "^1.3.1",
"bear/sunday": "^1.1.1",
"bear/resource": "^1.6.0",
"bear/app-meta": "^1.2",
"bear/query-repository": "^1.4",
"bear/sunday": "^1.2",
"monolog/monolog": "^1.22"
},
"require-dev": {
"phpunit/phpunit": "^5.7",
"squizlabs/php_codesniffer": "^2.8",
"phpmd/phpmd": "^2.6"
"phpunit/phpunit": "^5.7"
},
"autoload": {
"psr-4": {
Expand Down
4 changes: 2 additions & 2 deletions phpcs.xml 100644 → 100755
@@ -1,6 +1,5 @@
<?xml version="1.0"?>
<ruleset name="BEAR">
<description>The BEAR coding standard.</description>
<ruleset>
<!-- 2. General -->
<rule ref="Generic.NamingConventions.UpperCaseConstantName"/>
<rule ref="Generic.CodeAnalysis.UnusedFunctionParameter"/>
Expand All @@ -15,5 +14,6 @@
<exclude name="PEAR.Commenting.FunctionComment.SpacingBeforeTags"/>
<exclude name="PEAR.Commenting.FunctionComment.MissingParamTag"/>
<exclude name="PEAR.Commenting.FunctionComment.Missing"/>
<exclude name="PEAR.Commenting.FunctionComment.ParameterCommentsNotAligned"/>
</rule>
</ruleset>
12 changes: 3 additions & 9 deletions phpmd.xml
@@ -1,9 +1,7 @@
<ruleset name="PHP.Skeleton rules"
xmlns="http://pmd.sf.net/ruleset/1.0.0"
<ruleset xmlns="http://pmd.sf.net/ruleset/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0 http://pmd.sf.net/ruleset_xml_schema.xsd"
xsi:noNamespaceSchemaLocation="http://pmd.sf.net/ruleset_xml_schema.xsd">
<description>PHP.Skeleton rule set</description>
<!--codesize-->
<rule ref="rulesets/codesize.xml/CyclomaticComplexity" />
<rule ref="rulesets/codesize.xml/NPathComplexity" />
Expand All @@ -20,11 +18,7 @@
<rule ref="rulesets/design.xml/GotoStatement" />
<rule ref="rulesets/design.xml/NumberOfChildren" />
<rule ref="rulesets/design.xml/DepthOfInheritance" />
<rule ref="rulesets/design.xml/CouplingBetweenObjects" >
<properties>
<property name="minimum" value="20"/>
</properties>
</rule>
<rule ref="rulesets/design.xml/CouplingBetweenObjects" />
<!--naming-->
<rule ref="rulesets/naming.xml/ConstantNamingConventions" />
<rule ref="rulesets/naming.xml/BooleanGetMethodName" />
Expand All @@ -37,7 +31,7 @@
<rule ref="rulesets/controversial.xml/Superglobals" />
<rule ref="rulesets/controversial.xml/CamelCaseClassName" />
<rule ref="rulesets/controversial.xml/CamelCasePropertyName" />
<!--<rule ref="rulesets/controversial.xml/CamelCaseMethodName" />-->
<rule ref="rulesets/controversial.xml/CamelCaseMethodName" />
<rule ref="rulesets/controversial.xml/CamelCaseParameterName" />
<rule ref="rulesets/controversial.xml/CamelCaseVariableName" />
<!--cleancode-->
Expand Down
25 changes: 3 additions & 22 deletions src/AppInjector.php
Expand Up @@ -49,13 +49,7 @@ public function getInstance($interface, $name = Name::ANY)
}
}

/**
* @param AbstractAppMeta $appMeta
* @param string $contexts
*
* @return InjectorInterface
*/
private function getInjector(AbstractAppMeta $appMeta, $contexts)
private function getInjector(AbstractAppMeta $appMeta, string $contexts) : InjectorInterface
{
$module = $this->newModule($appMeta, $contexts);
$module->override(new AppMetaModule($appMeta));
Expand All @@ -71,29 +65,16 @@ private function getInjector(AbstractAppMeta $appMeta, $contexts)
return $injector;
}

/**
* Compile dependencies
*
* @param AbstractModule $module
* @param string $scriptDir
*
* @internal param AbstractAppMeta $appMeta
*/
private function compile(AbstractModule $module, $scriptDir)
private function compile(AbstractModule $module, string $scriptDir)
{
$compiler = new DiCompiler($module, $scriptDir);
$compiler->compile();
}

/**
* Return configured module
*
* @param AbstractAppMeta $appMeta
* @param string $contexts
*
* @return AbstractModule
*/
private function newModule(AbstractAppMeta $appMeta, $contexts)
private function newModule(AbstractAppMeta $appMeta, string $contexts) : AbstractModule
{
$contextsArray = array_reverse(explode('-', $contexts));
$module = null;
Expand Down
12 changes: 2 additions & 10 deletions src/Bootstrap.php
Expand Up @@ -40,24 +40,16 @@ final class Bootstrap
* @param string $name application name 'koriym\blog' (vendor\package)
* @param string $contexts application context 'prd-html-app'
* @param string $appDir application path
*
* @return AbstractApp
*/
public function getApp($name, $contexts, $appDir = null)
public function getApp(string $name, string $contexts, string $appDir = null) : AbstractApp
{
return $this->newApp(new AppMeta($name, $contexts, $appDir), $contexts);
}

/**
* Return cached contextual application instance
*
* @param AbstractAppMeta $appMeta
* @param string $contexts
* @param Cache $cache
*
* @return AbstractApp
*/
public function newApp(AbstractAppMeta $appMeta, $contexts, Cache $cache = null)
public function newApp(AbstractAppMeta $appMeta, string $contexts, Cache $cache = null) : AbstractApp
{
$isCacheable = is_int(strpos($contexts, 'prod-')) || is_int(strpos($contexts, 'stage-'));
$cache = $cache ?: ($isCacheable ? new ChainCache([new ApcuCache, new FilesystemCache($appMeta->tmpDir)]) : new VoidCache);
Expand Down
12 changes: 3 additions & 9 deletions src/Compiler.php
Expand Up @@ -42,13 +42,7 @@ public function __invoke($appName, $context, $appDir)
}
}

/**
* @param InjectorInterface $injector
* @param Reader $reader
* @param NamedParameterInterface $namedParams
* @param string $className
*/
private function scanClass(InjectorInterface $injector, Reader $reader, NamedParameterInterface $namedParams, $className)
private function scanClass(InjectorInterface $injector, Reader $reader, NamedParameterInterface $namedParams, string $className)
{
$instance = $injector->getInstance($className);
$class = new \ReflectionClass($className);
Expand All @@ -65,12 +59,12 @@ private function scanClass(InjectorInterface $injector, Reader $reader, NamedPar
}
}

private function isMagicMethod($method)
private function isMagicMethod($method) : bool
{
return in_array($method, ['__sleep', '__wakeup', 'offsetGet', 'offsetSet', 'offsetExists', 'offsetUnset', 'count', 'ksort', 'asort', 'jsonSerialize'], true);
}

private function saveNamedParam(NamedParameterInterface $namedParameter, $instance, $method)
private function saveNamedParam(NamedParameterInterface $namedParameter, $instance, string $method)
{
// named parameter
if (! in_array($method, ['onGet', 'onPost', 'onPut', 'onPatch', 'onDelete', 'onHead'], true)) {
Expand Down
14 changes: 2 additions & 12 deletions src/Provide/Error/DevVndErrorPage.php
Expand Up @@ -24,22 +24,12 @@ public function toString()
$this->view = json_encode($this->body, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES) . PHP_EOL;
}

/**
* @return array
*/
private function getHeader()
private function getHeader() : array
{
return ['content-type' => 'application/vnd.error+json'];
}

/**
* @param \Exception $e
* @param RouterMatch $request
* @param Status $status
*
* @return array
*/
private function getResponseBody(\Exception $e, RouterMatch $request, Status $status)
private function getResponseBody(\Exception $e, RouterMatch $request, Status $status) : array
{
return [
'message' => $status->text,
Expand Down
8 changes: 1 addition & 7 deletions src/Provide/Error/DevVndErrorPageFactory.php
Expand Up @@ -10,13 +10,7 @@

final class DevVndErrorPageFactory implements ErrorPageFactoryInterface
{
/**
* @param \Exception $e
* @param RouterMatch $request
*
* @return DevVndErrorPage
*/
public function newInstance(\Exception $e, RouterMatch $request)
public function newInstance(\Exception $e, RouterMatch $request) : DevVndErrorPage
{
return new DevVndErrorPage($e, $request);
}
Expand Down

0 comments on commit 85445b5

Please sign in to comment.