-
-
Notifications
You must be signed in to change notification settings - Fork 56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Classmap implementation #4
Merged
Merged
Changes from 1 commit
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
4a4b5e1
Added Classmap autoload object and handling
coenjacobs f7ef397
Split up replacement logic during moving of files
coenjacobs 38969f7
Regex magic for classmap replacer
coenjacobs 31d0a22
Store replaced class names to later replace in all files
coenjacobs f8ea2cd
Run routine to replace replaced class names across classmap
coenjacobs e206a50
Classmap configuration in the readme
coenjacobs a35ee8c
Replace static class prefix by config value
coenjacobs 44ac13c
Classmap loads split between files and folders
coenjacobs 05fea7d
Replace is_a( calls with instanceof
coenjacobs c91d232
All class directories will now be prefixed with vendor/package
coenjacobs c8542f7
Instanceof checks need to go against class object instead of string
coenjacobs dd3333f
Explicitely create target directories to avoid errors
coenjacobs a27c4a6
Different apporach to this reverted commit, same outcome
coenjacobs 05f9900
Move classmapped files to prefixed directory as well
coenjacobs 03d830f
Improved regexes on both detecting and replacing classes
coenjacobs File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
|
||
namespace CoenJacobs\Mozart\Replace; | ||
|
||
use CoenJacobs\Mozart\Composer\Autoload\Autoloader; | ||
|
||
abstract class BaseReplacer implements Replacer | ||
{ | ||
/** @var Autoloader */ | ||
public $autoloader; | ||
|
||
public function setAutoloader( $autoloader ) | ||
{ | ||
$this->autoloader = $autoloader; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
|
||
namespace CoenJacobs\Mozart\Replace; | ||
|
||
class ClassmapReplacer extends BaseReplacer | ||
{ | ||
public function replace( $content ) | ||
{ | ||
return $content; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
namespace CoenJacobs\Mozart\Replace; | ||
|
||
class NamespaceReplacer extends BaseReplacer | ||
{ | ||
/** @var string */ | ||
public $dep_namespace = ''; | ||
|
||
public function replace($contents) | ||
{ | ||
$searchNamespace = $this->autoloader->getSearchNamespace(); | ||
|
||
return preg_replace_callback( | ||
'/' . addslashes($searchNamespace) . '([\\\|;])/U', | ||
function ($matches) { | ||
$replace = trim($matches[0], $matches[1]); | ||
return $this->dep_namespace . $replace . $matches[1]; | ||
}, | ||
$contents | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php | ||
|
||
namespace CoenJacobs\Mozart\Replace; | ||
|
||
interface Replacer | ||
{ | ||
public function setAutoloader($autoloader); | ||
public function replace($contents); | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should prefer
instanceof
operator instead ofis_a()
function. The operator doesn't incur a function overhead, andis_a()
was only de-deprecated because of popular request. It should have been gone already.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, fixed: 05fea7d