Skip to content

Commit

Permalink
Merge branch 'hotfix/1-escape-chars'
Browse files Browse the repository at this point in the history
Fixes #1

Conflicts:
	CHANGELOG.md
  • Loading branch information
weierophinney committed Oct 30, 2019
2 parents 3ed0833 + be407c5 commit f0c5e03
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 13 deletions.
22 changes: 22 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,28 @@

All notable changes to this project will be documented in this file, in reverse chronological order by release.

## 0.1.1 - 2019-10-30

### Added

- Nothing.

### Changed

- Nothing.

### Deprecated

- Nothing.

### Removed

- Nothing.

### Fixed

- [#1](https://github.com/laminas/laminas-migration/pull/1) provides updates to replacements for strings containing escape characters, to ensure the same number of escape characters are used in replacements.

## 0.1.0 - 2019-10-30

### Added
Expand Down
6 changes: 5 additions & 1 deletion phpcs.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
<?xml version="1.0"?>
<ruleset>
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="./vendor/squizlabs/php_codesniffer/phpcs.xsd">
<rule ref="PSR12"/>

<arg value="p"/>
<arg name="colors"/>

<file>src</file>
<file>test</file>

<exclude-pattern>test/TestAsset/</exclude-pattern>
</ruleset>
16 changes: 6 additions & 10 deletions src/Helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,29 +19,25 @@ private static function replacements()
// Package namespaces.
// Duplicates with varying numbers of escapes provided to ensure
// matching occurs properly across all edge cases.
'Zend\ProblemDetails' => 'Expressive\\ProblemDetails',
'Zend\\ProblemDetails' => 'Expressive\\ProblemDetails',
'Zend\\\\ProblemDetails' => 'Expressive\\ProblemDetails',
'Zend\Expressive' => 'Expressive',
'Zend\\\\ProblemDetails' => 'Expressive\\\\ProblemDetails',
'Zend\\Expressive' => 'Expressive',
'Zend\\\\Expressive' => 'Expressive',
'ZF\ComposerAutoloading' => 'Laminas\\ComposerAutoloading',
'ZF\\ComposerAutoloading' => 'Laminas\\ComposerAutoloading',
'ZF\\\\ComposerAutoloading' => 'Laminas\\ComposerAutoloading',
'ZF\Deploy' => 'Laminas\\Deploy',
'ZF\\\\ComposerAutoloading' => 'Laminas\\\\ComposerAutoloading',
'ZF\\Deploy' => 'Laminas\\Deploy',
'ZF\\\\Deploy' => 'Laminas\\Deploy',
'ZF\DevelopmentMode' => 'Laminas\\DevelopmentMode',
'ZF\\\\Deploy' => 'Laminas\\\\Deploy',
'ZF\\DevelopmentMode' => 'Laminas\\DevelopmentMode',
'ZF\\\\DevelopmentMode' => 'Laminas\\DevelopmentMode',
'ZF\Apigility' => 'Apigility',
'ZF\\\\DevelopmentMode' => 'Laminas\\\\DevelopmentMode',
'ZF\\Apigility' => 'Apigility',
'ZF\\\\Apigility' => 'Apigility',
'ZendXml' => 'Laminas\\Xml',
'ZendOAuth' => 'Laminas\\OAuth',
'ZendDiagnostics' => 'Laminas\\Diagnostics',
'ZendService\\ReCaptcha' => 'Laminas\\ReCaptcha',
'ZendService\\\\ReCaptcha' => 'Laminas\\\\ReCaptcha',
'ZendService\\Twitter' => 'Laminas\\Twitter',
'ZendService\\\\Twitter' => 'Laminas\\\\Twitter',

// Do not rewrite:
'Doctrine\Zend' => 'Doctrine\Zend',
Expand Down
10 changes: 8 additions & 2 deletions test/HelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,16 @@
use Laminas\Migration\Helper;
use PHPUnit\Framework\TestCase;

use function file_get_contents;

class HelperTest extends TestCase
{
public function edgeCases() : iterable
public function edgeCases(): iterable
{
yield 'Example class' => [
file_get_contents(__DIR__ . '/TestAsset/TestClass.php'),
file_get_contents(__DIR__ . '/TestAsset/TestClass.php.out'),
];
yield 'Apigility module' => ['ZF\Apigility', 'Apigility'];
yield 'Apigility documentation module' => ['ZF\Apigility\Documentation', 'Apigility\Documentation'];
yield 'Apigility modules.config.php' => [
Expand All @@ -28,7 +34,7 @@ public function edgeCases() : iterable
* @param string $string
* @param string $expected
*/
public function testEdgeCases($string, $expected) : void
public function testEdgeCases($string, $expected): void
{
$this->assertSame($expected, Helper::replace($string));
}
Expand Down
20 changes: 20 additions & 0 deletions test/TestAsset/TestClass.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

namespace Zend\ProblemDetails;

use ZF\ComposerAutoloading\Something;
use ZF\Apigility\Doctrine\MyDoctrine;
use Zend\Version;
use ZendService\Amazon;
use ZendPdf\Renderer;

class MyClass extends \Zend\Expressive\Router
{
/** @var string|\Zend\View\Renderer */
private $class;

public function __construct()
{
$this->class = 'Zend\\View\\Renderer';
}
}
20 changes: 20 additions & 0 deletions test/TestAsset/TestClass.php.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

namespace Expressive\ProblemDetails;

use Laminas\ComposerAutoloading\Something;
use Apigility\Doctrine\MyDoctrine;
use Zend\Version;
use ZendService\Amazon;
use ZendPdf\Renderer;

class MyClass extends \Expressive\Router
{
/** @var string|\Laminas\View\Renderer */
private $class;

public function __construct()
{
$this->class = 'Laminas\\View\\Renderer';
}
}

0 comments on commit f0c5e03

Please sign in to comment.