implemented hashbrown assignment.
This commit is contained in:
@@ -1,4 +0,0 @@
|
|||||||
DATABASE_PASSWORD="QuaxlyQueen5012!"
|
|
||||||
IP_ADDRESS="173.255.248.228"
|
|
||||||
SPOTIFY_CLIENT_ID="ae7a0982e17e46c1a1662b5d69b70310"
|
|
||||||
SPOTIFY_CLIENT_SECRET="a2c123588a6346d381f6888eadcefafa"
|
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
* {
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
h3 {
|
||||||
|
font-size: 24px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.success,
|
||||||
|
.error {
|
||||||
|
padding: 30px;
|
||||||
|
border: 3px solid black;
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
.success {
|
||||||
|
background-color: green;
|
||||||
|
}
|
||||||
|
|
||||||
|
.error {
|
||||||
|
background-color: red;
|
||||||
|
}
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<title>Dummy Title</title>
|
||||||
|
<link href="css/styles.css" type="text/css" rel="stylesheet">
|
||||||
|
<script src="js/index.js"></script>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<h1>Hello cruel world!</h1>
|
||||||
|
<?php
|
||||||
|
if (isset($_POST['username']) && isset($_POST['password'])) {
|
||||||
|
if ($_POST['username'] == 'beavis' && $_POST['password'] == 'pass') {
|
||||||
|
echo '
|
||||||
|
<div class="success">
|
||||||
|
<h3>Access Granted</h3>
|
||||||
|
</div>
|
||||||
|
';
|
||||||
|
} else {
|
||||||
|
echo '
|
||||||
|
<div class="error">
|
||||||
|
<h3>Access Denied</h3>
|
||||||
|
</div>
|
||||||
|
';
|
||||||
|
echo form();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
echo form();
|
||||||
|
}
|
||||||
|
|
||||||
|
function form()
|
||||||
|
{
|
||||||
|
return '
|
||||||
|
<form method="post">
|
||||||
|
<label for="username">Username:</label>
|
||||||
|
<input id="username" name="username" required>
|
||||||
|
|
||||||
|
<label for="password">Password:</label>
|
||||||
|
<input type="password" id="password" name="password" required>
|
||||||
|
|
||||||
|
<input type="submit" value="Log In">
|
||||||
|
</form>
|
||||||
|
';
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<title>Dummy Title</title>
|
||||||
|
<link href="css/styles.css" type="text/css" rel="stylesheet">
|
||||||
|
<script src="js/index.js"></script>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<h1>Hello cruel world!</h1>
|
||||||
|
<?php
|
||||||
|
|
||||||
|
$user = 'beavis';
|
||||||
|
$pass = 'pass';
|
||||||
|
|
||||||
|
if (isset($_POST['username']) && isset($_POST['password'])) {
|
||||||
|
if ($_POST['username'] == $user && $_POST['password'] == $pass)
|
||||||
|
echo '<h1>Access Granted</h1>';
|
||||||
|
else
|
||||||
|
echo '<h1>Access Denied</h1>' . login_form();
|
||||||
|
} else
|
||||||
|
echo login_form();
|
||||||
|
|
||||||
|
function login_form()
|
||||||
|
{
|
||||||
|
$form = '
|
||||||
|
<form method="post">
|
||||||
|
<label for"username">Username:</label>
|
||||||
|
<input id="username" name="username" required>
|
||||||
|
|
||||||
|
<label for="password">Password:</label>
|
||||||
|
<input id="password" type="password" name="password" required>
|
||||||
|
|
||||||
|
<input type="submit">
|
||||||
|
';
|
||||||
|
|
||||||
|
return $form;
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<title>Dummy Title</title>
|
||||||
|
<link href="css/styles.css" type="text/css" rel="stylesheet">
|
||||||
|
<script src="js/index.js"></script>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<h1>Hello cruel world!</h1>
|
||||||
|
<?php
|
||||||
|
if (!empty($_POST)) {
|
||||||
|
foreach ($_POST as $key => $value) {
|
||||||
|
echo '<p>' . $value . '</p>';
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$form = '
|
||||||
|
<form method="post">
|
||||||
|
<input name="1">
|
||||||
|
<input name="2">
|
||||||
|
<input name="3">
|
||||||
|
<input name="4">
|
||||||
|
<input name="5">
|
||||||
|
|
||||||
|
<input type="submit">
|
||||||
|
</form>
|
||||||
|
';
|
||||||
|
|
||||||
|
echo $form;
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "violet/db-start",
|
|
||||||
"autoload": {
|
|
||||||
"psr-4": {
|
|
||||||
"Violet\\DbStart\\": "src/"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"authors": [
|
|
||||||
{
|
|
||||||
"name": "Joshua Ashton",
|
|
||||||
"email": "joshuatashton+dev@gmail.com"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"require": {
|
|
||||||
"vlucas/phpdotenv": "^5.6"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Generated
-479
@@ -1,479 +0,0 @@
|
|||||||
{
|
|
||||||
"_readme": [
|
|
||||||
"This file locks the dependencies of your project to a known state",
|
|
||||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
|
||||||
"This file is @generated automatically"
|
|
||||||
],
|
|
||||||
"content-hash": "0b19477b9c5e4e6bce08e35699865465",
|
|
||||||
"packages": [
|
|
||||||
{
|
|
||||||
"name": "graham-campbell/result-type",
|
|
||||||
"version": "v1.1.3",
|
|
||||||
"source": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://github.com/GrahamCampbell/Result-Type.git",
|
|
||||||
"reference": "3ba905c11371512af9d9bdd27d99b782216b6945"
|
|
||||||
},
|
|
||||||
"dist": {
|
|
||||||
"type": "zip",
|
|
||||||
"url": "https://api.github.com/repos/GrahamCampbell/Result-Type/zipball/3ba905c11371512af9d9bdd27d99b782216b6945",
|
|
||||||
"reference": "3ba905c11371512af9d9bdd27d99b782216b6945",
|
|
||||||
"shasum": ""
|
|
||||||
},
|
|
||||||
"require": {
|
|
||||||
"php": "^7.2.5 || ^8.0",
|
|
||||||
"phpoption/phpoption": "^1.9.3"
|
|
||||||
},
|
|
||||||
"require-dev": {
|
|
||||||
"phpunit/phpunit": "^8.5.39 || ^9.6.20 || ^10.5.28"
|
|
||||||
},
|
|
||||||
"type": "library",
|
|
||||||
"autoload": {
|
|
||||||
"psr-4": {
|
|
||||||
"GrahamCampbell\\ResultType\\": "src/"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"notification-url": "https://packagist.org/downloads/",
|
|
||||||
"license": [
|
|
||||||
"MIT"
|
|
||||||
],
|
|
||||||
"authors": [
|
|
||||||
{
|
|
||||||
"name": "Graham Campbell",
|
|
||||||
"email": "hello@gjcampbell.co.uk",
|
|
||||||
"homepage": "https://github.com/GrahamCampbell"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"description": "An Implementation Of The Result Type",
|
|
||||||
"keywords": [
|
|
||||||
"Graham Campbell",
|
|
||||||
"GrahamCampbell",
|
|
||||||
"Result Type",
|
|
||||||
"Result-Type",
|
|
||||||
"result"
|
|
||||||
],
|
|
||||||
"support": {
|
|
||||||
"issues": "https://github.com/GrahamCampbell/Result-Type/issues",
|
|
||||||
"source": "https://github.com/GrahamCampbell/Result-Type/tree/v1.1.3"
|
|
||||||
},
|
|
||||||
"funding": [
|
|
||||||
{
|
|
||||||
"url": "https://github.com/GrahamCampbell",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"url": "https://tidelift.com/funding/github/packagist/graham-campbell/result-type",
|
|
||||||
"type": "tidelift"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"time": "2024-07-20T21:45:45+00:00"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "phpoption/phpoption",
|
|
||||||
"version": "1.9.3",
|
|
||||||
"source": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://github.com/schmittjoh/php-option.git",
|
|
||||||
"reference": "e3fac8b24f56113f7cb96af14958c0dd16330f54"
|
|
||||||
},
|
|
||||||
"dist": {
|
|
||||||
"type": "zip",
|
|
||||||
"url": "https://api.github.com/repos/schmittjoh/php-option/zipball/e3fac8b24f56113f7cb96af14958c0dd16330f54",
|
|
||||||
"reference": "e3fac8b24f56113f7cb96af14958c0dd16330f54",
|
|
||||||
"shasum": ""
|
|
||||||
},
|
|
||||||
"require": {
|
|
||||||
"php": "^7.2.5 || ^8.0"
|
|
||||||
},
|
|
||||||
"require-dev": {
|
|
||||||
"bamarni/composer-bin-plugin": "^1.8.2",
|
|
||||||
"phpunit/phpunit": "^8.5.39 || ^9.6.20 || ^10.5.28"
|
|
||||||
},
|
|
||||||
"type": "library",
|
|
||||||
"extra": {
|
|
||||||
"bamarni-bin": {
|
|
||||||
"bin-links": true,
|
|
||||||
"forward-command": false
|
|
||||||
},
|
|
||||||
"branch-alias": {
|
|
||||||
"dev-master": "1.9-dev"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"autoload": {
|
|
||||||
"psr-4": {
|
|
||||||
"PhpOption\\": "src/PhpOption/"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"notification-url": "https://packagist.org/downloads/",
|
|
||||||
"license": [
|
|
||||||
"Apache-2.0"
|
|
||||||
],
|
|
||||||
"authors": [
|
|
||||||
{
|
|
||||||
"name": "Johannes M. Schmitt",
|
|
||||||
"email": "schmittjoh@gmail.com",
|
|
||||||
"homepage": "https://github.com/schmittjoh"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Graham Campbell",
|
|
||||||
"email": "hello@gjcampbell.co.uk",
|
|
||||||
"homepage": "https://github.com/GrahamCampbell"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"description": "Option Type for PHP",
|
|
||||||
"keywords": [
|
|
||||||
"language",
|
|
||||||
"option",
|
|
||||||
"php",
|
|
||||||
"type"
|
|
||||||
],
|
|
||||||
"support": {
|
|
||||||
"issues": "https://github.com/schmittjoh/php-option/issues",
|
|
||||||
"source": "https://github.com/schmittjoh/php-option/tree/1.9.3"
|
|
||||||
},
|
|
||||||
"funding": [
|
|
||||||
{
|
|
||||||
"url": "https://github.com/GrahamCampbell",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"url": "https://tidelift.com/funding/github/packagist/phpoption/phpoption",
|
|
||||||
"type": "tidelift"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"time": "2024-07-20T21:41:07+00:00"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "symfony/polyfill-ctype",
|
|
||||||
"version": "v1.31.0",
|
|
||||||
"source": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://github.com/symfony/polyfill-ctype.git",
|
|
||||||
"reference": "a3cc8b044a6ea513310cbd48ef7333b384945638"
|
|
||||||
},
|
|
||||||
"dist": {
|
|
||||||
"type": "zip",
|
|
||||||
"url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/a3cc8b044a6ea513310cbd48ef7333b384945638",
|
|
||||||
"reference": "a3cc8b044a6ea513310cbd48ef7333b384945638",
|
|
||||||
"shasum": ""
|
|
||||||
},
|
|
||||||
"require": {
|
|
||||||
"php": ">=7.2"
|
|
||||||
},
|
|
||||||
"provide": {
|
|
||||||
"ext-ctype": "*"
|
|
||||||
},
|
|
||||||
"suggest": {
|
|
||||||
"ext-ctype": "For best performance"
|
|
||||||
},
|
|
||||||
"type": "library",
|
|
||||||
"extra": {
|
|
||||||
"thanks": {
|
|
||||||
"url": "https://github.com/symfony/polyfill",
|
|
||||||
"name": "symfony/polyfill"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"autoload": {
|
|
||||||
"files": [
|
|
||||||
"bootstrap.php"
|
|
||||||
],
|
|
||||||
"psr-4": {
|
|
||||||
"Symfony\\Polyfill\\Ctype\\": ""
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"notification-url": "https://packagist.org/downloads/",
|
|
||||||
"license": [
|
|
||||||
"MIT"
|
|
||||||
],
|
|
||||||
"authors": [
|
|
||||||
{
|
|
||||||
"name": "Gert de Pagter",
|
|
||||||
"email": "BackEndTea@gmail.com"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Symfony Community",
|
|
||||||
"homepage": "https://symfony.com/contributors"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"description": "Symfony polyfill for ctype functions",
|
|
||||||
"homepage": "https://symfony.com",
|
|
||||||
"keywords": [
|
|
||||||
"compatibility",
|
|
||||||
"ctype",
|
|
||||||
"polyfill",
|
|
||||||
"portable"
|
|
||||||
],
|
|
||||||
"support": {
|
|
||||||
"source": "https://github.com/symfony/polyfill-ctype/tree/v1.31.0"
|
|
||||||
},
|
|
||||||
"funding": [
|
|
||||||
{
|
|
||||||
"url": "https://symfony.com/sponsor",
|
|
||||||
"type": "custom"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"url": "https://github.com/fabpot",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
|
|
||||||
"type": "tidelift"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"time": "2024-09-09T11:45:10+00:00"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "symfony/polyfill-mbstring",
|
|
||||||
"version": "v1.31.0",
|
|
||||||
"source": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://github.com/symfony/polyfill-mbstring.git",
|
|
||||||
"reference": "85181ba99b2345b0ef10ce42ecac37612d9fd341"
|
|
||||||
},
|
|
||||||
"dist": {
|
|
||||||
"type": "zip",
|
|
||||||
"url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/85181ba99b2345b0ef10ce42ecac37612d9fd341",
|
|
||||||
"reference": "85181ba99b2345b0ef10ce42ecac37612d9fd341",
|
|
||||||
"shasum": ""
|
|
||||||
},
|
|
||||||
"require": {
|
|
||||||
"php": ">=7.2"
|
|
||||||
},
|
|
||||||
"provide": {
|
|
||||||
"ext-mbstring": "*"
|
|
||||||
},
|
|
||||||
"suggest": {
|
|
||||||
"ext-mbstring": "For best performance"
|
|
||||||
},
|
|
||||||
"type": "library",
|
|
||||||
"extra": {
|
|
||||||
"thanks": {
|
|
||||||
"url": "https://github.com/symfony/polyfill",
|
|
||||||
"name": "symfony/polyfill"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"autoload": {
|
|
||||||
"files": [
|
|
||||||
"bootstrap.php"
|
|
||||||
],
|
|
||||||
"psr-4": {
|
|
||||||
"Symfony\\Polyfill\\Mbstring\\": ""
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"notification-url": "https://packagist.org/downloads/",
|
|
||||||
"license": [
|
|
||||||
"MIT"
|
|
||||||
],
|
|
||||||
"authors": [
|
|
||||||
{
|
|
||||||
"name": "Nicolas Grekas",
|
|
||||||
"email": "p@tchwork.com"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Symfony Community",
|
|
||||||
"homepage": "https://symfony.com/contributors"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"description": "Symfony polyfill for the Mbstring extension",
|
|
||||||
"homepage": "https://symfony.com",
|
|
||||||
"keywords": [
|
|
||||||
"compatibility",
|
|
||||||
"mbstring",
|
|
||||||
"polyfill",
|
|
||||||
"portable",
|
|
||||||
"shim"
|
|
||||||
],
|
|
||||||
"support": {
|
|
||||||
"source": "https://github.com/symfony/polyfill-mbstring/tree/v1.31.0"
|
|
||||||
},
|
|
||||||
"funding": [
|
|
||||||
{
|
|
||||||
"url": "https://symfony.com/sponsor",
|
|
||||||
"type": "custom"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"url": "https://github.com/fabpot",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
|
|
||||||
"type": "tidelift"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"time": "2024-09-09T11:45:10+00:00"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "symfony/polyfill-php80",
|
|
||||||
"version": "v1.31.0",
|
|
||||||
"source": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://github.com/symfony/polyfill-php80.git",
|
|
||||||
"reference": "60328e362d4c2c802a54fcbf04f9d3fb892b4cf8"
|
|
||||||
},
|
|
||||||
"dist": {
|
|
||||||
"type": "zip",
|
|
||||||
"url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/60328e362d4c2c802a54fcbf04f9d3fb892b4cf8",
|
|
||||||
"reference": "60328e362d4c2c802a54fcbf04f9d3fb892b4cf8",
|
|
||||||
"shasum": ""
|
|
||||||
},
|
|
||||||
"require": {
|
|
||||||
"php": ">=7.2"
|
|
||||||
},
|
|
||||||
"type": "library",
|
|
||||||
"extra": {
|
|
||||||
"thanks": {
|
|
||||||
"url": "https://github.com/symfony/polyfill",
|
|
||||||
"name": "symfony/polyfill"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"autoload": {
|
|
||||||
"files": [
|
|
||||||
"bootstrap.php"
|
|
||||||
],
|
|
||||||
"psr-4": {
|
|
||||||
"Symfony\\Polyfill\\Php80\\": ""
|
|
||||||
},
|
|
||||||
"classmap": [
|
|
||||||
"Resources/stubs"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"notification-url": "https://packagist.org/downloads/",
|
|
||||||
"license": [
|
|
||||||
"MIT"
|
|
||||||
],
|
|
||||||
"authors": [
|
|
||||||
{
|
|
||||||
"name": "Ion Bazan",
|
|
||||||
"email": "ion.bazan@gmail.com"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Nicolas Grekas",
|
|
||||||
"email": "p@tchwork.com"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Symfony Community",
|
|
||||||
"homepage": "https://symfony.com/contributors"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"description": "Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions",
|
|
||||||
"homepage": "https://symfony.com",
|
|
||||||
"keywords": [
|
|
||||||
"compatibility",
|
|
||||||
"polyfill",
|
|
||||||
"portable",
|
|
||||||
"shim"
|
|
||||||
],
|
|
||||||
"support": {
|
|
||||||
"source": "https://github.com/symfony/polyfill-php80/tree/v1.31.0"
|
|
||||||
},
|
|
||||||
"funding": [
|
|
||||||
{
|
|
||||||
"url": "https://symfony.com/sponsor",
|
|
||||||
"type": "custom"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"url": "https://github.com/fabpot",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
|
|
||||||
"type": "tidelift"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"time": "2024-09-09T11:45:10+00:00"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "vlucas/phpdotenv",
|
|
||||||
"version": "v5.6.1",
|
|
||||||
"source": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://github.com/vlucas/phpdotenv.git",
|
|
||||||
"reference": "a59a13791077fe3d44f90e7133eb68e7d22eaff2"
|
|
||||||
},
|
|
||||||
"dist": {
|
|
||||||
"type": "zip",
|
|
||||||
"url": "https://api.github.com/repos/vlucas/phpdotenv/zipball/a59a13791077fe3d44f90e7133eb68e7d22eaff2",
|
|
||||||
"reference": "a59a13791077fe3d44f90e7133eb68e7d22eaff2",
|
|
||||||
"shasum": ""
|
|
||||||
},
|
|
||||||
"require": {
|
|
||||||
"ext-pcre": "*",
|
|
||||||
"graham-campbell/result-type": "^1.1.3",
|
|
||||||
"php": "^7.2.5 || ^8.0",
|
|
||||||
"phpoption/phpoption": "^1.9.3",
|
|
||||||
"symfony/polyfill-ctype": "^1.24",
|
|
||||||
"symfony/polyfill-mbstring": "^1.24",
|
|
||||||
"symfony/polyfill-php80": "^1.24"
|
|
||||||
},
|
|
||||||
"require-dev": {
|
|
||||||
"bamarni/composer-bin-plugin": "^1.8.2",
|
|
||||||
"ext-filter": "*",
|
|
||||||
"phpunit/phpunit": "^8.5.34 || ^9.6.13 || ^10.4.2"
|
|
||||||
},
|
|
||||||
"suggest": {
|
|
||||||
"ext-filter": "Required to use the boolean validator."
|
|
||||||
},
|
|
||||||
"type": "library",
|
|
||||||
"extra": {
|
|
||||||
"bamarni-bin": {
|
|
||||||
"bin-links": true,
|
|
||||||
"forward-command": false
|
|
||||||
},
|
|
||||||
"branch-alias": {
|
|
||||||
"dev-master": "5.6-dev"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"autoload": {
|
|
||||||
"psr-4": {
|
|
||||||
"Dotenv\\": "src/"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"notification-url": "https://packagist.org/downloads/",
|
|
||||||
"license": [
|
|
||||||
"BSD-3-Clause"
|
|
||||||
],
|
|
||||||
"authors": [
|
|
||||||
{
|
|
||||||
"name": "Graham Campbell",
|
|
||||||
"email": "hello@gjcampbell.co.uk",
|
|
||||||
"homepage": "https://github.com/GrahamCampbell"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Vance Lucas",
|
|
||||||
"email": "vance@vancelucas.com",
|
|
||||||
"homepage": "https://github.com/vlucas"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"description": "Loads environment variables from `.env` to `getenv()`, `$_ENV` and `$_SERVER` automagically.",
|
|
||||||
"keywords": [
|
|
||||||
"dotenv",
|
|
||||||
"env",
|
|
||||||
"environment"
|
|
||||||
],
|
|
||||||
"support": {
|
|
||||||
"issues": "https://github.com/vlucas/phpdotenv/issues",
|
|
||||||
"source": "https://github.com/vlucas/phpdotenv/tree/v5.6.1"
|
|
||||||
},
|
|
||||||
"funding": [
|
|
||||||
{
|
|
||||||
"url": "https://github.com/GrahamCampbell",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"url": "https://tidelift.com/funding/github/packagist/vlucas/phpdotenv",
|
|
||||||
"type": "tidelift"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"time": "2024-07-20T21:52:34+00:00"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"packages-dev": [],
|
|
||||||
"aliases": [],
|
|
||||||
"minimum-stability": "stable",
|
|
||||||
"stability-flags": {},
|
|
||||||
"prefer-stable": false,
|
|
||||||
"prefer-lowest": false,
|
|
||||||
"platform": {},
|
|
||||||
"platform-dev": {},
|
|
||||||
"plugin-api-version": "2.6.0"
|
|
||||||
}
|
|
||||||
Executable
+139
@@ -0,0 +1,139 @@
|
|||||||
|
<?php
|
||||||
|
// Form handling
|
||||||
|
include_once 'includes/init.php';
|
||||||
|
|
||||||
|
if (isset($_POST['form_id'])) {
|
||||||
|
switch ($_POST['form_id']) {
|
||||||
|
case 'login':
|
||||||
|
$result = auth_user($_POST['username'], $_POST['password']);
|
||||||
|
if ($result === true)
|
||||||
|
header('Location: .');
|
||||||
|
else
|
||||||
|
$err = $result;
|
||||||
|
break;
|
||||||
|
case 'signup':
|
||||||
|
$result = create_user($_POST['username'], $_POST['password'], $_POST['v_password']);
|
||||||
|
if ($result === true)
|
||||||
|
header('Location: account.php?view=signup_success');
|
||||||
|
else
|
||||||
|
$err = $result;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// HTML Generation
|
||||||
|
include_once 'includes/head.php';
|
||||||
|
|
||||||
|
if (isset($_GET['action']) && $_GET['action'] == 'logout')
|
||||||
|
logout();
|
||||||
|
|
||||||
|
if (!isset($_GET['view']) && !isset($_SESSION['hashbrown_access']))
|
||||||
|
$view = 'login';
|
||||||
|
else
|
||||||
|
$view = $_GET['view'];
|
||||||
|
|
||||||
|
echo '<div class="content">';
|
||||||
|
|
||||||
|
switch ($view) {
|
||||||
|
case 'login':
|
||||||
|
echo login((isset($err) ? $err : ''));
|
||||||
|
break;
|
||||||
|
case 'signup':
|
||||||
|
echo signup((isset($err) ? $err : ''));
|
||||||
|
break;
|
||||||
|
case 'display':
|
||||||
|
echo display();
|
||||||
|
break;
|
||||||
|
case 'signup_success':
|
||||||
|
echo signup_success();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
echo '</div>';
|
||||||
|
|
||||||
|
include_once 'includes/foot.php';
|
||||||
|
|
||||||
|
function login($err = null)
|
||||||
|
{
|
||||||
|
$form = '
|
||||||
|
<form method="post" class="card">
|
||||||
|
<input type="hidden" name="form_id" value="login">
|
||||||
|
|
||||||
|
<label for="username">Username:</label>
|
||||||
|
<input id="username" type="text" name="username"' . (isset($_POST['username']) ? ' value="' . $_POST['username'] . '"' : '') . ' required>
|
||||||
|
|
||||||
|
<label for="password">Password:</label>
|
||||||
|
<input id="password" type="password" name="password"' . (isset($_POST['password']) ? ' value="' . $_POST['password'] . '"' : '') . ' required>
|
||||||
|
|
||||||
|
<a href="account.php?view=signup">Or signup instead</a>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<input type="reset" class="reset button">
|
||||||
|
<input type="submit" class="success button">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
' . $err . '
|
||||||
|
</form>
|
||||||
|
';
|
||||||
|
|
||||||
|
return $form;
|
||||||
|
}
|
||||||
|
|
||||||
|
function signup($err = null)
|
||||||
|
{
|
||||||
|
$form = '
|
||||||
|
<form method="post" class="card">
|
||||||
|
<input type="hidden" name="form_id" value="signup">
|
||||||
|
|
||||||
|
<label for="username">Username:</label>
|
||||||
|
<input id="username" type="text" name="username"' . (isset($_POST['username']) ? ' value="' . $_POST['username'] . '"' : '') . ' required>
|
||||||
|
|
||||||
|
<label for="password">Password:</label>
|
||||||
|
<input id="password" type="password" name="password"' . (isset($_POST['password']) ? ' value="' . $_POST['password'] . '"' : '') . ' required>
|
||||||
|
|
||||||
|
<label for="v_password">Verify Password:</label>
|
||||||
|
<input id="v_password" type="password" name="v_password"' . (isset($_POST['v_password']) ? ' value="' . $_POST['v_password'] . '"' : '') . ' required>
|
||||||
|
|
||||||
|
<a href="account.php?view=login">Or login instead</a>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<input type="reset" class="reset button">
|
||||||
|
<input type="submit" class="success button">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
' . $err . '
|
||||||
|
</form>
|
||||||
|
';
|
||||||
|
|
||||||
|
return $form;
|
||||||
|
}
|
||||||
|
|
||||||
|
function signup_success()
|
||||||
|
{
|
||||||
|
$display = '
|
||||||
|
<div class="card success">
|
||||||
|
<h3>Account creation success!</h3>
|
||||||
|
<p><a href="account.php?view=login">Login</a> to get started.</p>
|
||||||
|
</div>
|
||||||
|
';
|
||||||
|
|
||||||
|
return $display;
|
||||||
|
}
|
||||||
|
|
||||||
|
function display()
|
||||||
|
{
|
||||||
|
$display = '
|
||||||
|
<h1>Account</h1>
|
||||||
|
|
||||||
|
<div class="content">
|
||||||
|
<div class="card">
|
||||||
|
<div class="row space_between">
|
||||||
|
<h3>' . $_SESSION['username'] . '</h3>
|
||||||
|
<img src="' . get_user_image() . '">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
';
|
||||||
|
|
||||||
|
return $display;
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"name": "violet/hashbrown",
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"Violet\\Hashbrown\\": "src/"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"vlucas/phpdotenv": "^5.6"
|
||||||
|
}
|
||||||
|
}
|
||||||
Executable
Executable
+214
@@ -0,0 +1,214 @@
|
|||||||
|
/********** GENERAL **********/
|
||||||
|
* {
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
box-sizing: border-box;
|
||||||
|
transition-duration: 500ms;
|
||||||
|
}
|
||||||
|
|
||||||
|
body {
|
||||||
|
/* Positioning */
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
|
||||||
|
/* Styling */
|
||||||
|
background-color: #bbedbe;
|
||||||
|
}
|
||||||
|
|
||||||
|
h1 {
|
||||||
|
/* Positioning */
|
||||||
|
width: 100%;
|
||||||
|
padding: 2vw;
|
||||||
|
|
||||||
|
/* Font */
|
||||||
|
font-size: 6vw;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
h3 {
|
||||||
|
font-size: 4vw;
|
||||||
|
}
|
||||||
|
|
||||||
|
h5,
|
||||||
|
label {
|
||||||
|
font-size: 2vw;
|
||||||
|
}
|
||||||
|
|
||||||
|
h1,
|
||||||
|
h3,
|
||||||
|
h5,
|
||||||
|
p,
|
||||||
|
nav ul li a,
|
||||||
|
a,
|
||||||
|
input {
|
||||||
|
color: #0e3610;
|
||||||
|
}
|
||||||
|
|
||||||
|
a:hover {
|
||||||
|
color: #1c6b20;
|
||||||
|
}
|
||||||
|
|
||||||
|
/********** NAV **********/
|
||||||
|
nav {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
nav ul {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
justify-content: left;
|
||||||
|
}
|
||||||
|
|
||||||
|
nav ul li {
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
|
||||||
|
nav ul li a {
|
||||||
|
font-size: 2vw;
|
||||||
|
font-weight: 800;
|
||||||
|
|
||||||
|
text-decoration: none;
|
||||||
|
display: block;
|
||||||
|
padding: 15px;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
nav ul li a:hover {
|
||||||
|
transform: scale(1.2);
|
||||||
|
}
|
||||||
|
|
||||||
|
nav ul li a.active {
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
|
||||||
|
/********** GENERAL **********/
|
||||||
|
|
||||||
|
.content {
|
||||||
|
width: 80%;
|
||||||
|
margin: 0 auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
form {
|
||||||
|
/* Form Shape */
|
||||||
|
width: 60%;
|
||||||
|
padding: 2.5vw 5vw 2.5vw 5vw;
|
||||||
|
|
||||||
|
/* Positioning */
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.row {
|
||||||
|
/* Row Shape */
|
||||||
|
width: 100%;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
}
|
||||||
|
|
||||||
|
.space_between {
|
||||||
|
justify-content: space-between;
|
||||||
|
}
|
||||||
|
|
||||||
|
input {
|
||||||
|
/* Input Shape */
|
||||||
|
width: 50%;
|
||||||
|
padding: 1vw;
|
||||||
|
margin: 1vw;
|
||||||
|
border-radius: 18px;
|
||||||
|
border: none;
|
||||||
|
|
||||||
|
/* Styling */
|
||||||
|
background-color: #f1fbf2;
|
||||||
|
|
||||||
|
/* Font */
|
||||||
|
font-size: 1vw;
|
||||||
|
font-weight: 400;
|
||||||
|
}
|
||||||
|
|
||||||
|
input[type="text"],
|
||||||
|
input[type="password"] {
|
||||||
|
border: 2px solid #0e3610;
|
||||||
|
}
|
||||||
|
|
||||||
|
button {
|
||||||
|
/* Button Shape */
|
||||||
|
width: 60%;
|
||||||
|
padding: 1vw;
|
||||||
|
margin: 1vw;
|
||||||
|
border: none;
|
||||||
|
border-radius: 18px;
|
||||||
|
|
||||||
|
/* Font */
|
||||||
|
color: white;
|
||||||
|
font-size: 1vw;
|
||||||
|
font-weight: 600;
|
||||||
|
|
||||||
|
background-color: #1c6b20;
|
||||||
|
}
|
||||||
|
|
||||||
|
button:hover {
|
||||||
|
background-color: #26942D;
|
||||||
|
}
|
||||||
|
|
||||||
|
table {
|
||||||
|
border-spacing: 0;
|
||||||
|
table-layout: auto;
|
||||||
|
width: 90%;
|
||||||
|
border: 1px solid black;
|
||||||
|
}
|
||||||
|
|
||||||
|
td {
|
||||||
|
margin: 0;
|
||||||
|
padding: 1vw;
|
||||||
|
border: 1px solid black;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.card {
|
||||||
|
padding: 50px;
|
||||||
|
background-color: white;
|
||||||
|
border-radius: 18px;
|
||||||
|
width: 80%;
|
||||||
|
margin: 0 auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.center {
|
||||||
|
margin: 0 auto;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.card.error {
|
||||||
|
width: 30%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.error,
|
||||||
|
.error *,
|
||||||
|
.reset,
|
||||||
|
.reset * {
|
||||||
|
color: white;
|
||||||
|
background-color: red;
|
||||||
|
font-weight: 800;
|
||||||
|
}
|
||||||
|
|
||||||
|
.success {
|
||||||
|
color: white;
|
||||||
|
background-color: #0e3610;
|
||||||
|
}
|
||||||
|
|
||||||
|
.success * {
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
.success:hover {
|
||||||
|
background-color: #1c6b20;
|
||||||
|
}
|
||||||
|
|
||||||
|
img {
|
||||||
|
width: 250px;
|
||||||
|
height: auto;
|
||||||
|
border-radius: 50%;
|
||||||
|
}
|
||||||
Executable
Executable
BIN
Binary file not shown.
|
After Width: | Height: | Size: 90 KiB |
Executable
BIN
Binary file not shown.
|
After Width: | Height: | Size: 11 KiB |
Executable
BIN
Binary file not shown.
|
After Width: | Height: | Size: 84 KiB |
Executable
BIN
Binary file not shown.
|
After Width: | Height: | Size: 10 KiB |
Executable
+1
@@ -0,0 +1 @@
|
|||||||
|
skinner,gatekeeper||>><<||csm,alien||>><<||dana,skeptic||>><<||fox,believer
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
</body>
|
||||||
|
|
||||||
|
<footer></footer>
|
||||||
|
|
||||||
|
</html>
|
||||||
Executable
+189
@@ -0,0 +1,189 @@
|
|||||||
|
<?php
|
||||||
|
// Use environment variables for the database password and IP address.
|
||||||
|
$db_pass = $_ENV['DATABASE_PASSWORD'];
|
||||||
|
$ip_addr = $_ENV['IP_ADDRESS'];
|
||||||
|
|
||||||
|
// Make some constants
|
||||||
|
define('HOST', 'localhost');
|
||||||
|
define('USER', 'root');
|
||||||
|
define('PASS', $db_pass);
|
||||||
|
define('DB', 'secureusers');
|
||||||
|
|
||||||
|
function table_from_file($file)
|
||||||
|
{
|
||||||
|
$file = 'includes/' . $file;
|
||||||
|
$fs = fopen($file, 'r');
|
||||||
|
$string = fread($fs, filesize($file));
|
||||||
|
$values = explode('||>><<||', $string);
|
||||||
|
|
||||||
|
$table = '
|
||||||
|
<div class="card center">
|
||||||
|
<table class="center">
|
||||||
|
<tr>
|
||||||
|
<th>Agent</th>
|
||||||
|
<th>Codename</th>
|
||||||
|
</tr>
|
||||||
|
';
|
||||||
|
|
||||||
|
foreach ($values as $v) {
|
||||||
|
list($a, $b) = explode(',', $v);
|
||||||
|
|
||||||
|
$table .= '
|
||||||
|
<tr>
|
||||||
|
<td>' . ucfirst($a) . '</td>
|
||||||
|
<td>' . ucwords($b) . '</td>
|
||||||
|
</tr>
|
||||||
|
';
|
||||||
|
}
|
||||||
|
$table .= '</div></table>';
|
||||||
|
|
||||||
|
return $table;
|
||||||
|
}
|
||||||
|
|
||||||
|
function salt_and_hash($pw)
|
||||||
|
{
|
||||||
|
$salt = 'fdiojhlkjasdfjh';
|
||||||
|
$o_salt = 'qwelnbfnvaslkfj';
|
||||||
|
|
||||||
|
$pw = $salt . $pw . $o_salt;
|
||||||
|
return hash('sha512', $pw);
|
||||||
|
}
|
||||||
|
|
||||||
|
function increment_login_count($id)
|
||||||
|
{
|
||||||
|
p_query('UPDATE users SET login_count = login_count + 1 WHERE id = ?', 'i', $id);
|
||||||
|
}
|
||||||
|
|
||||||
|
function auth_user($username, $password)
|
||||||
|
{
|
||||||
|
$results = p_query('SELECT id, password FROM users WHERE username = ?', 's', $_POST['username'])->fetch_assoc();
|
||||||
|
|
||||||
|
if (!$results) {
|
||||||
|
return '
|
||||||
|
<div class="card error">
|
||||||
|
<p>Username or Password is incorrect!</p>
|
||||||
|
</div>
|
||||||
|
';
|
||||||
|
} else {
|
||||||
|
if ($results['password'] == salt_and_hash($password)) {
|
||||||
|
$_SESSION['hashbrown_access'] = true;
|
||||||
|
$_SESSION['username'] = $username;
|
||||||
|
increment_login_count($results['id']);
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
if (isset($_SESSION['login_attempts']))
|
||||||
|
$_SESSION['login_attempts']++;
|
||||||
|
else
|
||||||
|
$_SESSION['login_attempts'] = 1;
|
||||||
|
|
||||||
|
if ($_SESSION['login_attempts'] >= 3) {
|
||||||
|
return '
|
||||||
|
<div class="card error">
|
||||||
|
<p>Reached 3+ failed login attempts!</p>
|
||||||
|
</div>
|
||||||
|
';
|
||||||
|
} else {
|
||||||
|
return '
|
||||||
|
<div class="card error">
|
||||||
|
<p>Username or Password is incorrect!</p>
|
||||||
|
</div>
|
||||||
|
';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function create_user($username, $password, $v_password)
|
||||||
|
{
|
||||||
|
if ($password != $v_password) {
|
||||||
|
return '
|
||||||
|
<div class="card error">
|
||||||
|
<p>Passwords do not match!</p>
|
||||||
|
</div>
|
||||||
|
';
|
||||||
|
}
|
||||||
|
|
||||||
|
$exists = p_query('SELECT username FROM users WHERE username = ?', 's', $username)->fetch_assoc();
|
||||||
|
if ($exists) {
|
||||||
|
return '
|
||||||
|
<div class="card error">
|
||||||
|
<p>Username is taken!</p>
|
||||||
|
</div>
|
||||||
|
';
|
||||||
|
}
|
||||||
|
|
||||||
|
$user = p_query('INSERT INTO users (username, password) VALUES (?, ?)', 'ss', $username, salt_and_hash($password));
|
||||||
|
if (!$user) {
|
||||||
|
return '
|
||||||
|
<div class="card error">
|
||||||
|
<p>Unable to create user!</p>
|
||||||
|
</div>
|
||||||
|
';
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function logout()
|
||||||
|
{
|
||||||
|
foreach (array_keys($_SESSION) as $key)
|
||||||
|
unset($_SESSION[$key]);
|
||||||
|
|
||||||
|
header('Location: .');
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_user_image()
|
||||||
|
{
|
||||||
|
$result = p_query('SELECT image_path FROM users WHERE username = ?', 's', $_SESSION['username'])->fetch_assoc();
|
||||||
|
return 'img/' . $result['image_path'];
|
||||||
|
}
|
||||||
|
|
||||||
|
function update_user_pw($password, $v_password)
|
||||||
|
{
|
||||||
|
if ($password != $v_password) {
|
||||||
|
return '
|
||||||
|
<div class="card error">
|
||||||
|
<p>Passwords do not match!</p>
|
||||||
|
</div>
|
||||||
|
';
|
||||||
|
}
|
||||||
|
|
||||||
|
$result = p_query('UPDATE users SET password = ? WHERE username = ?', 'ss', salt_and_hash($password), $_SESSION['username']);
|
||||||
|
if ($result) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function query($stmt)
|
||||||
|
{
|
||||||
|
$conn = new mysqli(HOST, USER, PASS, DB);
|
||||||
|
$result = $conn->query($stmt);
|
||||||
|
if ($result)
|
||||||
|
return $result;
|
||||||
|
else
|
||||||
|
return mysqli_insert_id($conn);
|
||||||
|
}
|
||||||
|
|
||||||
|
function p_query($stmt, $types, ...$args)
|
||||||
|
{
|
||||||
|
$conn = new mysqli(HOST, USER, PASS, DB);
|
||||||
|
|
||||||
|
$stmt = $conn->prepare($stmt);
|
||||||
|
$stmt->bind_param($types, ...$args);
|
||||||
|
$stmt->execute();
|
||||||
|
|
||||||
|
$result = $stmt->get_result();
|
||||||
|
if ($result)
|
||||||
|
return $result;
|
||||||
|
else
|
||||||
|
return mysqli_insert_id($conn);
|
||||||
|
}
|
||||||
|
|
||||||
|
function pretty_dump($arg)
|
||||||
|
{
|
||||||
|
echo '<pre>';
|
||||||
|
print_r($arg);
|
||||||
|
echo '</pre>';
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
<?php include_once 'includes/nav.php'; ?>
|
||||||
|
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<title>Hashbrowns</title>
|
||||||
|
<link href="css/styles.css" type="text/css" rel="stylesheet">
|
||||||
|
<script src="js/index.js"></script>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<?php echo nav(); ?>
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
<?php
|
||||||
|
session_start();
|
||||||
|
require_once 'vendor/autoload.php';
|
||||||
|
|
||||||
|
$dotenv = Dotenv\Dotenv::createImmutable(__DIR__ . '/../');
|
||||||
|
$dotenv->safeLoad();
|
||||||
|
|
||||||
|
require_once 'includes/functions.php';
|
||||||
Executable
+26
@@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
function nav()
|
||||||
|
{
|
||||||
|
$nav = '
|
||||||
|
<nav>
|
||||||
|
<ul>
|
||||||
|
<li><a href="index.php"' . ($_SERVER['SCRIPT_NAME'] == '/index.php' ? ' class="active"' : '') . '>Home</a></li>
|
||||||
|
';
|
||||||
|
|
||||||
|
if (isset($_SESSION['hashbrown_access']) && $_SESSION['hashbrown_access']) {
|
||||||
|
$nav .= '
|
||||||
|
<li><a href="account.php?view=display"' . ($_SERVER['SCRIPT_NAME'] == '/account.php' ? ' class="active"' : '') . '>Account</a></li>
|
||||||
|
<li><a href="users.php"' . ($_SERVER['SCRIPT_NAME'] == '/users.php' ? ' class="active"' : '') . '>Users</a></li>
|
||||||
|
<li><a href="video.php"' . ($_SERVER['SCRIPT_NAME'] == '/video.php' ? ' class="active"' : '') . '>Video</a></li>
|
||||||
|
<li><a href="account.php?action=logout">Logout</a></li>
|
||||||
|
';
|
||||||
|
}
|
||||||
|
|
||||||
|
$nav .= '
|
||||||
|
</ul>
|
||||||
|
</nav>
|
||||||
|
';
|
||||||
|
|
||||||
|
return $nav;
|
||||||
|
}
|
||||||
Executable
+1
@@ -0,0 +1 @@
|
|||||||
|
dale,the government||>><<||bill,the barber||>><<||hank,the texan||>><<||boomhauer,the marshall
|
||||||
Executable
+29
@@ -0,0 +1,29 @@
|
|||||||
|
<?php
|
||||||
|
include_once 'includes/init.php';
|
||||||
|
|
||||||
|
if (!isset($_SESSION['hashbrown_access']) || !$_SESSION['hashbrown_access'])
|
||||||
|
header('Location: account.php?view=login');
|
||||||
|
|
||||||
|
include_once 'includes/head.php';
|
||||||
|
|
||||||
|
echo '<div id="content">';
|
||||||
|
echo getHome((isset($_GET['file']) ? $_GET['file'] : 'fbi.txt'));
|
||||||
|
echo '</div>';
|
||||||
|
|
||||||
|
include_once 'includes/foot.php';
|
||||||
|
|
||||||
|
function getHome($file)
|
||||||
|
{
|
||||||
|
$view = '
|
||||||
|
<h1>View Confidential Information</h1>
|
||||||
|
<form method="get" class="center">
|
||||||
|
<div class="row">
|
||||||
|
<button name="file" value="fbi.txt">FBI</button>
|
||||||
|
<button name="file" value="spies.txt">Spies</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
' . table_from_file($file) . '
|
||||||
|
';
|
||||||
|
|
||||||
|
return $view;
|
||||||
|
}
|
||||||
Executable
Executable
@@ -0,0 +1,32 @@
|
|||||||
|
<?php
|
||||||
|
include_once 'includes/init.php';
|
||||||
|
|
||||||
|
if (!isset($_SESSION['hashbrown_access']) || !$_SESSION['hashbrown_access'])
|
||||||
|
header('Location: account.php?view=login');
|
||||||
|
|
||||||
|
$users = query('SELECT * FROM users');
|
||||||
|
|
||||||
|
include_once 'includes/head.php';
|
||||||
|
echo '
|
||||||
|
<div class="card">
|
||||||
|
<h3 class="center">Users</h3>
|
||||||
|
<table class="center">
|
||||||
|
<tr>
|
||||||
|
<th>ID</th>
|
||||||
|
<th>Username</th>
|
||||||
|
<th>Password</th>
|
||||||
|
</tr>
|
||||||
|
';
|
||||||
|
|
||||||
|
foreach ($users as $u) {
|
||||||
|
echo '
|
||||||
|
<tr>
|
||||||
|
<td>' . $u['id'] . '</td>
|
||||||
|
<td>' . $u['username'] . '</td>
|
||||||
|
<td>' . $u['password'] . '</td>
|
||||||
|
</tr>
|
||||||
|
';
|
||||||
|
}
|
||||||
|
echo '</div></table>';
|
||||||
|
|
||||||
|
include_once 'includes/foot.php';
|
||||||
Executable
+13
@@ -0,0 +1,13 @@
|
|||||||
|
<?php
|
||||||
|
include_once 'includes/init.php';
|
||||||
|
|
||||||
|
if (!isset($_SESSION['hashbrown_access']) || !$_SESSION['hashbrown_access'])
|
||||||
|
header('Location: account.php?view=login');
|
||||||
|
|
||||||
|
include_once 'includes/functions.php';
|
||||||
|
include_once 'includes/head.php';
|
||||||
|
|
||||||
|
echo '<h1>YouTube Video</h1>';
|
||||||
|
echo '<iframe width="560" height="315" src="https://www.youtube.com/embed/8BIcAZxFfrc?si=DMccopjQMFNs361I" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>';
|
||||||
|
|
||||||
|
include_once 'includes/foot.php';
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
body {
|
||||||
|
background-color: black;
|
||||||
|
}
|
||||||
|
|
||||||
|
h1,
|
||||||
|
p,
|
||||||
|
input,
|
||||||
|
.cell {
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cell {
|
||||||
|
background-color: black;
|
||||||
|
outline: none;
|
||||||
|
border: 1px solid white;
|
||||||
|
transition-duration: 500ms;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cell:hover {
|
||||||
|
background-color: orange;
|
||||||
|
}
|
||||||
|
|
||||||
|
.button {
|
||||||
|
padding: 15px;
|
||||||
|
margin: 35px;
|
||||||
|
border: 3px solid white;
|
||||||
|
border-radius: 9px;
|
||||||
|
background-color: transparent;
|
||||||
|
transition-duration: 500ms;
|
||||||
|
}
|
||||||
|
|
||||||
|
.button:hover {
|
||||||
|
background-color: orange;
|
||||||
|
}
|
||||||
|
|
||||||
|
#content {
|
||||||
|
margin: 35px;
|
||||||
|
width: 40%;
|
||||||
|
margin: 0 auto;
|
||||||
|
border: 3px solid white;
|
||||||
|
border-radius: 18px;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.row {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-evenly;
|
||||||
|
}
|
||||||
@@ -0,0 +1,127 @@
|
|||||||
|
<?php
|
||||||
|
session_start();
|
||||||
|
place_hurkle();
|
||||||
|
if (!isset($_SESSION['size']))
|
||||||
|
$_SESSION['size'] = 10;
|
||||||
|
?>
|
||||||
|
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<title>Hurkle</title>
|
||||||
|
<link href="css/styles.css" type="text/css" rel="stylesheet">
|
||||||
|
<script src="js/index.js"></script>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<?php
|
||||||
|
function evaluate_input()
|
||||||
|
{
|
||||||
|
if (isset($_POST['position'])) {
|
||||||
|
echo '<p>Hurkle position: ' . $_SESSION['x'] . ':' . $_SESSION['y'] . '</p>';
|
||||||
|
[$x, $y] = explode(':', $_POST['position']);
|
||||||
|
|
||||||
|
if ($x == $_SESSION['x'] && $y == $_SESSION['y'])
|
||||||
|
echo '<p>You found the Hurkle!</p>';
|
||||||
|
else {
|
||||||
|
$direction = '';
|
||||||
|
if ($y < $_SESSION['y'])
|
||||||
|
$direction .= 'South';
|
||||||
|
else if ($y > $_SESSION['y'])
|
||||||
|
$direction .= 'North';
|
||||||
|
|
||||||
|
if ($x < $_SESSION['x'])
|
||||||
|
$direction .= 'East';
|
||||||
|
if ($x > $_SESSION['x'])
|
||||||
|
$direction .= 'West';
|
||||||
|
|
||||||
|
echo '<p>Hurkle is ' . $direction . '</p>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($_POST['reset'])) {
|
||||||
|
reset_session();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($_GET['size'])) {
|
||||||
|
$_SESSION['size'] = $_GET['size'];
|
||||||
|
reset_session();
|
||||||
|
header('Location: .');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
evaluate_input();
|
||||||
|
|
||||||
|
echo '
|
||||||
|
<div id="content">
|
||||||
|
<h1>Hurkle</h1>
|
||||||
|
';
|
||||||
|
echo generate_grid();
|
||||||
|
echo bottom_bar();
|
||||||
|
echo '</div>';
|
||||||
|
|
||||||
|
function bottom_bar()
|
||||||
|
{
|
||||||
|
$forms = '
|
||||||
|
<div class="row">
|
||||||
|
<form method="get">
|
||||||
|
<select name="size" id="size">
|
||||||
|
';
|
||||||
|
|
||||||
|
for ($i = 2; $i < 12; $i++)
|
||||||
|
$forms .= '<option value="' . $i . '">' . $i . '</option>';
|
||||||
|
|
||||||
|
$forms .= '
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<input type="submit" class="button">
|
||||||
|
</form>
|
||||||
|
<form method="post">
|
||||||
|
<input type="submit" name="reset" value="Restart" class="button">
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
';
|
||||||
|
|
||||||
|
return $forms;
|
||||||
|
}
|
||||||
|
|
||||||
|
function reset_session()
|
||||||
|
{
|
||||||
|
unset($_SESSION['x']);
|
||||||
|
unset($_SESSION['y']);
|
||||||
|
place_hurkle();
|
||||||
|
}
|
||||||
|
|
||||||
|
function generate_grid()
|
||||||
|
{
|
||||||
|
$grid = '
|
||||||
|
<form method="post" style="display: grid; grid-template-columns: repeat(' . $_SESSION['size'] . ', 50px); grid-template-rows: repeat(' . $_SESSION['size'] . ', 50px);">
|
||||||
|
';
|
||||||
|
|
||||||
|
for ($i = 0; $i < $_SESSION['size']; $i++) {
|
||||||
|
for ($j = 0; $j < $_SESSION['size']; $j++) {
|
||||||
|
$grid .= '
|
||||||
|
<input class="cell" type="submit" name="position" value="' . $j . ':' . $i . '">
|
||||||
|
';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$grid .= '
|
||||||
|
</form>
|
||||||
|
';
|
||||||
|
|
||||||
|
return $grid;
|
||||||
|
}
|
||||||
|
|
||||||
|
function place_hurkle()
|
||||||
|
{
|
||||||
|
if (!isset($_SESSION['x']) && !isset($_SESSION['y'])) {
|
||||||
|
$_SESSION['x'] = rand(0, $_SESSION['size'] - 1);
|
||||||
|
$_SESSION['y'] = rand(0, $_SESSION['size'] - 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
||||||
Executable
+1
@@ -0,0 +1 @@
|
|||||||
|
skinner,gatekeeper||>><<||csm,alien||>><<||dana,skeptic||>><<||fox,believer
|
||||||
Executable
+1
@@ -0,0 +1 @@
|
|||||||
|
dale,the government||>><<||bill,the barber||>><<||hank,the texan||>><<||boomhauer,the marshall
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
<?php
|
||||||
|
$nav = '
|
||||||
|
<nav>
|
||||||
|
<ul>
|
||||||
|
<li><a href="users.php">Users</a></li>
|
||||||
|
<li><a href="video.php">Video</a></li>
|
||||||
|
</ul>
|
||||||
|
</nav>
|
||||||
|
';
|
||||||
|
|
||||||
|
echo $nav;
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<title>Secure Users</title>
|
||||||
|
<link href="css/styles.css" type="text/css" rel="stylesheet">
|
||||||
|
<script src="js/index.js"></script>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<?php include_once 'includes/nav.php'; ?>
|
||||||
|
<h1>Hello cruel world!</h1>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
session_start();
|
session_start();
|
||||||
require_once 'vendor/autoload.php';
|
require_once '../vendor/autoload.php';
|
||||||
|
|
||||||
$dotenv = Dotenv\Dotenv::createImmutable(__DIR__);
|
$dotenv = Dotenv\Dotenv::createImmutable(__DIR__);
|
||||||
$dotenv->safeLoad();
|
$dotenv->safeLoad();
|
||||||
|
|||||||
Vendored
-25
@@ -1,25 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
// autoload.php @generated by Composer
|
|
||||||
|
|
||||||
if (PHP_VERSION_ID < 50600) {
|
|
||||||
if (!headers_sent()) {
|
|
||||||
header('HTTP/1.1 500 Internal Server Error');
|
|
||||||
}
|
|
||||||
$err = 'Composer 2.3.0 dropped support for autoloading on PHP <5.6 and you are running '.PHP_VERSION.', please upgrade PHP or use Composer 2.2 LTS via "composer self-update --2.2". Aborting.'.PHP_EOL;
|
|
||||||
if (!ini_get('display_errors')) {
|
|
||||||
if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') {
|
|
||||||
fwrite(STDERR, $err);
|
|
||||||
} elseif (!headers_sent()) {
|
|
||||||
echo $err;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
trigger_error(
|
|
||||||
$err,
|
|
||||||
E_USER_ERROR
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
require_once __DIR__ . '/composer/autoload_real.php';
|
|
||||||
|
|
||||||
return ComposerAutoloaderInit671bd9ce234283933d556ba9cb26b743::getLoader();
|
|
||||||
Vendored
-579
@@ -1,579 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of Composer.
|
|
||||||
*
|
|
||||||
* (c) Nils Adermann <naderman@naderman.de>
|
|
||||||
* Jordi Boggiano <j.boggiano@seld.be>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Composer\Autoload;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ClassLoader implements a PSR-0, PSR-4 and classmap class loader.
|
|
||||||
*
|
|
||||||
* $loader = new \Composer\Autoload\ClassLoader();
|
|
||||||
*
|
|
||||||
* // register classes with namespaces
|
|
||||||
* $loader->add('Symfony\Component', __DIR__.'/component');
|
|
||||||
* $loader->add('Symfony', __DIR__.'/framework');
|
|
||||||
*
|
|
||||||
* // activate the autoloader
|
|
||||||
* $loader->register();
|
|
||||||
*
|
|
||||||
* // to enable searching the include path (eg. for PEAR packages)
|
|
||||||
* $loader->setUseIncludePath(true);
|
|
||||||
*
|
|
||||||
* In this example, if you try to use a class in the Symfony\Component
|
|
||||||
* namespace or one of its children (Symfony\Component\Console for instance),
|
|
||||||
* the autoloader will first look for the class under the component/
|
|
||||||
* directory, and it will then fallback to the framework/ directory if not
|
|
||||||
* found before giving up.
|
|
||||||
*
|
|
||||||
* This class is loosely based on the Symfony UniversalClassLoader.
|
|
||||||
*
|
|
||||||
* @author Fabien Potencier <fabien@symfony.com>
|
|
||||||
* @author Jordi Boggiano <j.boggiano@seld.be>
|
|
||||||
* @see https://www.php-fig.org/psr/psr-0/
|
|
||||||
* @see https://www.php-fig.org/psr/psr-4/
|
|
||||||
*/
|
|
||||||
class ClassLoader
|
|
||||||
{
|
|
||||||
/** @var \Closure(string):void */
|
|
||||||
private static $includeFile;
|
|
||||||
|
|
||||||
/** @var string|null */
|
|
||||||
private $vendorDir;
|
|
||||||
|
|
||||||
// PSR-4
|
|
||||||
/**
|
|
||||||
* @var array<string, array<string, int>>
|
|
||||||
*/
|
|
||||||
private $prefixLengthsPsr4 = array();
|
|
||||||
/**
|
|
||||||
* @var array<string, list<string>>
|
|
||||||
*/
|
|
||||||
private $prefixDirsPsr4 = array();
|
|
||||||
/**
|
|
||||||
* @var list<string>
|
|
||||||
*/
|
|
||||||
private $fallbackDirsPsr4 = array();
|
|
||||||
|
|
||||||
// PSR-0
|
|
||||||
/**
|
|
||||||
* List of PSR-0 prefixes
|
|
||||||
*
|
|
||||||
* Structured as array('F (first letter)' => array('Foo\Bar (full prefix)' => array('path', 'path2')))
|
|
||||||
*
|
|
||||||
* @var array<string, array<string, list<string>>>
|
|
||||||
*/
|
|
||||||
private $prefixesPsr0 = array();
|
|
||||||
/**
|
|
||||||
* @var list<string>
|
|
||||||
*/
|
|
||||||
private $fallbackDirsPsr0 = array();
|
|
||||||
|
|
||||||
/** @var bool */
|
|
||||||
private $useIncludePath = false;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var array<string, string>
|
|
||||||
*/
|
|
||||||
private $classMap = array();
|
|
||||||
|
|
||||||
/** @var bool */
|
|
||||||
private $classMapAuthoritative = false;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var array<string, bool>
|
|
||||||
*/
|
|
||||||
private $missingClasses = array();
|
|
||||||
|
|
||||||
/** @var string|null */
|
|
||||||
private $apcuPrefix;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var array<string, self>
|
|
||||||
*/
|
|
||||||
private static $registeredLoaders = array();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param string|null $vendorDir
|
|
||||||
*/
|
|
||||||
public function __construct($vendorDir = null)
|
|
||||||
{
|
|
||||||
$this->vendorDir = $vendorDir;
|
|
||||||
self::initializeIncludeClosure();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return array<string, list<string>>
|
|
||||||
*/
|
|
||||||
public function getPrefixes()
|
|
||||||
{
|
|
||||||
if (!empty($this->prefixesPsr0)) {
|
|
||||||
return call_user_func_array('array_merge', array_values($this->prefixesPsr0));
|
|
||||||
}
|
|
||||||
|
|
||||||
return array();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return array<string, list<string>>
|
|
||||||
*/
|
|
||||||
public function getPrefixesPsr4()
|
|
||||||
{
|
|
||||||
return $this->prefixDirsPsr4;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return list<string>
|
|
||||||
*/
|
|
||||||
public function getFallbackDirs()
|
|
||||||
{
|
|
||||||
return $this->fallbackDirsPsr0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return list<string>
|
|
||||||
*/
|
|
||||||
public function getFallbackDirsPsr4()
|
|
||||||
{
|
|
||||||
return $this->fallbackDirsPsr4;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return array<string, string> Array of classname => path
|
|
||||||
*/
|
|
||||||
public function getClassMap()
|
|
||||||
{
|
|
||||||
return $this->classMap;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param array<string, string> $classMap Class to filename map
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function addClassMap(array $classMap)
|
|
||||||
{
|
|
||||||
if ($this->classMap) {
|
|
||||||
$this->classMap = array_merge($this->classMap, $classMap);
|
|
||||||
} else {
|
|
||||||
$this->classMap = $classMap;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Registers a set of PSR-0 directories for a given prefix, either
|
|
||||||
* appending or prepending to the ones previously set for this prefix.
|
|
||||||
*
|
|
||||||
* @param string $prefix The prefix
|
|
||||||
* @param list<string>|string $paths The PSR-0 root directories
|
|
||||||
* @param bool $prepend Whether to prepend the directories
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function add($prefix, $paths, $prepend = false)
|
|
||||||
{
|
|
||||||
$paths = (array) $paths;
|
|
||||||
if (!$prefix) {
|
|
||||||
if ($prepend) {
|
|
||||||
$this->fallbackDirsPsr0 = array_merge(
|
|
||||||
$paths,
|
|
||||||
$this->fallbackDirsPsr0
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
$this->fallbackDirsPsr0 = array_merge(
|
|
||||||
$this->fallbackDirsPsr0,
|
|
||||||
$paths
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$first = $prefix[0];
|
|
||||||
if (!isset($this->prefixesPsr0[$first][$prefix])) {
|
|
||||||
$this->prefixesPsr0[$first][$prefix] = $paths;
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if ($prepend) {
|
|
||||||
$this->prefixesPsr0[$first][$prefix] = array_merge(
|
|
||||||
$paths,
|
|
||||||
$this->prefixesPsr0[$first][$prefix]
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
$this->prefixesPsr0[$first][$prefix] = array_merge(
|
|
||||||
$this->prefixesPsr0[$first][$prefix],
|
|
||||||
$paths
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Registers a set of PSR-4 directories for a given namespace, either
|
|
||||||
* appending or prepending to the ones previously set for this namespace.
|
|
||||||
*
|
|
||||||
* @param string $prefix The prefix/namespace, with trailing '\\'
|
|
||||||
* @param list<string>|string $paths The PSR-4 base directories
|
|
||||||
* @param bool $prepend Whether to prepend the directories
|
|
||||||
*
|
|
||||||
* @throws \InvalidArgumentException
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function addPsr4($prefix, $paths, $prepend = false)
|
|
||||||
{
|
|
||||||
$paths = (array) $paths;
|
|
||||||
if (!$prefix) {
|
|
||||||
// Register directories for the root namespace.
|
|
||||||
if ($prepend) {
|
|
||||||
$this->fallbackDirsPsr4 = array_merge(
|
|
||||||
$paths,
|
|
||||||
$this->fallbackDirsPsr4
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
$this->fallbackDirsPsr4 = array_merge(
|
|
||||||
$this->fallbackDirsPsr4,
|
|
||||||
$paths
|
|
||||||
);
|
|
||||||
}
|
|
||||||
} elseif (!isset($this->prefixDirsPsr4[$prefix])) {
|
|
||||||
// Register directories for a new namespace.
|
|
||||||
$length = strlen($prefix);
|
|
||||||
if ('\\' !== $prefix[$length - 1]) {
|
|
||||||
throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
|
|
||||||
}
|
|
||||||
$this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
|
|
||||||
$this->prefixDirsPsr4[$prefix] = $paths;
|
|
||||||
} elseif ($prepend) {
|
|
||||||
// Prepend directories for an already registered namespace.
|
|
||||||
$this->prefixDirsPsr4[$prefix] = array_merge(
|
|
||||||
$paths,
|
|
||||||
$this->prefixDirsPsr4[$prefix]
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
// Append directories for an already registered namespace.
|
|
||||||
$this->prefixDirsPsr4[$prefix] = array_merge(
|
|
||||||
$this->prefixDirsPsr4[$prefix],
|
|
||||||
$paths
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Registers a set of PSR-0 directories for a given prefix,
|
|
||||||
* replacing any others previously set for this prefix.
|
|
||||||
*
|
|
||||||
* @param string $prefix The prefix
|
|
||||||
* @param list<string>|string $paths The PSR-0 base directories
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function set($prefix, $paths)
|
|
||||||
{
|
|
||||||
if (!$prefix) {
|
|
||||||
$this->fallbackDirsPsr0 = (array) $paths;
|
|
||||||
} else {
|
|
||||||
$this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Registers a set of PSR-4 directories for a given namespace,
|
|
||||||
* replacing any others previously set for this namespace.
|
|
||||||
*
|
|
||||||
* @param string $prefix The prefix/namespace, with trailing '\\'
|
|
||||||
* @param list<string>|string $paths The PSR-4 base directories
|
|
||||||
*
|
|
||||||
* @throws \InvalidArgumentException
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function setPsr4($prefix, $paths)
|
|
||||||
{
|
|
||||||
if (!$prefix) {
|
|
||||||
$this->fallbackDirsPsr4 = (array) $paths;
|
|
||||||
} else {
|
|
||||||
$length = strlen($prefix);
|
|
||||||
if ('\\' !== $prefix[$length - 1]) {
|
|
||||||
throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
|
|
||||||
}
|
|
||||||
$this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
|
|
||||||
$this->prefixDirsPsr4[$prefix] = (array) $paths;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Turns on searching the include path for class files.
|
|
||||||
*
|
|
||||||
* @param bool $useIncludePath
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function setUseIncludePath($useIncludePath)
|
|
||||||
{
|
|
||||||
$this->useIncludePath = $useIncludePath;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Can be used to check if the autoloader uses the include path to check
|
|
||||||
* for classes.
|
|
||||||
*
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
public function getUseIncludePath()
|
|
||||||
{
|
|
||||||
return $this->useIncludePath;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Turns off searching the prefix and fallback directories for classes
|
|
||||||
* that have not been registered with the class map.
|
|
||||||
*
|
|
||||||
* @param bool $classMapAuthoritative
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function setClassMapAuthoritative($classMapAuthoritative)
|
|
||||||
{
|
|
||||||
$this->classMapAuthoritative = $classMapAuthoritative;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Should class lookup fail if not found in the current class map?
|
|
||||||
*
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
public function isClassMapAuthoritative()
|
|
||||||
{
|
|
||||||
return $this->classMapAuthoritative;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* APCu prefix to use to cache found/not-found classes, if the extension is enabled.
|
|
||||||
*
|
|
||||||
* @param string|null $apcuPrefix
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function setApcuPrefix($apcuPrefix)
|
|
||||||
{
|
|
||||||
$this->apcuPrefix = function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? $apcuPrefix : null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The APCu prefix in use, or null if APCu caching is not enabled.
|
|
||||||
*
|
|
||||||
* @return string|null
|
|
||||||
*/
|
|
||||||
public function getApcuPrefix()
|
|
||||||
{
|
|
||||||
return $this->apcuPrefix;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Registers this instance as an autoloader.
|
|
||||||
*
|
|
||||||
* @param bool $prepend Whether to prepend the autoloader or not
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function register($prepend = false)
|
|
||||||
{
|
|
||||||
spl_autoload_register(array($this, 'loadClass'), true, $prepend);
|
|
||||||
|
|
||||||
if (null === $this->vendorDir) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($prepend) {
|
|
||||||
self::$registeredLoaders = array($this->vendorDir => $this) + self::$registeredLoaders;
|
|
||||||
} else {
|
|
||||||
unset(self::$registeredLoaders[$this->vendorDir]);
|
|
||||||
self::$registeredLoaders[$this->vendorDir] = $this;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Unregisters this instance as an autoloader.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function unregister()
|
|
||||||
{
|
|
||||||
spl_autoload_unregister(array($this, 'loadClass'));
|
|
||||||
|
|
||||||
if (null !== $this->vendorDir) {
|
|
||||||
unset(self::$registeredLoaders[$this->vendorDir]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Loads the given class or interface.
|
|
||||||
*
|
|
||||||
* @param string $class The name of the class
|
|
||||||
* @return true|null True if loaded, null otherwise
|
|
||||||
*/
|
|
||||||
public function loadClass($class)
|
|
||||||
{
|
|
||||||
if ($file = $this->findFile($class)) {
|
|
||||||
$includeFile = self::$includeFile;
|
|
||||||
$includeFile($file);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Finds the path to the file where the class is defined.
|
|
||||||
*
|
|
||||||
* @param string $class The name of the class
|
|
||||||
*
|
|
||||||
* @return string|false The path if found, false otherwise
|
|
||||||
*/
|
|
||||||
public function findFile($class)
|
|
||||||
{
|
|
||||||
// class map lookup
|
|
||||||
if (isset($this->classMap[$class])) {
|
|
||||||
return $this->classMap[$class];
|
|
||||||
}
|
|
||||||
if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (null !== $this->apcuPrefix) {
|
|
||||||
$file = apcu_fetch($this->apcuPrefix.$class, $hit);
|
|
||||||
if ($hit) {
|
|
||||||
return $file;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$file = $this->findFileWithExtension($class, '.php');
|
|
||||||
|
|
||||||
// Search for Hack files if we are running on HHVM
|
|
||||||
if (false === $file && defined('HHVM_VERSION')) {
|
|
||||||
$file = $this->findFileWithExtension($class, '.hh');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (null !== $this->apcuPrefix) {
|
|
||||||
apcu_add($this->apcuPrefix.$class, $file);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (false === $file) {
|
|
||||||
// Remember that this class does not exist.
|
|
||||||
$this->missingClasses[$class] = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $file;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the currently registered loaders keyed by their corresponding vendor directories.
|
|
||||||
*
|
|
||||||
* @return array<string, self>
|
|
||||||
*/
|
|
||||||
public static function getRegisteredLoaders()
|
|
||||||
{
|
|
||||||
return self::$registeredLoaders;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param string $class
|
|
||||||
* @param string $ext
|
|
||||||
* @return string|false
|
|
||||||
*/
|
|
||||||
private function findFileWithExtension($class, $ext)
|
|
||||||
{
|
|
||||||
// PSR-4 lookup
|
|
||||||
$logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext;
|
|
||||||
|
|
||||||
$first = $class[0];
|
|
||||||
if (isset($this->prefixLengthsPsr4[$first])) {
|
|
||||||
$subPath = $class;
|
|
||||||
while (false !== $lastPos = strrpos($subPath, '\\')) {
|
|
||||||
$subPath = substr($subPath, 0, $lastPos);
|
|
||||||
$search = $subPath . '\\';
|
|
||||||
if (isset($this->prefixDirsPsr4[$search])) {
|
|
||||||
$pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1);
|
|
||||||
foreach ($this->prefixDirsPsr4[$search] as $dir) {
|
|
||||||
if (file_exists($file = $dir . $pathEnd)) {
|
|
||||||
return $file;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// PSR-4 fallback dirs
|
|
||||||
foreach ($this->fallbackDirsPsr4 as $dir) {
|
|
||||||
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) {
|
|
||||||
return $file;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// PSR-0 lookup
|
|
||||||
if (false !== $pos = strrpos($class, '\\')) {
|
|
||||||
// namespaced class name
|
|
||||||
$logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1)
|
|
||||||
. strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR);
|
|
||||||
} else {
|
|
||||||
// PEAR-like class name
|
|
||||||
$logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($this->prefixesPsr0[$first])) {
|
|
||||||
foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) {
|
|
||||||
if (0 === strpos($class, $prefix)) {
|
|
||||||
foreach ($dirs as $dir) {
|
|
||||||
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
|
|
||||||
return $file;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// PSR-0 fallback dirs
|
|
||||||
foreach ($this->fallbackDirsPsr0 as $dir) {
|
|
||||||
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
|
|
||||||
return $file;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// PSR-0 include paths.
|
|
||||||
if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) {
|
|
||||||
return $file;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
private static function initializeIncludeClosure()
|
|
||||||
{
|
|
||||||
if (self::$includeFile !== null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Scope isolated include.
|
|
||||||
*
|
|
||||||
* Prevents access to $this/self from included files.
|
|
||||||
*
|
|
||||||
* @param string $file
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
self::$includeFile = \Closure::bind(static function($file) {
|
|
||||||
include $file;
|
|
||||||
}, null, null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-378
@@ -1,378 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of Composer.
|
|
||||||
*
|
|
||||||
* (c) Nils Adermann <naderman@naderman.de>
|
|
||||||
* Jordi Boggiano <j.boggiano@seld.be>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Composer;
|
|
||||||
|
|
||||||
use Composer\Autoload\ClassLoader;
|
|
||||||
use Composer\Semver\VersionParser;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This class is copied in every Composer installed project and available to all
|
|
||||||
*
|
|
||||||
* See also https://getcomposer.org/doc/07-runtime.md#installed-versions
|
|
||||||
*
|
|
||||||
* To require its presence, you can require `composer-runtime-api ^2.0`
|
|
||||||
*
|
|
||||||
* @final
|
|
||||||
*/
|
|
||||||
class InstalledVersions
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @var mixed[]|null
|
|
||||||
* @psalm-var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}|array{}|null
|
|
||||||
*/
|
|
||||||
private static $installed;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var bool
|
|
||||||
*/
|
|
||||||
private static $installedIsLocalDir;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var bool|null
|
|
||||||
*/
|
|
||||||
private static $canGetVendors;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var array[]
|
|
||||||
* @psalm-var array<string, array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}>
|
|
||||||
*/
|
|
||||||
private static $installedByVendor = array();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a list of all package names which are present, either by being installed, replaced or provided
|
|
||||||
*
|
|
||||||
* @return string[]
|
|
||||||
* @psalm-return list<string>
|
|
||||||
*/
|
|
||||||
public static function getInstalledPackages()
|
|
||||||
{
|
|
||||||
$packages = array();
|
|
||||||
foreach (self::getInstalled() as $installed) {
|
|
||||||
$packages[] = array_keys($installed['versions']);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (1 === \count($packages)) {
|
|
||||||
return $packages[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
return array_keys(array_flip(\call_user_func_array('array_merge', $packages)));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a list of all package names with a specific type e.g. 'library'
|
|
||||||
*
|
|
||||||
* @param string $type
|
|
||||||
* @return string[]
|
|
||||||
* @psalm-return list<string>
|
|
||||||
*/
|
|
||||||
public static function getInstalledPackagesByType($type)
|
|
||||||
{
|
|
||||||
$packagesByType = array();
|
|
||||||
|
|
||||||
foreach (self::getInstalled() as $installed) {
|
|
||||||
foreach ($installed['versions'] as $name => $package) {
|
|
||||||
if (isset($package['type']) && $package['type'] === $type) {
|
|
||||||
$packagesByType[] = $name;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $packagesByType;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks whether the given package is installed
|
|
||||||
*
|
|
||||||
* This also returns true if the package name is provided or replaced by another package
|
|
||||||
*
|
|
||||||
* @param string $packageName
|
|
||||||
* @param bool $includeDevRequirements
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
public static function isInstalled($packageName, $includeDevRequirements = true)
|
|
||||||
{
|
|
||||||
foreach (self::getInstalled() as $installed) {
|
|
||||||
if (isset($installed['versions'][$packageName])) {
|
|
||||||
return $includeDevRequirements || !isset($installed['versions'][$packageName]['dev_requirement']) || $installed['versions'][$packageName]['dev_requirement'] === false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks whether the given package satisfies a version constraint
|
|
||||||
*
|
|
||||||
* e.g. If you want to know whether version 2.3+ of package foo/bar is installed, you would call:
|
|
||||||
*
|
|
||||||
* Composer\InstalledVersions::satisfies(new VersionParser, 'foo/bar', '^2.3')
|
|
||||||
*
|
|
||||||
* @param VersionParser $parser Install composer/semver to have access to this class and functionality
|
|
||||||
* @param string $packageName
|
|
||||||
* @param string|null $constraint A version constraint to check for, if you pass one you have to make sure composer/semver is required by your package
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
public static function satisfies(VersionParser $parser, $packageName, $constraint)
|
|
||||||
{
|
|
||||||
$constraint = $parser->parseConstraints((string) $constraint);
|
|
||||||
$provided = $parser->parseConstraints(self::getVersionRanges($packageName));
|
|
||||||
|
|
||||||
return $provided->matches($constraint);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a version constraint representing all the range(s) which are installed for a given package
|
|
||||||
*
|
|
||||||
* It is easier to use this via isInstalled() with the $constraint argument if you need to check
|
|
||||||
* whether a given version of a package is installed, and not just whether it exists
|
|
||||||
*
|
|
||||||
* @param string $packageName
|
|
||||||
* @return string Version constraint usable with composer/semver
|
|
||||||
*/
|
|
||||||
public static function getVersionRanges($packageName)
|
|
||||||
{
|
|
||||||
foreach (self::getInstalled() as $installed) {
|
|
||||||
if (!isset($installed['versions'][$packageName])) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
$ranges = array();
|
|
||||||
if (isset($installed['versions'][$packageName]['pretty_version'])) {
|
|
||||||
$ranges[] = $installed['versions'][$packageName]['pretty_version'];
|
|
||||||
}
|
|
||||||
if (array_key_exists('aliases', $installed['versions'][$packageName])) {
|
|
||||||
$ranges = array_merge($ranges, $installed['versions'][$packageName]['aliases']);
|
|
||||||
}
|
|
||||||
if (array_key_exists('replaced', $installed['versions'][$packageName])) {
|
|
||||||
$ranges = array_merge($ranges, $installed['versions'][$packageName]['replaced']);
|
|
||||||
}
|
|
||||||
if (array_key_exists('provided', $installed['versions'][$packageName])) {
|
|
||||||
$ranges = array_merge($ranges, $installed['versions'][$packageName]['provided']);
|
|
||||||
}
|
|
||||||
|
|
||||||
return implode(' || ', $ranges);
|
|
||||||
}
|
|
||||||
|
|
||||||
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param string $packageName
|
|
||||||
* @return string|null If the package is being replaced or provided but is not really installed, null will be returned as version, use satisfies or getVersionRanges if you need to know if a given version is present
|
|
||||||
*/
|
|
||||||
public static function getVersion($packageName)
|
|
||||||
{
|
|
||||||
foreach (self::getInstalled() as $installed) {
|
|
||||||
if (!isset($installed['versions'][$packageName])) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!isset($installed['versions'][$packageName]['version'])) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $installed['versions'][$packageName]['version'];
|
|
||||||
}
|
|
||||||
|
|
||||||
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param string $packageName
|
|
||||||
* @return string|null If the package is being replaced or provided but is not really installed, null will be returned as version, use satisfies or getVersionRanges if you need to know if a given version is present
|
|
||||||
*/
|
|
||||||
public static function getPrettyVersion($packageName)
|
|
||||||
{
|
|
||||||
foreach (self::getInstalled() as $installed) {
|
|
||||||
if (!isset($installed['versions'][$packageName])) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!isset($installed['versions'][$packageName]['pretty_version'])) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $installed['versions'][$packageName]['pretty_version'];
|
|
||||||
}
|
|
||||||
|
|
||||||
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param string $packageName
|
|
||||||
* @return string|null If the package is being replaced or provided but is not really installed, null will be returned as reference
|
|
||||||
*/
|
|
||||||
public static function getReference($packageName)
|
|
||||||
{
|
|
||||||
foreach (self::getInstalled() as $installed) {
|
|
||||||
if (!isset($installed['versions'][$packageName])) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!isset($installed['versions'][$packageName]['reference'])) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $installed['versions'][$packageName]['reference'];
|
|
||||||
}
|
|
||||||
|
|
||||||
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param string $packageName
|
|
||||||
* @return string|null If the package is being replaced or provided but is not really installed, null will be returned as install path. Packages of type metapackages also have a null install path.
|
|
||||||
*/
|
|
||||||
public static function getInstallPath($packageName)
|
|
||||||
{
|
|
||||||
foreach (self::getInstalled() as $installed) {
|
|
||||||
if (!isset($installed['versions'][$packageName])) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
return isset($installed['versions'][$packageName]['install_path']) ? $installed['versions'][$packageName]['install_path'] : null;
|
|
||||||
}
|
|
||||||
|
|
||||||
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return array
|
|
||||||
* @psalm-return array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}
|
|
||||||
*/
|
|
||||||
public static function getRootPackage()
|
|
||||||
{
|
|
||||||
$installed = self::getInstalled();
|
|
||||||
|
|
||||||
return $installed[0]['root'];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the raw installed.php data for custom implementations
|
|
||||||
*
|
|
||||||
* @deprecated Use getAllRawData() instead which returns all datasets for all autoloaders present in the process. getRawData only returns the first dataset loaded, which may not be what you expect.
|
|
||||||
* @return array[]
|
|
||||||
* @psalm-return array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}
|
|
||||||
*/
|
|
||||||
public static function getRawData()
|
|
||||||
{
|
|
||||||
@trigger_error('getRawData only returns the first dataset loaded, which may not be what you expect. Use getAllRawData() instead which returns all datasets for all autoloaders present in the process.', E_USER_DEPRECATED);
|
|
||||||
|
|
||||||
if (null === self::$installed) {
|
|
||||||
// only require the installed.php file if this file is loaded from its dumped location,
|
|
||||||
// and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937
|
|
||||||
if (substr(__DIR__, -8, 1) !== 'C') {
|
|
||||||
self::$installed = include __DIR__ . '/installed.php';
|
|
||||||
} else {
|
|
||||||
self::$installed = array();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return self::$installed;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the raw data of all installed.php which are currently loaded for custom implementations
|
|
||||||
*
|
|
||||||
* @return array[]
|
|
||||||
* @psalm-return list<array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}>
|
|
||||||
*/
|
|
||||||
public static function getAllRawData()
|
|
||||||
{
|
|
||||||
return self::getInstalled();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Lets you reload the static array from another file
|
|
||||||
*
|
|
||||||
* This is only useful for complex integrations in which a project needs to use
|
|
||||||
* this class but then also needs to execute another project's autoloader in process,
|
|
||||||
* and wants to ensure both projects have access to their version of installed.php.
|
|
||||||
*
|
|
||||||
* A typical case would be PHPUnit, where it would need to make sure it reads all
|
|
||||||
* the data it needs from this class, then call reload() with
|
|
||||||
* `require $CWD/vendor/composer/installed.php` (or similar) as input to make sure
|
|
||||||
* the project in which it runs can then also use this class safely, without
|
|
||||||
* interference between PHPUnit's dependencies and the project's dependencies.
|
|
||||||
*
|
|
||||||
* @param array[] $data A vendor/composer/installed.php data set
|
|
||||||
* @return void
|
|
||||||
*
|
|
||||||
* @psalm-param array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $data
|
|
||||||
*/
|
|
||||||
public static function reload($data)
|
|
||||||
{
|
|
||||||
self::$installed = $data;
|
|
||||||
self::$installedByVendor = array();
|
|
||||||
|
|
||||||
// when using reload, we disable the duplicate protection to ensure that self::$installed data is
|
|
||||||
// always returned, but we cannot know whether it comes from the installed.php in __DIR__ or not,
|
|
||||||
// so we have to assume it does not, and that may result in duplicate data being returned when listing
|
|
||||||
// all installed packages for example
|
|
||||||
self::$installedIsLocalDir = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return array[]
|
|
||||||
* @psalm-return list<array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}>
|
|
||||||
*/
|
|
||||||
private static function getInstalled()
|
|
||||||
{
|
|
||||||
if (null === self::$canGetVendors) {
|
|
||||||
self::$canGetVendors = method_exists('Composer\Autoload\ClassLoader', 'getRegisteredLoaders');
|
|
||||||
}
|
|
||||||
|
|
||||||
$installed = array();
|
|
||||||
$copiedLocalDir = false;
|
|
||||||
|
|
||||||
if (self::$canGetVendors) {
|
|
||||||
$selfDir = strtr(__DIR__, '\\', '/');
|
|
||||||
foreach (ClassLoader::getRegisteredLoaders() as $vendorDir => $loader) {
|
|
||||||
$vendorDir = strtr($vendorDir, '\\', '/');
|
|
||||||
if (isset(self::$installedByVendor[$vendorDir])) {
|
|
||||||
$installed[] = self::$installedByVendor[$vendorDir];
|
|
||||||
} elseif (is_file($vendorDir.'/composer/installed.php')) {
|
|
||||||
/** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $required */
|
|
||||||
$required = require $vendorDir.'/composer/installed.php';
|
|
||||||
self::$installedByVendor[$vendorDir] = $required;
|
|
||||||
$installed[] = $required;
|
|
||||||
if (self::$installed === null && $vendorDir.'/composer' === $selfDir) {
|
|
||||||
self::$installed = $required;
|
|
||||||
self::$installedIsLocalDir = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (self::$installedIsLocalDir && $vendorDir.'/composer' === $selfDir) {
|
|
||||||
$copiedLocalDir = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (null === self::$installed) {
|
|
||||||
// only require the installed.php file if this file is loaded from its dumped location,
|
|
||||||
// and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937
|
|
||||||
if (substr(__DIR__, -8, 1) !== 'C') {
|
|
||||||
/** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $required */
|
|
||||||
$required = require __DIR__ . '/installed.php';
|
|
||||||
self::$installed = $required;
|
|
||||||
} else {
|
|
||||||
self::$installed = array();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (self::$installed !== array() && !$copiedLocalDir) {
|
|
||||||
$installed[] = self::$installed;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $installed;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Vendored
-21
@@ -1,21 +0,0 @@
|
|||||||
|
|
||||||
Copyright (c) Nils Adermann, Jordi Boggiano
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
|
||||||
in the Software without restriction, including without limitation the rights
|
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
copies of the Software, and to permit persons to whom the Software is furnished
|
|
||||||
to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in all
|
|
||||||
copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
||||||
THE SOFTWARE.
|
|
||||||
|
|
||||||
-15
@@ -1,15 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
// autoload_classmap.php @generated by Composer
|
|
||||||
|
|
||||||
$vendorDir = dirname(__DIR__);
|
|
||||||
$baseDir = dirname($vendorDir);
|
|
||||||
|
|
||||||
return array(
|
|
||||||
'Attribute' => $vendorDir . '/symfony/polyfill-php80/Resources/stubs/Attribute.php',
|
|
||||||
'Composer\\InstalledVersions' => $vendorDir . '/composer/InstalledVersions.php',
|
|
||||||
'PhpToken' => $vendorDir . '/symfony/polyfill-php80/Resources/stubs/PhpToken.php',
|
|
||||||
'Stringable' => $vendorDir . '/symfony/polyfill-php80/Resources/stubs/Stringable.php',
|
|
||||||
'UnhandledMatchError' => $vendorDir . '/symfony/polyfill-php80/Resources/stubs/UnhandledMatchError.php',
|
|
||||||
'ValueError' => $vendorDir . '/symfony/polyfill-php80/Resources/stubs/ValueError.php',
|
|
||||||
);
|
|
||||||
Vendored
-12
@@ -1,12 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
// autoload_files.php @generated by Composer
|
|
||||||
|
|
||||||
$vendorDir = dirname(__DIR__);
|
|
||||||
$baseDir = dirname($vendorDir);
|
|
||||||
|
|
||||||
return array(
|
|
||||||
'320cde22f66dd4f5d3fd621d3e88b98f' => $vendorDir . '/symfony/polyfill-ctype/bootstrap.php',
|
|
||||||
'0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => $vendorDir . '/symfony/polyfill-mbstring/bootstrap.php',
|
|
||||||
'a4a119a56e50fbb293281d9a48007e0e' => $vendorDir . '/symfony/polyfill-php80/bootstrap.php',
|
|
||||||
);
|
|
||||||
-9
@@ -1,9 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
// autoload_namespaces.php @generated by Composer
|
|
||||||
|
|
||||||
$vendorDir = dirname(__DIR__);
|
|
||||||
$baseDir = dirname($vendorDir);
|
|
||||||
|
|
||||||
return array(
|
|
||||||
);
|
|
||||||
Vendored
-16
@@ -1,16 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
// autoload_psr4.php @generated by Composer
|
|
||||||
|
|
||||||
$vendorDir = dirname(__DIR__);
|
|
||||||
$baseDir = dirname($vendorDir);
|
|
||||||
|
|
||||||
return array(
|
|
||||||
'Violet\\DbStart\\' => array($baseDir . '/src'),
|
|
||||||
'Symfony\\Polyfill\\Php80\\' => array($vendorDir . '/symfony/polyfill-php80'),
|
|
||||||
'Symfony\\Polyfill\\Mbstring\\' => array($vendorDir . '/symfony/polyfill-mbstring'),
|
|
||||||
'Symfony\\Polyfill\\Ctype\\' => array($vendorDir . '/symfony/polyfill-ctype'),
|
|
||||||
'PhpOption\\' => array($vendorDir . '/phpoption/phpoption/src/PhpOption'),
|
|
||||||
'GrahamCampbell\\ResultType\\' => array($vendorDir . '/graham-campbell/result-type/src'),
|
|
||||||
'Dotenv\\' => array($vendorDir . '/vlucas/phpdotenv/src'),
|
|
||||||
);
|
|
||||||
Vendored
-50
@@ -1,50 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
// autoload_real.php @generated by Composer
|
|
||||||
|
|
||||||
class ComposerAutoloaderInit671bd9ce234283933d556ba9cb26b743
|
|
||||||
{
|
|
||||||
private static $loader;
|
|
||||||
|
|
||||||
public static function loadClassLoader($class)
|
|
||||||
{
|
|
||||||
if ('Composer\Autoload\ClassLoader' === $class) {
|
|
||||||
require __DIR__ . '/ClassLoader.php';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return \Composer\Autoload\ClassLoader
|
|
||||||
*/
|
|
||||||
public static function getLoader()
|
|
||||||
{
|
|
||||||
if (null !== self::$loader) {
|
|
||||||
return self::$loader;
|
|
||||||
}
|
|
||||||
|
|
||||||
require __DIR__ . '/platform_check.php';
|
|
||||||
|
|
||||||
spl_autoload_register(array('ComposerAutoloaderInit671bd9ce234283933d556ba9cb26b743', 'loadClassLoader'), true, true);
|
|
||||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
|
|
||||||
spl_autoload_unregister(array('ComposerAutoloaderInit671bd9ce234283933d556ba9cb26b743', 'loadClassLoader'));
|
|
||||||
|
|
||||||
require __DIR__ . '/autoload_static.php';
|
|
||||||
call_user_func(\Composer\Autoload\ComposerStaticInit671bd9ce234283933d556ba9cb26b743::getInitializer($loader));
|
|
||||||
|
|
||||||
$loader->register(true);
|
|
||||||
|
|
||||||
$filesToLoad = \Composer\Autoload\ComposerStaticInit671bd9ce234283933d556ba9cb26b743::$files;
|
|
||||||
$requireFile = \Closure::bind(static function ($fileIdentifier, $file) {
|
|
||||||
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
|
||||||
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
|
|
||||||
|
|
||||||
require $file;
|
|
||||||
}
|
|
||||||
}, null, null);
|
|
||||||
foreach ($filesToLoad as $fileIdentifier => $file) {
|
|
||||||
$requireFile($fileIdentifier, $file);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $loader;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Vendored
-89
@@ -1,89 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
// autoload_static.php @generated by Composer
|
|
||||||
|
|
||||||
namespace Composer\Autoload;
|
|
||||||
|
|
||||||
class ComposerStaticInit671bd9ce234283933d556ba9cb26b743
|
|
||||||
{
|
|
||||||
public static $files = array (
|
|
||||||
'320cde22f66dd4f5d3fd621d3e88b98f' => __DIR__ . '/..' . '/symfony/polyfill-ctype/bootstrap.php',
|
|
||||||
'0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => __DIR__ . '/..' . '/symfony/polyfill-mbstring/bootstrap.php',
|
|
||||||
'a4a119a56e50fbb293281d9a48007e0e' => __DIR__ . '/..' . '/symfony/polyfill-php80/bootstrap.php',
|
|
||||||
);
|
|
||||||
|
|
||||||
public static $prefixLengthsPsr4 = array (
|
|
||||||
'V' =>
|
|
||||||
array (
|
|
||||||
'Violet\\DbStart\\' => 15,
|
|
||||||
),
|
|
||||||
'S' =>
|
|
||||||
array (
|
|
||||||
'Symfony\\Polyfill\\Php80\\' => 23,
|
|
||||||
'Symfony\\Polyfill\\Mbstring\\' => 26,
|
|
||||||
'Symfony\\Polyfill\\Ctype\\' => 23,
|
|
||||||
),
|
|
||||||
'P' =>
|
|
||||||
array (
|
|
||||||
'PhpOption\\' => 10,
|
|
||||||
),
|
|
||||||
'G' =>
|
|
||||||
array (
|
|
||||||
'GrahamCampbell\\ResultType\\' => 26,
|
|
||||||
),
|
|
||||||
'D' =>
|
|
||||||
array (
|
|
||||||
'Dotenv\\' => 7,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
public static $prefixDirsPsr4 = array (
|
|
||||||
'Violet\\DbStart\\' =>
|
|
||||||
array (
|
|
||||||
0 => __DIR__ . '/../..' . '/src',
|
|
||||||
),
|
|
||||||
'Symfony\\Polyfill\\Php80\\' =>
|
|
||||||
array (
|
|
||||||
0 => __DIR__ . '/..' . '/symfony/polyfill-php80',
|
|
||||||
),
|
|
||||||
'Symfony\\Polyfill\\Mbstring\\' =>
|
|
||||||
array (
|
|
||||||
0 => __DIR__ . '/..' . '/symfony/polyfill-mbstring',
|
|
||||||
),
|
|
||||||
'Symfony\\Polyfill\\Ctype\\' =>
|
|
||||||
array (
|
|
||||||
0 => __DIR__ . '/..' . '/symfony/polyfill-ctype',
|
|
||||||
),
|
|
||||||
'PhpOption\\' =>
|
|
||||||
array (
|
|
||||||
0 => __DIR__ . '/..' . '/phpoption/phpoption/src/PhpOption',
|
|
||||||
),
|
|
||||||
'GrahamCampbell\\ResultType\\' =>
|
|
||||||
array (
|
|
||||||
0 => __DIR__ . '/..' . '/graham-campbell/result-type/src',
|
|
||||||
),
|
|
||||||
'Dotenv\\' =>
|
|
||||||
array (
|
|
||||||
0 => __DIR__ . '/..' . '/vlucas/phpdotenv/src',
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
public static $classMap = array (
|
|
||||||
'Attribute' => __DIR__ . '/..' . '/symfony/polyfill-php80/Resources/stubs/Attribute.php',
|
|
||||||
'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php',
|
|
||||||
'PhpToken' => __DIR__ . '/..' . '/symfony/polyfill-php80/Resources/stubs/PhpToken.php',
|
|
||||||
'Stringable' => __DIR__ . '/..' . '/symfony/polyfill-php80/Resources/stubs/Stringable.php',
|
|
||||||
'UnhandledMatchError' => __DIR__ . '/..' . '/symfony/polyfill-php80/Resources/stubs/UnhandledMatchError.php',
|
|
||||||
'ValueError' => __DIR__ . '/..' . '/symfony/polyfill-php80/Resources/stubs/ValueError.php',
|
|
||||||
);
|
|
||||||
|
|
||||||
public static function getInitializer(ClassLoader $loader)
|
|
||||||
{
|
|
||||||
return \Closure::bind(function () use ($loader) {
|
|
||||||
$loader->prefixLengthsPsr4 = ComposerStaticInit671bd9ce234283933d556ba9cb26b743::$prefixLengthsPsr4;
|
|
||||||
$loader->prefixDirsPsr4 = ComposerStaticInit671bd9ce234283933d556ba9cb26b743::$prefixDirsPsr4;
|
|
||||||
$loader->classMap = ComposerStaticInit671bd9ce234283933d556ba9cb26b743::$classMap;
|
|
||||||
|
|
||||||
}, null, ClassLoader::class);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Vendored
-484
@@ -1,484 +0,0 @@
|
|||||||
{
|
|
||||||
"packages": [
|
|
||||||
{
|
|
||||||
"name": "graham-campbell/result-type",
|
|
||||||
"version": "v1.1.3",
|
|
||||||
"version_normalized": "1.1.3.0",
|
|
||||||
"source": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://github.com/GrahamCampbell/Result-Type.git",
|
|
||||||
"reference": "3ba905c11371512af9d9bdd27d99b782216b6945"
|
|
||||||
},
|
|
||||||
"dist": {
|
|
||||||
"type": "zip",
|
|
||||||
"url": "https://api.github.com/repos/GrahamCampbell/Result-Type/zipball/3ba905c11371512af9d9bdd27d99b782216b6945",
|
|
||||||
"reference": "3ba905c11371512af9d9bdd27d99b782216b6945",
|
|
||||||
"shasum": ""
|
|
||||||
},
|
|
||||||
"require": {
|
|
||||||
"php": "^7.2.5 || ^8.0",
|
|
||||||
"phpoption/phpoption": "^1.9.3"
|
|
||||||
},
|
|
||||||
"require-dev": {
|
|
||||||
"phpunit/phpunit": "^8.5.39 || ^9.6.20 || ^10.5.28"
|
|
||||||
},
|
|
||||||
"time": "2024-07-20T21:45:45+00:00",
|
|
||||||
"type": "library",
|
|
||||||
"installation-source": "dist",
|
|
||||||
"autoload": {
|
|
||||||
"psr-4": {
|
|
||||||
"GrahamCampbell\\ResultType\\": "src/"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"notification-url": "https://packagist.org/downloads/",
|
|
||||||
"license": [
|
|
||||||
"MIT"
|
|
||||||
],
|
|
||||||
"authors": [
|
|
||||||
{
|
|
||||||
"name": "Graham Campbell",
|
|
||||||
"email": "hello@gjcampbell.co.uk",
|
|
||||||
"homepage": "https://github.com/GrahamCampbell"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"description": "An Implementation Of The Result Type",
|
|
||||||
"keywords": [
|
|
||||||
"Graham Campbell",
|
|
||||||
"GrahamCampbell",
|
|
||||||
"Result Type",
|
|
||||||
"Result-Type",
|
|
||||||
"result"
|
|
||||||
],
|
|
||||||
"support": {
|
|
||||||
"issues": "https://github.com/GrahamCampbell/Result-Type/issues",
|
|
||||||
"source": "https://github.com/GrahamCampbell/Result-Type/tree/v1.1.3"
|
|
||||||
},
|
|
||||||
"funding": [
|
|
||||||
{
|
|
||||||
"url": "https://github.com/GrahamCampbell",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"url": "https://tidelift.com/funding/github/packagist/graham-campbell/result-type",
|
|
||||||
"type": "tidelift"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"install-path": "../graham-campbell/result-type"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "phpoption/phpoption",
|
|
||||||
"version": "1.9.3",
|
|
||||||
"version_normalized": "1.9.3.0",
|
|
||||||
"source": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://github.com/schmittjoh/php-option.git",
|
|
||||||
"reference": "e3fac8b24f56113f7cb96af14958c0dd16330f54"
|
|
||||||
},
|
|
||||||
"dist": {
|
|
||||||
"type": "zip",
|
|
||||||
"url": "https://api.github.com/repos/schmittjoh/php-option/zipball/e3fac8b24f56113f7cb96af14958c0dd16330f54",
|
|
||||||
"reference": "e3fac8b24f56113f7cb96af14958c0dd16330f54",
|
|
||||||
"shasum": ""
|
|
||||||
},
|
|
||||||
"require": {
|
|
||||||
"php": "^7.2.5 || ^8.0"
|
|
||||||
},
|
|
||||||
"require-dev": {
|
|
||||||
"bamarni/composer-bin-plugin": "^1.8.2",
|
|
||||||
"phpunit/phpunit": "^8.5.39 || ^9.6.20 || ^10.5.28"
|
|
||||||
},
|
|
||||||
"time": "2024-07-20T21:41:07+00:00",
|
|
||||||
"type": "library",
|
|
||||||
"extra": {
|
|
||||||
"bamarni-bin": {
|
|
||||||
"bin-links": true,
|
|
||||||
"forward-command": false
|
|
||||||
},
|
|
||||||
"branch-alias": {
|
|
||||||
"dev-master": "1.9-dev"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"installation-source": "dist",
|
|
||||||
"autoload": {
|
|
||||||
"psr-4": {
|
|
||||||
"PhpOption\\": "src/PhpOption/"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"notification-url": "https://packagist.org/downloads/",
|
|
||||||
"license": [
|
|
||||||
"Apache-2.0"
|
|
||||||
],
|
|
||||||
"authors": [
|
|
||||||
{
|
|
||||||
"name": "Johannes M. Schmitt",
|
|
||||||
"email": "schmittjoh@gmail.com",
|
|
||||||
"homepage": "https://github.com/schmittjoh"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Graham Campbell",
|
|
||||||
"email": "hello@gjcampbell.co.uk",
|
|
||||||
"homepage": "https://github.com/GrahamCampbell"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"description": "Option Type for PHP",
|
|
||||||
"keywords": [
|
|
||||||
"language",
|
|
||||||
"option",
|
|
||||||
"php",
|
|
||||||
"type"
|
|
||||||
],
|
|
||||||
"support": {
|
|
||||||
"issues": "https://github.com/schmittjoh/php-option/issues",
|
|
||||||
"source": "https://github.com/schmittjoh/php-option/tree/1.9.3"
|
|
||||||
},
|
|
||||||
"funding": [
|
|
||||||
{
|
|
||||||
"url": "https://github.com/GrahamCampbell",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"url": "https://tidelift.com/funding/github/packagist/phpoption/phpoption",
|
|
||||||
"type": "tidelift"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"install-path": "../phpoption/phpoption"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "symfony/polyfill-ctype",
|
|
||||||
"version": "v1.31.0",
|
|
||||||
"version_normalized": "1.31.0.0",
|
|
||||||
"source": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://github.com/symfony/polyfill-ctype.git",
|
|
||||||
"reference": "a3cc8b044a6ea513310cbd48ef7333b384945638"
|
|
||||||
},
|
|
||||||
"dist": {
|
|
||||||
"type": "zip",
|
|
||||||
"url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/a3cc8b044a6ea513310cbd48ef7333b384945638",
|
|
||||||
"reference": "a3cc8b044a6ea513310cbd48ef7333b384945638",
|
|
||||||
"shasum": ""
|
|
||||||
},
|
|
||||||
"require": {
|
|
||||||
"php": ">=7.2"
|
|
||||||
},
|
|
||||||
"provide": {
|
|
||||||
"ext-ctype": "*"
|
|
||||||
},
|
|
||||||
"suggest": {
|
|
||||||
"ext-ctype": "For best performance"
|
|
||||||
},
|
|
||||||
"time": "2024-09-09T11:45:10+00:00",
|
|
||||||
"type": "library",
|
|
||||||
"extra": {
|
|
||||||
"thanks": {
|
|
||||||
"url": "https://github.com/symfony/polyfill",
|
|
||||||
"name": "symfony/polyfill"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"installation-source": "dist",
|
|
||||||
"autoload": {
|
|
||||||
"files": [
|
|
||||||
"bootstrap.php"
|
|
||||||
],
|
|
||||||
"psr-4": {
|
|
||||||
"Symfony\\Polyfill\\Ctype\\": ""
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"notification-url": "https://packagist.org/downloads/",
|
|
||||||
"license": [
|
|
||||||
"MIT"
|
|
||||||
],
|
|
||||||
"authors": [
|
|
||||||
{
|
|
||||||
"name": "Gert de Pagter",
|
|
||||||
"email": "BackEndTea@gmail.com"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Symfony Community",
|
|
||||||
"homepage": "https://symfony.com/contributors"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"description": "Symfony polyfill for ctype functions",
|
|
||||||
"homepage": "https://symfony.com",
|
|
||||||
"keywords": [
|
|
||||||
"compatibility",
|
|
||||||
"ctype",
|
|
||||||
"polyfill",
|
|
||||||
"portable"
|
|
||||||
],
|
|
||||||
"support": {
|
|
||||||
"source": "https://github.com/symfony/polyfill-ctype/tree/v1.31.0"
|
|
||||||
},
|
|
||||||
"funding": [
|
|
||||||
{
|
|
||||||
"url": "https://symfony.com/sponsor",
|
|
||||||
"type": "custom"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"url": "https://github.com/fabpot",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
|
|
||||||
"type": "tidelift"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"install-path": "../symfony/polyfill-ctype"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "symfony/polyfill-mbstring",
|
|
||||||
"version": "v1.31.0",
|
|
||||||
"version_normalized": "1.31.0.0",
|
|
||||||
"source": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://github.com/symfony/polyfill-mbstring.git",
|
|
||||||
"reference": "85181ba99b2345b0ef10ce42ecac37612d9fd341"
|
|
||||||
},
|
|
||||||
"dist": {
|
|
||||||
"type": "zip",
|
|
||||||
"url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/85181ba99b2345b0ef10ce42ecac37612d9fd341",
|
|
||||||
"reference": "85181ba99b2345b0ef10ce42ecac37612d9fd341",
|
|
||||||
"shasum": ""
|
|
||||||
},
|
|
||||||
"require": {
|
|
||||||
"php": ">=7.2"
|
|
||||||
},
|
|
||||||
"provide": {
|
|
||||||
"ext-mbstring": "*"
|
|
||||||
},
|
|
||||||
"suggest": {
|
|
||||||
"ext-mbstring": "For best performance"
|
|
||||||
},
|
|
||||||
"time": "2024-09-09T11:45:10+00:00",
|
|
||||||
"type": "library",
|
|
||||||
"extra": {
|
|
||||||
"thanks": {
|
|
||||||
"url": "https://github.com/symfony/polyfill",
|
|
||||||
"name": "symfony/polyfill"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"installation-source": "dist",
|
|
||||||
"autoload": {
|
|
||||||
"files": [
|
|
||||||
"bootstrap.php"
|
|
||||||
],
|
|
||||||
"psr-4": {
|
|
||||||
"Symfony\\Polyfill\\Mbstring\\": ""
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"notification-url": "https://packagist.org/downloads/",
|
|
||||||
"license": [
|
|
||||||
"MIT"
|
|
||||||
],
|
|
||||||
"authors": [
|
|
||||||
{
|
|
||||||
"name": "Nicolas Grekas",
|
|
||||||
"email": "p@tchwork.com"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Symfony Community",
|
|
||||||
"homepage": "https://symfony.com/contributors"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"description": "Symfony polyfill for the Mbstring extension",
|
|
||||||
"homepage": "https://symfony.com",
|
|
||||||
"keywords": [
|
|
||||||
"compatibility",
|
|
||||||
"mbstring",
|
|
||||||
"polyfill",
|
|
||||||
"portable",
|
|
||||||
"shim"
|
|
||||||
],
|
|
||||||
"support": {
|
|
||||||
"source": "https://github.com/symfony/polyfill-mbstring/tree/v1.31.0"
|
|
||||||
},
|
|
||||||
"funding": [
|
|
||||||
{
|
|
||||||
"url": "https://symfony.com/sponsor",
|
|
||||||
"type": "custom"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"url": "https://github.com/fabpot",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
|
|
||||||
"type": "tidelift"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"install-path": "../symfony/polyfill-mbstring"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "symfony/polyfill-php80",
|
|
||||||
"version": "v1.31.0",
|
|
||||||
"version_normalized": "1.31.0.0",
|
|
||||||
"source": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://github.com/symfony/polyfill-php80.git",
|
|
||||||
"reference": "60328e362d4c2c802a54fcbf04f9d3fb892b4cf8"
|
|
||||||
},
|
|
||||||
"dist": {
|
|
||||||
"type": "zip",
|
|
||||||
"url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/60328e362d4c2c802a54fcbf04f9d3fb892b4cf8",
|
|
||||||
"reference": "60328e362d4c2c802a54fcbf04f9d3fb892b4cf8",
|
|
||||||
"shasum": ""
|
|
||||||
},
|
|
||||||
"require": {
|
|
||||||
"php": ">=7.2"
|
|
||||||
},
|
|
||||||
"time": "2024-09-09T11:45:10+00:00",
|
|
||||||
"type": "library",
|
|
||||||
"extra": {
|
|
||||||
"thanks": {
|
|
||||||
"url": "https://github.com/symfony/polyfill",
|
|
||||||
"name": "symfony/polyfill"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"installation-source": "dist",
|
|
||||||
"autoload": {
|
|
||||||
"files": [
|
|
||||||
"bootstrap.php"
|
|
||||||
],
|
|
||||||
"psr-4": {
|
|
||||||
"Symfony\\Polyfill\\Php80\\": ""
|
|
||||||
},
|
|
||||||
"classmap": [
|
|
||||||
"Resources/stubs"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"notification-url": "https://packagist.org/downloads/",
|
|
||||||
"license": [
|
|
||||||
"MIT"
|
|
||||||
],
|
|
||||||
"authors": [
|
|
||||||
{
|
|
||||||
"name": "Ion Bazan",
|
|
||||||
"email": "ion.bazan@gmail.com"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Nicolas Grekas",
|
|
||||||
"email": "p@tchwork.com"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Symfony Community",
|
|
||||||
"homepage": "https://symfony.com/contributors"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"description": "Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions",
|
|
||||||
"homepage": "https://symfony.com",
|
|
||||||
"keywords": [
|
|
||||||
"compatibility",
|
|
||||||
"polyfill",
|
|
||||||
"portable",
|
|
||||||
"shim"
|
|
||||||
],
|
|
||||||
"support": {
|
|
||||||
"source": "https://github.com/symfony/polyfill-php80/tree/v1.31.0"
|
|
||||||
},
|
|
||||||
"funding": [
|
|
||||||
{
|
|
||||||
"url": "https://symfony.com/sponsor",
|
|
||||||
"type": "custom"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"url": "https://github.com/fabpot",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
|
|
||||||
"type": "tidelift"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"install-path": "../symfony/polyfill-php80"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "vlucas/phpdotenv",
|
|
||||||
"version": "v5.6.1",
|
|
||||||
"version_normalized": "5.6.1.0",
|
|
||||||
"source": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://github.com/vlucas/phpdotenv.git",
|
|
||||||
"reference": "a59a13791077fe3d44f90e7133eb68e7d22eaff2"
|
|
||||||
},
|
|
||||||
"dist": {
|
|
||||||
"type": "zip",
|
|
||||||
"url": "https://api.github.com/repos/vlucas/phpdotenv/zipball/a59a13791077fe3d44f90e7133eb68e7d22eaff2",
|
|
||||||
"reference": "a59a13791077fe3d44f90e7133eb68e7d22eaff2",
|
|
||||||
"shasum": ""
|
|
||||||
},
|
|
||||||
"require": {
|
|
||||||
"ext-pcre": "*",
|
|
||||||
"graham-campbell/result-type": "^1.1.3",
|
|
||||||
"php": "^7.2.5 || ^8.0",
|
|
||||||
"phpoption/phpoption": "^1.9.3",
|
|
||||||
"symfony/polyfill-ctype": "^1.24",
|
|
||||||
"symfony/polyfill-mbstring": "^1.24",
|
|
||||||
"symfony/polyfill-php80": "^1.24"
|
|
||||||
},
|
|
||||||
"require-dev": {
|
|
||||||
"bamarni/composer-bin-plugin": "^1.8.2",
|
|
||||||
"ext-filter": "*",
|
|
||||||
"phpunit/phpunit": "^8.5.34 || ^9.6.13 || ^10.4.2"
|
|
||||||
},
|
|
||||||
"suggest": {
|
|
||||||
"ext-filter": "Required to use the boolean validator."
|
|
||||||
},
|
|
||||||
"time": "2024-07-20T21:52:34+00:00",
|
|
||||||
"type": "library",
|
|
||||||
"extra": {
|
|
||||||
"bamarni-bin": {
|
|
||||||
"bin-links": true,
|
|
||||||
"forward-command": false
|
|
||||||
},
|
|
||||||
"branch-alias": {
|
|
||||||
"dev-master": "5.6-dev"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"installation-source": "dist",
|
|
||||||
"autoload": {
|
|
||||||
"psr-4": {
|
|
||||||
"Dotenv\\": "src/"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"notification-url": "https://packagist.org/downloads/",
|
|
||||||
"license": [
|
|
||||||
"BSD-3-Clause"
|
|
||||||
],
|
|
||||||
"authors": [
|
|
||||||
{
|
|
||||||
"name": "Graham Campbell",
|
|
||||||
"email": "hello@gjcampbell.co.uk",
|
|
||||||
"homepage": "https://github.com/GrahamCampbell"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Vance Lucas",
|
|
||||||
"email": "vance@vancelucas.com",
|
|
||||||
"homepage": "https://github.com/vlucas"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"description": "Loads environment variables from `.env` to `getenv()`, `$_ENV` and `$_SERVER` automagically.",
|
|
||||||
"keywords": [
|
|
||||||
"dotenv",
|
|
||||||
"env",
|
|
||||||
"environment"
|
|
||||||
],
|
|
||||||
"support": {
|
|
||||||
"issues": "https://github.com/vlucas/phpdotenv/issues",
|
|
||||||
"source": "https://github.com/vlucas/phpdotenv/tree/v5.6.1"
|
|
||||||
},
|
|
||||||
"funding": [
|
|
||||||
{
|
|
||||||
"url": "https://github.com/GrahamCampbell",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"url": "https://tidelift.com/funding/github/packagist/vlucas/phpdotenv",
|
|
||||||
"type": "tidelift"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"install-path": "../vlucas/phpdotenv"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"dev": true,
|
|
||||||
"dev-package-names": []
|
|
||||||
}
|
|
||||||
Vendored
-77
@@ -1,77 +0,0 @@
|
|||||||
<?php return array(
|
|
||||||
'root' => array(
|
|
||||||
'name' => 'violet/db-start',
|
|
||||||
'pretty_version' => 'dev-main',
|
|
||||||
'version' => 'dev-main',
|
|
||||||
'reference' => '06f7540b264baf6e8fd1802ba2db18f824a95495',
|
|
||||||
'type' => 'library',
|
|
||||||
'install_path' => __DIR__ . '/../../',
|
|
||||||
'aliases' => array(),
|
|
||||||
'dev' => true,
|
|
||||||
),
|
|
||||||
'versions' => array(
|
|
||||||
'graham-campbell/result-type' => array(
|
|
||||||
'pretty_version' => 'v1.1.3',
|
|
||||||
'version' => '1.1.3.0',
|
|
||||||
'reference' => '3ba905c11371512af9d9bdd27d99b782216b6945',
|
|
||||||
'type' => 'library',
|
|
||||||
'install_path' => __DIR__ . '/../graham-campbell/result-type',
|
|
||||||
'aliases' => array(),
|
|
||||||
'dev_requirement' => false,
|
|
||||||
),
|
|
||||||
'phpoption/phpoption' => array(
|
|
||||||
'pretty_version' => '1.9.3',
|
|
||||||
'version' => '1.9.3.0',
|
|
||||||
'reference' => 'e3fac8b24f56113f7cb96af14958c0dd16330f54',
|
|
||||||
'type' => 'library',
|
|
||||||
'install_path' => __DIR__ . '/../phpoption/phpoption',
|
|
||||||
'aliases' => array(),
|
|
||||||
'dev_requirement' => false,
|
|
||||||
),
|
|
||||||
'symfony/polyfill-ctype' => array(
|
|
||||||
'pretty_version' => 'v1.31.0',
|
|
||||||
'version' => '1.31.0.0',
|
|
||||||
'reference' => 'a3cc8b044a6ea513310cbd48ef7333b384945638',
|
|
||||||
'type' => 'library',
|
|
||||||
'install_path' => __DIR__ . '/../symfony/polyfill-ctype',
|
|
||||||
'aliases' => array(),
|
|
||||||
'dev_requirement' => false,
|
|
||||||
),
|
|
||||||
'symfony/polyfill-mbstring' => array(
|
|
||||||
'pretty_version' => 'v1.31.0',
|
|
||||||
'version' => '1.31.0.0',
|
|
||||||
'reference' => '85181ba99b2345b0ef10ce42ecac37612d9fd341',
|
|
||||||
'type' => 'library',
|
|
||||||
'install_path' => __DIR__ . '/../symfony/polyfill-mbstring',
|
|
||||||
'aliases' => array(),
|
|
||||||
'dev_requirement' => false,
|
|
||||||
),
|
|
||||||
'symfony/polyfill-php80' => array(
|
|
||||||
'pretty_version' => 'v1.31.0',
|
|
||||||
'version' => '1.31.0.0',
|
|
||||||
'reference' => '60328e362d4c2c802a54fcbf04f9d3fb892b4cf8',
|
|
||||||
'type' => 'library',
|
|
||||||
'install_path' => __DIR__ . '/../symfony/polyfill-php80',
|
|
||||||
'aliases' => array(),
|
|
||||||
'dev_requirement' => false,
|
|
||||||
),
|
|
||||||
'violet/db-start' => array(
|
|
||||||
'pretty_version' => 'dev-main',
|
|
||||||
'version' => 'dev-main',
|
|
||||||
'reference' => '06f7540b264baf6e8fd1802ba2db18f824a95495',
|
|
||||||
'type' => 'library',
|
|
||||||
'install_path' => __DIR__ . '/../../',
|
|
||||||
'aliases' => array(),
|
|
||||||
'dev_requirement' => false,
|
|
||||||
),
|
|
||||||
'vlucas/phpdotenv' => array(
|
|
||||||
'pretty_version' => 'v5.6.1',
|
|
||||||
'version' => '5.6.1.0',
|
|
||||||
'reference' => 'a59a13791077fe3d44f90e7133eb68e7d22eaff2',
|
|
||||||
'type' => 'library',
|
|
||||||
'install_path' => __DIR__ . '/../vlucas/phpdotenv',
|
|
||||||
'aliases' => array(),
|
|
||||||
'dev_requirement' => false,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
Vendored
-26
@@ -1,26 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
// platform_check.php @generated by Composer
|
|
||||||
|
|
||||||
$issues = array();
|
|
||||||
|
|
||||||
if (!(PHP_VERSION_ID >= 70205)) {
|
|
||||||
$issues[] = 'Your Composer dependencies require a PHP version ">= 7.2.5". You are running ' . PHP_VERSION . '.';
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($issues) {
|
|
||||||
if (!headers_sent()) {
|
|
||||||
header('HTTP/1.1 500 Internal Server Error');
|
|
||||||
}
|
|
||||||
if (!ini_get('display_errors')) {
|
|
||||||
if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') {
|
|
||||||
fwrite(STDERR, 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . implode(PHP_EOL, $issues) . PHP_EOL.PHP_EOL);
|
|
||||||
} elseif (!headers_sent()) {
|
|
||||||
echo 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . str_replace('You are running '.PHP_VERSION.'.', '', implode(PHP_EOL, $issues)) . PHP_EOL.PHP_EOL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
trigger_error(
|
|
||||||
'Composer detected issues in your platform: ' . implode(' ', $issues),
|
|
||||||
E_USER_ERROR
|
|
||||||
);
|
|
||||||
}
|
|
||||||
-21
@@ -1,21 +0,0 @@
|
|||||||
The MIT License (MIT)
|
|
||||||
|
|
||||||
Copyright (c) 2020-2024 Graham Campbell <hello@gjcampbell.co.uk>
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
|
||||||
in the Software without restriction, including without limitation the rights
|
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
copies of the Software, and to permit persons to whom the Software is
|
|
||||||
furnished to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in
|
|
||||||
all copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
||||||
THE SOFTWARE.
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "graham-campbell/result-type",
|
|
||||||
"description": "An Implementation Of The Result Type",
|
|
||||||
"keywords": ["result", "result-type", "Result", "Result Type", "Result-Type", "Graham Campbell", "GrahamCampbell"],
|
|
||||||
"license": "MIT",
|
|
||||||
"authors": [
|
|
||||||
{
|
|
||||||
"name": "Graham Campbell",
|
|
||||||
"email": "hello@gjcampbell.co.uk",
|
|
||||||
"homepage": "https://github.com/GrahamCampbell"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"require": {
|
|
||||||
"php": "^7.2.5 || ^8.0",
|
|
||||||
"phpoption/phpoption": "^1.9.3"
|
|
||||||
},
|
|
||||||
"require-dev": {
|
|
||||||
"phpunit/phpunit": "^8.5.39 || ^9.6.20 || ^10.5.28"
|
|
||||||
},
|
|
||||||
"autoload": {
|
|
||||||
"psr-4": {
|
|
||||||
"GrahamCampbell\\ResultType\\": "src/"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"autoload-dev": {
|
|
||||||
"psr-4": {
|
|
||||||
"GrahamCampbell\\Tests\\ResultType\\": "tests/"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"config": {
|
|
||||||
"preferred-install": "dist"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-121
@@ -1,121 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of Result Type.
|
|
||||||
*
|
|
||||||
* (c) Graham Campbell <hello@gjcampbell.co.uk>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace GrahamCampbell\ResultType;
|
|
||||||
|
|
||||||
use PhpOption\None;
|
|
||||||
use PhpOption\Some;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @template T
|
|
||||||
* @template E
|
|
||||||
*
|
|
||||||
* @extends \GrahamCampbell\ResultType\Result<T,E>
|
|
||||||
*/
|
|
||||||
final class Error extends Result
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @var E
|
|
||||||
*/
|
|
||||||
private $value;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Internal constructor for an error value.
|
|
||||||
*
|
|
||||||
* @param E $value
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
private function __construct($value)
|
|
||||||
{
|
|
||||||
$this->value = $value;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a new error value.
|
|
||||||
*
|
|
||||||
* @template F
|
|
||||||
*
|
|
||||||
* @param F $value
|
|
||||||
*
|
|
||||||
* @return \GrahamCampbell\ResultType\Result<T,F>
|
|
||||||
*/
|
|
||||||
public static function create($value)
|
|
||||||
{
|
|
||||||
return new self($value);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the success option value.
|
|
||||||
*
|
|
||||||
* @return \PhpOption\Option<T>
|
|
||||||
*/
|
|
||||||
public function success()
|
|
||||||
{
|
|
||||||
return None::create();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Map over the success value.
|
|
||||||
*
|
|
||||||
* @template S
|
|
||||||
*
|
|
||||||
* @param callable(T):S $f
|
|
||||||
*
|
|
||||||
* @return \GrahamCampbell\ResultType\Result<S,E>
|
|
||||||
*/
|
|
||||||
public function map(callable $f)
|
|
||||||
{
|
|
||||||
return self::create($this->value);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Flat map over the success value.
|
|
||||||
*
|
|
||||||
* @template S
|
|
||||||
* @template F
|
|
||||||
*
|
|
||||||
* @param callable(T):\GrahamCampbell\ResultType\Result<S,F> $f
|
|
||||||
*
|
|
||||||
* @return \GrahamCampbell\ResultType\Result<S,F>
|
|
||||||
*/
|
|
||||||
public function flatMap(callable $f)
|
|
||||||
{
|
|
||||||
/** @var \GrahamCampbell\ResultType\Result<S,F> */
|
|
||||||
return self::create($this->value);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the error option value.
|
|
||||||
*
|
|
||||||
* @return \PhpOption\Option<E>
|
|
||||||
*/
|
|
||||||
public function error()
|
|
||||||
{
|
|
||||||
return Some::create($this->value);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Map over the error value.
|
|
||||||
*
|
|
||||||
* @template F
|
|
||||||
*
|
|
||||||
* @param callable(E):F $f
|
|
||||||
*
|
|
||||||
* @return \GrahamCampbell\ResultType\Result<T,F>
|
|
||||||
*/
|
|
||||||
public function mapError(callable $f)
|
|
||||||
{
|
|
||||||
return self::create($f($this->value));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,69 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of Result Type.
|
|
||||||
*
|
|
||||||
* (c) Graham Campbell <hello@gjcampbell.co.uk>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace GrahamCampbell\ResultType;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @template T
|
|
||||||
* @template E
|
|
||||||
*/
|
|
||||||
abstract class Result
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Get the success option value.
|
|
||||||
*
|
|
||||||
* @return \PhpOption\Option<T>
|
|
||||||
*/
|
|
||||||
abstract public function success();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Map over the success value.
|
|
||||||
*
|
|
||||||
* @template S
|
|
||||||
*
|
|
||||||
* @param callable(T):S $f
|
|
||||||
*
|
|
||||||
* @return \GrahamCampbell\ResultType\Result<S,E>
|
|
||||||
*/
|
|
||||||
abstract public function map(callable $f);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Flat map over the success value.
|
|
||||||
*
|
|
||||||
* @template S
|
|
||||||
* @template F
|
|
||||||
*
|
|
||||||
* @param callable(T):\GrahamCampbell\ResultType\Result<S,F> $f
|
|
||||||
*
|
|
||||||
* @return \GrahamCampbell\ResultType\Result<S,F>
|
|
||||||
*/
|
|
||||||
abstract public function flatMap(callable $f);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the error option value.
|
|
||||||
*
|
|
||||||
* @return \PhpOption\Option<E>
|
|
||||||
*/
|
|
||||||
abstract public function error();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Map over the error value.
|
|
||||||
*
|
|
||||||
* @template F
|
|
||||||
*
|
|
||||||
* @param callable(E):F $f
|
|
||||||
*
|
|
||||||
* @return \GrahamCampbell\ResultType\Result<T,F>
|
|
||||||
*/
|
|
||||||
abstract public function mapError(callable $f);
|
|
||||||
}
|
|
||||||
-120
@@ -1,120 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of Result Type.
|
|
||||||
*
|
|
||||||
* (c) Graham Campbell <hello@gjcampbell.co.uk>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace GrahamCampbell\ResultType;
|
|
||||||
|
|
||||||
use PhpOption\None;
|
|
||||||
use PhpOption\Some;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @template T
|
|
||||||
* @template E
|
|
||||||
*
|
|
||||||
* @extends \GrahamCampbell\ResultType\Result<T,E>
|
|
||||||
*/
|
|
||||||
final class Success extends Result
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @var T
|
|
||||||
*/
|
|
||||||
private $value;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Internal constructor for a success value.
|
|
||||||
*
|
|
||||||
* @param T $value
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
private function __construct($value)
|
|
||||||
{
|
|
||||||
$this->value = $value;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a new error value.
|
|
||||||
*
|
|
||||||
* @template S
|
|
||||||
*
|
|
||||||
* @param S $value
|
|
||||||
*
|
|
||||||
* @return \GrahamCampbell\ResultType\Result<S,E>
|
|
||||||
*/
|
|
||||||
public static function create($value)
|
|
||||||
{
|
|
||||||
return new self($value);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the success option value.
|
|
||||||
*
|
|
||||||
* @return \PhpOption\Option<T>
|
|
||||||
*/
|
|
||||||
public function success()
|
|
||||||
{
|
|
||||||
return Some::create($this->value);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Map over the success value.
|
|
||||||
*
|
|
||||||
* @template S
|
|
||||||
*
|
|
||||||
* @param callable(T):S $f
|
|
||||||
*
|
|
||||||
* @return \GrahamCampbell\ResultType\Result<S,E>
|
|
||||||
*/
|
|
||||||
public function map(callable $f)
|
|
||||||
{
|
|
||||||
return self::create($f($this->value));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Flat map over the success value.
|
|
||||||
*
|
|
||||||
* @template S
|
|
||||||
* @template F
|
|
||||||
*
|
|
||||||
* @param callable(T):\GrahamCampbell\ResultType\Result<S,F> $f
|
|
||||||
*
|
|
||||||
* @return \GrahamCampbell\ResultType\Result<S,F>
|
|
||||||
*/
|
|
||||||
public function flatMap(callable $f)
|
|
||||||
{
|
|
||||||
return $f($this->value);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the error option value.
|
|
||||||
*
|
|
||||||
* @return \PhpOption\Option<E>
|
|
||||||
*/
|
|
||||||
public function error()
|
|
||||||
{
|
|
||||||
return None::create();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Map over the error value.
|
|
||||||
*
|
|
||||||
* @template F
|
|
||||||
*
|
|
||||||
* @param callable(E):F $f
|
|
||||||
*
|
|
||||||
* @return \GrahamCampbell\ResultType\Result<T,F>
|
|
||||||
*/
|
|
||||||
public function mapError(callable $f)
|
|
||||||
{
|
|
||||||
return self::create($this->value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Vendored
-201
@@ -1,201 +0,0 @@
|
|||||||
Apache License
|
|
||||||
Version 2.0, January 2004
|
|
||||||
http://www.apache.org/licenses/
|
|
||||||
|
|
||||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
||||||
|
|
||||||
1. Definitions.
|
|
||||||
|
|
||||||
"License" shall mean the terms and conditions for use, reproduction,
|
|
||||||
and distribution as defined by Sections 1 through 9 of this document.
|
|
||||||
|
|
||||||
"Licensor" shall mean the copyright owner or entity authorized by
|
|
||||||
the copyright owner that is granting the License.
|
|
||||||
|
|
||||||
"Legal Entity" shall mean the union of the acting entity and all
|
|
||||||
other entities that control, are controlled by, or are under common
|
|
||||||
control with that entity. For the purposes of this definition,
|
|
||||||
"control" means (i) the power, direct or indirect, to cause the
|
|
||||||
direction or management of such entity, whether by contract or
|
|
||||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
||||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
||||||
|
|
||||||
"You" (or "Your") shall mean an individual or Legal Entity
|
|
||||||
exercising permissions granted by this License.
|
|
||||||
|
|
||||||
"Source" form shall mean the preferred form for making modifications,
|
|
||||||
including but not limited to software source code, documentation
|
|
||||||
source, and configuration files.
|
|
||||||
|
|
||||||
"Object" form shall mean any form resulting from mechanical
|
|
||||||
transformation or translation of a Source form, including but
|
|
||||||
not limited to compiled object code, generated documentation,
|
|
||||||
and conversions to other media types.
|
|
||||||
|
|
||||||
"Work" shall mean the work of authorship, whether in Source or
|
|
||||||
Object form, made available under the License, as indicated by a
|
|
||||||
copyright notice that is included in or attached to the work
|
|
||||||
(an example is provided in the Appendix below).
|
|
||||||
|
|
||||||
"Derivative Works" shall mean any work, whether in Source or Object
|
|
||||||
form, that is based on (or derived from) the Work and for which the
|
|
||||||
editorial revisions, annotations, elaborations, or other modifications
|
|
||||||
represent, as a whole, an original work of authorship. For the purposes
|
|
||||||
of this License, Derivative Works shall not include works that remain
|
|
||||||
separable from, or merely link (or bind by name) to the interfaces of,
|
|
||||||
the Work and Derivative Works thereof.
|
|
||||||
|
|
||||||
"Contribution" shall mean any work of authorship, including
|
|
||||||
the original version of the Work and any modifications or additions
|
|
||||||
to that Work or Derivative Works thereof, that is intentionally
|
|
||||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
||||||
or by an individual or Legal Entity authorized to submit on behalf of
|
|
||||||
the copyright owner. For the purposes of this definition, "submitted"
|
|
||||||
means any form of electronic, verbal, or written communication sent
|
|
||||||
to the Licensor or its representatives, including but not limited to
|
|
||||||
communication on electronic mailing lists, source code control systems,
|
|
||||||
and issue tracking systems that are managed by, or on behalf of, the
|
|
||||||
Licensor for the purpose of discussing and improving the Work, but
|
|
||||||
excluding communication that is conspicuously marked or otherwise
|
|
||||||
designated in writing by the copyright owner as "Not a Contribution."
|
|
||||||
|
|
||||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
||||||
on behalf of whom a Contribution has been received by Licensor and
|
|
||||||
subsequently incorporated within the Work.
|
|
||||||
|
|
||||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
||||||
this License, each Contributor hereby grants to You a perpetual,
|
|
||||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
||||||
copyright license to reproduce, prepare Derivative Works of,
|
|
||||||
publicly display, publicly perform, sublicense, and distribute the
|
|
||||||
Work and such Derivative Works in Source or Object form.
|
|
||||||
|
|
||||||
3. Grant of Patent License. Subject to the terms and conditions of
|
|
||||||
this License, each Contributor hereby grants to You a perpetual,
|
|
||||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
||||||
(except as stated in this section) patent license to make, have made,
|
|
||||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
||||||
where such license applies only to those patent claims licensable
|
|
||||||
by such Contributor that are necessarily infringed by their
|
|
||||||
Contribution(s) alone or by combination of their Contribution(s)
|
|
||||||
with the Work to which such Contribution(s) was submitted. If You
|
|
||||||
institute patent litigation against any entity (including a
|
|
||||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
||||||
or a Contribution incorporated within the Work constitutes direct
|
|
||||||
or contributory patent infringement, then any patent licenses
|
|
||||||
granted to You under this License for that Work shall terminate
|
|
||||||
as of the date such litigation is filed.
|
|
||||||
|
|
||||||
4. Redistribution. You may reproduce and distribute copies of the
|
|
||||||
Work or Derivative Works thereof in any medium, with or without
|
|
||||||
modifications, and in Source or Object form, provided that You
|
|
||||||
meet the following conditions:
|
|
||||||
|
|
||||||
(a) You must give any other recipients of the Work or
|
|
||||||
Derivative Works a copy of this License; and
|
|
||||||
|
|
||||||
(b) You must cause any modified files to carry prominent notices
|
|
||||||
stating that You changed the files; and
|
|
||||||
|
|
||||||
(c) You must retain, in the Source form of any Derivative Works
|
|
||||||
that You distribute, all copyright, patent, trademark, and
|
|
||||||
attribution notices from the Source form of the Work,
|
|
||||||
excluding those notices that do not pertain to any part of
|
|
||||||
the Derivative Works; and
|
|
||||||
|
|
||||||
(d) If the Work includes a "NOTICE" text file as part of its
|
|
||||||
distribution, then any Derivative Works that You distribute must
|
|
||||||
include a readable copy of the attribution notices contained
|
|
||||||
within such NOTICE file, excluding those notices that do not
|
|
||||||
pertain to any part of the Derivative Works, in at least one
|
|
||||||
of the following places: within a NOTICE text file distributed
|
|
||||||
as part of the Derivative Works; within the Source form or
|
|
||||||
documentation, if provided along with the Derivative Works; or,
|
|
||||||
within a display generated by the Derivative Works, if and
|
|
||||||
wherever such third-party notices normally appear. The contents
|
|
||||||
of the NOTICE file are for informational purposes only and
|
|
||||||
do not modify the License. You may add Your own attribution
|
|
||||||
notices within Derivative Works that You distribute, alongside
|
|
||||||
or as an addendum to the NOTICE text from the Work, provided
|
|
||||||
that such additional attribution notices cannot be construed
|
|
||||||
as modifying the License.
|
|
||||||
|
|
||||||
You may add Your own copyright statement to Your modifications and
|
|
||||||
may provide additional or different license terms and conditions
|
|
||||||
for use, reproduction, or distribution of Your modifications, or
|
|
||||||
for any such Derivative Works as a whole, provided Your use,
|
|
||||||
reproduction, and distribution of the Work otherwise complies with
|
|
||||||
the conditions stated in this License.
|
|
||||||
|
|
||||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
||||||
any Contribution intentionally submitted for inclusion in the Work
|
|
||||||
by You to the Licensor shall be under the terms and conditions of
|
|
||||||
this License, without any additional terms or conditions.
|
|
||||||
Notwithstanding the above, nothing herein shall supersede or modify
|
|
||||||
the terms of any separate license agreement you may have executed
|
|
||||||
with Licensor regarding such Contributions.
|
|
||||||
|
|
||||||
6. Trademarks. This License does not grant permission to use the trade
|
|
||||||
names, trademarks, service marks, or product names of the Licensor,
|
|
||||||
except as required for reasonable and customary use in describing the
|
|
||||||
origin of the Work and reproducing the content of the NOTICE file.
|
|
||||||
|
|
||||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
||||||
agreed to in writing, Licensor provides the Work (and each
|
|
||||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
||||||
implied, including, without limitation, any warranties or conditions
|
|
||||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
||||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
||||||
appropriateness of using or redistributing the Work and assume any
|
|
||||||
risks associated with Your exercise of permissions under this License.
|
|
||||||
|
|
||||||
8. Limitation of Liability. In no event and under no legal theory,
|
|
||||||
whether in tort (including negligence), contract, or otherwise,
|
|
||||||
unless required by applicable law (such as deliberate and grossly
|
|
||||||
negligent acts) or agreed to in writing, shall any Contributor be
|
|
||||||
liable to You for damages, including any direct, indirect, special,
|
|
||||||
incidental, or consequential damages of any character arising as a
|
|
||||||
result of this License or out of the use or inability to use the
|
|
||||||
Work (including but not limited to damages for loss of goodwill,
|
|
||||||
work stoppage, computer failure or malfunction, or any and all
|
|
||||||
other commercial damages or losses), even if such Contributor
|
|
||||||
has been advised of the possibility of such damages.
|
|
||||||
|
|
||||||
9. Accepting Warranty or Additional Liability. While redistributing
|
|
||||||
the Work or Derivative Works thereof, You may choose to offer,
|
|
||||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
||||||
or other liability obligations and/or rights consistent with this
|
|
||||||
License. However, in accepting such obligations, You may act only
|
|
||||||
on Your own behalf and on Your sole responsibility, not on behalf
|
|
||||||
of any other Contributor, and only if You agree to indemnify,
|
|
||||||
defend, and hold each Contributor harmless for any liability
|
|
||||||
incurred by, or claims asserted against, such Contributor by reason
|
|
||||||
of your accepting any such warranty or additional liability.
|
|
||||||
|
|
||||||
END OF TERMS AND CONDITIONS
|
|
||||||
|
|
||||||
APPENDIX: How to apply the Apache License to your work.
|
|
||||||
|
|
||||||
To apply the Apache License to your work, attach the following
|
|
||||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
||||||
replaced with your own identifying information. (Don't include
|
|
||||||
the brackets!) The text should be enclosed in the appropriate
|
|
||||||
comment syntax for the file format. We also recommend that a
|
|
||||||
file or class name and description of purpose be included on the
|
|
||||||
same "printed page" as the copyright notice for easier
|
|
||||||
identification within third-party archives.
|
|
||||||
|
|
||||||
Copyright [yyyy] [name of copyright owner]
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
-50
@@ -1,50 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "phpoption/phpoption",
|
|
||||||
"description": "Option Type for PHP",
|
|
||||||
"keywords": ["php", "option", "language", "type"],
|
|
||||||
"license": "Apache-2.0",
|
|
||||||
"authors": [
|
|
||||||
{
|
|
||||||
"name": "Johannes M. Schmitt",
|
|
||||||
"email": "schmittjoh@gmail.com",
|
|
||||||
"homepage": "https://github.com/schmittjoh"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Graham Campbell",
|
|
||||||
"email": "hello@gjcampbell.co.uk",
|
|
||||||
"homepage": "https://github.com/GrahamCampbell"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"require": {
|
|
||||||
"php": "^7.2.5 || ^8.0"
|
|
||||||
},
|
|
||||||
"require-dev": {
|
|
||||||
"bamarni/composer-bin-plugin": "^1.8.2",
|
|
||||||
"phpunit/phpunit": "^8.5.39 || ^9.6.20 || ^10.5.28"
|
|
||||||
},
|
|
||||||
"autoload": {
|
|
||||||
"psr-4": {
|
|
||||||
"PhpOption\\": "src/PhpOption/"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"autoload-dev": {
|
|
||||||
"psr-4": {
|
|
||||||
"PhpOption\\Tests\\": "tests/PhpOption/Tests/"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"config": {
|
|
||||||
"allow-plugins": {
|
|
||||||
"bamarni/composer-bin-plugin": true
|
|
||||||
},
|
|
||||||
"preferred-install": "dist"
|
|
||||||
},
|
|
||||||
"extra": {
|
|
||||||
"bamarni-bin": {
|
|
||||||
"bin-links": true,
|
|
||||||
"forward-command": false
|
|
||||||
},
|
|
||||||
"branch-alias": {
|
|
||||||
"dev-master": "1.9-dev"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,175 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright 2012 Johannes M. Schmitt <schmittjoh@gmail.com>
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace PhpOption;
|
|
||||||
|
|
||||||
use Traversable;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @template T
|
|
||||||
*
|
|
||||||
* @extends Option<T>
|
|
||||||
*/
|
|
||||||
final class LazyOption extends Option
|
|
||||||
{
|
|
||||||
/** @var callable(mixed...):(Option<T>) */
|
|
||||||
private $callback;
|
|
||||||
|
|
||||||
/** @var array<int, mixed> */
|
|
||||||
private $arguments;
|
|
||||||
|
|
||||||
/** @var Option<T>|null */
|
|
||||||
private $option;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @template S
|
|
||||||
* @param callable(mixed...):(Option<S>) $callback
|
|
||||||
* @param array<int, mixed> $arguments
|
|
||||||
*
|
|
||||||
* @return LazyOption<S>
|
|
||||||
*/
|
|
||||||
public static function create($callback, array $arguments = []): self
|
|
||||||
{
|
|
||||||
return new self($callback, $arguments);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param callable(mixed...):(Option<T>) $callback
|
|
||||||
* @param array<int, mixed> $arguments
|
|
||||||
*/
|
|
||||||
public function __construct($callback, array $arguments = [])
|
|
||||||
{
|
|
||||||
if (!is_callable($callback)) {
|
|
||||||
throw new \InvalidArgumentException('Invalid callback given');
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->callback = $callback;
|
|
||||||
$this->arguments = $arguments;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function isDefined(): bool
|
|
||||||
{
|
|
||||||
return $this->option()->isDefined();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function isEmpty(): bool
|
|
||||||
{
|
|
||||||
return $this->option()->isEmpty();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function get()
|
|
||||||
{
|
|
||||||
return $this->option()->get();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getOrElse($default)
|
|
||||||
{
|
|
||||||
return $this->option()->getOrElse($default);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getOrCall($callable)
|
|
||||||
{
|
|
||||||
return $this->option()->getOrCall($callable);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getOrThrow(\Exception $ex)
|
|
||||||
{
|
|
||||||
return $this->option()->getOrThrow($ex);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function orElse(Option $else)
|
|
||||||
{
|
|
||||||
return $this->option()->orElse($else);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function ifDefined($callable)
|
|
||||||
{
|
|
||||||
$this->option()->forAll($callable);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function forAll($callable)
|
|
||||||
{
|
|
||||||
return $this->option()->forAll($callable);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function map($callable)
|
|
||||||
{
|
|
||||||
return $this->option()->map($callable);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function flatMap($callable)
|
|
||||||
{
|
|
||||||
return $this->option()->flatMap($callable);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function filter($callable)
|
|
||||||
{
|
|
||||||
return $this->option()->filter($callable);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function filterNot($callable)
|
|
||||||
{
|
|
||||||
return $this->option()->filterNot($callable);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function select($value)
|
|
||||||
{
|
|
||||||
return $this->option()->select($value);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function reject($value)
|
|
||||||
{
|
|
||||||
return $this->option()->reject($value);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return Traversable<T>
|
|
||||||
*/
|
|
||||||
public function getIterator(): Traversable
|
|
||||||
{
|
|
||||||
return $this->option()->getIterator();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function foldLeft($initialValue, $callable)
|
|
||||||
{
|
|
||||||
return $this->option()->foldLeft($initialValue, $callable);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function foldRight($initialValue, $callable)
|
|
||||||
{
|
|
||||||
return $this->option()->foldRight($initialValue, $callable);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return Option<T>
|
|
||||||
*/
|
|
||||||
private function option(): Option
|
|
||||||
{
|
|
||||||
if (null === $this->option) {
|
|
||||||
/** @var mixed */
|
|
||||||
$option = call_user_func_array($this->callback, $this->arguments);
|
|
||||||
if ($option instanceof Option) {
|
|
||||||
$this->option = $option;
|
|
||||||
} else {
|
|
||||||
throw new \RuntimeException(sprintf('Expected instance of %s', Option::class));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->option;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-136
@@ -1,136 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright 2012 Johannes M. Schmitt <schmittjoh@gmail.com>
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace PhpOption;
|
|
||||||
|
|
||||||
use EmptyIterator;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @extends Option<mixed>
|
|
||||||
*/
|
|
||||||
final class None extends Option
|
|
||||||
{
|
|
||||||
/** @var None|null */
|
|
||||||
private static $instance;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return None
|
|
||||||
*/
|
|
||||||
public static function create(): self
|
|
||||||
{
|
|
||||||
if (null === self::$instance) {
|
|
||||||
self::$instance = new self();
|
|
||||||
}
|
|
||||||
|
|
||||||
return self::$instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function get()
|
|
||||||
{
|
|
||||||
throw new \RuntimeException('None has no value.');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getOrCall($callable)
|
|
||||||
{
|
|
||||||
return $callable();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getOrElse($default)
|
|
||||||
{
|
|
||||||
return $default;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getOrThrow(\Exception $ex)
|
|
||||||
{
|
|
||||||
throw $ex;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function isEmpty(): bool
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function isDefined(): bool
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function orElse(Option $else)
|
|
||||||
{
|
|
||||||
return $else;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function ifDefined($callable)
|
|
||||||
{
|
|
||||||
// Just do nothing in that case.
|
|
||||||
}
|
|
||||||
|
|
||||||
public function forAll($callable)
|
|
||||||
{
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function map($callable)
|
|
||||||
{
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function flatMap($callable)
|
|
||||||
{
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function filter($callable)
|
|
||||||
{
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function filterNot($callable)
|
|
||||||
{
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function select($value)
|
|
||||||
{
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function reject($value)
|
|
||||||
{
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getIterator(): EmptyIterator
|
|
||||||
{
|
|
||||||
return new EmptyIterator();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function foldLeft($initialValue, $callable)
|
|
||||||
{
|
|
||||||
return $initialValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function foldRight($initialValue, $callable)
|
|
||||||
{
|
|
||||||
return $initialValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
private function __construct()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-434
@@ -1,434 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright 2012 Johannes M. Schmitt <schmittjoh@gmail.com>
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace PhpOption;
|
|
||||||
|
|
||||||
use ArrayAccess;
|
|
||||||
use IteratorAggregate;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @template T
|
|
||||||
*
|
|
||||||
* @implements IteratorAggregate<T>
|
|
||||||
*/
|
|
||||||
abstract class Option implements IteratorAggregate
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Creates an option given a return value.
|
|
||||||
*
|
|
||||||
* This is intended for consuming existing APIs and allows you to easily
|
|
||||||
* convert them to an option. By default, we treat ``null`` as the None
|
|
||||||
* case, and everything else as Some.
|
|
||||||
*
|
|
||||||
* @template S
|
|
||||||
*
|
|
||||||
* @param S $value The actual return value.
|
|
||||||
* @param S $noneValue The value which should be considered "None"; null by
|
|
||||||
* default.
|
|
||||||
*
|
|
||||||
* @return Option<S>
|
|
||||||
*/
|
|
||||||
public static function fromValue($value, $noneValue = null)
|
|
||||||
{
|
|
||||||
if ($value === $noneValue) {
|
|
||||||
return None::create();
|
|
||||||
}
|
|
||||||
|
|
||||||
return new Some($value);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates an option from an array's value.
|
|
||||||
*
|
|
||||||
* If the key does not exist in the array, the array is not actually an
|
|
||||||
* array, or the array's value at the given key is null, None is returned.
|
|
||||||
* Otherwise, Some is returned wrapping the value at the given key.
|
|
||||||
*
|
|
||||||
* @template S
|
|
||||||
*
|
|
||||||
* @param array<string|int,S>|ArrayAccess<string|int,S>|null $array A potential array or \ArrayAccess value.
|
|
||||||
* @param string|int|null $key The key to check.
|
|
||||||
*
|
|
||||||
* @return Option<S>
|
|
||||||
*/
|
|
||||||
public static function fromArraysValue($array, $key)
|
|
||||||
{
|
|
||||||
if ($key === null || !(is_array($array) || $array instanceof ArrayAccess) || !isset($array[$key])) {
|
|
||||||
return None::create();
|
|
||||||
}
|
|
||||||
|
|
||||||
return new Some($array[$key]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a lazy-option with the given callback.
|
|
||||||
*
|
|
||||||
* This is also a helper constructor for lazy-consuming existing APIs where
|
|
||||||
* the return value is not yet an option. By default, we treat ``null`` as
|
|
||||||
* None case, and everything else as Some.
|
|
||||||
*
|
|
||||||
* @template S
|
|
||||||
*
|
|
||||||
* @param callable $callback The callback to evaluate.
|
|
||||||
* @param array $arguments The arguments for the callback.
|
|
||||||
* @param S $noneValue The value which should be considered "None";
|
|
||||||
* null by default.
|
|
||||||
*
|
|
||||||
* @return LazyOption<S>
|
|
||||||
*/
|
|
||||||
public static function fromReturn($callback, array $arguments = [], $noneValue = null)
|
|
||||||
{
|
|
||||||
return new LazyOption(static function () use ($callback, $arguments, $noneValue) {
|
|
||||||
/** @var mixed */
|
|
||||||
$return = call_user_func_array($callback, $arguments);
|
|
||||||
|
|
||||||
if ($return === $noneValue) {
|
|
||||||
return None::create();
|
|
||||||
}
|
|
||||||
|
|
||||||
return new Some($return);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Option factory, which creates new option based on passed value.
|
|
||||||
*
|
|
||||||
* If value is already an option, it simply returns. If value is callable,
|
|
||||||
* LazyOption with passed callback created and returned. If Option
|
|
||||||
* returned from callback, it returns directly. On other case value passed
|
|
||||||
* to Option::fromValue() method.
|
|
||||||
*
|
|
||||||
* @template S
|
|
||||||
*
|
|
||||||
* @param Option<S>|callable|S $value
|
|
||||||
* @param S $noneValue Used when $value is mixed or
|
|
||||||
* callable, for None-check.
|
|
||||||
*
|
|
||||||
* @return Option<S>|LazyOption<S>
|
|
||||||
*/
|
|
||||||
public static function ensure($value, $noneValue = null)
|
|
||||||
{
|
|
||||||
if ($value instanceof self) {
|
|
||||||
return $value;
|
|
||||||
} elseif (is_callable($value)) {
|
|
||||||
return new LazyOption(static function () use ($value, $noneValue) {
|
|
||||||
/** @var mixed */
|
|
||||||
$return = $value();
|
|
||||||
|
|
||||||
if ($return instanceof self) {
|
|
||||||
return $return;
|
|
||||||
} else {
|
|
||||||
return self::fromValue($return, $noneValue);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
return self::fromValue($value, $noneValue);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Lift a function so that it accepts Option as parameters.
|
|
||||||
*
|
|
||||||
* We return a new closure that wraps the original callback. If any of the
|
|
||||||
* parameters passed to the lifted function is empty, the function will
|
|
||||||
* return a value of None. Otherwise, we will pass all parameters to the
|
|
||||||
* original callback and return the value inside a new Option, unless an
|
|
||||||
* Option is returned from the function, in which case, we use that.
|
|
||||||
*
|
|
||||||
* @template S
|
|
||||||
*
|
|
||||||
* @param callable $callback
|
|
||||||
* @param mixed $noneValue
|
|
||||||
*
|
|
||||||
* @return callable
|
|
||||||
*/
|
|
||||||
public static function lift($callback, $noneValue = null)
|
|
||||||
{
|
|
||||||
return static function () use ($callback, $noneValue) {
|
|
||||||
/** @var array<int, mixed> */
|
|
||||||
$args = func_get_args();
|
|
||||||
|
|
||||||
$reduced_args = array_reduce(
|
|
||||||
$args,
|
|
||||||
/** @param bool $status */
|
|
||||||
static function ($status, self $o) {
|
|
||||||
return $o->isEmpty() ? true : $status;
|
|
||||||
},
|
|
||||||
false
|
|
||||||
);
|
|
||||||
// if at least one parameter is empty, return None
|
|
||||||
if ($reduced_args) {
|
|
||||||
return None::create();
|
|
||||||
}
|
|
||||||
|
|
||||||
$args = array_map(
|
|
||||||
/** @return T */
|
|
||||||
static function (self $o) {
|
|
||||||
// it is safe to do so because the fold above checked
|
|
||||||
// that all arguments are of type Some
|
|
||||||
/** @var T */
|
|
||||||
return $o->get();
|
|
||||||
},
|
|
||||||
$args
|
|
||||||
);
|
|
||||||
|
|
||||||
return self::ensure(call_user_func_array($callback, $args), $noneValue);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the value if available, or throws an exception otherwise.
|
|
||||||
*
|
|
||||||
* @throws \RuntimeException If value is not available.
|
|
||||||
*
|
|
||||||
* @return T
|
|
||||||
*/
|
|
||||||
abstract public function get();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the value if available, or the default value if not.
|
|
||||||
*
|
|
||||||
* @template S
|
|
||||||
*
|
|
||||||
* @param S $default
|
|
||||||
*
|
|
||||||
* @return T|S
|
|
||||||
*/
|
|
||||||
abstract public function getOrElse($default);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the value if available, or the results of the callable.
|
|
||||||
*
|
|
||||||
* This is preferable over ``getOrElse`` if the computation of the default
|
|
||||||
* value is expensive.
|
|
||||||
*
|
|
||||||
* @template S
|
|
||||||
*
|
|
||||||
* @param callable():S $callable
|
|
||||||
*
|
|
||||||
* @return T|S
|
|
||||||
*/
|
|
||||||
abstract public function getOrCall($callable);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the value if available, or throws the passed exception.
|
|
||||||
*
|
|
||||||
* @param \Exception $ex
|
|
||||||
*
|
|
||||||
* @return T
|
|
||||||
*/
|
|
||||||
abstract public function getOrThrow(\Exception $ex);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns true if no value is available, false otherwise.
|
|
||||||
*
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
abstract public function isEmpty();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns true if a value is available, false otherwise.
|
|
||||||
*
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
abstract public function isDefined();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns this option if non-empty, or the passed option otherwise.
|
|
||||||
*
|
|
||||||
* This can be used to try multiple alternatives, and is especially useful
|
|
||||||
* with lazy evaluating options:
|
|
||||||
*
|
|
||||||
* ```php
|
|
||||||
* $repo->findSomething()
|
|
||||||
* ->orElse(new LazyOption(array($repo, 'findSomethingElse')))
|
|
||||||
* ->orElse(new LazyOption(array($repo, 'createSomething')));
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* @param Option<T> $else
|
|
||||||
*
|
|
||||||
* @return Option<T>
|
|
||||||
*/
|
|
||||||
abstract public function orElse(self $else);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This is similar to map() below except that the return value has no meaning;
|
|
||||||
* the passed callable is simply executed if the option is non-empty, and
|
|
||||||
* ignored if the option is empty.
|
|
||||||
*
|
|
||||||
* In all cases, the return value of the callable is discarded.
|
|
||||||
*
|
|
||||||
* ```php
|
|
||||||
* $comment->getMaybeFile()->ifDefined(function($file) {
|
|
||||||
* // Do something with $file here.
|
|
||||||
* });
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* If you're looking for something like ``ifEmpty``, you can use ``getOrCall``
|
|
||||||
* and ``getOrElse`` in these cases.
|
|
||||||
*
|
|
||||||
* @deprecated Use forAll() instead.
|
|
||||||
*
|
|
||||||
* @param callable(T):mixed $callable
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
abstract public function ifDefined($callable);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This is similar to map() except that the return value of the callable has no meaning.
|
|
||||||
*
|
|
||||||
* The passed callable is simply executed if the option is non-empty, and ignored if the
|
|
||||||
* option is empty. This method is preferred for callables with side-effects, while map()
|
|
||||||
* is intended for callables without side-effects.
|
|
||||||
*
|
|
||||||
* @param callable(T):mixed $callable
|
|
||||||
*
|
|
||||||
* @return Option<T>
|
|
||||||
*/
|
|
||||||
abstract public function forAll($callable);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Applies the callable to the value of the option if it is non-empty,
|
|
||||||
* and returns the return value of the callable wrapped in Some().
|
|
||||||
*
|
|
||||||
* If the option is empty, then the callable is not applied.
|
|
||||||
*
|
|
||||||
* ```php
|
|
||||||
* (new Some("foo"))->map('strtoupper')->get(); // "FOO"
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* @template S
|
|
||||||
*
|
|
||||||
* @param callable(T):S $callable
|
|
||||||
*
|
|
||||||
* @return Option<S>
|
|
||||||
*/
|
|
||||||
abstract public function map($callable);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Applies the callable to the value of the option if it is non-empty, and
|
|
||||||
* returns the return value of the callable directly.
|
|
||||||
*
|
|
||||||
* In contrast to ``map``, the return value of the callable is expected to
|
|
||||||
* be an Option itself; it is not automatically wrapped in Some().
|
|
||||||
*
|
|
||||||
* @template S
|
|
||||||
*
|
|
||||||
* @param callable(T):Option<S> $callable must return an Option
|
|
||||||
*
|
|
||||||
* @return Option<S>
|
|
||||||
*/
|
|
||||||
abstract public function flatMap($callable);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* If the option is empty, it is returned immediately without applying the callable.
|
|
||||||
*
|
|
||||||
* If the option is non-empty, the callable is applied, and if it returns true,
|
|
||||||
* the option itself is returned; otherwise, None is returned.
|
|
||||||
*
|
|
||||||
* @param callable(T):bool $callable
|
|
||||||
*
|
|
||||||
* @return Option<T>
|
|
||||||
*/
|
|
||||||
abstract public function filter($callable);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* If the option is empty, it is returned immediately without applying the callable.
|
|
||||||
*
|
|
||||||
* If the option is non-empty, the callable is applied, and if it returns false,
|
|
||||||
* the option itself is returned; otherwise, None is returned.
|
|
||||||
*
|
|
||||||
* @param callable(T):bool $callable
|
|
||||||
*
|
|
||||||
* @return Option<T>
|
|
||||||
*/
|
|
||||||
abstract public function filterNot($callable);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* If the option is empty, it is returned immediately.
|
|
||||||
*
|
|
||||||
* If the option is non-empty, and its value does not equal the passed value
|
|
||||||
* (via a shallow comparison ===), then None is returned. Otherwise, the
|
|
||||||
* Option is returned.
|
|
||||||
*
|
|
||||||
* In other words, this will filter all but the passed value.
|
|
||||||
*
|
|
||||||
* @param T $value
|
|
||||||
*
|
|
||||||
* @return Option<T>
|
|
||||||
*/
|
|
||||||
abstract public function select($value);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* If the option is empty, it is returned immediately.
|
|
||||||
*
|
|
||||||
* If the option is non-empty, and its value does equal the passed value (via
|
|
||||||
* a shallow comparison ===), then None is returned; otherwise, the Option is
|
|
||||||
* returned.
|
|
||||||
*
|
|
||||||
* In other words, this will let all values through except the passed value.
|
|
||||||
*
|
|
||||||
* @param T $value
|
|
||||||
*
|
|
||||||
* @return Option<T>
|
|
||||||
*/
|
|
||||||
abstract public function reject($value);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Binary operator for the initial value and the option's value.
|
|
||||||
*
|
|
||||||
* If empty, the initial value is returned. If non-empty, the callable
|
|
||||||
* receives the initial value and the option's value as arguments.
|
|
||||||
*
|
|
||||||
* ```php
|
|
||||||
*
|
|
||||||
* $some = new Some(5);
|
|
||||||
* $none = None::create();
|
|
||||||
* $result = $some->foldLeft(1, function($a, $b) { return $a + $b; }); // int(6)
|
|
||||||
* $result = $none->foldLeft(1, function($a, $b) { return $a + $b; }); // int(1)
|
|
||||||
*
|
|
||||||
* // This can be used instead of something like the following:
|
|
||||||
* $option = Option::fromValue($integerOrNull);
|
|
||||||
* $result = 1;
|
|
||||||
* if ( ! $option->isEmpty()) {
|
|
||||||
* $result += $option->get();
|
|
||||||
* }
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* @template S
|
|
||||||
*
|
|
||||||
* @param S $initialValue
|
|
||||||
* @param callable(S, T):S $callable
|
|
||||||
*
|
|
||||||
* @return S
|
|
||||||
*/
|
|
||||||
abstract public function foldLeft($initialValue, $callable);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* foldLeft() but with reversed arguments for the callable.
|
|
||||||
*
|
|
||||||
* @template S
|
|
||||||
*
|
|
||||||
* @param S $initialValue
|
|
||||||
* @param callable(T, S):S $callable
|
|
||||||
*
|
|
||||||
* @return S
|
|
||||||
*/
|
|
||||||
abstract public function foldRight($initialValue, $callable);
|
|
||||||
}
|
|
||||||
-169
@@ -1,169 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright 2012 Johannes M. Schmitt <schmittjoh@gmail.com>
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace PhpOption;
|
|
||||||
|
|
||||||
use ArrayIterator;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @template T
|
|
||||||
*
|
|
||||||
* @extends Option<T>
|
|
||||||
*/
|
|
||||||
final class Some extends Option
|
|
||||||
{
|
|
||||||
/** @var T */
|
|
||||||
private $value;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param T $value
|
|
||||||
*/
|
|
||||||
public function __construct($value)
|
|
||||||
{
|
|
||||||
$this->value = $value;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @template U
|
|
||||||
*
|
|
||||||
* @param U $value
|
|
||||||
*
|
|
||||||
* @return Some<U>
|
|
||||||
*/
|
|
||||||
public static function create($value): self
|
|
||||||
{
|
|
||||||
return new self($value);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function isDefined(): bool
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function isEmpty(): bool
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function get()
|
|
||||||
{
|
|
||||||
return $this->value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getOrElse($default)
|
|
||||||
{
|
|
||||||
return $this->value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getOrCall($callable)
|
|
||||||
{
|
|
||||||
return $this->value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getOrThrow(\Exception $ex)
|
|
||||||
{
|
|
||||||
return $this->value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function orElse(Option $else)
|
|
||||||
{
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function ifDefined($callable)
|
|
||||||
{
|
|
||||||
$this->forAll($callable);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function forAll($callable)
|
|
||||||
{
|
|
||||||
$callable($this->value);
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function map($callable)
|
|
||||||
{
|
|
||||||
return new self($callable($this->value));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function flatMap($callable)
|
|
||||||
{
|
|
||||||
/** @var mixed */
|
|
||||||
$rs = $callable($this->value);
|
|
||||||
if (!$rs instanceof Option) {
|
|
||||||
throw new \RuntimeException('Callables passed to flatMap() must return an Option. Maybe you should use map() instead?');
|
|
||||||
}
|
|
||||||
|
|
||||||
return $rs;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function filter($callable)
|
|
||||||
{
|
|
||||||
if (true === $callable($this->value)) {
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
return None::create();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function filterNot($callable)
|
|
||||||
{
|
|
||||||
if (false === $callable($this->value)) {
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
return None::create();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function select($value)
|
|
||||||
{
|
|
||||||
if ($this->value === $value) {
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
return None::create();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function reject($value)
|
|
||||||
{
|
|
||||||
if ($this->value === $value) {
|
|
||||||
return None::create();
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return ArrayIterator<int, T>
|
|
||||||
*/
|
|
||||||
public function getIterator(): ArrayIterator
|
|
||||||
{
|
|
||||||
return new ArrayIterator([$this->value]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function foldLeft($initialValue, $callable)
|
|
||||||
{
|
|
||||||
return $callable($initialValue, $this->value);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function foldRight($initialValue, $callable)
|
|
||||||
{
|
|
||||||
return $callable($this->value, $initialValue);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-232
@@ -1,232 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of the Symfony package.
|
|
||||||
*
|
|
||||||
* (c) Fabien Potencier <fabien@symfony.com>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Symfony\Polyfill\Ctype;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Ctype implementation through regex.
|
|
||||||
*
|
|
||||||
* @internal
|
|
||||||
*
|
|
||||||
* @author Gert de Pagter <BackEndTea@gmail.com>
|
|
||||||
*/
|
|
||||||
final class Ctype
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Returns TRUE if every character in text is either a letter or a digit, FALSE otherwise.
|
|
||||||
*
|
|
||||||
* @see https://php.net/ctype-alnum
|
|
||||||
*
|
|
||||||
* @param mixed $text
|
|
||||||
*
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
public static function ctype_alnum($text)
|
|
||||||
{
|
|
||||||
$text = self::convert_int_to_char_for_ctype($text, __FUNCTION__);
|
|
||||||
|
|
||||||
return \is_string($text) && '' !== $text && !preg_match('/[^A-Za-z0-9]/', $text);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns TRUE if every character in text is a letter, FALSE otherwise.
|
|
||||||
*
|
|
||||||
* @see https://php.net/ctype-alpha
|
|
||||||
*
|
|
||||||
* @param mixed $text
|
|
||||||
*
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
public static function ctype_alpha($text)
|
|
||||||
{
|
|
||||||
$text = self::convert_int_to_char_for_ctype($text, __FUNCTION__);
|
|
||||||
|
|
||||||
return \is_string($text) && '' !== $text && !preg_match('/[^A-Za-z]/', $text);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns TRUE if every character in text is a control character from the current locale, FALSE otherwise.
|
|
||||||
*
|
|
||||||
* @see https://php.net/ctype-cntrl
|
|
||||||
*
|
|
||||||
* @param mixed $text
|
|
||||||
*
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
public static function ctype_cntrl($text)
|
|
||||||
{
|
|
||||||
$text = self::convert_int_to_char_for_ctype($text, __FUNCTION__);
|
|
||||||
|
|
||||||
return \is_string($text) && '' !== $text && !preg_match('/[^\x00-\x1f\x7f]/', $text);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns TRUE if every character in the string text is a decimal digit, FALSE otherwise.
|
|
||||||
*
|
|
||||||
* @see https://php.net/ctype-digit
|
|
||||||
*
|
|
||||||
* @param mixed $text
|
|
||||||
*
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
public static function ctype_digit($text)
|
|
||||||
{
|
|
||||||
$text = self::convert_int_to_char_for_ctype($text, __FUNCTION__);
|
|
||||||
|
|
||||||
return \is_string($text) && '' !== $text && !preg_match('/[^0-9]/', $text);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns TRUE if every character in text is printable and actually creates visible output (no white space), FALSE otherwise.
|
|
||||||
*
|
|
||||||
* @see https://php.net/ctype-graph
|
|
||||||
*
|
|
||||||
* @param mixed $text
|
|
||||||
*
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
public static function ctype_graph($text)
|
|
||||||
{
|
|
||||||
$text = self::convert_int_to_char_for_ctype($text, __FUNCTION__);
|
|
||||||
|
|
||||||
return \is_string($text) && '' !== $text && !preg_match('/[^!-~]/', $text);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns TRUE if every character in text is a lowercase letter.
|
|
||||||
*
|
|
||||||
* @see https://php.net/ctype-lower
|
|
||||||
*
|
|
||||||
* @param mixed $text
|
|
||||||
*
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
public static function ctype_lower($text)
|
|
||||||
{
|
|
||||||
$text = self::convert_int_to_char_for_ctype($text, __FUNCTION__);
|
|
||||||
|
|
||||||
return \is_string($text) && '' !== $text && !preg_match('/[^a-z]/', $text);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns TRUE if every character in text will actually create output (including blanks). Returns FALSE if text contains control characters or characters that do not have any output or control function at all.
|
|
||||||
*
|
|
||||||
* @see https://php.net/ctype-print
|
|
||||||
*
|
|
||||||
* @param mixed $text
|
|
||||||
*
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
public static function ctype_print($text)
|
|
||||||
{
|
|
||||||
$text = self::convert_int_to_char_for_ctype($text, __FUNCTION__);
|
|
||||||
|
|
||||||
return \is_string($text) && '' !== $text && !preg_match('/[^ -~]/', $text);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns TRUE if every character in text is printable, but neither letter, digit or blank, FALSE otherwise.
|
|
||||||
*
|
|
||||||
* @see https://php.net/ctype-punct
|
|
||||||
*
|
|
||||||
* @param mixed $text
|
|
||||||
*
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
public static function ctype_punct($text)
|
|
||||||
{
|
|
||||||
$text = self::convert_int_to_char_for_ctype($text, __FUNCTION__);
|
|
||||||
|
|
||||||
return \is_string($text) && '' !== $text && !preg_match('/[^!-\/\:-@\[-`\{-~]/', $text);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns TRUE if every character in text creates some sort of white space, FALSE otherwise. Besides the blank character this also includes tab, vertical tab, line feed, carriage return and form feed characters.
|
|
||||||
*
|
|
||||||
* @see https://php.net/ctype-space
|
|
||||||
*
|
|
||||||
* @param mixed $text
|
|
||||||
*
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
public static function ctype_space($text)
|
|
||||||
{
|
|
||||||
$text = self::convert_int_to_char_for_ctype($text, __FUNCTION__);
|
|
||||||
|
|
||||||
return \is_string($text) && '' !== $text && !preg_match('/[^\s]/', $text);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns TRUE if every character in text is an uppercase letter.
|
|
||||||
*
|
|
||||||
* @see https://php.net/ctype-upper
|
|
||||||
*
|
|
||||||
* @param mixed $text
|
|
||||||
*
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
public static function ctype_upper($text)
|
|
||||||
{
|
|
||||||
$text = self::convert_int_to_char_for_ctype($text, __FUNCTION__);
|
|
||||||
|
|
||||||
return \is_string($text) && '' !== $text && !preg_match('/[^A-Z]/', $text);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns TRUE if every character in text is a hexadecimal 'digit', that is a decimal digit or a character from [A-Fa-f] , FALSE otherwise.
|
|
||||||
*
|
|
||||||
* @see https://php.net/ctype-xdigit
|
|
||||||
*
|
|
||||||
* @param mixed $text
|
|
||||||
*
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
public static function ctype_xdigit($text)
|
|
||||||
{
|
|
||||||
$text = self::convert_int_to_char_for_ctype($text, __FUNCTION__);
|
|
||||||
|
|
||||||
return \is_string($text) && '' !== $text && !preg_match('/[^A-Fa-f0-9]/', $text);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Converts integers to their char versions according to normal ctype behaviour, if needed.
|
|
||||||
*
|
|
||||||
* If an integer between -128 and 255 inclusive is provided,
|
|
||||||
* it is interpreted as the ASCII value of a single character
|
|
||||||
* (negative values have 256 added in order to allow characters in the Extended ASCII range).
|
|
||||||
* Any other integer is interpreted as a string containing the decimal digits of the integer.
|
|
||||||
*
|
|
||||||
* @param mixed $int
|
|
||||||
* @param string $function
|
|
||||||
*
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
private static function convert_int_to_char_for_ctype($int, $function)
|
|
||||||
{
|
|
||||||
if (!\is_int($int)) {
|
|
||||||
return $int;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($int < -128 || $int > 255) {
|
|
||||||
return (string) $int;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (\PHP_VERSION_ID >= 80100) {
|
|
||||||
@trigger_error($function.'(): Argument of type int will be interpreted as string in the future', \E_USER_DEPRECATED);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($int < 0) {
|
|
||||||
$int += 256;
|
|
||||||
}
|
|
||||||
|
|
||||||
return \chr($int);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-19
@@ -1,19 +0,0 @@
|
|||||||
Copyright (c) 2018-present Fabien Potencier
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
|
||||||
in the Software without restriction, including without limitation the rights
|
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
copies of the Software, and to permit persons to whom the Software is furnished
|
|
||||||
to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in all
|
|
||||||
copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
||||||
THE SOFTWARE.
|
|
||||||
-12
@@ -1,12 +0,0 @@
|
|||||||
Symfony Polyfill / Ctype
|
|
||||||
========================
|
|
||||||
|
|
||||||
This component provides `ctype_*` functions to users who run php versions without the ctype extension.
|
|
||||||
|
|
||||||
More information can be found in the
|
|
||||||
[main Polyfill README](https://github.com/symfony/polyfill/blob/main/README.md).
|
|
||||||
|
|
||||||
License
|
|
||||||
=======
|
|
||||||
|
|
||||||
This library is released under the [MIT license](LICENSE).
|
|
||||||
-50
@@ -1,50 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of the Symfony package.
|
|
||||||
*
|
|
||||||
* (c) Fabien Potencier <fabien@symfony.com>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
use Symfony\Polyfill\Ctype as p;
|
|
||||||
|
|
||||||
if (\PHP_VERSION_ID >= 80000) {
|
|
||||||
return require __DIR__.'/bootstrap80.php';
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!function_exists('ctype_alnum')) {
|
|
||||||
function ctype_alnum($text) { return p\Ctype::ctype_alnum($text); }
|
|
||||||
}
|
|
||||||
if (!function_exists('ctype_alpha')) {
|
|
||||||
function ctype_alpha($text) { return p\Ctype::ctype_alpha($text); }
|
|
||||||
}
|
|
||||||
if (!function_exists('ctype_cntrl')) {
|
|
||||||
function ctype_cntrl($text) { return p\Ctype::ctype_cntrl($text); }
|
|
||||||
}
|
|
||||||
if (!function_exists('ctype_digit')) {
|
|
||||||
function ctype_digit($text) { return p\Ctype::ctype_digit($text); }
|
|
||||||
}
|
|
||||||
if (!function_exists('ctype_graph')) {
|
|
||||||
function ctype_graph($text) { return p\Ctype::ctype_graph($text); }
|
|
||||||
}
|
|
||||||
if (!function_exists('ctype_lower')) {
|
|
||||||
function ctype_lower($text) { return p\Ctype::ctype_lower($text); }
|
|
||||||
}
|
|
||||||
if (!function_exists('ctype_print')) {
|
|
||||||
function ctype_print($text) { return p\Ctype::ctype_print($text); }
|
|
||||||
}
|
|
||||||
if (!function_exists('ctype_punct')) {
|
|
||||||
function ctype_punct($text) { return p\Ctype::ctype_punct($text); }
|
|
||||||
}
|
|
||||||
if (!function_exists('ctype_space')) {
|
|
||||||
function ctype_space($text) { return p\Ctype::ctype_space($text); }
|
|
||||||
}
|
|
||||||
if (!function_exists('ctype_upper')) {
|
|
||||||
function ctype_upper($text) { return p\Ctype::ctype_upper($text); }
|
|
||||||
}
|
|
||||||
if (!function_exists('ctype_xdigit')) {
|
|
||||||
function ctype_xdigit($text) { return p\Ctype::ctype_xdigit($text); }
|
|
||||||
}
|
|
||||||
-46
@@ -1,46 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of the Symfony package.
|
|
||||||
*
|
|
||||||
* (c) Fabien Potencier <fabien@symfony.com>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
use Symfony\Polyfill\Ctype as p;
|
|
||||||
|
|
||||||
if (!function_exists('ctype_alnum')) {
|
|
||||||
function ctype_alnum(mixed $text): bool { return p\Ctype::ctype_alnum($text); }
|
|
||||||
}
|
|
||||||
if (!function_exists('ctype_alpha')) {
|
|
||||||
function ctype_alpha(mixed $text): bool { return p\Ctype::ctype_alpha($text); }
|
|
||||||
}
|
|
||||||
if (!function_exists('ctype_cntrl')) {
|
|
||||||
function ctype_cntrl(mixed $text): bool { return p\Ctype::ctype_cntrl($text); }
|
|
||||||
}
|
|
||||||
if (!function_exists('ctype_digit')) {
|
|
||||||
function ctype_digit(mixed $text): bool { return p\Ctype::ctype_digit($text); }
|
|
||||||
}
|
|
||||||
if (!function_exists('ctype_graph')) {
|
|
||||||
function ctype_graph(mixed $text): bool { return p\Ctype::ctype_graph($text); }
|
|
||||||
}
|
|
||||||
if (!function_exists('ctype_lower')) {
|
|
||||||
function ctype_lower(mixed $text): bool { return p\Ctype::ctype_lower($text); }
|
|
||||||
}
|
|
||||||
if (!function_exists('ctype_print')) {
|
|
||||||
function ctype_print(mixed $text): bool { return p\Ctype::ctype_print($text); }
|
|
||||||
}
|
|
||||||
if (!function_exists('ctype_punct')) {
|
|
||||||
function ctype_punct(mixed $text): bool { return p\Ctype::ctype_punct($text); }
|
|
||||||
}
|
|
||||||
if (!function_exists('ctype_space')) {
|
|
||||||
function ctype_space(mixed $text): bool { return p\Ctype::ctype_space($text); }
|
|
||||||
}
|
|
||||||
if (!function_exists('ctype_upper')) {
|
|
||||||
function ctype_upper(mixed $text): bool { return p\Ctype::ctype_upper($text); }
|
|
||||||
}
|
|
||||||
if (!function_exists('ctype_xdigit')) {
|
|
||||||
function ctype_xdigit(mixed $text): bool { return p\Ctype::ctype_xdigit($text); }
|
|
||||||
}
|
|
||||||
-38
@@ -1,38 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "symfony/polyfill-ctype",
|
|
||||||
"type": "library",
|
|
||||||
"description": "Symfony polyfill for ctype functions",
|
|
||||||
"keywords": ["polyfill", "compatibility", "portable", "ctype"],
|
|
||||||
"homepage": "https://symfony.com",
|
|
||||||
"license": "MIT",
|
|
||||||
"authors": [
|
|
||||||
{
|
|
||||||
"name": "Gert de Pagter",
|
|
||||||
"email": "BackEndTea@gmail.com"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Symfony Community",
|
|
||||||
"homepage": "https://symfony.com/contributors"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"require": {
|
|
||||||
"php": ">=7.2"
|
|
||||||
},
|
|
||||||
"provide": {
|
|
||||||
"ext-ctype": "*"
|
|
||||||
},
|
|
||||||
"autoload": {
|
|
||||||
"psr-4": { "Symfony\\Polyfill\\Ctype\\": "" },
|
|
||||||
"files": [ "bootstrap.php" ]
|
|
||||||
},
|
|
||||||
"suggest": {
|
|
||||||
"ext-ctype": "For best performance"
|
|
||||||
},
|
|
||||||
"minimum-stability": "dev",
|
|
||||||
"extra": {
|
|
||||||
"thanks": {
|
|
||||||
"name": "symfony/polyfill",
|
|
||||||
"url": "https://github.com/symfony/polyfill"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-19
@@ -1,19 +0,0 @@
|
|||||||
Copyright (c) 2015-present Fabien Potencier
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
|
||||||
in the Software without restriction, including without limitation the rights
|
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
copies of the Software, and to permit persons to whom the Software is furnished
|
|
||||||
to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in all
|
|
||||||
copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
||||||
THE SOFTWARE.
|
|
||||||
-1045
File diff suppressed because it is too large
Load Diff
-13
@@ -1,13 +0,0 @@
|
|||||||
Symfony Polyfill / Mbstring
|
|
||||||
===========================
|
|
||||||
|
|
||||||
This component provides a partial, native PHP implementation for the
|
|
||||||
[Mbstring](https://php.net/mbstring) extension.
|
|
||||||
|
|
||||||
More information can be found in the
|
|
||||||
[main Polyfill README](https://github.com/symfony/polyfill/blob/main/README.md).
|
|
||||||
|
|
||||||
License
|
|
||||||
=======
|
|
||||||
|
|
||||||
This library is released under the [MIT license](LICENSE).
|
|
||||||
@@ -1,119 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
return [
|
|
||||||
'İ' => 'i̇',
|
|
||||||
'µ' => 'μ',
|
|
||||||
'ſ' => 's',
|
|
||||||
'ͅ' => 'ι',
|
|
||||||
'ς' => 'σ',
|
|
||||||
'ϐ' => 'β',
|
|
||||||
'ϑ' => 'θ',
|
|
||||||
'ϕ' => 'φ',
|
|
||||||
'ϖ' => 'π',
|
|
||||||
'ϰ' => 'κ',
|
|
||||||
'ϱ' => 'ρ',
|
|
||||||
'ϵ' => 'ε',
|
|
||||||
'ẛ' => 'ṡ',
|
|
||||||
'ι' => 'ι',
|
|
||||||
'ß' => 'ss',
|
|
||||||
'ʼn' => 'ʼn',
|
|
||||||
'ǰ' => 'ǰ',
|
|
||||||
'ΐ' => 'ΐ',
|
|
||||||
'ΰ' => 'ΰ',
|
|
||||||
'և' => 'եւ',
|
|
||||||
'ẖ' => 'ẖ',
|
|
||||||
'ẗ' => 'ẗ',
|
|
||||||
'ẘ' => 'ẘ',
|
|
||||||
'ẙ' => 'ẙ',
|
|
||||||
'ẚ' => 'aʾ',
|
|
||||||
'ẞ' => 'ss',
|
|
||||||
'ὐ' => 'ὐ',
|
|
||||||
'ὒ' => 'ὒ',
|
|
||||||
'ὔ' => 'ὔ',
|
|
||||||
'ὖ' => 'ὖ',
|
|
||||||
'ᾀ' => 'ἀι',
|
|
||||||
'ᾁ' => 'ἁι',
|
|
||||||
'ᾂ' => 'ἂι',
|
|
||||||
'ᾃ' => 'ἃι',
|
|
||||||
'ᾄ' => 'ἄι',
|
|
||||||
'ᾅ' => 'ἅι',
|
|
||||||
'ᾆ' => 'ἆι',
|
|
||||||
'ᾇ' => 'ἇι',
|
|
||||||
'ᾈ' => 'ἀι',
|
|
||||||
'ᾉ' => 'ἁι',
|
|
||||||
'ᾊ' => 'ἂι',
|
|
||||||
'ᾋ' => 'ἃι',
|
|
||||||
'ᾌ' => 'ἄι',
|
|
||||||
'ᾍ' => 'ἅι',
|
|
||||||
'ᾎ' => 'ἆι',
|
|
||||||
'ᾏ' => 'ἇι',
|
|
||||||
'ᾐ' => 'ἠι',
|
|
||||||
'ᾑ' => 'ἡι',
|
|
||||||
'ᾒ' => 'ἢι',
|
|
||||||
'ᾓ' => 'ἣι',
|
|
||||||
'ᾔ' => 'ἤι',
|
|
||||||
'ᾕ' => 'ἥι',
|
|
||||||
'ᾖ' => 'ἦι',
|
|
||||||
'ᾗ' => 'ἧι',
|
|
||||||
'ᾘ' => 'ἠι',
|
|
||||||
'ᾙ' => 'ἡι',
|
|
||||||
'ᾚ' => 'ἢι',
|
|
||||||
'ᾛ' => 'ἣι',
|
|
||||||
'ᾜ' => 'ἤι',
|
|
||||||
'ᾝ' => 'ἥι',
|
|
||||||
'ᾞ' => 'ἦι',
|
|
||||||
'ᾟ' => 'ἧι',
|
|
||||||
'ᾠ' => 'ὠι',
|
|
||||||
'ᾡ' => 'ὡι',
|
|
||||||
'ᾢ' => 'ὢι',
|
|
||||||
'ᾣ' => 'ὣι',
|
|
||||||
'ᾤ' => 'ὤι',
|
|
||||||
'ᾥ' => 'ὥι',
|
|
||||||
'ᾦ' => 'ὦι',
|
|
||||||
'ᾧ' => 'ὧι',
|
|
||||||
'ᾨ' => 'ὠι',
|
|
||||||
'ᾩ' => 'ὡι',
|
|
||||||
'ᾪ' => 'ὢι',
|
|
||||||
'ᾫ' => 'ὣι',
|
|
||||||
'ᾬ' => 'ὤι',
|
|
||||||
'ᾭ' => 'ὥι',
|
|
||||||
'ᾮ' => 'ὦι',
|
|
||||||
'ᾯ' => 'ὧι',
|
|
||||||
'ᾲ' => 'ὰι',
|
|
||||||
'ᾳ' => 'αι',
|
|
||||||
'ᾴ' => 'άι',
|
|
||||||
'ᾶ' => 'ᾶ',
|
|
||||||
'ᾷ' => 'ᾶι',
|
|
||||||
'ᾼ' => 'αι',
|
|
||||||
'ῂ' => 'ὴι',
|
|
||||||
'ῃ' => 'ηι',
|
|
||||||
'ῄ' => 'ήι',
|
|
||||||
'ῆ' => 'ῆ',
|
|
||||||
'ῇ' => 'ῆι',
|
|
||||||
'ῌ' => 'ηι',
|
|
||||||
'ῒ' => 'ῒ',
|
|
||||||
'ῖ' => 'ῖ',
|
|
||||||
'ῗ' => 'ῗ',
|
|
||||||
'ῢ' => 'ῢ',
|
|
||||||
'ῤ' => 'ῤ',
|
|
||||||
'ῦ' => 'ῦ',
|
|
||||||
'ῧ' => 'ῧ',
|
|
||||||
'ῲ' => 'ὼι',
|
|
||||||
'ῳ' => 'ωι',
|
|
||||||
'ῴ' => 'ώι',
|
|
||||||
'ῶ' => 'ῶ',
|
|
||||||
'ῷ' => 'ῶι',
|
|
||||||
'ῼ' => 'ωι',
|
|
||||||
'ff' => 'ff',
|
|
||||||
'fi' => 'fi',
|
|
||||||
'fl' => 'fl',
|
|
||||||
'ffi' => 'ffi',
|
|
||||||
'ffl' => 'ffl',
|
|
||||||
'ſt' => 'st',
|
|
||||||
'st' => 'st',
|
|
||||||
'ﬓ' => 'մն',
|
|
||||||
'ﬔ' => 'մե',
|
|
||||||
'ﬕ' => 'մի',
|
|
||||||
'ﬖ' => 'վն',
|
|
||||||
'ﬗ' => 'մխ',
|
|
||||||
];
|
|
||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user