language stringclasses 1
value | owner stringlengths 2 15 | repo stringlengths 2 21 | sha stringlengths 45 45 | message stringlengths 7 36.3k | path stringlengths 1 199 | patch stringlengths 15 102k | is_multipart bool 2
classes |
|---|---|---|---|---|---|---|---|
Other | laravel | framework | fe9711b86f02704869c688ede0a79579db067f12.json | add stringable tests | src/Illuminate/Support/Stringable.php | @@ -23,7 +23,7 @@ class Stringable
* @param string $value
* @return void
*/
- public function __construct($value)
+ public function __construct($value = '')
{
$this->value = (string) $value;
}
@@ -100,6 +100,17 @@ public function ascii($language = 'en')
return new static(Str::ascii($this->value, $language));
}
+ /**
+ * Get the trailing name component of the path.
+ *
+ * @param string $suffix
+ * @return static
+ */
+ public function basename($suffix = '')
+ {
+ return new static(basename($this->value, $suffix));
+ }
+
/**
* Get the portion of a string before the first occurrence of a given value.
*
@@ -154,6 +165,17 @@ public function containsAll(array $needles)
return Str::containsAll($this->value, $needles);
}
+ /**
+ * Get the parent directory's path.
+ *
+ * @param int $levels
+ * @return static
+ */
+ public function dirname($levels = 1)
+ {
+ return new static(dirname($this->value, $levels));
+ }
+
/**
* Determine if a given string ends with a given substring.
*
@@ -181,11 +203,11 @@ public function exactly($value)
*
* @param string $delimiter
* @param int $limit
- * @return array
+ * @return \Illuminate\Support\Collection
*/
public function explode($delimiter, $limit = PHP_INT_MAX)
{
- return explode($delimiter, $this->value, $limit);
+ return collect(explode($delimiter, $this->value, $limit));
}
/**
@@ -274,15 +296,37 @@ public function lower()
}
/**
- * Limit the number of words in a string.
+ * Get the string matching the given pattern.
*
- * @param int $words
- * @param string $end
- * @return static
+ * @param string $pattern
+ * @return static|null
*/
- public function words($words = 100, $end = '...')
+ public function match($pattern)
{
- return new static(Str::words($this->value, $words, $end));
+ preg_match($pattern, $this->value, $matches);
+
+ if (! $matches) {
+ return new static;
+ }
+
+ return new static($matches[1] ?? $matches[0]);
+ }
+
+ /**
+ * Get the string matching the given pattern.
+ *
+ * @param string $pattern
+ * @return static|null
+ */
+ public function matchAll($pattern)
+ {
+ preg_match_all($pattern, $this->value, $matches);
+
+ if (empty($matches[0])) {
+ return collect();
+ }
+
+ return collect($matches[1] ?? $matches[0]);
}
/**
@@ -500,6 +544,33 @@ public function ucfirst()
return new static(Str::ucfirst($this->value));
}
+ /**
+ * Execute the given callback if the string is empty.
+ *
+ * @param callable $callback
+ * @return static
+ */
+ public function whenEmpty($callback)
+ {
+ if ($this->isEmpty()) {
+ $callback($this);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Limit the number of words in a string.
+ *
+ * @param int $words
+ * @param string $end
+ * @return static
+ */
+ public function words($words = 100, $end = '...')
+ {
+ return new static(Str::words($this->value, $words, $end));
+ }
+
/**
* Proxy dynamic properties onto methods.
* | true |
Other | laravel | framework | fe9711b86f02704869c688ede0a79579db067f12.json | add stringable tests | tests/Support/SupportStringableTest.php | @@ -0,0 +1,27 @@
+<?php
+
+namespace Illuminate\Tests\Support;
+
+use Illuminate\Support\Stringable;
+use PHPUnit\Framework\TestCase;
+
+class SupportStrTest extends TestCase
+{
+ public function testMatch()
+ {
+ $string = new Stringable('foo bar');
+
+ $this->assertEquals('bar', $string->match('/bar/'));
+ $this->assertEquals('bar', $string->match('/foo (.*)/'));
+ $this->assertTrue($string->match('/nothing/')->isEmpty());
+
+ $string = new Stringable('bar foo bar');
+
+ $this->assertEquals(['bar', 'bar'], $string->matchAll('/bar/')->all());
+
+ $string = new Stringable('bar fun bar fly');
+
+ $this->assertEquals(['un', 'ly'], $string->matchAll('/f(\w*)/')->all());
+ $this->assertTrue($string->matchAll('/nothing/')->isEmpty());
+ }
+} | true |
Other | laravel | framework | acbbf272214e65f176a2b6a407201ff51729f787.json | add stringable class | src/Illuminate/Support/Str.php | @@ -41,6 +41,17 @@ class Str
*/
protected static $uuidFactory;
+ /**
+ * Get a new stringable object from the given string.
+ *
+ * @param string $string
+ * @return \Illuminate\Support\Stringable
+ */
+ public static function of($string)
+ {
+ return new Stringable($string);
+ }
+
/**
* Return the remainder of a string after the first occurrence of a given value.
* | true |
Other | laravel | framework | acbbf272214e65f176a2b6a407201ff51729f787.json | add stringable class | src/Illuminate/Support/Stringable.php | @@ -0,0 +1,523 @@
+<?php
+
+namespace Illuminate\Support;
+
+use Closure;
+use Illuminate\Support\Str;
+use Illuminate\Support\Traits\Macroable;
+
+class Stringable
+{
+ use Macroable;
+
+ /**
+ * The underlying string value.
+ *
+ * @var string
+ */
+ protected $value;
+
+ /**
+ * Create a new instance of the class.
+ *
+ * @param string $value
+ * @return void
+ */
+ public function __construct($value)
+ {
+ $this->value = (string) $value;
+ }
+
+ /**
+ * The cache of snake-cased words.
+ *
+ * @var array
+ */
+ protected static $snakeCache = [];
+
+ /**
+ * The cache of camel-cased words.
+ *
+ * @var array
+ */
+ protected static $camelCache = [];
+
+ /**
+ * The cache of studly-cased words.
+ *
+ * @var array
+ */
+ protected static $studlyCache = [];
+
+ /**
+ * The callback that should be used to generate UUIDs.
+ *
+ * @var callable
+ */
+ protected static $uuidFactory;
+
+ /**
+ * Return the remainder of a string after the first occurrence of a given value.
+ *
+ * @param string $search
+ * @return static
+ */
+ public function after($search)
+ {
+ return new static(Str::after($this->value, $search));
+ }
+
+ /**
+ * Return the remainder of a string after the last occurrence of a given value.
+ *
+ * @param string $search
+ * @return static
+ */
+ public function afterLast($search)
+ {
+ return new static(Str::afterLast($this->value, $search));
+ }
+
+ /**
+ * Append the given values to the string.
+ *
+ * @param dynamic $values
+ * @return static
+ */
+ public function append(...$values)
+ {
+ return new static($this->value.implode('', $values));
+ }
+
+ /**
+ * Transliterate a UTF-8 value to ASCII.
+ *
+ * @param string $language
+ * @return static
+ */
+ public function ascii($language = 'en')
+ {
+ return new static(Str::ascii($this->value, $language));
+ }
+
+ /**
+ * Get the portion of a string before the first occurrence of a given value.
+ *
+ * @param string $search
+ * @return static
+ */
+ public function before($search)
+ {
+ return new static(Str::before($this->value, $search));
+ }
+
+ /**
+ * Get the portion of a string before the last occurrence of a given value.
+ *
+ * @param string $search
+ * @return static
+ */
+ public function beforeLast($search)
+ {
+ return new static(Str::beforeLast($this->value, $search));
+ }
+
+ /**
+ * Convert a value to camel case.
+ *
+ * @return static
+ */
+ public function camel()
+ {
+ return new static(Str::camel($this->value));
+ }
+
+ /**
+ * Determine if a given string contains a given substring.
+ *
+ * @param string|array $needles
+ * @return bool
+ */
+ public function contains($haystack, $needles)
+ {
+ return Str::contains($this->value, $needles);
+ }
+
+ /**
+ * Determine if a given string contains all array values.
+ *
+ * @param array $needles
+ * @return bool
+ */
+ public function containsAll(array $needles)
+ {
+ return Str::containsAll($this->value, $needles);
+ }
+
+ /**
+ * Determine if a given string ends with a given substring.
+ *
+ * @param string|array $needles
+ * @return bool
+ */
+ public function endsWith($needles)
+ {
+ return Str::endsWith($this->value, $needles);
+ }
+
+ /**
+ * Determine if the string is an exact match with the given value.
+ *
+ * @param string $value
+ * @return bool
+ */
+ public function exactly($value)
+ {
+ return $this->value === $value;
+ }
+
+ /**
+ * Explode the string into an array.
+ *
+ * @param string $delimiter
+ * @param int $limit
+ * @return array
+ */
+ public function explode($delimiter, $limit = PHP_INT_MAX)
+ {
+ return explode($delimiter, $this->value, $limit);
+ }
+
+ /**
+ * Cap a string with a single instance of a given value.
+ *
+ * @param string $cap
+ * @return static
+ */
+ public function finish($cap)
+ {
+ return new static(Str::finish($this->value, $cap));
+ }
+
+ /**
+ * Determine if a given string matches a given pattern.
+ *
+ * @param string|array $pattern
+ * @return bool
+ */
+ public function is($pattern)
+ {
+ return Str::is($pattern, $this->value);
+ }
+
+ /**
+ * Determine if a given string is 7 bit ASCII.
+ *
+ * @return bool
+ */
+ public function isAscii()
+ {
+ return Str::isAscii($this->value);
+ }
+
+ /**
+ * Determine if the given string is empty.
+ *
+ * @return bool
+ */
+ public function isEmpty()
+ {
+ return empty($this->value);
+ }
+
+ /**
+ * Convert a string to kebab case.
+ *
+ * @return static
+ */
+ public function kebab()
+ {
+ return new static(Str::kebab($this->value));
+ }
+
+ /**
+ * Return the length of the given string.
+ *
+ * @param string $encoding
+ * @return int
+ */
+ public function length($encoding = null)
+ {
+ return Str::length($this->value, $encoding);
+ }
+
+ /**
+ * Limit the number of characters in a string.
+ *
+ * @param int $limit
+ * @param string $end
+ * @return static
+ */
+ public function limit($limit = 100, $end = '...')
+ {
+ return new static(Str::limit($this->value, $limit, $end));
+ }
+
+ /**
+ * Convert the given string to lower-case.
+ *
+ * @return static
+ */
+ public function lower()
+ {
+ return new static(Str::lower($this->value));
+ }
+
+ /**
+ * Limit the number of words in a string.
+ *
+ * @param int $words
+ * @param string $end
+ * @return static
+ */
+ public function words($words = 100, $end = '...')
+ {
+ return new static(Str::words($this->value, $words, $end));
+ }
+
+ /**
+ * Parse a Class@method style callback into class and method.
+ *
+ * @param string|null $default
+ * @return array
+ */
+ public function parseCallback($default = null)
+ {
+ return Str::parseCallback($this->value);
+ }
+
+ /**
+ * Get the plural form of an English word.
+ *
+ * @param int $count
+ * @return static
+ */
+ public function plural($count = 2)
+ {
+ return new static(Str::plural($this->value, $count));
+ }
+
+ /**
+ * Pluralize the last word of an English, studly caps case string.
+ *
+ * @param int $count
+ * @return static
+ */
+ public function pluralStudly($count = 2)
+ {
+ return new static(Str::pluralStudly($this->value, $count));
+ }
+
+ /**
+ * Prepend the given values to the string.
+ *
+ * @param dynamic $values
+ * @return static
+ */
+ public function prepend(...$values)
+ {
+ return new static(implode('', $values).$this->value);
+ }
+
+ /**
+ * Replace a given value in the string sequentially with an array.
+ *
+ * @param string $search
+ * @param array $replace
+ * @return static
+ */
+ public function replaceArray($search, array $replace)
+ {
+ return new static(Str::replaceArray($search, $replace, $this->value));
+ }
+
+ /**
+ * Replace the first occurrence of a given value in the string.
+ *
+ * @param string $search
+ * @param string $replace
+ * @return static
+ */
+ public function replaceFirst($search, $replace)
+ {
+ return new static(Str::replaceFirst($search, $replace, $this->value));
+ }
+
+ /**
+ * Replace the last occurrence of a given value in the string.
+ *
+ * @param string $search
+ * @param string $replace
+ * @return static
+ */
+ public function replaceLast($search, $replace)
+ {
+ return new static(Str::replaceLast($search, $replace, $this->value));
+ }
+
+ /**
+ * Replace the patterns matching the given regular expression.
+ *
+ * @param string $pattern
+ * @param \Closure|string $replace
+ * @param int $limit
+ * @return static
+ */
+ public function replaceMatches($pattern, $replace, $limit = -1)
+ {
+ if ($replace instanceof Closure) {
+ return new static(preg_replace_callback($pattern, $replace, $this->value, $limit));
+ } else {
+ return new static(preg_replace($pattern, $replace, $this->value, $limit));
+ }
+ }
+
+ /**
+ * Begin a string with a single instance of a given value.
+ *
+ * @param string $prefix
+ * @return static
+ */
+ public function start($prefix)
+ {
+ return new static(Str::start($this->value, $prefix));
+ }
+
+ /**
+ * Convert the given string to upper-case.
+ *
+ * @return static
+ */
+ public function upper()
+ {
+ return new static(Str::upper($this->value));
+ }
+
+ /**
+ * Convert the given string to title case.
+ *
+ * @return static
+ */
+ public function title()
+ {
+ return new static(Str::title($this->value));
+ }
+
+ /**
+ * Get the singular form of an English word.
+ *
+ * @return static
+ */
+ public function singular()
+ {
+ return new static(Str::singular($this->value));
+ }
+
+ /**
+ * Generate a URL friendly "slug" from a given string.
+ *
+ * @param string $separator
+ * @param string|null $language
+ * @return static
+ */
+ public function slug($separator = '-', $language = 'en')
+ {
+ return new static(Str::slug($this->value, $separator, $language));
+ }
+
+ /**
+ * Convert a string to snake case.
+ *
+ * @param string $delimiter
+ * @return static
+ */
+ public function snake($delimiter = '_')
+ {
+ return new static(Str::snake($this->value, $delimiter));
+ }
+
+ /**
+ * Determine if a given string starts with a given substring.
+ *
+ * @param string|array $needles
+ * @return bool
+ */
+ public function startsWith($needles)
+ {
+ return Str::startsWith($this->value, $needles);
+ }
+
+ /**
+ * Convert a value to studly caps case.
+ *
+ * @return static
+ */
+ public function studly()
+ {
+ return new static(Str::studly($this->value));
+ }
+
+ /**
+ * Returns the portion of string specified by the start and length parameters.
+ *
+ * @param int $start
+ * @param int|null $length
+ * @return static
+ */
+ public function substr($start, $length = null)
+ {
+ return new static(Str::substr($this->value, $start, $length));
+ }
+
+ /**
+ * Trim the string of the given characeters.
+ *
+ * @param string $characters
+ * @return static
+ */
+ public function trim($characters = null)
+ {
+ return new static(trim($this->value, $characters));
+ }
+
+ /**
+ * Make a string's first character uppercase.
+ *
+ * @return static
+ */
+ public function ucfirst()
+ {
+ return new static(Str::ucfirst($this->value));
+ }
+
+ /**
+ * Proxy dynamic properties onto methods.
+ *
+ * @param string $key
+ * @return mixed
+ */
+ public function __get($key)
+ {
+ return $this->{$key}();
+ }
+
+ /**
+ * Get the raw string value.
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->value;
+ }
+} | true |
Other | laravel | framework | d06cc79d92c18b0ff423466554eeed0aea09ae51.json | Update branch aliases | src/Illuminate/Auth/composer.json | @@ -27,7 +27,7 @@
},
"extra": {
"branch-alias": {
- "dev-master": "6.0-dev"
+ "dev-master": "6.x-dev"
}
},
"suggest": { | true |
Other | laravel | framework | d06cc79d92c18b0ff423466554eeed0aea09ae51.json | Update branch aliases | src/Illuminate/Broadcasting/composer.json | @@ -29,7 +29,7 @@
},
"extra": {
"branch-alias": {
- "dev-master": "6.0-dev"
+ "dev-master": "6.x-dev"
}
},
"suggest": { | true |
Other | laravel | framework | d06cc79d92c18b0ff423466554eeed0aea09ae51.json | Update branch aliases | src/Illuminate/Bus/composer.json | @@ -26,7 +26,7 @@
},
"extra": {
"branch-alias": {
- "dev-master": "6.0-dev"
+ "dev-master": "6.x-dev"
}
},
"config": { | true |
Other | laravel | framework | d06cc79d92c18b0ff423466554eeed0aea09ae51.json | Update branch aliases | src/Illuminate/Cache/composer.json | @@ -25,7 +25,7 @@
},
"extra": {
"branch-alias": {
- "dev-master": "6.0-dev"
+ "dev-master": "6.x-dev"
}
},
"suggest": { | true |
Other | laravel | framework | d06cc79d92c18b0ff423466554eeed0aea09ae51.json | Update branch aliases | src/Illuminate/Config/composer.json | @@ -25,7 +25,7 @@
},
"extra": {
"branch-alias": {
- "dev-master": "6.0-dev"
+ "dev-master": "6.x-dev"
}
},
"config": { | true |
Other | laravel | framework | d06cc79d92c18b0ff423466554eeed0aea09ae51.json | Update branch aliases | src/Illuminate/Console/composer.json | @@ -27,7 +27,7 @@
},
"extra": {
"branch-alias": {
- "dev-master": "6.0-dev"
+ "dev-master": "6.x-dev"
}
},
"suggest": { | true |
Other | laravel | framework | d06cc79d92c18b0ff423466554eeed0aea09ae51.json | Update branch aliases | src/Illuminate/Container/composer.json | @@ -25,7 +25,7 @@
},
"extra": {
"branch-alias": {
- "dev-master": "6.0-dev"
+ "dev-master": "6.x-dev"
}
},
"config": { | true |
Other | laravel | framework | d06cc79d92c18b0ff423466554eeed0aea09ae51.json | Update branch aliases | src/Illuminate/Contracts/composer.json | @@ -25,7 +25,7 @@
},
"extra": {
"branch-alias": {
- "dev-master": "6.0-dev"
+ "dev-master": "6.x-dev"
}
},
"config": { | true |
Other | laravel | framework | d06cc79d92c18b0ff423466554eeed0aea09ae51.json | Update branch aliases | src/Illuminate/Cookie/composer.json | @@ -27,7 +27,7 @@
},
"extra": {
"branch-alias": {
- "dev-master": "6.0-dev"
+ "dev-master": "6.x-dev"
}
},
"config": { | true |
Other | laravel | framework | d06cc79d92c18b0ff423466554eeed0aea09ae51.json | Update branch aliases | src/Illuminate/Database/composer.json | @@ -28,7 +28,7 @@
},
"extra": {
"branch-alias": {
- "dev-master": "6.0-dev"
+ "dev-master": "6.x-dev"
}
},
"suggest": { | true |
Other | laravel | framework | d06cc79d92c18b0ff423466554eeed0aea09ae51.json | Update branch aliases | src/Illuminate/Encryption/composer.json | @@ -28,7 +28,7 @@
},
"extra": {
"branch-alias": {
- "dev-master": "6.0-dev"
+ "dev-master": "6.x-dev"
}
},
"config": { | true |
Other | laravel | framework | d06cc79d92c18b0ff423466554eeed0aea09ae51.json | Update branch aliases | src/Illuminate/Events/composer.json | @@ -26,7 +26,7 @@
},
"extra": {
"branch-alias": {
- "dev-master": "6.0-dev"
+ "dev-master": "6.x-dev"
}
},
"config": { | true |
Other | laravel | framework | d06cc79d92c18b0ff423466554eeed0aea09ae51.json | Update branch aliases | src/Illuminate/Filesystem/composer.json | @@ -26,7 +26,7 @@
},
"extra": {
"branch-alias": {
- "dev-master": "6.0-dev"
+ "dev-master": "6.x-dev"
}
},
"suggest": { | true |
Other | laravel | framework | d06cc79d92c18b0ff423466554eeed0aea09ae51.json | Update branch aliases | src/Illuminate/Hashing/composer.json | @@ -25,7 +25,7 @@
},
"extra": {
"branch-alias": {
- "dev-master": "6.0-dev"
+ "dev-master": "6.x-dev"
}
},
"config": { | true |
Other | laravel | framework | d06cc79d92c18b0ff423466554eeed0aea09ae51.json | Update branch aliases | src/Illuminate/Http/composer.json | @@ -31,7 +31,7 @@
},
"extra": {
"branch-alias": {
- "dev-master": "6.0-dev"
+ "dev-master": "6.x-dev"
}
},
"config": { | true |
Other | laravel | framework | d06cc79d92c18b0ff423466554eeed0aea09ae51.json | Update branch aliases | src/Illuminate/Log/composer.json | @@ -26,7 +26,7 @@
},
"extra": {
"branch-alias": {
- "dev-master": "6.0-dev"
+ "dev-master": "6.x-dev"
}
},
"config": { | true |
Other | laravel | framework | d06cc79d92c18b0ff423466554eeed0aea09ae51.json | Update branch aliases | src/Illuminate/Mail/composer.json | @@ -32,7 +32,7 @@
},
"extra": {
"branch-alias": {
- "dev-master": "6.0-dev"
+ "dev-master": "6.x-dev"
}
},
"suggest": { | true |
Other | laravel | framework | d06cc79d92c18b0ff423466554eeed0aea09ae51.json | Update branch aliases | src/Illuminate/Notifications/composer.json | @@ -31,7 +31,7 @@
},
"extra": {
"branch-alias": {
- "dev-master": "6.0-dev"
+ "dev-master": "6.x-dev"
}
},
"suggest": { | true |
Other | laravel | framework | d06cc79d92c18b0ff423466554eeed0aea09ae51.json | Update branch aliases | src/Illuminate/Pagination/composer.json | @@ -26,7 +26,7 @@
},
"extra": {
"branch-alias": {
- "dev-master": "6.0-dev"
+ "dev-master": "6.x-dev"
}
},
"config": { | true |
Other | laravel | framework | d06cc79d92c18b0ff423466554eeed0aea09ae51.json | Update branch aliases | src/Illuminate/Pipeline/composer.json | @@ -26,7 +26,7 @@
},
"extra": {
"branch-alias": {
- "dev-master": "6.0-dev"
+ "dev-master": "6.x-dev"
}
},
"config": { | true |
Other | laravel | framework | d06cc79d92c18b0ff423466554eeed0aea09ae51.json | Update branch aliases | src/Illuminate/Queue/composer.json | @@ -34,7 +34,7 @@
},
"extra": {
"branch-alias": {
- "dev-master": "6.0-dev"
+ "dev-master": "6.x-dev"
}
},
"suggest": { | true |
Other | laravel | framework | d06cc79d92c18b0ff423466554eeed0aea09ae51.json | Update branch aliases | src/Illuminate/Redis/composer.json | @@ -29,7 +29,7 @@
},
"extra": {
"branch-alias": {
- "dev-master": "6.0-dev"
+ "dev-master": "6.x-dev"
}
},
"config": { | true |
Other | laravel | framework | d06cc79d92c18b0ff423466554eeed0aea09ae51.json | Update branch aliases | src/Illuminate/Routing/composer.json | @@ -34,7 +34,7 @@
},
"extra": {
"branch-alias": {
- "dev-master": "6.0-dev"
+ "dev-master": "6.x-dev"
}
},
"suggest": { | true |
Other | laravel | framework | d06cc79d92c18b0ff423466554eeed0aea09ae51.json | Update branch aliases | src/Illuminate/Session/composer.json | @@ -29,7 +29,7 @@
},
"extra": {
"branch-alias": {
- "dev-master": "6.0-dev"
+ "dev-master": "6.x-dev"
}
},
"suggest": { | true |
Other | laravel | framework | d06cc79d92c18b0ff423466554eeed0aea09ae51.json | Update branch aliases | src/Illuminate/Support/composer.json | @@ -34,7 +34,7 @@
},
"extra": {
"branch-alias": {
- "dev-master": "6.0-dev"
+ "dev-master": "6.x-dev"
}
},
"suggest": { | true |
Other | laravel | framework | d06cc79d92c18b0ff423466554eeed0aea09ae51.json | Update branch aliases | src/Illuminate/Translation/composer.json | @@ -27,7 +27,7 @@
},
"extra": {
"branch-alias": {
- "dev-master": "6.0-dev"
+ "dev-master": "6.x-dev"
}
},
"config": { | true |
Other | laravel | framework | d06cc79d92c18b0ff423466554eeed0aea09ae51.json | Update branch aliases | src/Illuminate/Validation/composer.json | @@ -30,7 +30,7 @@
},
"extra": {
"branch-alias": {
- "dev-master": "6.0-dev"
+ "dev-master": "6.x-dev"
}
},
"suggest": { | true |
Other | laravel | framework | d06cc79d92c18b0ff423466554eeed0aea09ae51.json | Update branch aliases | src/Illuminate/View/composer.json | @@ -30,7 +30,7 @@
},
"extra": {
"branch-alias": {
- "dev-master": "6.0-dev"
+ "dev-master": "6.x-dev"
}
},
"config": { | true |
Other | laravel | framework | aefefaf8dc2bb8f190b03f8ccbc04c730643c87b.json | Update branch aliases | src/Illuminate/Auth/composer.json | @@ -27,7 +27,7 @@
},
"extra": {
"branch-alias": {
- "dev-master": "7.0-dev"
+ "dev-master": "7.x-dev"
}
},
"suggest": { | true |
Other | laravel | framework | aefefaf8dc2bb8f190b03f8ccbc04c730643c87b.json | Update branch aliases | src/Illuminate/Broadcasting/composer.json | @@ -29,7 +29,7 @@
},
"extra": {
"branch-alias": {
- "dev-master": "7.0-dev"
+ "dev-master": "7.x-dev"
}
},
"suggest": { | true |
Other | laravel | framework | aefefaf8dc2bb8f190b03f8ccbc04c730643c87b.json | Update branch aliases | src/Illuminate/Bus/composer.json | @@ -26,7 +26,7 @@
},
"extra": {
"branch-alias": {
- "dev-master": "7.0-dev"
+ "dev-master": "7.x-dev"
}
},
"config": { | true |
Other | laravel | framework | aefefaf8dc2bb8f190b03f8ccbc04c730643c87b.json | Update branch aliases | src/Illuminate/Cache/composer.json | @@ -25,7 +25,7 @@
},
"extra": {
"branch-alias": {
- "dev-master": "7.0-dev"
+ "dev-master": "7.x-dev"
}
},
"suggest": { | true |
Other | laravel | framework | aefefaf8dc2bb8f190b03f8ccbc04c730643c87b.json | Update branch aliases | src/Illuminate/Config/composer.json | @@ -25,7 +25,7 @@
},
"extra": {
"branch-alias": {
- "dev-master": "7.0-dev"
+ "dev-master": "7.x-dev"
}
},
"config": { | true |
Other | laravel | framework | aefefaf8dc2bb8f190b03f8ccbc04c730643c87b.json | Update branch aliases | src/Illuminate/Console/composer.json | @@ -27,7 +27,7 @@
},
"extra": {
"branch-alias": {
- "dev-master": "7.0-dev"
+ "dev-master": "7.x-dev"
}
},
"suggest": { | true |
Other | laravel | framework | aefefaf8dc2bb8f190b03f8ccbc04c730643c87b.json | Update branch aliases | src/Illuminate/Container/composer.json | @@ -25,7 +25,7 @@
},
"extra": {
"branch-alias": {
- "dev-master": "7.0-dev"
+ "dev-master": "7.x-dev"
}
},
"config": { | true |
Other | laravel | framework | aefefaf8dc2bb8f190b03f8ccbc04c730643c87b.json | Update branch aliases | src/Illuminate/Contracts/composer.json | @@ -25,7 +25,7 @@
},
"extra": {
"branch-alias": {
- "dev-master": "7.0-dev"
+ "dev-master": "7.x-dev"
}
},
"config": { | true |
Other | laravel | framework | aefefaf8dc2bb8f190b03f8ccbc04c730643c87b.json | Update branch aliases | src/Illuminate/Cookie/composer.json | @@ -27,7 +27,7 @@
},
"extra": {
"branch-alias": {
- "dev-master": "7.0-dev"
+ "dev-master": "7.x-dev"
}
},
"config": { | true |
Other | laravel | framework | aefefaf8dc2bb8f190b03f8ccbc04c730643c87b.json | Update branch aliases | src/Illuminate/Database/composer.json | @@ -29,7 +29,7 @@
},
"extra": {
"branch-alias": {
- "dev-master": "7.0-dev"
+ "dev-master": "7.x-dev"
}
},
"suggest": { | true |
Other | laravel | framework | aefefaf8dc2bb8f190b03f8ccbc04c730643c87b.json | Update branch aliases | src/Illuminate/Encryption/composer.json | @@ -28,7 +28,7 @@
},
"extra": {
"branch-alias": {
- "dev-master": "7.0-dev"
+ "dev-master": "7.x-dev"
}
},
"config": { | true |
Other | laravel | framework | aefefaf8dc2bb8f190b03f8ccbc04c730643c87b.json | Update branch aliases | src/Illuminate/Events/composer.json | @@ -26,7 +26,7 @@
},
"extra": {
"branch-alias": {
- "dev-master": "7.0-dev"
+ "dev-master": "7.x-dev"
}
},
"config": { | true |
Other | laravel | framework | aefefaf8dc2bb8f190b03f8ccbc04c730643c87b.json | Update branch aliases | src/Illuminate/Filesystem/composer.json | @@ -26,7 +26,7 @@
},
"extra": {
"branch-alias": {
- "dev-master": "7.0-dev"
+ "dev-master": "7.x-dev"
}
},
"suggest": { | true |
Other | laravel | framework | aefefaf8dc2bb8f190b03f8ccbc04c730643c87b.json | Update branch aliases | src/Illuminate/Foundation/Application.php | @@ -33,7 +33,7 @@ class Application extends Container implements ApplicationContract, CachesConfig
*
* @var string
*/
- const VERSION = '7.0-dev';
+ const VERSION = '7.x-dev';
/**
* The base path for the Laravel installation. | true |
Other | laravel | framework | aefefaf8dc2bb8f190b03f8ccbc04c730643c87b.json | Update branch aliases | src/Illuminate/Hashing/composer.json | @@ -25,7 +25,7 @@
},
"extra": {
"branch-alias": {
- "dev-master": "7.0-dev"
+ "dev-master": "7.x-dev"
}
},
"config": { | true |
Other | laravel | framework | aefefaf8dc2bb8f190b03f8ccbc04c730643c87b.json | Update branch aliases | src/Illuminate/Http/composer.json | @@ -31,7 +31,7 @@
},
"extra": {
"branch-alias": {
- "dev-master": "7.0-dev"
+ "dev-master": "7.x-dev"
}
},
"config": { | true |
Other | laravel | framework | aefefaf8dc2bb8f190b03f8ccbc04c730643c87b.json | Update branch aliases | src/Illuminate/Log/composer.json | @@ -26,7 +26,7 @@
},
"extra": {
"branch-alias": {
- "dev-master": "7.0-dev"
+ "dev-master": "7.x-dev"
}
},
"config": { | true |
Other | laravel | framework | aefefaf8dc2bb8f190b03f8ccbc04c730643c87b.json | Update branch aliases | src/Illuminate/Mail/composer.json | @@ -32,7 +32,7 @@
},
"extra": {
"branch-alias": {
- "dev-master": "7.0-dev"
+ "dev-master": "7.x-dev"
}
},
"suggest": { | true |
Other | laravel | framework | aefefaf8dc2bb8f190b03f8ccbc04c730643c87b.json | Update branch aliases | src/Illuminate/Notifications/composer.json | @@ -31,7 +31,7 @@
},
"extra": {
"branch-alias": {
- "dev-master": "7.0-dev"
+ "dev-master": "7.x-dev"
}
},
"suggest": { | true |
Other | laravel | framework | aefefaf8dc2bb8f190b03f8ccbc04c730643c87b.json | Update branch aliases | src/Illuminate/Pagination/composer.json | @@ -26,7 +26,7 @@
},
"extra": {
"branch-alias": {
- "dev-master": "7.0-dev"
+ "dev-master": "7.x-dev"
}
},
"config": { | true |
Other | laravel | framework | aefefaf8dc2bb8f190b03f8ccbc04c730643c87b.json | Update branch aliases | src/Illuminate/Pipeline/composer.json | @@ -25,7 +25,7 @@
},
"extra": {
"branch-alias": {
- "dev-master": "7.0-dev"
+ "dev-master": "7.x-dev"
}
},
"config": { | true |
Other | laravel | framework | aefefaf8dc2bb8f190b03f8ccbc04c730643c87b.json | Update branch aliases | src/Illuminate/Queue/composer.json | @@ -33,7 +33,7 @@
},
"extra": {
"branch-alias": {
- "dev-master": "7.0-dev"
+ "dev-master": "7.x-dev"
}
},
"suggest": { | true |
Other | laravel | framework | aefefaf8dc2bb8f190b03f8ccbc04c730643c87b.json | Update branch aliases | src/Illuminate/Redis/composer.json | @@ -29,7 +29,7 @@
},
"extra": {
"branch-alias": {
- "dev-master": "7.0-dev"
+ "dev-master": "7.x-dev"
}
},
"config": { | true |
Other | laravel | framework | aefefaf8dc2bb8f190b03f8ccbc04c730643c87b.json | Update branch aliases | src/Illuminate/Routing/composer.json | @@ -33,7 +33,7 @@
},
"extra": {
"branch-alias": {
- "dev-master": "7.0-dev"
+ "dev-master": "7.x-dev"
}
},
"suggest": { | true |
Other | laravel | framework | aefefaf8dc2bb8f190b03f8ccbc04c730643c87b.json | Update branch aliases | src/Illuminate/Session/composer.json | @@ -29,7 +29,7 @@
},
"extra": {
"branch-alias": {
- "dev-master": "7.0-dev"
+ "dev-master": "7.x-dev"
}
},
"suggest": { | true |
Other | laravel | framework | aefefaf8dc2bb8f190b03f8ccbc04c730643c87b.json | Update branch aliases | src/Illuminate/Support/composer.json | @@ -35,7 +35,7 @@
},
"extra": {
"branch-alias": {
- "dev-master": "7.0-dev"
+ "dev-master": "7.x-dev"
}
},
"suggest": { | true |
Other | laravel | framework | aefefaf8dc2bb8f190b03f8ccbc04c730643c87b.json | Update branch aliases | src/Illuminate/Translation/composer.json | @@ -27,7 +27,7 @@
},
"extra": {
"branch-alias": {
- "dev-master": "7.0-dev"
+ "dev-master": "7.x-dev"
}
},
"config": { | true |
Other | laravel | framework | aefefaf8dc2bb8f190b03f8ccbc04c730643c87b.json | Update branch aliases | src/Illuminate/Validation/composer.json | @@ -30,7 +30,7 @@
},
"extra": {
"branch-alias": {
- "dev-master": "7.0-dev"
+ "dev-master": "7.x-dev"
}
},
"suggest": { | true |
Other | laravel | framework | aefefaf8dc2bb8f190b03f8ccbc04c730643c87b.json | Update branch aliases | src/Illuminate/View/composer.json | @@ -29,7 +29,7 @@
},
"extra": {
"branch-alias": {
- "dev-master": "7.0-dev"
+ "dev-master": "7.x-dev"
}
},
"config": { | true |
Other | laravel | framework | fb9446f27855e6fb330cf4a65f717f32bd20a4c1.json | Add redis.connection aliases in container (#31034) | src/Illuminate/Foundation/Application.php | @@ -1185,6 +1185,7 @@ public function registerCoreContainerAliases()
'queue.failer' => [\Illuminate\Queue\Failed\FailedJobProviderInterface::class],
'redirect' => [\Illuminate\Routing\Redirector::class],
'redis' => [\Illuminate\Redis\RedisManager::class, \Illuminate\Contracts\Redis\Factory::class],
+ 'redis.connection' => [\Illuminate\Redis\Connections\Connection::class, \Illuminate\Contracts\Redis\Connection::class],
'request' => [\Illuminate\Http\Request::class, \Symfony\Component\HttpFoundation\Request::class],
'router' => [\Illuminate\Routing\Router::class, \Illuminate\Contracts\Routing\Registrar::class, \Illuminate\Contracts\Routing\BindingRegistrar::class],
'session' => [\Illuminate\Session\SessionManager::class], | false |
Other | laravel | framework | 3c18d9581d75868910d047d2d135dca983660a98.json | adjust doc blocks | src/Illuminate/View/ComponentAttributeBag.php | @@ -59,7 +59,7 @@ public function only($keys)
}
/**
- * Implode the given attributes into a single HTML ready string.
+ * Merge additional attributes / values into the attribute bag.
*
* @param array $attributes
* @return static
@@ -92,10 +92,10 @@ public function setAttributes(array $attributes)
}
/**
- * Implode the given attributes into a single HTML ready string.
+ * Merge additional attributes / values into the attribute bag.
*
* @param array $attributes
- * @return string
+ * @return static
*/
public function __invoke(array $attributeDefaults = [])
{ | false |
Other | laravel | framework | 1242c57e64b1ab37096cca4d3b57e621d662ecf2.json | Apply fixes from StyleCI (#31025) | tests/View/Blade/BladeComponentTagCompilerTest.php | @@ -10,7 +10,7 @@
class BladeComponentTagCompilerTest extends AbstractBladeTestCase
{
- public function tearDown() : void
+ public function tearDown(): void
{
Mockery::close();
} | false |
Other | laravel | framework | 85c804dfb025e998e7f2e9e2f5c2ba091e60a906.json | Apply fixes from StyleCI (#31024) | src/Illuminate/View/Component.php | @@ -3,7 +3,6 @@
namespace Illuminate\View;
use Closure;
-use Illuminate\Support\HtmlString;
use Illuminate\Support\Str;
use ReflectionClass;
use ReflectionMethod; | true |
Other | laravel | framework | 85c804dfb025e998e7f2e9e2f5c2ba091e60a906.json | Apply fixes from StyleCI (#31024) | tests/View/ViewComponentAttributeBagTest.php | @@ -2,7 +2,6 @@
namespace Illuminate\Tests\View;
-use Illuminate\View\Component;
use Illuminate\View\ComponentAttributeBag;
use PHPUnit\Framework\TestCase;
| true |
Other | laravel | framework | e9d3e71d529fcb5764c7d13eaab26deca0ffe4e1.json | adjust behavior of attribute bag | src/Illuminate/View/ComponentAttributeBag.php | @@ -3,6 +3,7 @@
namespace Illuminate\View;
use ArrayAccess;
+use Illuminate\Support\Arr;
use Illuminate\Support\HtmlString;
class ComponentAttributeBag implements ArrayAccess
@@ -32,11 +33,31 @@ public function __construct(array $attributes = [])
* @param mixed $default
* @return mixed
*/
- public function only($key, $default = null)
+ public function get($key, $default = null)
{
return $this->attributes[$key] ?? value($default);
}
+ /**
+ * Get a given attribute from the attribute array.
+ *
+ * @param array|string $key
+ * @param mixed $default
+ * @return static
+ */
+ public function only($keys)
+ {
+ if (is_null($keys)) {
+ $values = $this->attributes;
+ } else {
+ $keys = Arr::wrap($keys);
+
+ $values = Arr::only($this->attributes, $keys);
+ }
+
+ return new static($values);
+ }
+
/**
* Implode the given attributes into a single HTML ready string.
*
@@ -101,7 +122,7 @@ public function offsetExists($offset)
*/
public function offsetGet($offset)
{
- return $this->only($offset);
+ return $this->get($offset);
}
/** | true |
Other | laravel | framework | e9d3e71d529fcb5764c7d13eaab26deca0ffe4e1.json | adjust behavior of attribute bag | tests/View/ViewComponentTest.php | @@ -7,14 +7,6 @@
class ViewComponentTest extends TestCase
{
- public function testAttributeRetrieval()
- {
- $component = new TestViewComponent;
- $component->withAttributes(['class' => 'font-bold', 'name' => 'test']);
-
- $this->assertEquals('class="mt-4 font-bold" name="test"', (string) $component->attributes(['class' => 'mt-4']));
- }
-
public function testDataExposure()
{
$component = new TestViewComponent; | true |
Other | laravel | framework | 4902c74f609b31835fcdf729f85d3f3e8254ae51.json | Apply fixes from StyleCI (#31022) | src/Illuminate/Foundation/Console/ComponentMakeCommand.php | @@ -65,9 +65,9 @@ protected function writeView()
file_put_contents(
$path.'.blade.php',
- "<div>
- <!-- ".Inspiring::quote()." -->
-</div>"
+ '<div>
+ <!-- '.Inspiring::quote().' -->
+</div>'
);
}
| true |
Other | laravel | framework | 4902c74f609b31835fcdf729f85d3f3e8254ae51.json | Apply fixes from StyleCI (#31022) | src/Illuminate/Foundation/Providers/ArtisanServiceProvider.php | @@ -57,8 +57,8 @@
use Illuminate\Queue\Console\FailedTableCommand;
use Illuminate\Queue\Console\FlushFailedCommand as FlushFailedQueueCommand;
use Illuminate\Queue\Console\ForgetFailedCommand as ForgetFailedQueueCommand;
-use Illuminate\Queue\Console\ListFailedCommand as ListFailedQueueCommand;
use Illuminate\Queue\Console\ListenCommand as QueueListenCommand;
+use Illuminate\Queue\Console\ListFailedCommand as ListFailedQueueCommand;
use Illuminate\Queue\Console\RestartCommand as QueueRestartCommand;
use Illuminate\Queue\Console\RetryCommand as QueueRetryCommand;
use Illuminate\Queue\Console\TableCommand; | true |
Other | laravel | framework | 4902c74f609b31835fcdf729f85d3f3e8254ae51.json | Apply fixes from StyleCI (#31022) | src/Illuminate/View/Compilers/ComponentTagCompiler.php | @@ -2,11 +2,10 @@
namespace Illuminate\View\Compilers;
+use Illuminate\Support\Str;
use InvalidArgumentException;
use ReflectionClass;
-use Illuminate\Support\Str;
-
/**
* @author Spatie bvba <info@spatie.be>
* @author Taylor Otwell <taylor@laravel.com>
@@ -152,8 +151,8 @@ protected function componentString(string $component, array $attributes)
[$data, $attributes] = $this->partitionDataAndAttributes($class, $attributes);
- return " @component('{$class}', [".$this->attributesToString($data->all())."])
-<?php \$component->withAttributes([".$this->attributesToString($attributes->all())."]); ?>";
+ return " @component('{$class}', [".$this->attributesToString($data->all()).'])
+<?php $component->withAttributes(['.$this->attributesToString($attributes->all()).']); ?>';
}
/** | true |
Other | laravel | framework | 4902c74f609b31835fcdf729f85d3f3e8254ae51.json | Apply fixes from StyleCI (#31022) | src/Illuminate/View/Compilers/Concerns/CompilesComponents.php | @@ -90,7 +90,7 @@ public function compileClassComponentClosing()
'<?php $component = $__componentOriginal'.$hash.'; ?>',
'<?php unset($__componentOriginal'.$hash.'); ?>',
'<?php endif; ?>',
- '<?php echo $__env->renderComponent(); ?>'
+ '<?php echo $__env->renderComponent(); ?>',
]);
}
| true |
Other | laravel | framework | 4902c74f609b31835fcdf729f85d3f3e8254ae51.json | Apply fixes from StyleCI (#31022) | src/Illuminate/View/Component.php | @@ -145,5 +145,4 @@ protected function ignoredMethods()
'withAttributes',
], $this->except);
}
-
} | true |
Other | laravel | framework | 4902c74f609b31835fcdf729f85d3f3e8254ae51.json | Apply fixes from StyleCI (#31022) | tests/View/Blade/BladeComponentTagCompilerTest.php | @@ -4,7 +4,6 @@
use Illuminate\View\Compilers\ComponentTagCompiler;
use Illuminate\View\Component;
-use InvalidArgumentException;
class BladeComponentTagCompilerTest extends AbstractBladeTestCase
{ | true |
Other | laravel | framework | a9f74f7e7f495f34418c1158d6c1ae3e80d3cd6d.json | make view from command | src/Illuminate/Foundation/Console/ComponentMakeCommand.php | @@ -3,6 +3,7 @@
namespace Illuminate\Foundation\Console;
use Illuminate\Console\GeneratorCommand;
+use Illuminate\Foundation\Inspiring;
use Illuminate\Support\Str;
use Symfony\Component\Console\Input\InputOption;
@@ -29,6 +30,47 @@ class ComponentMakeCommand extends GeneratorCommand
*/
protected $type = 'Component';
+ /**
+ * Execute the console command.
+ *
+ * @return void
+ */
+ public function handle()
+ {
+ if (parent::handle() === false && ! $this->option('force')) {
+ return false;
+ }
+
+ if ($this->input->getParameterOption('--view') !== false) {
+ $this->writeView();
+ }
+ }
+
+ /**
+ * Write the view for the component.
+ *
+ * @return void
+ */
+ protected function writeView()
+ {
+ $view = $this->option('view')
+ ? $this->option('view')
+ : 'components.'.Str::kebab(class_basename($this->argument('name')));
+
+ $path = resource_path('views').'/'.str_replace('.', '/', $view);
+
+ if (! $this->files->isDirectory(dirname($path))) {
+ $this->files->makeDirectory(dirname($path), 0777, true, true);
+ }
+
+ file_put_contents(
+ $path.'.blade.php',
+ "<div>
+ <!-- ".Inspiring::quote()." -->
+</div>"
+ );
+ }
+
/**
* Build the class with the given name.
*
@@ -73,6 +115,7 @@ protected function getDefaultNamespace($rootNamespace)
protected function getOptions()
{
return [
+ ['force', null, InputOption::VALUE_NONE, 'Create the class even if the component already exists'],
['view', null, InputOption::VALUE_OPTIONAL, 'Create a new Blade template for the component'],
];
} | false |
Other | laravel | framework | 1639f12de6dcea56681ea4fbcf4e72820f345a78.json | add component tests | tests/View/ViewComponentTest.php | @@ -0,0 +1,25 @@
+<?php
+
+namespace Illuminate\Tests\View;
+
+use Illuminate\View\Component;
+use PHPUnit\Framework\TestCase;
+
+class ViewFactoryTest extends TestCase
+{
+ public function testAttributeRetrieval()
+ {
+ $component = new TestViewComponent;
+ $component->withAttributes(['class' => 'font-bold', 'name' => 'test']);
+
+ $this->assertEquals('class="mt-4 font-bold" name="test"', (string) $component->attributes(['class' => 'mt-4']));
+ }
+}
+
+class TestViewComponent extends Component
+{
+ public function view()
+ {
+ return 'test';
+ }
+} | false |
Other | laravel | framework | 4c1bad1a5f2d41a9cc3765ecd90dd74e8cd7b150.json | change behavior of attributes method | src/Illuminate/View/Compilers/ComponentTagCompiler.php | @@ -74,7 +74,7 @@ protected function compileOpeningTags(string $value)
(?<attributes>
(?:
\s+
- [\w\-:]+
+ [\w\-:\.]+
(
=
(?:
@@ -115,7 +115,7 @@ protected function compileSelfClosingTags(string $value)
(?<attributes>
(?:
\s+
- [\w\-:]+
+ [\w\-:\.]+
(
=
(?:
@@ -234,7 +234,7 @@ protected function getAttributesFromAttributeString(string $attributeString)
$attributeString = $this->parseBindAttributes($attributeString);
$pattern = '/
- (?<attribute>[\w:-]+)
+ (?<attribute>[\w\.:-]+)
(
=
(?<value> | true |
Other | laravel | framework | 4c1bad1a5f2d41a9cc3765ecd90dd74e8cd7b150.json | change behavior of attributes method | src/Illuminate/View/Component.php | @@ -94,20 +94,16 @@ public function attribute($key, $default = null)
* @param array $attributes
* @return string
*/
- public function attributes(array $attributes)
+ public function attributes(array $attributeDefaults = [])
{
- return new HtmlString(collect($attributes)->map(function ($value, $key) {
- if (is_numeric($key)) {
- [$key, $value] = [$value, ''];
- }
-
- $currentValue = $this->attributes[$key] ?? '';
-
- if ($currentValue === true) {
+ return new HtmlString(collect($this->attributes)->map(function ($value, $key) use ($attributeDefaults) {
+ if ($value === true) {
return $key;
}
- return $key.'="'.str_replace('"', '\\"', trim($value.' '.$currentValue)).'"';
+ $values = collect([$attributeDefaults[$key] ?? '', $value])->filter()->unique()->join(' ');
+
+ return $key.'="'.str_replace('"', '\\"', trim($values)).'"';
})->filter()->implode(' '));
}
| true |
Other | laravel | framework | 98936eecd8c79ff6f31afe3b4596b69a878e6f92.json | Add new line per StyleCI | src/Illuminate/Routing/RoutingServiceProvider.php | @@ -130,6 +130,7 @@ protected function registerPsrRequest()
{
$this->app->bind(ServerRequestInterface::class, function ($app) {
$psr17Factory = new Psr17Factory;
+
return (new PsrHttpFactory($psr17Factory, $psr17Factory, $psr17Factory, $psr17Factory))
->createRequest($app->make('request'));
}); | false |
Other | laravel | framework | 7ff132507aa480fc53505dcee54ed341e7a35585.json | Fix use order per StyleCI | src/Illuminate/Routing/RoutingServiceProvider.php | @@ -8,10 +8,10 @@
use Illuminate\Routing\Contracts\ControllerDispatcher as ControllerDispatcherContract;
use Illuminate\Support\ServiceProvider;
use Nyholm\Psr7\Factory\Psr17Factory;
+use Nyholm\Psr7\Response as PsrResponse;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Symfony\Bridge\PsrHttpMessage\Factory\PsrHttpFactory;
-use Nyholm\Psr7\Response as PsrResponse;
class RoutingServiceProvider extends ServiceProvider
{ | false |
Other | laravel | framework | 3d432b4d3eba328ab80c9c180042385b519228c7.json | Apply fixes from StyleCI (#31014) | src/Illuminate/Foundation/Testing/Constraints/SeeInOrder.php | @@ -38,7 +38,7 @@ public function __construct($content)
* @param array $values
* @return bool
*/
- public function matches($values) : bool
+ public function matches($values): bool
{
$position = 0;
@@ -67,7 +67,7 @@ public function matches($values) : bool
* @param array $values
* @return string
*/
- public function failureDescription($values) : string
+ public function failureDescription($values): string
{
return sprintf(
'Failed asserting that \'%s\' contains "%s" in specified order.',
@@ -81,7 +81,7 @@ public function failureDescription($values) : string
*
* @return string
*/
- public function toString() : string
+ public function toString(): string
{
return (new ReflectionClass($this))->name;
} | true |
Other | laravel | framework | 3d432b4d3eba328ab80c9c180042385b519228c7.json | Apply fixes from StyleCI (#31014) | tests/Foundation/Http/Middleware/TrimStringsTest.php | @@ -9,7 +9,7 @@
class TrimStringsTest extends TestCase
{
- public function testTrimStringsIgnoringExceptAttribute() : void
+ public function testTrimStringsIgnoringExceptAttribute(): void
{
$middleware = new TrimStringsWithExceptAttribute();
$symfonyRequest = new SymfonyRequest([ | true |
Other | laravel | framework | b09b12c07c7553afcccf43982c8bd242e8d89e8d.json | add cli command for blade components | src/Illuminate/Foundation/Console/ComponentMakeCommand.php | @@ -0,0 +1,78 @@
+<?php
+
+namespace Illuminate\Foundation\Console;
+
+use Illuminate\Console\GeneratorCommand;
+use Symfony\Component\Console\Input\InputOption;
+
+class ComponentMakeCommand extends GeneratorCommand
+{
+ /**
+ * The console command name.
+ *
+ * @var string
+ */
+ protected $name = 'make:component';
+
+ /**
+ * The console command description.
+ *
+ * @var string
+ */
+ protected $description = 'Create a new view component class';
+
+ /**
+ * The type of class being generated.
+ *
+ * @var string
+ */
+ protected $type = 'Component';
+
+ /**
+ * Build the class with the given name.
+ *
+ * @param string $name
+ * @return string
+ */
+ protected function buildClass($name)
+ {
+ return str_replace(
+ 'DummyView',
+ $this->option('view'),
+ parent::buildClass($name)
+ );
+ }
+
+ /**
+ * Get the stub file for the generator.
+ *
+ * @return string
+ */
+ protected function getStub()
+ {
+ return __DIR__.'/stubs/view-component.stub';
+ }
+
+ /**
+ * Get the default namespace for the class.
+ *
+ * @param string $rootNamespace
+ * @return string
+ */
+ protected function getDefaultNamespace($rootNamespace)
+ {
+ return $rootNamespace.'\ViewComponents';
+ }
+
+ /**
+ * Get the console command options.
+ *
+ * @return array
+ */
+ protected function getOptions()
+ {
+ return [
+ ['view', null, InputOption::VALUE_OPTIONAL, 'Create a new Blade template for the component'],
+ ];
+ }
+} | true |
Other | laravel | framework | b09b12c07c7553afcccf43982c8bd242e8d89e8d.json | add cli command for blade components | src/Illuminate/Foundation/Console/stubs/view-component.stub | @@ -0,0 +1,28 @@
+<?php
+
+namespace DummyNamespace;
+
+use Illuminate\View\Component;
+
+class DummyClass extends Component
+{
+ /**
+ * Create a new component instance.
+ *
+ * @return void
+ */
+ public function __construct()
+ {
+ //
+ }
+
+ /**
+ * Get the view that represents the component.
+ *
+ * @return string
+ */
+ public function view()
+ {
+ return 'DummyView';
+ }
+} | true |
Other | laravel | framework | b09b12c07c7553afcccf43982c8bd242e8d89e8d.json | add cli command for blade components | src/Illuminate/Foundation/Providers/ArtisanServiceProvider.php | @@ -15,6 +15,7 @@
use Illuminate\Database\Console\WipeCommand;
use Illuminate\Foundation\Console\ChannelMakeCommand;
use Illuminate\Foundation\Console\ClearCompiledCommand;
+use Illuminate\Foundation\Console\ComponentMakeCommand;
use Illuminate\Foundation\Console\ConfigCacheCommand;
use Illuminate\Foundation\Console\ConfigClearCommand;
use Illuminate\Foundation\Console\ConsoleMakeCommand;
@@ -56,8 +57,8 @@
use Illuminate\Queue\Console\FailedTableCommand;
use Illuminate\Queue\Console\FlushFailedCommand as FlushFailedQueueCommand;
use Illuminate\Queue\Console\ForgetFailedCommand as ForgetFailedQueueCommand;
-use Illuminate\Queue\Console\ListenCommand as QueueListenCommand;
use Illuminate\Queue\Console\ListFailedCommand as ListFailedQueueCommand;
+use Illuminate\Queue\Console\ListenCommand as QueueListenCommand;
use Illuminate\Queue\Console\RestartCommand as QueueRestartCommand;
use Illuminate\Queue\Console\RetryCommand as QueueRetryCommand;
use Illuminate\Queue\Console\TableCommand;
@@ -119,6 +120,7 @@ class ArtisanServiceProvider extends ServiceProvider implements DeferrableProvid
protected $devCommands = [
'CacheTable' => 'command.cache.table',
'ChannelMake' => 'command.channel.make',
+ 'ComponentMake' => 'command.component.make',
'ConsoleMake' => 'command.console.make',
'ControllerMake' => 'command.controller.make',
'EventGenerate' => 'command.event.generate',
@@ -246,6 +248,18 @@ protected function registerClearResetsCommand()
});
}
+ /**
+ * Register the command.
+ *
+ * @return void
+ */
+ protected function registerComponentMakeCommand()
+ {
+ $this->app->singleton('command.component.make', function ($app) {
+ return new ComponentMakeCommand($app['files']);
+ });
+ }
+
/**
* Register the command.
* | true |
Other | laravel | framework | 7fc934449119483ae62263cc5cbd0900360812eb.json | add method to register multiple components' | src/Illuminate/View/Compilers/BladeCompiler.php | @@ -485,11 +485,13 @@ public function check($name, ...$parameters)
* Register a class-based component alias directive.
*
* @param string $class
- * @param string $alias
+ * @param string|null $alias
* @return void
*/
- public function component($class, $alias)
+ public function component($class, $alias = null)
{
+ $alias = $alias ?: strtolower(class_basename($class));
+
$this->directive($alias, function ($expression) use ($class) {
return static::compileClassComponentOpening(
$class, $expression ?: '[]', static::newComponentHash($class)
@@ -501,6 +503,23 @@ public function component($class, $alias)
});
}
+ /**
+ * Register an array of class-based components.
+ *
+ * @param array $components
+ * @return void
+ */
+ public function components(array $components)
+ {
+ foreach ($components as $key => $value) {
+ if (is_numeric($key)) {
+ static::component($value);
+ } else {
+ static::component($key, $value);
+ }
+ }
+ }
+
/**
* Register a component alias directive.
* | false |
Other | laravel | framework | 7d9c4feec50429dd3151065dbfdd45317805681d.json | use single line | src/Illuminate/View/Compilers/BladeCompiler.php | @@ -119,9 +119,7 @@ public function compile($path = null)
}
if (! is_null($this->cachePath)) {
- $contents = $this->compileString(
- $this->files->get($this->getPath())
- );
+ $contents = $this->compileString($this->files->get($this->getPath()));
if (! empty($this->getPath())) {
$contents = $this->appendFilePath($contents); | false |
Other | laravel | framework | 2d09053c86e4fd4f3718115dff263c26fb730aa0.json | Apply fixes from StyleCI (#31003) | src/Illuminate/Database/Eloquent/Builder.php | @@ -1398,17 +1398,17 @@ public static function __callStatic($method, $parameters)
*/
protected static function registerMixin($mixin, $replace)
{
- $methods = (new ReflectionClass($mixin))->getMethods(
+ $methods = (new ReflectionClass($mixin))->getMethods(
ReflectionMethod::IS_PUBLIC | ReflectionMethod::IS_PROTECTED
);
- foreach ($methods as $method) {
- if ($replace || ! static::hasGlobalMacro($method->name)) {
- $method->setAccessible(true);
+ foreach ($methods as $method) {
+ if ($replace || ! static::hasGlobalMacro($method->name)) {
+ $method->setAccessible(true);
- static::macro($method->name, $method->invoke($mixin));
- }
+ static::macro($method->name, $method->invoke($mixin));
}
+ }
}
/** | false |
Other | laravel | framework | cd2a15005648d7ae15b2a457a6a71106bd4cc95f.json | Apply fixes from StyleCI (#30988) | src/Illuminate/Foundation/Testing/Assert.php | @@ -25,15 +25,15 @@ abstract class Assert extends PHPUnit
*/
public static function assertArraySubset($subset, $array, bool $checkForIdentity = false, string $msg = ''): void
{
- if (!(is_array($subset) || $subset instanceof ArrayAccess)) {
+ if (! (is_array($subset) || $subset instanceof ArrayAccess)) {
if (class_exists(InvalidArgumentException::class)) {
throw InvalidArgumentException::create(1, 'array or ArrayAccess');
} else {
throw InvalidArgumentHelper::factory(1, 'array or ArrayAccess');
}
}
- if (!(is_array($array) || $array instanceof ArrayAccess)) {
+ if (! (is_array($array) || $array instanceof ArrayAccess)) {
if (class_exists(InvalidArgumentException::class)) {
throw InvalidArgumentException::create(2, 'array or ArrayAccess');
} else { | true |
Other | laravel | framework | cd2a15005648d7ae15b2a457a6a71106bd4cc95f.json | Apply fixes from StyleCI (#30988) | src/Illuminate/Foundation/Testing/Constraints/ArraySubset.php | @@ -74,7 +74,7 @@ public function evaluate($other, string $description = '', bool $returnResult =
return $result;
}
- if (!$result) {
+ if (! $result) {
$f = new ComparisonFailure(
$patched,
$other,
@@ -209,7 +209,7 @@ public function evaluate($other, string $description = '', bool $returnResult =
return $result;
}
- if (!$result) {
+ if (! $result) {
$f = new ComparisonFailure(
$patched,
$other, | true |
Other | laravel | framework | a1f2ef4b46347a5d35d7395997453cdcd0a1c62d.json | Apply fixes from StyleCI (#30981) | src/Illuminate/Mail/Markdown.php | @@ -8,7 +8,6 @@
use League\CommonMark\CommonMarkConverter;
use League\CommonMark\Environment;
use League\CommonMark\Ext\Table\TableExtension;
-use Parsedown;
use TijsVerkoyen\CssToInlineStyles\CssToInlineStyles;
class Markdown | false |
Other | laravel | framework | 83dfd84b3868a8eec375fb7550508b5b1b68ded3.json | use common mark for safety features | composer.json | @@ -23,6 +23,8 @@
"dragonmantank/cron-expression": "^2.0",
"egulias/email-validator": "^2.1.10",
"erusev/parsedown": "^1.7",
+ "league/commonmark": "^1.1",
+ "league/commonmark-ext-table": "^2.1",
"league/flysystem": "^1.0.8",
"monolog/monolog": "^1.12|^2.0",
"nesbot/carbon": "^2.0", | true |
Other | laravel | framework | 83dfd84b3868a8eec375fb7550508b5b1b68ded3.json | use common mark for safety features | src/Illuminate/Mail/Markdown.php | @@ -5,6 +5,9 @@
use Illuminate\Contracts\View\Factory as ViewFactory;
use Illuminate\Support\HtmlString;
use Illuminate\Support\Str;
+use League\CommonMark\CommonMarkConverter;
+use League\CommonMark\Environment;
+use League\CommonMark\Ext\Table\TableExtension;
use Parsedown;
use TijsVerkoyen\CssToInlineStyles\CssToInlineStyles;
@@ -98,9 +101,15 @@ public function renderText($view, array $data = [])
*/
public static function parse($text)
{
- $parsedown = new Parsedown;
+ $environment = Environment::createCommonMarkEnvironment();
- return new HtmlString($parsedown->text($text));
+ $environment->addExtension(new TableExtension);
+
+ $converter = new CommonMarkConverter([
+ 'allow_unsafe_links' => false,
+ ], $environment);
+
+ return new HtmlString($converter->convertToHtml($text));
}
/** | true |
Other | laravel | framework | 7cb1ff67b7cba591394760e6743710abe8959377.json | Add mixin support to Eloquent Builder | src/Illuminate/Database/Eloquent/Builder.php | @@ -13,6 +13,8 @@
use Illuminate\Support\Arr;
use Illuminate\Support\Str;
use Illuminate\Support\Traits\ForwardsCalls;
+use ReflectionClass;
+use ReflectionMethod;
/**
* @property-read HigherOrderBuilderProxy $orWhere
@@ -1372,6 +1374,24 @@ public static function __callStatic($method, $parameters)
return;
}
+ if ($method === 'mixin') {
+ $mixin = $parameters[0];
+ $replace = $parameters[1] ?? true;
+
+ $methods = (new ReflectionClass($mixin))->getMethods(
+ ReflectionMethod::IS_PUBLIC | ReflectionMethod::IS_PROTECTED
+ );
+
+ foreach ($methods as $method) {
+ if ($replace || ! static::hasMacro($method->name)) {
+ $method->setAccessible(true);
+ static::macro($method->name, $method->invoke($mixin));
+ }
+ }
+
+ return;
+ }
+
if (! static::hasGlobalMacro($method)) {
static::throwBadMethodCallException($method);
} | false |
Other | laravel | framework | 66eb5d01609f1021baed99a3f5d9d16bec6dcfcb.json | Add phpdoc hints for Request class (#30975) | src/Illuminate/Http/Request.php | @@ -12,6 +12,11 @@
use Symfony\Component\HttpFoundation\ParameterBag;
use Symfony\Component\HttpFoundation\Request as SymfonyRequest;
+/**
+ * @method array validate(array $rules, ...$params)
+ * @method array validateWithBag(array $rules, ...$params)
+ * @method string hasValidSignature(\Illuminate\Http\Request $request, bool $absolute = true)
+ */
class Request extends SymfonyRequest implements Arrayable, ArrayAccess
{
use Concerns\InteractsWithContentTypes, | false |
Other | laravel | framework | ba39f805f506a8fddbe36e957849de623e73fafb.json | Apply fixes from StyleCI (#30955) | src/Illuminate/Validation/Concerns/ValidatesAttributes.php | @@ -442,7 +442,7 @@ public function validateDifferent($attribute, $value, $parameters)
foreach ($parameters as $parameter) {
if (Arr::has($this->data, $parameter)) {
$other = Arr::get($this->data, $parameter);
-
+
if ($value === $other) {
return false;
} | false |
Other | laravel | framework | e1b8fef59f436902c34f235841303fce055dddab.json | get view data via array access | src/Illuminate/Foundation/Testing/TestResponse.php | @@ -916,13 +916,23 @@ public function assertViewMissing($key)
*/
protected function ensureResponseHasView()
{
- if (! isset($this->original) || ! $this->original instanceof View) {
+ if (! $this->responseHasView()) {
return PHPUnit::fail('The response is not a view.');
}
return $this;
}
+ /**
+ * Determine if the original response is a view.
+ *
+ * @return bool
+ */
+ protected function responseHasView()
+ {
+ return isset($this->original) && $this->original instanceof View;
+ }
+
/**
* Assert that the session has a given value.
*
@@ -1215,7 +1225,9 @@ public function __isset($key)
*/
public function offsetExists($offset)
{
- return isset($this->json()[$offset]);
+ return $this->responseHasView()
+ ? isset($this->original->gatherData()[$key])
+ : isset($this->json()[$offset]);
}
/**
@@ -1226,7 +1238,9 @@ public function offsetExists($offset)
*/
public function offsetGet($offset)
{
- return $this->json()[$offset];
+ return $this->responseHasView()
+ ? $this->viewData($offset)
+ : $this->json()[$offset];
}
/** | false |
Other | laravel | framework | fdeb204e1cd3374a71d669fd2ff08323d88c1eef.json | Add new validateWithBag macro to Request (#30896) | src/Illuminate/Foundation/Providers/FoundationServiceProvider.php | @@ -5,6 +5,7 @@
use Illuminate\Http\Request;
use Illuminate\Support\AggregateServiceProvider;
use Illuminate\Support\Facades\URL;
+use Illuminate\Validation\ValidationException;
class FoundationServiceProvider extends AggregateServiceProvider
{
@@ -54,6 +55,16 @@ public function registerRequestValidation()
Request::macro('validate', function (array $rules, ...$params) {
return validator()->validate($this->all(), $rules, ...$params);
});
+
+ Request::macro('validateWithBag', function (string $errorBag, array $rules, ...$params) {
+ try {
+ return $this->validate($rules, ...$params);
+ } catch (ValidationException $e) {
+ $e->errorBag = $errorBag;
+
+ throw $e;
+ }
+ });
}
/** | true |
Other | laravel | framework | fdeb204e1cd3374a71d669fd2ff08323d88c1eef.json | Add new validateWithBag macro to Request (#30896) | tests/Integration/Validation/RequestValidationTest.php | @@ -28,4 +28,24 @@ public function testValidateMacroWhenItFails()
$request->validate(['name' => 'string']);
}
+
+ public function testValidateWithBagMacro()
+ {
+ $request = Request::create('/', 'GET', ['name' => 'Taylor']);
+
+ $validated = $request->validateWithBag('some_bag', ['name' => 'string']);
+
+ $this->assertSame(['name' => 'Taylor'], $validated);
+ }
+
+ public function testValidateWithBagMacroWhenItFails()
+ {
+ $request = Request::create('/', 'GET', ['name' => null]);
+
+ try {
+ $request->validateWithBag('some_bag', ['name' => 'string']);
+ } catch (ValidationException $validationException) {
+ $this->assertEquals('some_bag', $validationException->errorBag);
+ }
+ }
} | true |
Other | laravel | framework | 0dd1a50f041f227e21c42f0bd92f91af9121eab8.json | add missing docblocks (#30898) | src/Illuminate/Broadcasting/Broadcasters/PusherBroadcaster.php | @@ -102,6 +102,8 @@ protected function decodePusherResponse($request, $response)
* @param string $event
* @param array $payload
* @return void
+ *
+ * @throws \Illuminate\Broadcasting\BroadcastException
*/
public function broadcast(array $channels, $event, array $payload = [])
{ | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.