Skip to content

Commit

Permalink
Merge pull request #15 from arueckauer/feature/laminas-coding-standar…
Browse files Browse the repository at this point in the history
…d-2.3

Upgrade laminas-coding-standard to 2.3
  • Loading branch information
Ocramius authored Oct 21, 2021
2 parents 40b229d + 153f9cf commit 048bd2a
Show file tree
Hide file tree
Showing 16 changed files with 444 additions and 130 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"laminas/laminas-zendframework-bridge": "^1.0"
},
"require-dev": {
"laminas/laminas-coding-standard": "~1.0.0",
"laminas/laminas-coding-standard": "~2.3.0",
"mikey179/vfsstream": "^1.6.10",
"phpunit/phpunit": "^9.3"
},
Expand Down
329 changes: 274 additions & 55 deletions composer.lock

Large diffs are not rendered by default.

16 changes: 14 additions & 2 deletions phpcs.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,23 @@
<?xml version="1.0"?>
<ruleset name="Laminas coding standard">
<rule ref="./vendor/laminas/laminas-coding-standard/ruleset.xml"/>
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="vendor/squizlabs/php_codesniffer/phpcs.xsd">

<arg name="basepath" value="."/>
<arg name="cache" value=".phpcs-cache"/>
<arg name="colors"/>
<arg name="extensions" value="php"/>
<arg name="parallel" value="80"/>

<!-- Show progress -->
<arg value="p"/>

<!-- Paths to check -->
<file>src</file>
<file>test</file>
<file>bin/laminas-development-mode</file>
<file>development.config.php.dist</file>
<file>development.local.php.dist</file>

<!-- Include all rules from the Laminas Coding Standard -->
<rule ref="LaminasCodingStandard"/>
</ruleset>
28 changes: 16 additions & 12 deletions src/AutoComposer.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
<?php

declare(strict_types=1);

namespace Laminas\DevelopmentMode;

use function getenv;
use function is_resource;
use function printf;
use function var_export;

use const PHP_EOL;
use const STDERR;

/**
* Automatically switch to and from development mode based on type of composer
* install/update used.
Expand All @@ -17,26 +26,21 @@
*/
class AutoComposer
{
const COMPOSER_DEV_MODE = 'COMPOSER_DEV_MODE';
public const COMPOSER_DEV_MODE = 'COMPOSER_DEV_MODE';

/**
* @var value of COMPOSER_DEV_MODE
*/
/** @var string Value of COMPOSER_DEV_MODE */
private $composerDevMode;

/**
* @var resource
*/
/** @var resource */
private $errorStream;

/** @var string[] */
private $expectedValues = [
'0', // production mode
'1', // development mode
];

/**
* @param string Path to project.
*/
/** @var string Path to project. */
private $projectDir;

/**
Expand All @@ -46,8 +50,8 @@ class AutoComposer
public function __construct($projectDir = '', $errorStream = null)
{
$this->composerDevMode = getenv(self::COMPOSER_DEV_MODE);
$this->projectDir = $projectDir;
$this->errorStream = is_resource($errorStream) ? $errorStream : STDERR;
$this->projectDir = $projectDir;
$this->errorStream = is_resource($errorStream) ? $errorStream : STDERR;
}

/**
Expand Down
8 changes: 8 additions & 0 deletions src/Command.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
<?php

declare(strict_types=1);

namespace Laminas\DevelopmentMode;

use function array_shift;
use function count;
use function fwrite;

use const PHP_EOL;
use const STDERR;

class Command
{
/**
Expand Down
28 changes: 14 additions & 14 deletions src/ConfigDiscoveryTrait.php
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
<?php

declare(strict_types=1);

namespace Laminas\DevelopmentMode;

use RuntimeException;

use function file_exists;
use function is_array;
use function sprintf;
use function unlink;

use const PHP_EOL;

/**
* Shared functionality for the Disable/Enable commands.
*/
trait ConfigDiscoveryTrait
{
/**
* @var null|array
*/
/** @var null|array */
private $applicationConfig;

/**
* @var string
*/
/** @var string */
private $applicationConfigPath = 'config/application.config.php';

/**
* @var string
*/
/** @var string */
private $mezzioConfigPath = 'config/config.php';

/**
* @var string Base name for configuration cache.
*/
/** @var string Base name for configuration cache. */
private $configCacheBase = 'module-config-cache';

/**
Expand Down Expand Up @@ -109,8 +109,8 @@ private function getConfigCacheKey()
* Raises an exception if retrieved configuration is not an array.
*
* @return array
* @throws RuntimeException if config/application.config.php does not
* return an array
* @throws RuntimeException If config/application.config.php does not
* return an array.
*/
private function getApplicationConfig()
{
Expand Down
24 changes: 15 additions & 9 deletions src/Disable.php
Original file line number Diff line number Diff line change
@@ -1,25 +1,31 @@
<?php

declare(strict_types=1);

namespace Laminas\DevelopmentMode;

use RuntimeException;

use function file_exists;
use function fwrite;
use function is_resource;
use function sprintf;
use function unlink;

use const PHP_EOL;
use const STDERR;

class Disable
{
use ConfigDiscoveryTrait;

const DEVEL_CONFIG = 'config/development.config.php';
const DEVEL_LOCAL = 'config/autoload/development.local.php';
public const DEVEL_CONFIG = 'config/development.config.php';
public const DEVEL_LOCAL = 'config/autoload/development.local.php';

/**
* @var resource
*/
/** @var resource */
private $errorStream;

/**
* @param string Path to project.
*/
/** @var string Path to project. */
private $projectDir;

/**
Expand All @@ -28,7 +34,7 @@ class Disable
*/
public function __construct($projectDir = '', $errorStream = null)
{
$this->projectDir = $projectDir;
$this->projectDir = $projectDir;
$this->errorStream = is_resource($errorStream) ? $errorStream : STDERR;
}

Expand Down
32 changes: 21 additions & 11 deletions src/Enable.php
Original file line number Diff line number Diff line change
@@ -1,27 +1,37 @@
<?php

declare(strict_types=1);

namespace Laminas\DevelopmentMode;

use RuntimeException;

use function basename;
use function copy;
use function file_exists;
use function fwrite;
use function in_array;
use function is_resource;
use function sprintf;
use function symlink;

use const PHP_EOL;
use const PHP_OS;
use const STDERR;

class Enable
{
use ConfigDiscoveryTrait;

const DEVEL_CONFIG = 'config/development.config.php';
const DEVEL_CONFIG_DIST = 'config/development.config.php.dist';
const DEVEL_LOCAL = 'config/autoload/development.local.php';
const DEVEL_LOCAL_DIST = 'config/autoload/development.local.php.dist';
public const DEVEL_CONFIG = 'config/development.config.php';
public const DEVEL_CONFIG_DIST = 'config/development.config.php.dist';
public const DEVEL_LOCAL = 'config/autoload/development.local.php';
public const DEVEL_LOCAL_DIST = 'config/autoload/development.local.php.dist';

/**
* @var resource
*/
/** @var resource */
private $errorStream;

/**
* @param string Path to project.
*/
/** @var string Path to project. */
private $projectDir;

/**
Expand All @@ -30,7 +40,7 @@ class Enable
*/
public function __construct($projectDir = '', $errorStream = null)
{
$this->projectDir = $projectDir;
$this->projectDir = $projectDir;
$this->errorStream = is_resource($errorStream) ? $errorStream : STDERR;
}

Expand Down
10 changes: 6 additions & 4 deletions src/Help.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
<?php

declare(strict_types=1);

namespace Laminas\DevelopmentMode;

use function fwrite;
use function is_resource;

class Help
{
/**
* @var string
*/
private $message = <<< EOH
/** @var string */
private $message = <<<EOH
Enable/Disable development mode.
Usage:
Expand Down
12 changes: 8 additions & 4 deletions src/Status.php
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
<?php

declare(strict_types=1);

namespace Laminas\DevelopmentMode;

use function file_exists;
use function sprintf;

use const PHP_EOL;

class Status
{
const DEVEL_CONFIG = 'config/development.config.php';
public const DEVEL_CONFIG = 'config/development.config.php';

/**
* @param string
*/
/** @var string */
private $develConfigFile;

/**
Expand Down
14 changes: 11 additions & 3 deletions test/AutoComposerTest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php

declare(strict_types=1);

namespace LaminasTest\DevelopmentMode;

Expand All @@ -8,6 +9,13 @@
use org\bovigo\vfs\vfsStreamContainer;
use PHPUnit\Framework\TestCase;

use function fclose;
use function fopen;
use function is_resource;
use function putenv;

use const PHP_EOL;

class AutoComposerTest extends TestCase
{
use RemoveCacheFileTrait;
Expand All @@ -20,12 +28,12 @@ class AutoComposerTest extends TestCase

public function setUp(): void
{
$this->projectDir = vfsStream::setup('project', null, [
$this->projectDir = vfsStream::setup('project', null, [
'config' => [
'autoload' => [],
],
'cache' => [],
'data' => [],
'cache' => [],
'data' => [],
]);
$this->errorStream = fopen('php://memory', 'w+');
}
Expand Down
Loading

0 comments on commit 048bd2a

Please sign in to comment.