Supported Versions: PHP 4, PHP 5, PHP 7, PHP 8
Replace all occurrences of the search string with the replacement string
<?php str_replace( array|string $search, array|string $replace, string|array $subject, int &$count = null): string|array
<?php public static function appPath()
{
return str_replace('\\', '/', config('blueprint.app_path'));
}
public static function useReturnTypeHints()
<?php public function parse($content, $strip_dashes = true)
{
$content = str_replace(["\r\n", "\r"], "\n", $content);
if ($strip_dashes) {
$content = preg_replace('/^(\s*)-\s*/m', '\1', $content);
<?php return array_map(
function ($option) {
$raw_value = str_replace("''", "'", trim($option, "'"));
if (!preg_match('/\s/', $raw_value)) {
return $raw_value;
<?php protected function getPath(Model $model)
{
$path = str_replace('\\', '/', Blueprint::relativeNamespace($model->fullyQualifiedClassName()));
return sprintf('%s/%s.php', $this->basePath ?? Blueprint::appPath(), $path);
}
<?php protected function populateStub(string $stub, Controller $controller)
{
$stub = str_replace('{{ namespace }}', $controller->fullyQualifiedNamespace(), $stub);
$stub = str_replace('{{ class }}', $controller->className(), $stub);
$stub = str_replace('{{ methods }}', $this->buildMethods($controller), $stub);
$stub = str_replace('{{ imports }}', $this->buildImports($controller), $stub);
<?php protected function populateStub(string $stub, Controller $controller)
{
$stub = str_replace('{{ namespace }}', $controller->fullyQualifiedNamespace(), $stub);
$stub = str_replace('{{ class }}', $controller->className(), $stub);
$stub = str_replace('{{ methods }}', $this->buildMethods($controller), $stub);
$stub = str_replace('{{ imports }}', $this->buildImports($controller), $stub);
<?php {
$stub = str_replace('{{ namespace }}', $controller->fullyQualifiedNamespace(), $stub);
$stub = str_replace('{{ class }}', $controller->className(), $stub);
$stub = str_replace('{{ methods }}', $this->buildMethods($controller), $stub);
$stub = str_replace('{{ imports }}', $this->buildImports($controller), $stub);
return $stub;
<?php $stub = str_replace('{{ namespace }}', $controller->fullyQualifiedNamespace(), $stub);
$stub = str_replace('{{ class }}', $controller->className(), $stub);
$stub = str_replace('{{ methods }}', $this->buildMethods($controller), $stub);
$stub = str_replace('{{ imports }}', $this->buildImports($controller), $stub);
return $stub;
}
<?php $methods = '';
foreach ($controller->methods() as $name => $statements) {
$method = str_replace('{{ method }}', $name, $template);
if (in_array($name, ['edit', 'update', 'show', 'destroy'])) {
$context = Str::singular($controller->prefix());
<?php $search = ' * @return \\Illuminate\\Http\\Response';
$method = str_replace($search, ' * @param \\' . $reference . ' ' . $variable . PHP_EOL . $search, $method);
$search = '(Request $request';
$method = str_replace($search, $search . ', ' . $context . ' ' . $variable, $method);
<?php $method = str_replace($search, ' * @param \\' . $reference . ' ' . $variable . PHP_EOL . $search, $method);
$search = '(Request $request';
$method = str_replace($search, $search . ', ' . $context . ' ' . $variable, $method);
$this->addImport($controller, $reference);
}
<?php $fqcn = config('blueprint.namespace') . '\\Http\\Requests\\' . ($controller->namespace() ? $controller->namespace() . '\\' : '') . $class_name;
$method = str_replace('\Illuminate\Http\Request $request', '\\' . $fqcn . ' $request', $method);
$method = str_replace('(Request $request', '(' . $class_name . ' $request', $method);
$this->addImport($controller, $fqcn);
<?php $fqcn = config('blueprint.namespace') . '\\Http\\Requests\\' . ($controller->namespace() ? $controller->namespace() . '\\' : '') . $class_name;
$method = str_replace('\Illuminate\Http\Request $request', '\\' . $fqcn . ' $request', $method);
$method = str_replace('(Request $request', '(' . $class_name . ' $request', $method);
$this->addImport($controller, $fqcn);
} elseif ($statement instanceof DispatchStatement) {
<?php $body .= self::INDENT . $statement->output() . PHP_EOL;
} elseif ($statement instanceof ResourceStatement) {
$fqcn = config('blueprint.namespace') . '\\Http\\Resources\\' . ($controller->namespace() ? $controller->namespace() . '\\' : '') . $statement->name();
$method = str_replace('* @return \\Illuminate\\Http\\Response', '* @return \\' . $fqcn, $method);
$this->addImport($controller, $fqcn);
$body .= self::INDENT . $statement->output() . PHP_EOL;
<?php $this->addImport($controller, $this->determineModel($controller, $queryStatement->model()));
}
$body = str_replace('::all();', '::paginate();', $body);
}
} elseif ($statement instanceof RedirectStatement) {
$body .= self::INDENT . $statement->output() . PHP_EOL;