-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature: Copy PhpStorm meta file on project start (#120)
* Add phpstorm meta file to internal phar storage * Add PhpStormMeta config service + unit tests * Copy phpstorm file during project start + feature tests * Bump to v5.7.0
- Loading branch information
Showing
7 changed files
with
355 additions
and
10 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<?php declare( strict_types=1 ); | ||
|
||
namespace App\Services\Config; | ||
|
||
use Illuminate\Filesystem\Filesystem; | ||
|
||
/** | ||
* Manages the .phpstorm.meta.php file to add better | ||
* code completion for the PHP-DI container. | ||
*/ | ||
class PhpStormMeta extends BaseConfig { | ||
|
||
public const PHAR_META_FILE = '/phpstorm.meta.php'; | ||
public const META_FILE = '/.phpstorm.meta.php'; | ||
|
||
/** | ||
* Path to the default meta file inside the phar. | ||
* | ||
* @var string | ||
*/ | ||
protected $metaFile; | ||
|
||
public function __construct( Filesystem $filesystem, string $directory ) { | ||
parent::__construct( $filesystem, $directory ); | ||
$this->metaFile = $this->directory . self::PHAR_META_FILE; | ||
} | ||
|
||
/** | ||
* Check if this project has a .phpstorm.meta.php file. | ||
* | ||
* @param string $projectRoot | ||
* | ||
* @return bool | ||
*/ | ||
public function existsInProject( string $projectRoot ): bool { | ||
return $this->filesystem->exists( $projectRoot . self::META_FILE ); | ||
} | ||
|
||
/** | ||
* Copy the .phpstorm.meta.php file to the project root. | ||
* | ||
* @param string $projectRoot The root path of the local project. | ||
* | ||
* @throws \Illuminate\Contracts\Filesystem\FileNotFoundException | ||
* | ||
* @return bool | ||
*/ | ||
public function copy( string $projectRoot ): bool { | ||
$content = $this->filesystem->get( $this->metaFile ); | ||
|
||
return (bool) $this->filesystem->put( $projectRoot . self::META_FILE, $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
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,18 @@ | ||
<?php declare(strict_types=1); | ||
|
||
// .phpstorm.meta.php | ||
namespace PHPSTORM_META { | ||
// PHP-DI container code completion | ||
override( \Psr\Container\ContainerInterface::get( 0 ), map( [ | ||
'' => '@', | ||
] ) ); | ||
override( \DI\Container::get( 0 ), map( [ | ||
'' => '@', | ||
] ) ); | ||
override( \DI\FactoryInterface::make( 0 ), map( [ | ||
'' => '@', | ||
] ) ); | ||
override( \DI\Container::make( 0 ), map( [ | ||
'' => '@', | ||
] ) ); | ||
} |
Oops, something went wrong.