[Web] update directorytree/ldaprecord

This commit is contained in:
FreddleSpl0it
2024-02-20 10:30:11 +01:00
parent 40146839ef
commit d479d18507
481 changed files with 13919 additions and 6171 deletions
+1 -1
View File
@@ -8,7 +8,7 @@
"matthiasmullie/minify": "^1.3", "matthiasmullie/minify": "^1.3",
"bshaffer/oauth2-server-php": "^1.11", "bshaffer/oauth2-server-php": "^1.11",
"mustangostang/spyc": "^0.6.3", "mustangostang/spyc": "^0.6.3",
"directorytree/ldaprecord": "^2.4", "directorytree/ldaprecord": "^3.3",
"twig/twig": "^3.0", "twig/twig": "^3.0",
"stevenmaguire/oauth2-keycloak": "^4.0", "stevenmaguire/oauth2-keycloak": "^4.0",
"league/oauth2-client": "^2.7" "league/oauth2-client": "^2.7"
+230 -110
View File
@@ -68,6 +68,75 @@
}, },
"time": "2018-12-04T00:29:32+00:00" "time": "2018-12-04T00:29:32+00:00"
}, },
{
"name": "carbonphp/carbon-doctrine-types",
"version": "3.2.0",
"source": {
"type": "git",
"url": "https://github.com/CarbonPHP/carbon-doctrine-types.git",
"reference": "18ba5ddfec8976260ead6e866180bd5d2f71aa1d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/CarbonPHP/carbon-doctrine-types/zipball/18ba5ddfec8976260ead6e866180bd5d2f71aa1d",
"reference": "18ba5ddfec8976260ead6e866180bd5d2f71aa1d",
"shasum": ""
},
"require": {
"php": "^8.1"
},
"conflict": {
"doctrine/dbal": "<4.0.0 || >=5.0.0"
},
"require-dev": {
"doctrine/dbal": "^4.0.0",
"nesbot/carbon": "^2.71.0 || ^3.0.0",
"phpunit/phpunit": "^10.3"
},
"type": "library",
"autoload": {
"psr-4": {
"Carbon\\Doctrine\\": "src/Carbon/Doctrine/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "KyleKatarn",
"email": "kylekatarnls@gmail.com"
}
],
"description": "Types to use Carbon in Doctrine",
"keywords": [
"carbon",
"date",
"datetime",
"doctrine",
"time"
],
"support": {
"issues": "https://github.com/CarbonPHP/carbon-doctrine-types/issues",
"source": "https://github.com/CarbonPHP/carbon-doctrine-types/tree/3.2.0"
},
"funding": [
{
"url": "https://github.com/kylekatarnls",
"type": "github"
},
{
"url": "https://opencollective.com/Carbon",
"type": "open_collective"
},
{
"url": "https://tidelift.com/funding/github/packagist/nesbot/carbon",
"type": "tidelift"
}
],
"time": "2024-02-09T16:56:22+00:00"
},
{ {
"name": "ddeboer/imap", "name": "ddeboer/imap",
"version": "1.13.1", "version": "1.13.1",
@@ -145,27 +214,28 @@
}, },
{ {
"name": "directorytree/ldaprecord", "name": "directorytree/ldaprecord",
"version": "v2.10.1", "version": "v2.20.5",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/DirectoryTree/LdapRecord.git", "url": "https://github.com/DirectoryTree/LdapRecord.git",
"reference": "bf512d9af7a7b0e2ed7a666ab29cefdd027bee88" "reference": "5bd0a5a9d257cf1049ae83055dbba4c3479ddf16"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/DirectoryTree/LdapRecord/zipball/bf512d9af7a7b0e2ed7a666ab29cefdd027bee88", "url": "https://api.github.com/repos/DirectoryTree/LdapRecord/zipball/5bd0a5a9d257cf1049ae83055dbba4c3479ddf16",
"reference": "bf512d9af7a7b0e2ed7a666ab29cefdd027bee88", "reference": "5bd0a5a9d257cf1049ae83055dbba4c3479ddf16",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"ext-json": "*", "ext-json": "*",
"ext-ldap": "*", "ext-ldap": "*",
"illuminate/contracts": "^5.0|^6.0|^7.0|^8.0|^9.0", "illuminate/contracts": "^5.0|^6.0|^7.0|^8.0|^9.0|^10.0",
"nesbot/carbon": "^1.0|^2.0", "nesbot/carbon": "^1.0|^2.0",
"php": ">=7.3", "php": ">=7.3",
"psr/log": "*", "psr/log": "^1.0|^2.0|^3.0",
"psr/simple-cache": "^1.0|^2.0", "psr/simple-cache": "^1.0|^2.0",
"tightenco/collect": "^5.6|^6.0|^7.0|^8.0" "symfony/polyfill-php80": "^1.25",
"tightenco/collect": "^5.6|^6.0|^7.0|^8.0|^9.0"
}, },
"require-dev": { "require-dev": {
"mockery/mockery": "^1.0", "mockery/mockery": "^1.0",
@@ -214,7 +284,7 @@
"type": "github" "type": "github"
} }
], ],
"time": "2022-02-25T16:00:51+00:00" "time": "2023-10-11T16:34:34+00:00"
}, },
{ {
"name": "firebase/php-jwt", "name": "firebase/php-jwt",
@@ -609,27 +679,27 @@
}, },
{ {
"name": "illuminate/contracts", "name": "illuminate/contracts",
"version": "v9.3.0", "version": "v10.44.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/illuminate/contracts.git", "url": "https://github.com/illuminate/contracts.git",
"reference": "bf4b3c254c49d28157645d01e4883b5951b1e1d0" "reference": "8d7152c4a1f5d9cf7da3e8b71f23e4556f6138ac"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/illuminate/contracts/zipball/bf4b3c254c49d28157645d01e4883b5951b1e1d0", "url": "https://api.github.com/repos/illuminate/contracts/zipball/8d7152c4a1f5d9cf7da3e8b71f23e4556f6138ac",
"reference": "bf4b3c254c49d28157645d01e4883b5951b1e1d0", "reference": "8d7152c4a1f5d9cf7da3e8b71f23e4556f6138ac",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"php": "^8.0.2", "php": "^8.1",
"psr/container": "^1.1.1|^2.0.1", "psr/container": "^1.1.1|^2.0.1",
"psr/simple-cache": "^1.0|^2.0|^3.0" "psr/simple-cache": "^1.0|^2.0|^3.0"
}, },
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-master": "9.x-dev" "dev-master": "10.x-dev"
} }
}, },
"autoload": { "autoload": {
@@ -653,7 +723,7 @@
"issues": "https://github.com/laravel/framework/issues", "issues": "https://github.com/laravel/framework/issues",
"source": "https://github.com/laravel/framework" "source": "https://github.com/laravel/framework"
}, },
"time": "2022-02-22T14:45:39+00:00" "time": "2024-01-15T18:52:32+00:00"
}, },
{ {
"name": "league/oauth2-client", "name": "league/oauth2-client",
@@ -908,34 +978,41 @@
}, },
{ {
"name": "nesbot/carbon", "name": "nesbot/carbon",
"version": "2.57.0", "version": "2.72.3",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/briannesbitt/Carbon.git", "url": "https://github.com/briannesbitt/Carbon.git",
"reference": "4a54375c21eea4811dbd1149fe6b246517554e78" "reference": "0c6fd108360c562f6e4fd1dedb8233b423e91c83"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/4a54375c21eea4811dbd1149fe6b246517554e78", "url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/0c6fd108360c562f6e4fd1dedb8233b423e91c83",
"reference": "4a54375c21eea4811dbd1149fe6b246517554e78", "reference": "0c6fd108360c562f6e4fd1dedb8233b423e91c83",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"carbonphp/carbon-doctrine-types": "*",
"ext-json": "*", "ext-json": "*",
"php": "^7.1.8 || ^8.0", "php": "^7.1.8 || ^8.0",
"psr/clock": "^1.0",
"symfony/polyfill-mbstring": "^1.0", "symfony/polyfill-mbstring": "^1.0",
"symfony/polyfill-php80": "^1.16", "symfony/polyfill-php80": "^1.16",
"symfony/translation": "^3.4 || ^4.0 || ^5.0 || ^6.0" "symfony/translation": "^3.4 || ^4.0 || ^5.0 || ^6.0"
}, },
"provide": {
"psr/clock-implementation": "1.0"
},
"require-dev": { "require-dev": {
"doctrine/dbal": "^2.0 || ^3.0", "doctrine/dbal": "^2.0 || ^3.1.4 || ^4.0",
"doctrine/orm": "^2.7", "doctrine/orm": "^2.7 || ^3.0",
"friendsofphp/php-cs-fixer": "^3.0", "friendsofphp/php-cs-fixer": "^3.0",
"kylekatarnls/multi-tester": "^2.0", "kylekatarnls/multi-tester": "^2.0",
"ondrejmirtes/better-reflection": "*",
"phpmd/phpmd": "^2.9", "phpmd/phpmd": "^2.9",
"phpstan/extension-installer": "^1.0", "phpstan/extension-installer": "^1.0",
"phpstan/phpstan": "^0.12.54 || ^1.0", "phpstan/phpstan": "^0.12.99 || ^1.7.14",
"phpunit/phpunit": "^7.5.20 || ^8.5.14", "phpunit/php-file-iterator": "^2.0.5 || ^3.0.6",
"phpunit/phpunit": "^7.5.20 || ^8.5.26 || ^9.5.20",
"squizlabs/php_codesniffer": "^3.4" "squizlabs/php_codesniffer": "^3.4"
}, },
"bin": [ "bin": [
@@ -992,15 +1069,19 @@
}, },
"funding": [ "funding": [
{ {
"url": "https://opencollective.com/Carbon", "url": "https://github.com/sponsors/kylekatarnls",
"type": "open_collective" "type": "github"
}, },
{ {
"url": "https://tidelift.com/funding/github/packagist/nesbot/carbon", "url": "https://opencollective.com/Carbon#sponsor",
"type": "opencollective"
},
{
"url": "https://tidelift.com/subscription/pkg/packagist-nesbot-carbon?utm_source=packagist-nesbot-carbon&utm_medium=referral&utm_campaign=readme",
"type": "tidelift" "type": "tidelift"
} }
], ],
"time": "2022-02-13T18:13:33+00:00" "time": "2024-01-25T10:35:09+00:00"
}, },
{ {
"name": "paragonie/random_compat", "name": "paragonie/random_compat",
@@ -1221,6 +1302,54 @@
], ],
"time": "2022-02-28T15:31:21+00:00" "time": "2022-02-28T15:31:21+00:00"
}, },
{
"name": "psr/clock",
"version": "1.0.0",
"source": {
"type": "git",
"url": "https://github.com/php-fig/clock.git",
"reference": "e41a24703d4560fd0acb709162f73b8adfc3aa0d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-fig/clock/zipball/e41a24703d4560fd0acb709162f73b8adfc3aa0d",
"reference": "e41a24703d4560fd0acb709162f73b8adfc3aa0d",
"shasum": ""
},
"require": {
"php": "^7.0 || ^8.0"
},
"type": "library",
"autoload": {
"psr-4": {
"Psr\\Clock\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "PHP-FIG",
"homepage": "https://www.php-fig.org/"
}
],
"description": "Common interface for reading the clock.",
"homepage": "https://github.com/php-fig/clock",
"keywords": [
"clock",
"now",
"psr",
"psr-20",
"time"
],
"support": {
"issues": "https://github.com/php-fig/clock/issues",
"source": "https://github.com/php-fig/clock/tree/1.0.0"
},
"time": "2022-11-25T14:36:26+00:00"
},
{ {
"name": "psr/container", "name": "psr/container",
"version": "2.0.2", "version": "2.0.2",
@@ -1767,16 +1896,16 @@
}, },
{ {
"name": "symfony/deprecation-contracts", "name": "symfony/deprecation-contracts",
"version": "v3.2.1", "version": "v3.4.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/deprecation-contracts.git", "url": "https://github.com/symfony/deprecation-contracts.git",
"reference": "e2d1534420bd723d0ef5aec58a22c5fe60ce6f5e" "reference": "7c3aff79d10325257a001fcf92d991f24fc967cf"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/e2d1534420bd723d0ef5aec58a22c5fe60ce6f5e", "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/7c3aff79d10325257a001fcf92d991f24fc967cf",
"reference": "e2d1534420bd723d0ef5aec58a22c5fe60ce6f5e", "reference": "7c3aff79d10325257a001fcf92d991f24fc967cf",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@@ -1785,7 +1914,7 @@
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-main": "3.3-dev" "dev-main": "3.4-dev"
}, },
"thanks": { "thanks": {
"name": "symfony/contracts", "name": "symfony/contracts",
@@ -1814,7 +1943,7 @@
"description": "A generic function and convention to trigger deprecation notices", "description": "A generic function and convention to trigger deprecation notices",
"homepage": "https://symfony.com", "homepage": "https://symfony.com",
"support": { "support": {
"source": "https://github.com/symfony/deprecation-contracts/tree/v3.2.1" "source": "https://github.com/symfony/deprecation-contracts/tree/v3.4.0"
}, },
"funding": [ "funding": [
{ {
@@ -1830,7 +1959,7 @@
"type": "tidelift" "type": "tidelift"
} }
], ],
"time": "2023-03-01T10:25:55+00:00" "time": "2023-05-23T14:45:45+00:00"
}, },
{ {
"name": "symfony/polyfill-ctype", "name": "symfony/polyfill-ctype",
@@ -1916,16 +2045,16 @@
}, },
{ {
"name": "symfony/polyfill-mbstring", "name": "symfony/polyfill-mbstring",
"version": "v1.24.0", "version": "v1.29.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/polyfill-mbstring.git", "url": "https://github.com/symfony/polyfill-mbstring.git",
"reference": "0abb51d2f102e00a4eefcf46ba7fec406d245825" "reference": "9773676c8a1bb1f8d4340a62efe641cf76eda7ec"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/0abb51d2f102e00a4eefcf46ba7fec406d245825", "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/9773676c8a1bb1f8d4340a62efe641cf76eda7ec",
"reference": "0abb51d2f102e00a4eefcf46ba7fec406d245825", "reference": "9773676c8a1bb1f8d4340a62efe641cf76eda7ec",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@@ -1939,9 +2068,6 @@
}, },
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": {
"dev-main": "1.23-dev"
},
"thanks": { "thanks": {
"name": "symfony/polyfill", "name": "symfony/polyfill",
"url": "https://github.com/symfony/polyfill" "url": "https://github.com/symfony/polyfill"
@@ -1979,7 +2105,7 @@
"shim" "shim"
], ],
"support": { "support": {
"source": "https://github.com/symfony/polyfill-mbstring/tree/v1.24.0" "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.29.0"
}, },
"funding": [ "funding": [
{ {
@@ -1995,20 +2121,20 @@
"type": "tidelift" "type": "tidelift"
} }
], ],
"time": "2021-11-30T18:21:41+00:00" "time": "2024-01-29T20:11:03+00:00"
}, },
{ {
"name": "symfony/polyfill-php80", "name": "symfony/polyfill-php80",
"version": "v1.24.0", "version": "v1.29.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/polyfill-php80.git", "url": "https://github.com/symfony/polyfill-php80.git",
"reference": "57b712b08eddb97c762a8caa32c84e037892d2e9" "reference": "87b68208d5c1188808dd7839ee1e6c8ec3b02f1b"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/57b712b08eddb97c762a8caa32c84e037892d2e9", "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/87b68208d5c1188808dd7839ee1e6c8ec3b02f1b",
"reference": "57b712b08eddb97c762a8caa32c84e037892d2e9", "reference": "87b68208d5c1188808dd7839ee1e6c8ec3b02f1b",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@@ -2016,9 +2142,6 @@
}, },
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": {
"dev-main": "1.23-dev"
},
"thanks": { "thanks": {
"name": "symfony/polyfill", "name": "symfony/polyfill",
"url": "https://github.com/symfony/polyfill" "url": "https://github.com/symfony/polyfill"
@@ -2062,7 +2185,7 @@
"shim" "shim"
], ],
"support": { "support": {
"source": "https://github.com/symfony/polyfill-php80/tree/v1.24.0" "source": "https://github.com/symfony/polyfill-php80/tree/v1.29.0"
}, },
"funding": [ "funding": [
{ {
@@ -2078,32 +2201,35 @@
"type": "tidelift" "type": "tidelift"
} }
], ],
"time": "2021-09-13T13:58:33+00:00" "time": "2024-01-29T20:11:03+00:00"
}, },
{ {
"name": "symfony/translation", "name": "symfony/translation",
"version": "v6.0.5", "version": "v6.4.3",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/translation.git", "url": "https://github.com/symfony/translation.git",
"reference": "e69501c71107cc3146b32aaa45f4edd0c3427875" "reference": "637c51191b6b184184bbf98937702bcf554f7d04"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/translation/zipball/e69501c71107cc3146b32aaa45f4edd0c3427875", "url": "https://api.github.com/repos/symfony/translation/zipball/637c51191b6b184184bbf98937702bcf554f7d04",
"reference": "e69501c71107cc3146b32aaa45f4edd0c3427875", "reference": "637c51191b6b184184bbf98937702bcf554f7d04",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"php": ">=8.0.2", "php": ">=8.1",
"symfony/deprecation-contracts": "^2.5|^3",
"symfony/polyfill-mbstring": "~1.0", "symfony/polyfill-mbstring": "~1.0",
"symfony/translation-contracts": "^2.3|^3.0" "symfony/translation-contracts": "^2.5|^3.0"
}, },
"conflict": { "conflict": {
"symfony/config": "<5.4", "symfony/config": "<5.4",
"symfony/console": "<5.4", "symfony/console": "<5.4",
"symfony/dependency-injection": "<5.4", "symfony/dependency-injection": "<5.4",
"symfony/http-client-contracts": "<2.5",
"symfony/http-kernel": "<5.4", "symfony/http-kernel": "<5.4",
"symfony/service-contracts": "<2.5",
"symfony/twig-bundle": "<5.4", "symfony/twig-bundle": "<5.4",
"symfony/yaml": "<5.4" "symfony/yaml": "<5.4"
}, },
@@ -2111,22 +2237,19 @@
"symfony/translation-implementation": "2.3|3.0" "symfony/translation-implementation": "2.3|3.0"
}, },
"require-dev": { "require-dev": {
"nikic/php-parser": "^4.18|^5.0",
"psr/log": "^1|^2|^3", "psr/log": "^1|^2|^3",
"symfony/config": "^5.4|^6.0", "symfony/config": "^5.4|^6.0|^7.0",
"symfony/console": "^5.4|^6.0", "symfony/console": "^5.4|^6.0|^7.0",
"symfony/dependency-injection": "^5.4|^6.0", "symfony/dependency-injection": "^5.4|^6.0|^7.0",
"symfony/finder": "^5.4|^6.0", "symfony/finder": "^5.4|^6.0|^7.0",
"symfony/http-client-contracts": "^1.1|^2.0|^3.0", "symfony/http-client-contracts": "^2.5|^3.0",
"symfony/http-kernel": "^5.4|^6.0", "symfony/http-kernel": "^5.4|^6.0|^7.0",
"symfony/intl": "^5.4|^6.0", "symfony/intl": "^5.4|^6.0|^7.0",
"symfony/polyfill-intl-icu": "^1.21", "symfony/polyfill-intl-icu": "^1.21",
"symfony/service-contracts": "^1.1.2|^2|^3", "symfony/routing": "^5.4|^6.0|^7.0",
"symfony/yaml": "^5.4|^6.0" "symfony/service-contracts": "^2.5|^3",
}, "symfony/yaml": "^5.4|^6.0|^7.0"
"suggest": {
"psr/log-implementation": "To use logging capability in translator",
"symfony/config": "",
"symfony/yaml": ""
}, },
"type": "library", "type": "library",
"autoload": { "autoload": {
@@ -2157,7 +2280,7 @@
"description": "Provides tools to internationalize your application", "description": "Provides tools to internationalize your application",
"homepage": "https://symfony.com", "homepage": "https://symfony.com",
"support": { "support": {
"source": "https://github.com/symfony/translation/tree/v6.0.5" "source": "https://github.com/symfony/translation/tree/v6.4.3"
}, },
"funding": [ "funding": [
{ {
@@ -2173,32 +2296,29 @@
"type": "tidelift" "type": "tidelift"
} }
], ],
"time": "2022-02-09T15:52:48+00:00" "time": "2024-01-29T13:11:52+00:00"
}, },
{ {
"name": "symfony/translation-contracts", "name": "symfony/translation-contracts",
"version": "v3.0.0", "version": "v3.4.1",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/translation-contracts.git", "url": "https://github.com/symfony/translation-contracts.git",
"reference": "1b6ea5a7442af5a12dba3dbd6d71034b5b234e77" "reference": "06450585bf65e978026bda220cdebca3f867fde7"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/translation-contracts/zipball/1b6ea5a7442af5a12dba3dbd6d71034b5b234e77", "url": "https://api.github.com/repos/symfony/translation-contracts/zipball/06450585bf65e978026bda220cdebca3f867fde7",
"reference": "1b6ea5a7442af5a12dba3dbd6d71034b5b234e77", "reference": "06450585bf65e978026bda220cdebca3f867fde7",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"php": ">=8.0.2" "php": ">=8.1"
},
"suggest": {
"symfony/translation-implementation": ""
}, },
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-main": "3.0-dev" "dev-main": "3.4-dev"
}, },
"thanks": { "thanks": {
"name": "symfony/contracts", "name": "symfony/contracts",
@@ -2208,7 +2328,10 @@
"autoload": { "autoload": {
"psr-4": { "psr-4": {
"Symfony\\Contracts\\Translation\\": "" "Symfony\\Contracts\\Translation\\": ""
} },
"exclude-from-classmap": [
"/Test/"
]
}, },
"notification-url": "https://packagist.org/downloads/", "notification-url": "https://packagist.org/downloads/",
"license": [ "license": [
@@ -2235,7 +2358,7 @@
"standards" "standards"
], ],
"support": { "support": {
"source": "https://github.com/symfony/translation-contracts/tree/v3.0.0" "source": "https://github.com/symfony/translation-contracts/tree/v3.4.1"
}, },
"funding": [ "funding": [
{ {
@@ -2251,42 +2374,39 @@
"type": "tidelift" "type": "tidelift"
} }
], ],
"time": "2021-09-07T12:43:40+00:00" "time": "2023-12-26T14:02:43+00:00"
}, },
{ {
"name": "symfony/var-dumper", "name": "symfony/var-dumper",
"version": "v6.0.5", "version": "v6.4.3",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/var-dumper.git", "url": "https://github.com/symfony/var-dumper.git",
"reference": "60d6a756d5f485df5e6e40b337334848f79f61ce" "reference": "0435a08f69125535336177c29d56af3abc1f69da"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/var-dumper/zipball/60d6a756d5f485df5e6e40b337334848f79f61ce", "url": "https://api.github.com/repos/symfony/var-dumper/zipball/0435a08f69125535336177c29d56af3abc1f69da",
"reference": "60d6a756d5f485df5e6e40b337334848f79f61ce", "reference": "0435a08f69125535336177c29d56af3abc1f69da",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"php": ">=8.0.2", "php": ">=8.1",
"symfony/deprecation-contracts": "^2.5|^3",
"symfony/polyfill-mbstring": "~1.0" "symfony/polyfill-mbstring": "~1.0"
}, },
"conflict": { "conflict": {
"phpunit/phpunit": "<5.4.3",
"symfony/console": "<5.4" "symfony/console": "<5.4"
}, },
"require-dev": { "require-dev": {
"ext-iconv": "*", "ext-iconv": "*",
"symfony/console": "^5.4|^6.0", "symfony/console": "^5.4|^6.0|^7.0",
"symfony/process": "^5.4|^6.0", "symfony/error-handler": "^6.3|^7.0",
"symfony/uid": "^5.4|^6.0", "symfony/http-kernel": "^5.4|^6.0|^7.0",
"symfony/process": "^5.4|^6.0|^7.0",
"symfony/uid": "^5.4|^6.0|^7.0",
"twig/twig": "^2.13|^3.0.4" "twig/twig": "^2.13|^3.0.4"
}, },
"suggest": {
"ext-iconv": "To convert non-UTF-8 strings to UTF-8 (or symfony/polyfill-iconv in case ext-iconv cannot be used).",
"ext-intl": "To show region name in time zone dump",
"symfony/console": "To use the ServerDumpCommand and/or the bin/var-dump-server script"
},
"bin": [ "bin": [
"Resources/bin/var-dump-server" "Resources/bin/var-dump-server"
], ],
@@ -2323,7 +2443,7 @@
"dump" "dump"
], ],
"support": { "support": {
"source": "https://github.com/symfony/var-dumper/tree/v6.0.5" "source": "https://github.com/symfony/var-dumper/tree/v6.4.3"
}, },
"funding": [ "funding": [
{ {
@@ -2339,24 +2459,24 @@
"type": "tidelift" "type": "tidelift"
} }
], ],
"time": "2022-02-21T17:15:17+00:00" "time": "2024-01-23T14:53:30+00:00"
}, },
{ {
"name": "tightenco/collect", "name": "tightenco/collect",
"version": "v8.83.2", "version": "v9.52.7",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/tighten/collect.git", "url": "https://github.com/tighten/collect.git",
"reference": "d9c66d586ec2d216d8a31283d73f8df1400cc722" "reference": "b15143cd11fe01a700fcc449df61adc64452fa6d"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/tighten/collect/zipball/d9c66d586ec2d216d8a31283d73f8df1400cc722", "url": "https://api.github.com/repos/tighten/collect/zipball/b15143cd11fe01a700fcc449df61adc64452fa6d",
"reference": "d9c66d586ec2d216d8a31283d73f8df1400cc722", "reference": "b15143cd11fe01a700fcc449df61adc64452fa6d",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"php": "^7.3|^8.0", "php": "^8.0",
"symfony/var-dumper": "^3.4 || ^4.0 || ^5.0 || ^6.0" "symfony/var-dumper": "^3.4 || ^4.0 || ^5.0 || ^6.0"
}, },
"require-dev": { "require-dev": {
@@ -2391,9 +2511,9 @@
], ],
"support": { "support": {
"issues": "https://github.com/tighten/collect/issues", "issues": "https://github.com/tighten/collect/issues",
"source": "https://github.com/tighten/collect/tree/v8.83.2" "source": "https://github.com/tighten/collect/tree/v9.52.7"
}, },
"time": "2022-02-16T16:15:54+00:00" "time": "2023-04-14T21:51:36+00:00"
}, },
{ {
"name": "twig/twig", "name": "twig/twig",
@@ -2480,5 +2600,5 @@
"prefer-lowest": false, "prefer-lowest": false,
"platform": [], "platform": [],
"platform-dev": [], "platform-dev": [],
"plugin-api-version": "2.3.0" "plugin-api-version": "2.6.0"
} }
+15 -2
View File
@@ -3,8 +3,21 @@
// autoload.php @generated by Composer // autoload.php @generated by Composer
if (PHP_VERSION_ID < 50600) { if (PHP_VERSION_ID < 50600) {
echo '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 (!headers_sent()) {
exit(1); 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'; require_once __DIR__ . '/composer/autoload_real.php';
+34 -12
View File
@@ -12,6 +12,7 @@
namespace Composer; namespace Composer;
$GLOBALS['_composer_bin_dir'] = __DIR__;
$GLOBALS['_composer_autoload_path'] = __DIR__ . '/..'.'/autoload.php'; $GLOBALS['_composer_autoload_path'] = __DIR__ . '/..'.'/autoload.php';
if (PHP_VERSION_ID < 80000) { if (PHP_VERSION_ID < 80000) {
@@ -23,18 +24,17 @@ if (PHP_VERSION_ID < 80000) {
{ {
private $handle; private $handle;
private $position; private $position;
private $realpath;
public function stream_open($path, $mode, $options, &$opened_path) public function stream_open($path, $mode, $options, &$opened_path)
{ {
// get rid of composer-bin-proxy:// prefix for __FILE__ & __DIR__ resolution // get rid of phpvfscomposer:// prefix for __FILE__ & __DIR__ resolution
$opened_path = substr($path, 21); $opened_path = substr($path, 17);
$opened_path = realpath($opened_path) ?: $opened_path; $this->realpath = realpath($opened_path) ?: $opened_path;
$this->handle = fopen($opened_path, $mode); $opened_path = $this->realpath;
$this->handle = fopen($this->realpath, $mode);
$this->position = 0; $this->position = 0;
// remove all traces of this stream wrapper once it has been used
stream_wrapper_unregister('composer-bin-proxy');
return (bool) $this->handle; return (bool) $this->handle;
} }
@@ -66,6 +66,16 @@ if (PHP_VERSION_ID < 80000) {
return $operation ? flock($this->handle, $operation) : true; return $operation ? flock($this->handle, $operation) : true;
} }
public function stream_seek($offset, $whence)
{
if (0 === fseek($this->handle, $offset, $whence)) {
$this->position = ftell($this->handle);
return true;
}
return false;
}
public function stream_tell() public function stream_tell()
{ {
return $this->position; return $this->position;
@@ -78,20 +88,32 @@ if (PHP_VERSION_ID < 80000) {
public function stream_stat() public function stream_stat()
{ {
return fstat($this->handle); return array();
} }
public function stream_set_option($option, $arg1, $arg2) public function stream_set_option($option, $arg1, $arg2)
{ {
return true; return true;
} }
public function url_stat($path, $flags)
{
$path = substr($path, 17);
if (file_exists($path)) {
return stat($path);
}
return false;
}
} }
} }
if (function_exists('stream_wrapper_register') && stream_wrapper_register('composer-bin-proxy', 'Composer\BinProxyWrapper')) { if (
include("composer-bin-proxy://" . __DIR__ . '/..'.'/nesbot/carbon/bin/carbon'); (function_exists('stream_get_wrappers') && in_array('phpvfscomposer', stream_get_wrappers(), true))
exit(0); || (function_exists('stream_wrapper_register') && stream_wrapper_register('phpvfscomposer', 'Composer\BinProxyWrapper'))
) {
return include("phpvfscomposer://" . __DIR__ . '/..'.'/nesbot/carbon/bin/carbon');
} }
} }
include __DIR__ . '/..'.'/nesbot/carbon/bin/carbon'; return include __DIR__ . '/..'.'/nesbot/carbon/bin/carbon';
+34 -12
View File
@@ -12,6 +12,7 @@
namespace Composer; namespace Composer;
$GLOBALS['_composer_bin_dir'] = __DIR__;
$GLOBALS['_composer_autoload_path'] = __DIR__ . '/..'.'/autoload.php'; $GLOBALS['_composer_autoload_path'] = __DIR__ . '/..'.'/autoload.php';
if (PHP_VERSION_ID < 80000) { if (PHP_VERSION_ID < 80000) {
@@ -23,18 +24,17 @@ if (PHP_VERSION_ID < 80000) {
{ {
private $handle; private $handle;
private $position; private $position;
private $realpath;
public function stream_open($path, $mode, $options, &$opened_path) public function stream_open($path, $mode, $options, &$opened_path)
{ {
// get rid of composer-bin-proxy:// prefix for __FILE__ & __DIR__ resolution // get rid of phpvfscomposer:// prefix for __FILE__ & __DIR__ resolution
$opened_path = substr($path, 21); $opened_path = substr($path, 17);
$opened_path = realpath($opened_path) ?: $opened_path; $this->realpath = realpath($opened_path) ?: $opened_path;
$this->handle = fopen($opened_path, $mode); $opened_path = $this->realpath;
$this->handle = fopen($this->realpath, $mode);
$this->position = 0; $this->position = 0;
// remove all traces of this stream wrapper once it has been used
stream_wrapper_unregister('composer-bin-proxy');
return (bool) $this->handle; return (bool) $this->handle;
} }
@@ -66,6 +66,16 @@ if (PHP_VERSION_ID < 80000) {
return $operation ? flock($this->handle, $operation) : true; return $operation ? flock($this->handle, $operation) : true;
} }
public function stream_seek($offset, $whence)
{
if (0 === fseek($this->handle, $offset, $whence)) {
$this->position = ftell($this->handle);
return true;
}
return false;
}
public function stream_tell() public function stream_tell()
{ {
return $this->position; return $this->position;
@@ -78,20 +88,32 @@ if (PHP_VERSION_ID < 80000) {
public function stream_stat() public function stream_stat()
{ {
return fstat($this->handle); return array();
} }
public function stream_set_option($option, $arg1, $arg2) public function stream_set_option($option, $arg1, $arg2)
{ {
return true; return true;
} }
public function url_stat($path, $flags)
{
$path = substr($path, 17);
if (file_exists($path)) {
return stat($path);
}
return false;
}
} }
} }
if (function_exists('stream_wrapper_register') && stream_wrapper_register('composer-bin-proxy', 'Composer\BinProxyWrapper')) { if (
include("composer-bin-proxy://" . __DIR__ . '/..'.'/symfony/var-dumper/Resources/bin/var-dump-server'); (function_exists('stream_get_wrappers') && in_array('phpvfscomposer', stream_get_wrappers(), true))
exit(0); || (function_exists('stream_wrapper_register') && stream_wrapper_register('phpvfscomposer', 'Composer\BinProxyWrapper'))
) {
return include("phpvfscomposer://" . __DIR__ . '/..'.'/symfony/var-dumper/Resources/bin/var-dump-server');
} }
} }
include __DIR__ . '/..'.'/symfony/var-dumper/Resources/bin/var-dump-server'; return include __DIR__ . '/..'.'/symfony/var-dumper/Resources/bin/var-dump-server';
@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2023 Carbon
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.
@@ -0,0 +1,14 @@
# carbonphp/carbon-doctrine-types
Types to use Carbon in Doctrine
## Documentation
[Check how to use in the official Carbon documentation](https://carbon.nesbot.com/symfony/)
This package is an externalization of [src/Carbon/Doctrine](https://github.com/briannesbitt/Carbon/tree/2.71.0/src/Carbon/Doctrine)
from `nestbot/carbon` package.
Externalization allows to better deal with different versions of dbal. With
version 4.0 of dbal, it no longer sustainable to be compatible with all version
using a single code.
@@ -0,0 +1,36 @@
{
"name": "carbonphp/carbon-doctrine-types",
"description": "Types to use Carbon in Doctrine",
"type": "library",
"keywords": [
"date",
"time",
"DateTime",
"Carbon",
"Doctrine"
],
"require": {
"php": "^8.1"
},
"require-dev": {
"doctrine/dbal": "^4.0.0",
"nesbot/carbon": "^2.71.0 || ^3.0.0",
"phpunit/phpunit": "^10.3"
},
"conflict": {
"doctrine/dbal": "<4.0.0 || >=5.0.0"
},
"license": "MIT",
"autoload": {
"psr-4": {
"Carbon\\Doctrine\\": "src/Carbon/Doctrine/"
}
},
"authors": [
{
"name": "KyleKatarn",
"email": "kylekatarnls@gmail.com"
}
],
"minimum-stability": "dev"
}
@@ -0,0 +1,16 @@
<?php
declare(strict_types=1);
namespace Carbon\Doctrine;
use Doctrine\DBAL\Platforms\AbstractPlatform;
interface CarbonDoctrineType
{
public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform);
public function convertToPHPValue(mixed $value, AbstractPlatform $platform);
public function convertToDatabaseValue($value, AbstractPlatform $platform);
}
@@ -0,0 +1,9 @@
<?php
declare(strict_types=1);
namespace Carbon\Doctrine;
class CarbonImmutableType extends DateTimeImmutableType implements CarbonDoctrineType
{
}
@@ -0,0 +1,9 @@
<?php
declare(strict_types=1);
namespace Carbon\Doctrine;
class CarbonType extends DateTimeType implements CarbonDoctrineType
{
}
@@ -1,13 +1,6 @@
<?php <?php
/** declare(strict_types=1);
* This file is part of the Carbon package.
*
* (c) Brian Nesbitt <brian@nesbot.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Carbon\Doctrine; namespace Carbon\Doctrine;
@@ -15,7 +8,12 @@ use Carbon\Carbon;
use Carbon\CarbonInterface; use Carbon\CarbonInterface;
use DateTimeInterface; use DateTimeInterface;
use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Types\ConversionException; use Doctrine\DBAL\Platforms\DB2Platform;
use Doctrine\DBAL\Platforms\OraclePlatform;
use Doctrine\DBAL\Platforms\SQLitePlatform;
use Doctrine\DBAL\Platforms\SQLServerPlatform;
use Doctrine\DBAL\Types\Exception\InvalidType;
use Doctrine\DBAL\Types\Exception\ValueNotConvertible;
use Exception; use Exception;
/** /**
@@ -23,6 +21,14 @@ use Exception;
*/ */
trait CarbonTypeConverter trait CarbonTypeConverter
{ {
/**
* This property differentiates types installed by carbonphp/carbon-doctrine-types
* from the ones embedded previously in nesbot/carbon source directly.
*
* @readonly
*/
public bool $external = true;
/** /**
* @return class-string<T> * @return class-string<T>
*/ */
@@ -31,20 +37,12 @@ trait CarbonTypeConverter
return Carbon::class; return Carbon::class;
} }
/** public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform): string
* @return string
*/
public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
{ {
$precision = $fieldDeclaration['precision'] ?: 10; $precision = min(
$fieldDeclaration['precision'] ?? DateTimeDefaultPrecision::get(),
if ($fieldDeclaration['secondPrecision'] ?? false) { $this->getMaximumPrecision($platform),
$precision = 0; );
}
if ($precision === 10) {
$precision = DateTimeDefaultPrecision::get();
}
$type = parent::getSQLDeclaration($fieldDeclaration, $platform); $type = parent::getSQLDeclaration($fieldDeclaration, $platform);
@@ -63,10 +61,25 @@ trait CarbonTypeConverter
/** /**
* @SuppressWarnings(PHPMD.UnusedFormalParameter) * @SuppressWarnings(PHPMD.UnusedFormalParameter)
*
* @return T|null
*/ */
public function convertToPHPValue($value, AbstractPlatform $platform) public function convertToDatabaseValue($value, AbstractPlatform $platform): ?string
{
if ($value === null) {
return $value;
}
if ($value instanceof DateTimeInterface) {
return $value->format('Y-m-d H:i:s.u');
}
throw InvalidType::new(
$value,
static::class,
['null', 'DateTime', 'Carbon']
);
}
private function doConvertToPHPValue(mixed $value)
{ {
$class = $this->getCarbonClassName(); $class = $this->getCarbonClassName();
@@ -88,9 +101,9 @@ trait CarbonTypeConverter
} }
if (!$date) { if (!$date) {
throw ConversionException::conversionFailedFormat( throw ValueNotConvertible::new(
$value, $value,
$this->getName(), static::class,
'Y-m-d H:i:s.u or any format supported by '.$class.'::parse()', 'Y-m-d H:i:s.u or any format supported by '.$class.'::parse()',
$error $error
); );
@@ -99,25 +112,20 @@ trait CarbonTypeConverter
return $date; return $date;
} }
/** private function getMaximumPrecision(AbstractPlatform $platform): int
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*
* @return string|null
*/
public function convertToDatabaseValue($value, AbstractPlatform $platform)
{ {
if ($value === null) { if ($platform instanceof DB2Platform) {
return $value; return 12;
} }
if ($value instanceof DateTimeInterface) { if ($platform instanceof OraclePlatform) {
return $value->format('Y-m-d H:i:s.u'); return 9;
} }
throw ConversionException::conversionFailedInvalidType( if ($platform instanceof SQLServerPlatform || $platform instanceof SQLitePlatform) {
$value, return 3;
$this->getName(), }
['null', 'DateTime', 'Carbon']
); return 6;
} }
} }
@@ -1,13 +1,6 @@
<?php <?php
/** declare(strict_types=1);
* This file is part of the Carbon package.
*
* (c) Brian Nesbitt <brian@nesbot.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Carbon\Doctrine; namespace Carbon\Doctrine;
@@ -1,12 +1,12 @@
<?php <?php
/** declare(strict_types=1);
* Thanks to https://github.com/flaushi for his suggestion:
* https://github.com/doctrine/dbal/issues/2873#issuecomment-534956358
*/
namespace Carbon\Doctrine; namespace Carbon\Doctrine;
use Carbon\CarbonImmutable; use Carbon\CarbonImmutable;
use DateTimeImmutable;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Types\VarDateTimeImmutableType; use Doctrine\DBAL\Types\VarDateTimeImmutableType;
class DateTimeImmutableType extends VarDateTimeImmutableType implements CarbonDoctrineType class DateTimeImmutableType extends VarDateTimeImmutableType implements CarbonDoctrineType
@@ -14,6 +14,14 @@ class DateTimeImmutableType extends VarDateTimeImmutableType implements CarbonDo
/** @use CarbonTypeConverter<CarbonImmutable> */ /** @use CarbonTypeConverter<CarbonImmutable> */
use CarbonTypeConverter; use CarbonTypeConverter;
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function convertToPHPValue(mixed $value, AbstractPlatform $platform): ?CarbonImmutable
{
return $this->doConvertToPHPValue($value);
}
/** /**
* @return class-string<CarbonImmutable> * @return class-string<CarbonImmutable>
*/ */
@@ -0,0 +1,24 @@
<?php
declare(strict_types=1);
namespace Carbon\Doctrine;
use Carbon\Carbon;
use DateTime;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Types\VarDateTimeType;
class DateTimeType extends VarDateTimeType implements CarbonDoctrineType
{
/** @use CarbonTypeConverter<Carbon> */
use CarbonTypeConverter;
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function convertToPHPValue(mixed $value, AbstractPlatform $platform): ?Carbon
{
return $this->doConvertToPHPValue($value);
}
}
+56 -49
View File
@@ -42,35 +42,37 @@ namespace Composer\Autoload;
*/ */
class ClassLoader class ClassLoader
{ {
/** @var ?string */ /** @var \Closure(string):void */
private static $includeFile;
/** @var string|null */
private $vendorDir; private $vendorDir;
// PSR-4 // PSR-4
/** /**
* @var array[] * @var array<string, array<string, int>>
* @psalm-var array<string, array<string, int>>
*/ */
private $prefixLengthsPsr4 = array(); private $prefixLengthsPsr4 = array();
/** /**
* @var array[] * @var array<string, list<string>>
* @psalm-var array<string, array<int, string>>
*/ */
private $prefixDirsPsr4 = array(); private $prefixDirsPsr4 = array();
/** /**
* @var array[] * @var list<string>
* @psalm-var array<string, string>
*/ */
private $fallbackDirsPsr4 = array(); private $fallbackDirsPsr4 = array();
// PSR-0 // PSR-0
/** /**
* @var array[] * List of PSR-0 prefixes
* @psalm-var array<string, array<string, string[]>> *
* Structured as array('F (first letter)' => array('Foo\Bar (full prefix)' => array('path', 'path2')))
*
* @var array<string, array<string, list<string>>>
*/ */
private $prefixesPsr0 = array(); private $prefixesPsr0 = array();
/** /**
* @var array[] * @var list<string>
* @psalm-var array<string, string>
*/ */
private $fallbackDirsPsr0 = array(); private $fallbackDirsPsr0 = array();
@@ -78,8 +80,7 @@ class ClassLoader
private $useIncludePath = false; private $useIncludePath = false;
/** /**
* @var string[] * @var array<string, string>
* @psalm-var array<string, string>
*/ */
private $classMap = array(); private $classMap = array();
@@ -87,29 +88,29 @@ class ClassLoader
private $classMapAuthoritative = false; private $classMapAuthoritative = false;
/** /**
* @var bool[] * @var array<string, bool>
* @psalm-var array<string, bool>
*/ */
private $missingClasses = array(); private $missingClasses = array();
/** @var ?string */ /** @var string|null */
private $apcuPrefix; private $apcuPrefix;
/** /**
* @var self[] * @var array<string, self>
*/ */
private static $registeredLoaders = array(); private static $registeredLoaders = array();
/** /**
* @param ?string $vendorDir * @param string|null $vendorDir
*/ */
public function __construct($vendorDir = null) public function __construct($vendorDir = null)
{ {
$this->vendorDir = $vendorDir; $this->vendorDir = $vendorDir;
self::initializeIncludeClosure();
} }
/** /**
* @return string[] * @return array<string, list<string>>
*/ */
public function getPrefixes() public function getPrefixes()
{ {
@@ -121,8 +122,7 @@ class ClassLoader
} }
/** /**
* @return array[] * @return array<string, list<string>>
* @psalm-return array<string, array<int, string>>
*/ */
public function getPrefixesPsr4() public function getPrefixesPsr4()
{ {
@@ -130,8 +130,7 @@ class ClassLoader
} }
/** /**
* @return array[] * @return list<string>
* @psalm-return array<string, string>
*/ */
public function getFallbackDirs() public function getFallbackDirs()
{ {
@@ -139,8 +138,7 @@ class ClassLoader
} }
/** /**
* @return array[] * @return list<string>
* @psalm-return array<string, string>
*/ */
public function getFallbackDirsPsr4() public function getFallbackDirsPsr4()
{ {
@@ -148,8 +146,7 @@ class ClassLoader
} }
/** /**
* @return string[] Array of classname => path * @return array<string, string> Array of classname => path
* @psalm-return array<string, string>
*/ */
public function getClassMap() public function getClassMap()
{ {
@@ -157,8 +154,7 @@ class ClassLoader
} }
/** /**
* @param string[] $classMap Class to filename map * @param array<string, string> $classMap Class to filename map
* @psalm-param array<string, string> $classMap
* *
* @return void * @return void
*/ */
@@ -176,23 +172,24 @@ class ClassLoader
* appending or prepending to the ones previously set for this prefix. * appending or prepending to the ones previously set for this prefix.
* *
* @param string $prefix The prefix * @param string $prefix The prefix
* @param string[]|string $paths The PSR-0 root directories * @param list<string>|string $paths The PSR-0 root directories
* @param bool $prepend Whether to prepend the directories * @param bool $prepend Whether to prepend the directories
* *
* @return void * @return void
*/ */
public function add($prefix, $paths, $prepend = false) public function add($prefix, $paths, $prepend = false)
{ {
$paths = (array) $paths;
if (!$prefix) { if (!$prefix) {
if ($prepend) { if ($prepend) {
$this->fallbackDirsPsr0 = array_merge( $this->fallbackDirsPsr0 = array_merge(
(array) $paths, $paths,
$this->fallbackDirsPsr0 $this->fallbackDirsPsr0
); );
} else { } else {
$this->fallbackDirsPsr0 = array_merge( $this->fallbackDirsPsr0 = array_merge(
$this->fallbackDirsPsr0, $this->fallbackDirsPsr0,
(array) $paths $paths
); );
} }
@@ -201,19 +198,19 @@ class ClassLoader
$first = $prefix[0]; $first = $prefix[0];
if (!isset($this->prefixesPsr0[$first][$prefix])) { if (!isset($this->prefixesPsr0[$first][$prefix])) {
$this->prefixesPsr0[$first][$prefix] = (array) $paths; $this->prefixesPsr0[$first][$prefix] = $paths;
return; return;
} }
if ($prepend) { if ($prepend) {
$this->prefixesPsr0[$first][$prefix] = array_merge( $this->prefixesPsr0[$first][$prefix] = array_merge(
(array) $paths, $paths,
$this->prefixesPsr0[$first][$prefix] $this->prefixesPsr0[$first][$prefix]
); );
} else { } else {
$this->prefixesPsr0[$first][$prefix] = array_merge( $this->prefixesPsr0[$first][$prefix] = array_merge(
$this->prefixesPsr0[$first][$prefix], $this->prefixesPsr0[$first][$prefix],
(array) $paths $paths
); );
} }
} }
@@ -223,7 +220,7 @@ class ClassLoader
* appending or prepending to the ones previously set for this namespace. * appending or prepending to the ones previously set for this namespace.
* *
* @param string $prefix The prefix/namespace, with trailing '\\' * @param string $prefix The prefix/namespace, with trailing '\\'
* @param string[]|string $paths The PSR-4 base directories * @param list<string>|string $paths The PSR-4 base directories
* @param bool $prepend Whether to prepend the directories * @param bool $prepend Whether to prepend the directories
* *
* @throws \InvalidArgumentException * @throws \InvalidArgumentException
@@ -232,17 +229,18 @@ class ClassLoader
*/ */
public function addPsr4($prefix, $paths, $prepend = false) public function addPsr4($prefix, $paths, $prepend = false)
{ {
$paths = (array) $paths;
if (!$prefix) { if (!$prefix) {
// Register directories for the root namespace. // Register directories for the root namespace.
if ($prepend) { if ($prepend) {
$this->fallbackDirsPsr4 = array_merge( $this->fallbackDirsPsr4 = array_merge(
(array) $paths, $paths,
$this->fallbackDirsPsr4 $this->fallbackDirsPsr4
); );
} else { } else {
$this->fallbackDirsPsr4 = array_merge( $this->fallbackDirsPsr4 = array_merge(
$this->fallbackDirsPsr4, $this->fallbackDirsPsr4,
(array) $paths $paths
); );
} }
} elseif (!isset($this->prefixDirsPsr4[$prefix])) { } elseif (!isset($this->prefixDirsPsr4[$prefix])) {
@@ -252,18 +250,18 @@ class ClassLoader
throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
} }
$this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
$this->prefixDirsPsr4[$prefix] = (array) $paths; $this->prefixDirsPsr4[$prefix] = $paths;
} elseif ($prepend) { } elseif ($prepend) {
// Prepend directories for an already registered namespace. // Prepend directories for an already registered namespace.
$this->prefixDirsPsr4[$prefix] = array_merge( $this->prefixDirsPsr4[$prefix] = array_merge(
(array) $paths, $paths,
$this->prefixDirsPsr4[$prefix] $this->prefixDirsPsr4[$prefix]
); );
} else { } else {
// Append directories for an already registered namespace. // Append directories for an already registered namespace.
$this->prefixDirsPsr4[$prefix] = array_merge( $this->prefixDirsPsr4[$prefix] = array_merge(
$this->prefixDirsPsr4[$prefix], $this->prefixDirsPsr4[$prefix],
(array) $paths $paths
); );
} }
} }
@@ -273,7 +271,7 @@ class ClassLoader
* replacing any others previously set for this prefix. * replacing any others previously set for this prefix.
* *
* @param string $prefix The prefix * @param string $prefix The prefix
* @param string[]|string $paths The PSR-0 base directories * @param list<string>|string $paths The PSR-0 base directories
* *
* @return void * @return void
*/ */
@@ -291,7 +289,7 @@ class ClassLoader
* replacing any others previously set for this namespace. * replacing any others previously set for this namespace.
* *
* @param string $prefix The prefix/namespace, with trailing '\\' * @param string $prefix The prefix/namespace, with trailing '\\'
* @param string[]|string $paths The PSR-4 base directories * @param list<string>|string $paths The PSR-4 base directories
* *
* @throws \InvalidArgumentException * @throws \InvalidArgumentException
* *
@@ -425,7 +423,8 @@ class ClassLoader
public function loadClass($class) public function loadClass($class)
{ {
if ($file = $this->findFile($class)) { if ($file = $this->findFile($class)) {
includeFile($file); $includeFile = self::$includeFile;
$includeFile($file);
return true; return true;
} }
@@ -476,9 +475,9 @@ class ClassLoader
} }
/** /**
* Returns the currently registered loaders indexed by their corresponding vendor directories. * Returns the currently registered loaders keyed by their corresponding vendor directories.
* *
* @return self[] * @return array<string, self>
*/ */
public static function getRegisteredLoaders() public static function getRegisteredLoaders()
{ {
@@ -555,6 +554,14 @@ class ClassLoader
return false; return false;
} }
/**
* @return void
*/
private static function initializeIncludeClosure()
{
if (self::$includeFile !== null) {
return;
} }
/** /**
@@ -564,9 +571,9 @@ class ClassLoader
* *
* @param string $file * @param string $file
* @return void * @return void
* @private
*/ */
function includeFile($file) self::$includeFile = \Closure::bind(static function($file) {
{
include $file; include $file;
}, null, null);
}
} }
+11 -4
View File
@@ -98,7 +98,7 @@ class InstalledVersions
{ {
foreach (self::getInstalled() as $installed) { foreach (self::getInstalled() as $installed) {
if (isset($installed['versions'][$packageName])) { if (isset($installed['versions'][$packageName])) {
return $includeDevRequirements || empty($installed['versions'][$packageName]['dev_requirement']); return $includeDevRequirements || !isset($installed['versions'][$packageName]['dev_requirement']) || $installed['versions'][$packageName]['dev_requirement'] === false;
} }
} }
@@ -119,7 +119,7 @@ class InstalledVersions
*/ */
public static function satisfies(VersionParser $parser, $packageName, $constraint) public static function satisfies(VersionParser $parser, $packageName, $constraint)
{ {
$constraint = $parser->parseConstraints($constraint); $constraint = $parser->parseConstraints((string) $constraint);
$provided = $parser->parseConstraints(self::getVersionRanges($packageName)); $provided = $parser->parseConstraints(self::getVersionRanges($packageName));
return $provided->matches($constraint); return $provided->matches($constraint);
@@ -328,7 +328,9 @@ class InstalledVersions
if (isset(self::$installedByVendor[$vendorDir])) { if (isset(self::$installedByVendor[$vendorDir])) {
$installed[] = self::$installedByVendor[$vendorDir]; $installed[] = self::$installedByVendor[$vendorDir];
} elseif (is_file($vendorDir.'/composer/installed.php')) { } elseif (is_file($vendorDir.'/composer/installed.php')) {
$installed[] = self::$installedByVendor[$vendorDir] = require $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';
$installed[] = self::$installedByVendor[$vendorDir] = $required;
if (null === self::$installed && strtr($vendorDir.'/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) { if (null === self::$installed && strtr($vendorDir.'/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) {
self::$installed = $installed[count($installed) - 1]; self::$installed = $installed[count($installed) - 1];
} }
@@ -340,12 +342,17 @@ class InstalledVersions
// only require the installed.php file if this file is loaded from its dumped location, // 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 // 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') { if (substr(__DIR__, -8, 1) !== 'C') {
self::$installed = require __DIR__ . '/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 __DIR__ . '/installed.php';
self::$installed = $required;
} else { } else {
self::$installed = array(); self::$installed = array();
} }
} }
if (self::$installed !== array()) {
$installed[] = self::$installed; $installed[] = self::$installed;
}
return $installed; return $installed;
} }
@@ -8,6 +8,7 @@ $baseDir = dirname($vendorDir);
return array( return array(
'Attribute' => $vendorDir . '/symfony/polyfill-php80/Resources/stubs/Attribute.php', 'Attribute' => $vendorDir . '/symfony/polyfill-php80/Resources/stubs/Attribute.php',
'Composer\\InstalledVersions' => $vendorDir . '/composer/InstalledVersions.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', 'Stringable' => $vendorDir . '/symfony/polyfill-php80/Resources/stubs/Stringable.php',
'UnhandledMatchError' => $vendorDir . '/symfony/polyfill-php80/Resources/stubs/UnhandledMatchError.php', 'UnhandledMatchError' => $vendorDir . '/symfony/polyfill-php80/Resources/stubs/UnhandledMatchError.php',
'ValueError' => $vendorDir . '/symfony/polyfill-php80/Resources/stubs/ValueError.php', 'ValueError' => $vendorDir . '/symfony/polyfill-php80/Resources/stubs/ValueError.php',
+2 -2
View File
@@ -6,12 +6,12 @@ $vendorDir = dirname(__DIR__);
$baseDir = dirname($vendorDir); $baseDir = dirname($vendorDir);
return array( return array(
'6e3fae29631ef280660b3cdad06f25a8' => $vendorDir . '/symfony/deprecation-contracts/function.php',
'0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => $vendorDir . '/symfony/polyfill-mbstring/bootstrap.php', '0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => $vendorDir . '/symfony/polyfill-mbstring/bootstrap.php',
'7b11c4dc42b3b3023073cb14e519683c' => $vendorDir . '/ralouphie/getallheaders/src/getallheaders.php', '7b11c4dc42b3b3023073cb14e519683c' => $vendorDir . '/ralouphie/getallheaders/src/getallheaders.php',
'c964ee0ededf28c96ebd9db5099ef910' => $vendorDir . '/guzzlehttp/promises/src/functions_include.php', 'c964ee0ededf28c96ebd9db5099ef910' => $vendorDir . '/guzzlehttp/promises/src/functions_include.php',
'6e3fae29631ef280660b3cdad06f25a8' => $vendorDir . '/symfony/deprecation-contracts/function.php',
'37a3dc5111fe8f707ab4c132ef1dbc62' => $vendorDir . '/guzzlehttp/guzzle/src/functions_include.php',
'a4a119a56e50fbb293281d9a48007e0e' => $vendorDir . '/symfony/polyfill-php80/bootstrap.php', 'a4a119a56e50fbb293281d9a48007e0e' => $vendorDir . '/symfony/polyfill-php80/bootstrap.php',
'37a3dc5111fe8f707ab4c132ef1dbc62' => $vendorDir . '/guzzlehttp/guzzle/src/functions_include.php',
'a1105708a18b76903365ca1c4aa61b02' => $vendorDir . '/symfony/translation/Resources/functions.php', 'a1105708a18b76903365ca1c4aa61b02' => $vendorDir . '/symfony/translation/Resources/functions.php',
'667aeda72477189d0494fecd327c3641' => $vendorDir . '/symfony/var-dumper/Resources/functions/dump.php', '667aeda72477189d0494fecd327c3641' => $vendorDir . '/symfony/var-dumper/Resources/functions/dump.php',
'320cde22f66dd4f5d3fd621d3e88b98f' => $vendorDir . '/symfony/polyfill-ctype/bootstrap.php', '320cde22f66dd4f5d3fd621d3e88b98f' => $vendorDir . '/symfony/polyfill-ctype/bootstrap.php',
+2
View File
@@ -21,6 +21,7 @@ return array(
'Psr\\Http\\Message\\' => array($vendorDir . '/psr/http-factory/src', $vendorDir . '/psr/http-message/src'), 'Psr\\Http\\Message\\' => array($vendorDir . '/psr/http-factory/src', $vendorDir . '/psr/http-message/src'),
'Psr\\Http\\Client\\' => array($vendorDir . '/psr/http-client/src'), 'Psr\\Http\\Client\\' => array($vendorDir . '/psr/http-client/src'),
'Psr\\Container\\' => array($vendorDir . '/psr/container/src'), 'Psr\\Container\\' => array($vendorDir . '/psr/container/src'),
'Psr\\Clock\\' => array($vendorDir . '/psr/clock/src'),
'PhpMimeMailParser\\' => array($vendorDir . '/php-mime-mail-parser/php-mime-mail-parser/src'), 'PhpMimeMailParser\\' => array($vendorDir . '/php-mime-mail-parser/php-mime-mail-parser/src'),
'PHPMailer\\PHPMailer\\' => array($vendorDir . '/phpmailer/phpmailer/src'), 'PHPMailer\\PHPMailer\\' => array($vendorDir . '/phpmailer/phpmailer/src'),
'MatthiasMullie\\PathConverter\\' => array($vendorDir . '/matthiasmullie/path-converter/src'), 'MatthiasMullie\\PathConverter\\' => array($vendorDir . '/matthiasmullie/path-converter/src'),
@@ -34,5 +35,6 @@ return array(
'GuzzleHttp\\' => array($vendorDir . '/guzzlehttp/guzzle/src'), 'GuzzleHttp\\' => array($vendorDir . '/guzzlehttp/guzzle/src'),
'Firebase\\JWT\\' => array($vendorDir . '/firebase/php-jwt/src'), 'Firebase\\JWT\\' => array($vendorDir . '/firebase/php-jwt/src'),
'Ddeboer\\Imap\\' => array($vendorDir . '/ddeboer/imap/src'), 'Ddeboer\\Imap\\' => array($vendorDir . '/ddeboer/imap/src'),
'Carbon\\Doctrine\\' => array($vendorDir . '/carbonphp/carbon-doctrine-types/src/Carbon/Doctrine'),
'Carbon\\' => array($vendorDir . '/nesbot/carbon/src/Carbon'), 'Carbon\\' => array($vendorDir . '/nesbot/carbon/src/Carbon'),
); );
+9 -16
View File
@@ -33,25 +33,18 @@ class ComposerAutoloaderInit873464e4bd965a3168f133248b1b218b
$loader->register(true); $loader->register(true);
$includeFiles = \Composer\Autoload\ComposerStaticInit873464e4bd965a3168f133248b1b218b::$files; $filesToLoad = \Composer\Autoload\ComposerStaticInit873464e4bd965a3168f133248b1b218b::$files;
foreach ($includeFiles as $fileIdentifier => $file) { $requireFile = \Closure::bind(static function ($fileIdentifier, $file) {
composerRequire873464e4bd965a3168f133248b1b218b($fileIdentifier, $file);
}
return $loader;
}
}
/**
* @param string $fileIdentifier
* @param string $file
* @return void
*/
function composerRequire873464e4bd965a3168f133248b1b218b($fileIdentifier, $file)
{
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) { if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true; $GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
require $file; require $file;
} }
}, null, null);
foreach ($filesToLoad as $fileIdentifier => $file) {
$requireFile($fileIdentifier, $file);
}
return $loader;
}
} }
+13 -2
View File
@@ -7,12 +7,12 @@ namespace Composer\Autoload;
class ComposerStaticInit873464e4bd965a3168f133248b1b218b class ComposerStaticInit873464e4bd965a3168f133248b1b218b
{ {
public static $files = array ( public static $files = array (
'6e3fae29631ef280660b3cdad06f25a8' => __DIR__ . '/..' . '/symfony/deprecation-contracts/function.php',
'0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => __DIR__ . '/..' . '/symfony/polyfill-mbstring/bootstrap.php', '0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => __DIR__ . '/..' . '/symfony/polyfill-mbstring/bootstrap.php',
'7b11c4dc42b3b3023073cb14e519683c' => __DIR__ . '/..' . '/ralouphie/getallheaders/src/getallheaders.php', '7b11c4dc42b3b3023073cb14e519683c' => __DIR__ . '/..' . '/ralouphie/getallheaders/src/getallheaders.php',
'c964ee0ededf28c96ebd9db5099ef910' => __DIR__ . '/..' . '/guzzlehttp/promises/src/functions_include.php', 'c964ee0ededf28c96ebd9db5099ef910' => __DIR__ . '/..' . '/guzzlehttp/promises/src/functions_include.php',
'6e3fae29631ef280660b3cdad06f25a8' => __DIR__ . '/..' . '/symfony/deprecation-contracts/function.php',
'37a3dc5111fe8f707ab4c132ef1dbc62' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/functions_include.php',
'a4a119a56e50fbb293281d9a48007e0e' => __DIR__ . '/..' . '/symfony/polyfill-php80/bootstrap.php', 'a4a119a56e50fbb293281d9a48007e0e' => __DIR__ . '/..' . '/symfony/polyfill-php80/bootstrap.php',
'37a3dc5111fe8f707ab4c132ef1dbc62' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/functions_include.php',
'a1105708a18b76903365ca1c4aa61b02' => __DIR__ . '/..' . '/symfony/translation/Resources/functions.php', 'a1105708a18b76903365ca1c4aa61b02' => __DIR__ . '/..' . '/symfony/translation/Resources/functions.php',
'667aeda72477189d0494fecd327c3641' => __DIR__ . '/..' . '/symfony/var-dumper/Resources/functions/dump.php', '667aeda72477189d0494fecd327c3641' => __DIR__ . '/..' . '/symfony/var-dumper/Resources/functions/dump.php',
'320cde22f66dd4f5d3fd621d3e88b98f' => __DIR__ . '/..' . '/symfony/polyfill-ctype/bootstrap.php', '320cde22f66dd4f5d3fd621d3e88b98f' => __DIR__ . '/..' . '/symfony/polyfill-ctype/bootstrap.php',
@@ -48,6 +48,7 @@ class ComposerStaticInit873464e4bd965a3168f133248b1b218b
'Psr\\Http\\Message\\' => 17, 'Psr\\Http\\Message\\' => 17,
'Psr\\Http\\Client\\' => 16, 'Psr\\Http\\Client\\' => 16,
'Psr\\Container\\' => 14, 'Psr\\Container\\' => 14,
'Psr\\Clock\\' => 10,
'PhpMimeMailParser\\' => 18, 'PhpMimeMailParser\\' => 18,
'PHPMailer\\PHPMailer\\' => 20, 'PHPMailer\\PHPMailer\\' => 20,
), ),
@@ -85,6 +86,7 @@ class ComposerStaticInit873464e4bd965a3168f133248b1b218b
), ),
'C' => 'C' =>
array ( array (
'Carbon\\Doctrine\\' => 16,
'Carbon\\' => 7, 'Carbon\\' => 7,
), ),
); );
@@ -151,6 +153,10 @@ class ComposerStaticInit873464e4bd965a3168f133248b1b218b
array ( array (
0 => __DIR__ . '/..' . '/psr/container/src', 0 => __DIR__ . '/..' . '/psr/container/src',
), ),
'Psr\\Clock\\' =>
array (
0 => __DIR__ . '/..' . '/psr/clock/src',
),
'PhpMimeMailParser\\' => 'PhpMimeMailParser\\' =>
array ( array (
0 => __DIR__ . '/..' . '/php-mime-mail-parser/php-mime-mail-parser/src', 0 => __DIR__ . '/..' . '/php-mime-mail-parser/php-mime-mail-parser/src',
@@ -203,6 +209,10 @@ class ComposerStaticInit873464e4bd965a3168f133248b1b218b
array ( array (
0 => __DIR__ . '/..' . '/ddeboer/imap/src', 0 => __DIR__ . '/..' . '/ddeboer/imap/src',
), ),
'Carbon\\Doctrine\\' =>
array (
0 => __DIR__ . '/..' . '/carbonphp/carbon-doctrine-types/src/Carbon/Doctrine',
),
'Carbon\\' => 'Carbon\\' =>
array ( array (
0 => __DIR__ . '/..' . '/nesbot/carbon/src/Carbon', 0 => __DIR__ . '/..' . '/nesbot/carbon/src/Carbon',
@@ -222,6 +232,7 @@ class ComposerStaticInit873464e4bd965a3168f133248b1b218b
public static $classMap = array ( public static $classMap = array (
'Attribute' => __DIR__ . '/..' . '/symfony/polyfill-php80/Resources/stubs/Attribute.php', 'Attribute' => __DIR__ . '/..' . '/symfony/polyfill-php80/Resources/stubs/Attribute.php',
'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.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', 'Stringable' => __DIR__ . '/..' . '/symfony/polyfill-php80/Resources/stubs/Stringable.php',
'UnhandledMatchError' => __DIR__ . '/..' . '/symfony/polyfill-php80/Resources/stubs/UnhandledMatchError.php', 'UnhandledMatchError' => __DIR__ . '/..' . '/symfony/polyfill-php80/Resources/stubs/UnhandledMatchError.php',
'ValueError' => __DIR__ . '/..' . '/symfony/polyfill-php80/Resources/stubs/ValueError.php', 'ValueError' => __DIR__ . '/..' . '/symfony/polyfill-php80/Resources/stubs/ValueError.php',
+245 -119
View File
@@ -61,6 +61,78 @@
], ],
"install-path": "../bshaffer/oauth2-server-php" "install-path": "../bshaffer/oauth2-server-php"
}, },
{
"name": "carbonphp/carbon-doctrine-types",
"version": "3.2.0",
"version_normalized": "3.2.0.0",
"source": {
"type": "git",
"url": "https://github.com/CarbonPHP/carbon-doctrine-types.git",
"reference": "18ba5ddfec8976260ead6e866180bd5d2f71aa1d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/CarbonPHP/carbon-doctrine-types/zipball/18ba5ddfec8976260ead6e866180bd5d2f71aa1d",
"reference": "18ba5ddfec8976260ead6e866180bd5d2f71aa1d",
"shasum": ""
},
"require": {
"php": "^8.1"
},
"conflict": {
"doctrine/dbal": "<4.0.0 || >=5.0.0"
},
"require-dev": {
"doctrine/dbal": "^4.0.0",
"nesbot/carbon": "^2.71.0 || ^3.0.0",
"phpunit/phpunit": "^10.3"
},
"time": "2024-02-09T16:56:22+00:00",
"type": "library",
"installation-source": "dist",
"autoload": {
"psr-4": {
"Carbon\\Doctrine\\": "src/Carbon/Doctrine/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "KyleKatarn",
"email": "kylekatarnls@gmail.com"
}
],
"description": "Types to use Carbon in Doctrine",
"keywords": [
"carbon",
"date",
"datetime",
"doctrine",
"time"
],
"support": {
"issues": "https://github.com/CarbonPHP/carbon-doctrine-types/issues",
"source": "https://github.com/CarbonPHP/carbon-doctrine-types/tree/3.2.0"
},
"funding": [
{
"url": "https://github.com/kylekatarnls",
"type": "github"
},
{
"url": "https://opencollective.com/Carbon",
"type": "open_collective"
},
{
"url": "https://tidelift.com/funding/github/packagist/nesbot/carbon",
"type": "tidelift"
}
],
"install-path": "../carbonphp/carbon-doctrine-types"
},
{ {
"name": "ddeboer/imap", "name": "ddeboer/imap",
"version": "1.13.1", "version": "1.13.1",
@@ -141,35 +213,36 @@
}, },
{ {
"name": "directorytree/ldaprecord", "name": "directorytree/ldaprecord",
"version": "v2.10.1", "version": "v2.20.5",
"version_normalized": "2.10.1.0", "version_normalized": "2.20.5.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/DirectoryTree/LdapRecord.git", "url": "https://github.com/DirectoryTree/LdapRecord.git",
"reference": "bf512d9af7a7b0e2ed7a666ab29cefdd027bee88" "reference": "5bd0a5a9d257cf1049ae83055dbba4c3479ddf16"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/DirectoryTree/LdapRecord/zipball/bf512d9af7a7b0e2ed7a666ab29cefdd027bee88", "url": "https://api.github.com/repos/DirectoryTree/LdapRecord/zipball/5bd0a5a9d257cf1049ae83055dbba4c3479ddf16",
"reference": "bf512d9af7a7b0e2ed7a666ab29cefdd027bee88", "reference": "5bd0a5a9d257cf1049ae83055dbba4c3479ddf16",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"ext-json": "*", "ext-json": "*",
"ext-ldap": "*", "ext-ldap": "*",
"illuminate/contracts": "^5.0|^6.0|^7.0|^8.0|^9.0", "illuminate/contracts": "^5.0|^6.0|^7.0|^8.0|^9.0|^10.0",
"nesbot/carbon": "^1.0|^2.0", "nesbot/carbon": "^1.0|^2.0",
"php": ">=7.3", "php": ">=7.3",
"psr/log": "*", "psr/log": "^1.0|^2.0|^3.0",
"psr/simple-cache": "^1.0|^2.0", "psr/simple-cache": "^1.0|^2.0",
"tightenco/collect": "^5.6|^6.0|^7.0|^8.0" "symfony/polyfill-php80": "^1.25",
"tightenco/collect": "^5.6|^6.0|^7.0|^8.0|^9.0"
}, },
"require-dev": { "require-dev": {
"mockery/mockery": "^1.0", "mockery/mockery": "^1.0",
"phpunit/phpunit": "^9.0", "phpunit/phpunit": "^9.0",
"spatie/ray": "^1.24" "spatie/ray": "^1.24"
}, },
"time": "2022-02-25T16:00:51+00:00", "time": "2023-10-11T16:34:34+00:00",
"type": "library", "type": "library",
"installation-source": "dist", "installation-source": "dist",
"autoload": { "autoload": {
@@ -620,29 +693,29 @@
}, },
{ {
"name": "illuminate/contracts", "name": "illuminate/contracts",
"version": "v9.3.0", "version": "v10.44.0",
"version_normalized": "9.3.0.0", "version_normalized": "10.44.0.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/illuminate/contracts.git", "url": "https://github.com/illuminate/contracts.git",
"reference": "bf4b3c254c49d28157645d01e4883b5951b1e1d0" "reference": "8d7152c4a1f5d9cf7da3e8b71f23e4556f6138ac"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/illuminate/contracts/zipball/bf4b3c254c49d28157645d01e4883b5951b1e1d0", "url": "https://api.github.com/repos/illuminate/contracts/zipball/8d7152c4a1f5d9cf7da3e8b71f23e4556f6138ac",
"reference": "bf4b3c254c49d28157645d01e4883b5951b1e1d0", "reference": "8d7152c4a1f5d9cf7da3e8b71f23e4556f6138ac",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"php": "^8.0.2", "php": "^8.1",
"psr/container": "^1.1.1|^2.0.1", "psr/container": "^1.1.1|^2.0.1",
"psr/simple-cache": "^1.0|^2.0|^3.0" "psr/simple-cache": "^1.0|^2.0|^3.0"
}, },
"time": "2022-02-22T14:45:39+00:00", "time": "2024-01-15T18:52:32+00:00",
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-master": "9.x-dev" "dev-master": "10.x-dev"
} }
}, },
"installation-source": "dist", "installation-source": "dist",
@@ -930,38 +1003,45 @@
}, },
{ {
"name": "nesbot/carbon", "name": "nesbot/carbon",
"version": "2.57.0", "version": "2.72.3",
"version_normalized": "2.57.0.0", "version_normalized": "2.72.3.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/briannesbitt/Carbon.git", "url": "https://github.com/briannesbitt/Carbon.git",
"reference": "4a54375c21eea4811dbd1149fe6b246517554e78" "reference": "0c6fd108360c562f6e4fd1dedb8233b423e91c83"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/4a54375c21eea4811dbd1149fe6b246517554e78", "url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/0c6fd108360c562f6e4fd1dedb8233b423e91c83",
"reference": "4a54375c21eea4811dbd1149fe6b246517554e78", "reference": "0c6fd108360c562f6e4fd1dedb8233b423e91c83",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"carbonphp/carbon-doctrine-types": "*",
"ext-json": "*", "ext-json": "*",
"php": "^7.1.8 || ^8.0", "php": "^7.1.8 || ^8.0",
"psr/clock": "^1.0",
"symfony/polyfill-mbstring": "^1.0", "symfony/polyfill-mbstring": "^1.0",
"symfony/polyfill-php80": "^1.16", "symfony/polyfill-php80": "^1.16",
"symfony/translation": "^3.4 || ^4.0 || ^5.0 || ^6.0" "symfony/translation": "^3.4 || ^4.0 || ^5.0 || ^6.0"
}, },
"provide": {
"psr/clock-implementation": "1.0"
},
"require-dev": { "require-dev": {
"doctrine/dbal": "^2.0 || ^3.0", "doctrine/dbal": "^2.0 || ^3.1.4 || ^4.0",
"doctrine/orm": "^2.7", "doctrine/orm": "^2.7 || ^3.0",
"friendsofphp/php-cs-fixer": "^3.0", "friendsofphp/php-cs-fixer": "^3.0",
"kylekatarnls/multi-tester": "^2.0", "kylekatarnls/multi-tester": "^2.0",
"ondrejmirtes/better-reflection": "*",
"phpmd/phpmd": "^2.9", "phpmd/phpmd": "^2.9",
"phpstan/extension-installer": "^1.0", "phpstan/extension-installer": "^1.0",
"phpstan/phpstan": "^0.12.54 || ^1.0", "phpstan/phpstan": "^0.12.99 || ^1.7.14",
"phpunit/phpunit": "^7.5.20 || ^8.5.14", "phpunit/php-file-iterator": "^2.0.5 || ^3.0.6",
"phpunit/phpunit": "^7.5.20 || ^8.5.26 || ^9.5.20",
"squizlabs/php_codesniffer": "^3.4" "squizlabs/php_codesniffer": "^3.4"
}, },
"time": "2022-02-13T18:13:33+00:00", "time": "2024-01-25T10:35:09+00:00",
"bin": [ "bin": [
"bin/carbon" "bin/carbon"
], ],
@@ -1017,11 +1097,15 @@
}, },
"funding": [ "funding": [
{ {
"url": "https://opencollective.com/Carbon", "url": "https://github.com/sponsors/kylekatarnls",
"type": "open_collective" "type": "github"
}, },
{ {
"url": "https://tidelift.com/funding/github/packagist/nesbot/carbon", "url": "https://opencollective.com/Carbon#sponsor",
"type": "opencollective"
},
{
"url": "https://tidelift.com/subscription/pkg/packagist-nesbot-carbon?utm_source=packagist-nesbot-carbon&utm_medium=referral&utm_campaign=readme",
"type": "tidelift" "type": "tidelift"
} }
], ],
@@ -1255,6 +1339,57 @@
], ],
"install-path": "../phpmailer/phpmailer" "install-path": "../phpmailer/phpmailer"
}, },
{
"name": "psr/clock",
"version": "1.0.0",
"version_normalized": "1.0.0.0",
"source": {
"type": "git",
"url": "https://github.com/php-fig/clock.git",
"reference": "e41a24703d4560fd0acb709162f73b8adfc3aa0d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-fig/clock/zipball/e41a24703d4560fd0acb709162f73b8adfc3aa0d",
"reference": "e41a24703d4560fd0acb709162f73b8adfc3aa0d",
"shasum": ""
},
"require": {
"php": "^7.0 || ^8.0"
},
"time": "2022-11-25T14:36:26+00:00",
"type": "library",
"installation-source": "dist",
"autoload": {
"psr-4": {
"Psr\\Clock\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "PHP-FIG",
"homepage": "https://www.php-fig.org/"
}
],
"description": "Common interface for reading the clock.",
"homepage": "https://github.com/php-fig/clock",
"keywords": [
"clock",
"now",
"psr",
"psr-20",
"time"
],
"support": {
"issues": "https://github.com/php-fig/clock/issues",
"source": "https://github.com/php-fig/clock/tree/1.0.0"
},
"install-path": "../psr/clock"
},
{ {
"name": "psr/container", "name": "psr/container",
"version": "2.0.2", "version": "2.0.2",
@@ -1826,27 +1961,27 @@
}, },
{ {
"name": "symfony/deprecation-contracts", "name": "symfony/deprecation-contracts",
"version": "v3.2.1", "version": "v3.4.0",
"version_normalized": "3.2.1.0", "version_normalized": "3.4.0.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/deprecation-contracts.git", "url": "https://github.com/symfony/deprecation-contracts.git",
"reference": "e2d1534420bd723d0ef5aec58a22c5fe60ce6f5e" "reference": "7c3aff79d10325257a001fcf92d991f24fc967cf"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/e2d1534420bd723d0ef5aec58a22c5fe60ce6f5e", "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/7c3aff79d10325257a001fcf92d991f24fc967cf",
"reference": "e2d1534420bd723d0ef5aec58a22c5fe60ce6f5e", "reference": "7c3aff79d10325257a001fcf92d991f24fc967cf",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"php": ">=8.1" "php": ">=8.1"
}, },
"time": "2023-03-01T10:25:55+00:00", "time": "2023-05-23T14:45:45+00:00",
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-main": "3.3-dev" "dev-main": "3.4-dev"
}, },
"thanks": { "thanks": {
"name": "symfony/contracts", "name": "symfony/contracts",
@@ -1876,7 +2011,7 @@
"description": "A generic function and convention to trigger deprecation notices", "description": "A generic function and convention to trigger deprecation notices",
"homepage": "https://symfony.com", "homepage": "https://symfony.com",
"support": { "support": {
"source": "https://github.com/symfony/deprecation-contracts/tree/v3.2.1" "source": "https://github.com/symfony/deprecation-contracts/tree/v3.4.0"
}, },
"funding": [ "funding": [
{ {
@@ -1981,17 +2116,17 @@
}, },
{ {
"name": "symfony/polyfill-mbstring", "name": "symfony/polyfill-mbstring",
"version": "v1.24.0", "version": "v1.29.0",
"version_normalized": "1.24.0.0", "version_normalized": "1.29.0.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/polyfill-mbstring.git", "url": "https://github.com/symfony/polyfill-mbstring.git",
"reference": "0abb51d2f102e00a4eefcf46ba7fec406d245825" "reference": "9773676c8a1bb1f8d4340a62efe641cf76eda7ec"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/0abb51d2f102e00a4eefcf46ba7fec406d245825", "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/9773676c8a1bb1f8d4340a62efe641cf76eda7ec",
"reference": "0abb51d2f102e00a4eefcf46ba7fec406d245825", "reference": "9773676c8a1bb1f8d4340a62efe641cf76eda7ec",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@@ -2003,12 +2138,9 @@
"suggest": { "suggest": {
"ext-mbstring": "For best performance" "ext-mbstring": "For best performance"
}, },
"time": "2021-11-30T18:21:41+00:00", "time": "2024-01-29T20:11:03+00:00",
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": {
"dev-main": "1.23-dev"
},
"thanks": { "thanks": {
"name": "symfony/polyfill", "name": "symfony/polyfill",
"url": "https://github.com/symfony/polyfill" "url": "https://github.com/symfony/polyfill"
@@ -2047,7 +2179,7 @@
"shim" "shim"
], ],
"support": { "support": {
"source": "https://github.com/symfony/polyfill-mbstring/tree/v1.24.0" "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.29.0"
}, },
"funding": [ "funding": [
{ {
@@ -2067,28 +2199,25 @@
}, },
{ {
"name": "symfony/polyfill-php80", "name": "symfony/polyfill-php80",
"version": "v1.24.0", "version": "v1.29.0",
"version_normalized": "1.24.0.0", "version_normalized": "1.29.0.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/polyfill-php80.git", "url": "https://github.com/symfony/polyfill-php80.git",
"reference": "57b712b08eddb97c762a8caa32c84e037892d2e9" "reference": "87b68208d5c1188808dd7839ee1e6c8ec3b02f1b"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/57b712b08eddb97c762a8caa32c84e037892d2e9", "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/87b68208d5c1188808dd7839ee1e6c8ec3b02f1b",
"reference": "57b712b08eddb97c762a8caa32c84e037892d2e9", "reference": "87b68208d5c1188808dd7839ee1e6c8ec3b02f1b",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"php": ">=7.1" "php": ">=7.1"
}, },
"time": "2021-09-13T13:58:33+00:00", "time": "2024-01-29T20:11:03+00:00",
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": {
"dev-main": "1.23-dev"
},
"thanks": { "thanks": {
"name": "symfony/polyfill", "name": "symfony/polyfill",
"url": "https://github.com/symfony/polyfill" "url": "https://github.com/symfony/polyfill"
@@ -2133,7 +2262,7 @@
"shim" "shim"
], ],
"support": { "support": {
"source": "https://github.com/symfony/polyfill-php80/tree/v1.24.0" "source": "https://github.com/symfony/polyfill-php80/tree/v1.29.0"
}, },
"funding": [ "funding": [
{ {
@@ -2153,29 +2282,32 @@
}, },
{ {
"name": "symfony/translation", "name": "symfony/translation",
"version": "v6.0.5", "version": "v6.4.3",
"version_normalized": "6.0.5.0", "version_normalized": "6.4.3.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/translation.git", "url": "https://github.com/symfony/translation.git",
"reference": "e69501c71107cc3146b32aaa45f4edd0c3427875" "reference": "637c51191b6b184184bbf98937702bcf554f7d04"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/translation/zipball/e69501c71107cc3146b32aaa45f4edd0c3427875", "url": "https://api.github.com/repos/symfony/translation/zipball/637c51191b6b184184bbf98937702bcf554f7d04",
"reference": "e69501c71107cc3146b32aaa45f4edd0c3427875", "reference": "637c51191b6b184184bbf98937702bcf554f7d04",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"php": ">=8.0.2", "php": ">=8.1",
"symfony/deprecation-contracts": "^2.5|^3",
"symfony/polyfill-mbstring": "~1.0", "symfony/polyfill-mbstring": "~1.0",
"symfony/translation-contracts": "^2.3|^3.0" "symfony/translation-contracts": "^2.5|^3.0"
}, },
"conflict": { "conflict": {
"symfony/config": "<5.4", "symfony/config": "<5.4",
"symfony/console": "<5.4", "symfony/console": "<5.4",
"symfony/dependency-injection": "<5.4", "symfony/dependency-injection": "<5.4",
"symfony/http-client-contracts": "<2.5",
"symfony/http-kernel": "<5.4", "symfony/http-kernel": "<5.4",
"symfony/service-contracts": "<2.5",
"symfony/twig-bundle": "<5.4", "symfony/twig-bundle": "<5.4",
"symfony/yaml": "<5.4" "symfony/yaml": "<5.4"
}, },
@@ -2183,24 +2315,21 @@
"symfony/translation-implementation": "2.3|3.0" "symfony/translation-implementation": "2.3|3.0"
}, },
"require-dev": { "require-dev": {
"nikic/php-parser": "^4.18|^5.0",
"psr/log": "^1|^2|^3", "psr/log": "^1|^2|^3",
"symfony/config": "^5.4|^6.0", "symfony/config": "^5.4|^6.0|^7.0",
"symfony/console": "^5.4|^6.0", "symfony/console": "^5.4|^6.0|^7.0",
"symfony/dependency-injection": "^5.4|^6.0", "symfony/dependency-injection": "^5.4|^6.0|^7.0",
"symfony/finder": "^5.4|^6.0", "symfony/finder": "^5.4|^6.0|^7.0",
"symfony/http-client-contracts": "^1.1|^2.0|^3.0", "symfony/http-client-contracts": "^2.5|^3.0",
"symfony/http-kernel": "^5.4|^6.0", "symfony/http-kernel": "^5.4|^6.0|^7.0",
"symfony/intl": "^5.4|^6.0", "symfony/intl": "^5.4|^6.0|^7.0",
"symfony/polyfill-intl-icu": "^1.21", "symfony/polyfill-intl-icu": "^1.21",
"symfony/service-contracts": "^1.1.2|^2|^3", "symfony/routing": "^5.4|^6.0|^7.0",
"symfony/yaml": "^5.4|^6.0" "symfony/service-contracts": "^2.5|^3",
"symfony/yaml": "^5.4|^6.0|^7.0"
}, },
"suggest": { "time": "2024-01-29T13:11:52+00:00",
"psr/log-implementation": "To use logging capability in translator",
"symfony/config": "",
"symfony/yaml": ""
},
"time": "2022-02-09T15:52:48+00:00",
"type": "library", "type": "library",
"installation-source": "dist", "installation-source": "dist",
"autoload": { "autoload": {
@@ -2231,7 +2360,7 @@
"description": "Provides tools to internationalize your application", "description": "Provides tools to internationalize your application",
"homepage": "https://symfony.com", "homepage": "https://symfony.com",
"support": { "support": {
"source": "https://github.com/symfony/translation/tree/v6.0.5" "source": "https://github.com/symfony/translation/tree/v6.4.3"
}, },
"funding": [ "funding": [
{ {
@@ -2251,30 +2380,27 @@
}, },
{ {
"name": "symfony/translation-contracts", "name": "symfony/translation-contracts",
"version": "v3.0.0", "version": "v3.4.1",
"version_normalized": "3.0.0.0", "version_normalized": "3.4.1.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/translation-contracts.git", "url": "https://github.com/symfony/translation-contracts.git",
"reference": "1b6ea5a7442af5a12dba3dbd6d71034b5b234e77" "reference": "06450585bf65e978026bda220cdebca3f867fde7"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/translation-contracts/zipball/1b6ea5a7442af5a12dba3dbd6d71034b5b234e77", "url": "https://api.github.com/repos/symfony/translation-contracts/zipball/06450585bf65e978026bda220cdebca3f867fde7",
"reference": "1b6ea5a7442af5a12dba3dbd6d71034b5b234e77", "reference": "06450585bf65e978026bda220cdebca3f867fde7",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"php": ">=8.0.2" "php": ">=8.1"
}, },
"suggest": { "time": "2023-12-26T14:02:43+00:00",
"symfony/translation-implementation": ""
},
"time": "2021-09-07T12:43:40+00:00",
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-main": "3.0-dev" "dev-main": "3.4-dev"
}, },
"thanks": { "thanks": {
"name": "symfony/contracts", "name": "symfony/contracts",
@@ -2285,7 +2411,10 @@
"autoload": { "autoload": {
"psr-4": { "psr-4": {
"Symfony\\Contracts\\Translation\\": "" "Symfony\\Contracts\\Translation\\": ""
} },
"exclude-from-classmap": [
"/Test/"
]
}, },
"notification-url": "https://packagist.org/downloads/", "notification-url": "https://packagist.org/downloads/",
"license": [ "license": [
@@ -2312,7 +2441,7 @@
"standards" "standards"
], ],
"support": { "support": {
"source": "https://github.com/symfony/translation-contracts/tree/v3.0.0" "source": "https://github.com/symfony/translation-contracts/tree/v3.4.1"
}, },
"funding": [ "funding": [
{ {
@@ -2332,40 +2461,37 @@
}, },
{ {
"name": "symfony/var-dumper", "name": "symfony/var-dumper",
"version": "v6.0.5", "version": "v6.4.3",
"version_normalized": "6.0.5.0", "version_normalized": "6.4.3.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/var-dumper.git", "url": "https://github.com/symfony/var-dumper.git",
"reference": "60d6a756d5f485df5e6e40b337334848f79f61ce" "reference": "0435a08f69125535336177c29d56af3abc1f69da"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/var-dumper/zipball/60d6a756d5f485df5e6e40b337334848f79f61ce", "url": "https://api.github.com/repos/symfony/var-dumper/zipball/0435a08f69125535336177c29d56af3abc1f69da",
"reference": "60d6a756d5f485df5e6e40b337334848f79f61ce", "reference": "0435a08f69125535336177c29d56af3abc1f69da",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"php": ">=8.0.2", "php": ">=8.1",
"symfony/deprecation-contracts": "^2.5|^3",
"symfony/polyfill-mbstring": "~1.0" "symfony/polyfill-mbstring": "~1.0"
}, },
"conflict": { "conflict": {
"phpunit/phpunit": "<5.4.3",
"symfony/console": "<5.4" "symfony/console": "<5.4"
}, },
"require-dev": { "require-dev": {
"ext-iconv": "*", "ext-iconv": "*",
"symfony/console": "^5.4|^6.0", "symfony/console": "^5.4|^6.0|^7.0",
"symfony/process": "^5.4|^6.0", "symfony/error-handler": "^6.3|^7.0",
"symfony/uid": "^5.4|^6.0", "symfony/http-kernel": "^5.4|^6.0|^7.0",
"symfony/process": "^5.4|^6.0|^7.0",
"symfony/uid": "^5.4|^6.0|^7.0",
"twig/twig": "^2.13|^3.0.4" "twig/twig": "^2.13|^3.0.4"
}, },
"suggest": { "time": "2024-01-23T14:53:30+00:00",
"ext-iconv": "To convert non-UTF-8 strings to UTF-8 (or symfony/polyfill-iconv in case ext-iconv cannot be used).",
"ext-intl": "To show region name in time zone dump",
"symfony/console": "To use the ServerDumpCommand and/or the bin/var-dump-server script"
},
"time": "2022-02-21T17:15:17+00:00",
"bin": [ "bin": [
"Resources/bin/var-dump-server" "Resources/bin/var-dump-server"
], ],
@@ -2403,7 +2529,7 @@
"dump" "dump"
], ],
"support": { "support": {
"source": "https://github.com/symfony/var-dumper/tree/v6.0.5" "source": "https://github.com/symfony/var-dumper/tree/v6.4.3"
}, },
"funding": [ "funding": [
{ {
@@ -2423,21 +2549,21 @@
}, },
{ {
"name": "tightenco/collect", "name": "tightenco/collect",
"version": "v8.83.2", "version": "v9.52.7",
"version_normalized": "8.83.2.0", "version_normalized": "9.52.7.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/tighten/collect.git", "url": "https://github.com/tighten/collect.git",
"reference": "d9c66d586ec2d216d8a31283d73f8df1400cc722" "reference": "b15143cd11fe01a700fcc449df61adc64452fa6d"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/tighten/collect/zipball/d9c66d586ec2d216d8a31283d73f8df1400cc722", "url": "https://api.github.com/repos/tighten/collect/zipball/b15143cd11fe01a700fcc449df61adc64452fa6d",
"reference": "d9c66d586ec2d216d8a31283d73f8df1400cc722", "reference": "b15143cd11fe01a700fcc449df61adc64452fa6d",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"php": "^7.3|^8.0", "php": "^8.0",
"symfony/var-dumper": "^3.4 || ^4.0 || ^5.0 || ^6.0" "symfony/var-dumper": "^3.4 || ^4.0 || ^5.0 || ^6.0"
}, },
"require-dev": { "require-dev": {
@@ -2445,7 +2571,7 @@
"nesbot/carbon": "^2.23.0", "nesbot/carbon": "^2.23.0",
"phpunit/phpunit": "^8.3" "phpunit/phpunit": "^8.3"
}, },
"time": "2022-02-16T16:15:54+00:00", "time": "2023-04-14T21:51:36+00:00",
"type": "library", "type": "library",
"installation-source": "dist", "installation-source": "dist",
"autoload": { "autoload": {
@@ -2474,7 +2600,7 @@
], ],
"support": { "support": {
"issues": "https://github.com/tighten/collect/issues", "issues": "https://github.com/tighten/collect/issues",
"source": "https://github.com/tighten/collect/tree/v8.83.2" "source": "https://github.com/tighten/collect/tree/v9.52.7"
}, },
"install-path": "../tightenco/collect" "install-path": "../tightenco/collect"
}, },
+56 -32
View File
@@ -3,7 +3,7 @@
'name' => '__root__', 'name' => '__root__',
'pretty_version' => 'dev-master', 'pretty_version' => 'dev-master',
'version' => 'dev-master', 'version' => 'dev-master',
'reference' => '96390c2e12fd8d886495fde5514ad431e4e66069', 'reference' => '40146839efb3754b2db4045f0111178ffd1883c5',
'type' => 'library', 'type' => 'library',
'install_path' => __DIR__ . '/../../', 'install_path' => __DIR__ . '/../../',
'aliases' => array(), 'aliases' => array(),
@@ -13,7 +13,7 @@
'__root__' => array( '__root__' => array(
'pretty_version' => 'dev-master', 'pretty_version' => 'dev-master',
'version' => 'dev-master', 'version' => 'dev-master',
'reference' => '96390c2e12fd8d886495fde5514ad431e4e66069', 'reference' => '40146839efb3754b2db4045f0111178ffd1883c5',
'type' => 'library', 'type' => 'library',
'install_path' => __DIR__ . '/../../', 'install_path' => __DIR__ . '/../../',
'aliases' => array(), 'aliases' => array(),
@@ -28,6 +28,15 @@
'aliases' => array(), 'aliases' => array(),
'dev_requirement' => false, 'dev_requirement' => false,
), ),
'carbonphp/carbon-doctrine-types' => array(
'pretty_version' => '3.2.0',
'version' => '3.2.0.0',
'reference' => '18ba5ddfec8976260ead6e866180bd5d2f71aa1d',
'type' => 'library',
'install_path' => __DIR__ . '/../carbonphp/carbon-doctrine-types',
'aliases' => array(),
'dev_requirement' => false,
),
'ddeboer/imap' => array( 'ddeboer/imap' => array(
'pretty_version' => '1.13.1', 'pretty_version' => '1.13.1',
'version' => '1.13.1.0', 'version' => '1.13.1.0',
@@ -38,9 +47,9 @@
'dev_requirement' => false, 'dev_requirement' => false,
), ),
'directorytree/ldaprecord' => array( 'directorytree/ldaprecord' => array(
'pretty_version' => 'v2.10.1', 'pretty_version' => 'v2.20.5',
'version' => '2.10.1.0', 'version' => '2.20.5.0',
'reference' => 'bf512d9af7a7b0e2ed7a666ab29cefdd027bee88', 'reference' => '5bd0a5a9d257cf1049ae83055dbba4c3479ddf16',
'type' => 'library', 'type' => 'library',
'install_path' => __DIR__ . '/../directorytree/ldaprecord', 'install_path' => __DIR__ . '/../directorytree/ldaprecord',
'aliases' => array(), 'aliases' => array(),
@@ -89,9 +98,9 @@
'dev_requirement' => false, 'dev_requirement' => false,
), ),
'illuminate/contracts' => array( 'illuminate/contracts' => array(
'pretty_version' => 'v9.3.0', 'pretty_version' => 'v10.44.0',
'version' => '9.3.0.0', 'version' => '10.44.0.0',
'reference' => 'bf4b3c254c49d28157645d01e4883b5951b1e1d0', 'reference' => '8d7152c4a1f5d9cf7da3e8b71f23e4556f6138ac',
'type' => 'library', 'type' => 'library',
'install_path' => __DIR__ . '/../illuminate/contracts', 'install_path' => __DIR__ . '/../illuminate/contracts',
'aliases' => array(), 'aliases' => array(),
@@ -140,9 +149,9 @@
'dev_requirement' => false, 'dev_requirement' => false,
), ),
'nesbot/carbon' => array( 'nesbot/carbon' => array(
'pretty_version' => '2.57.0', 'pretty_version' => '2.72.3',
'version' => '2.57.0.0', 'version' => '2.72.3.0',
'reference' => '4a54375c21eea4811dbd1149fe6b246517554e78', 'reference' => '0c6fd108360c562f6e4fd1dedb8233b423e91c83',
'type' => 'library', 'type' => 'library',
'install_path' => __DIR__ . '/../nesbot/carbon', 'install_path' => __DIR__ . '/../nesbot/carbon',
'aliases' => array(), 'aliases' => array(),
@@ -175,6 +184,21 @@
'aliases' => array(), 'aliases' => array(),
'dev_requirement' => false, 'dev_requirement' => false,
), ),
'psr/clock' => array(
'pretty_version' => '1.0.0',
'version' => '1.0.0.0',
'reference' => 'e41a24703d4560fd0acb709162f73b8adfc3aa0d',
'type' => 'library',
'install_path' => __DIR__ . '/../psr/clock',
'aliases' => array(),
'dev_requirement' => false,
),
'psr/clock-implementation' => array(
'dev_requirement' => false,
'provided' => array(
0 => '1.0',
),
),
'psr/container' => array( 'psr/container' => array(
'pretty_version' => '2.0.2', 'pretty_version' => '2.0.2',
'version' => '2.0.2.0', 'version' => '2.0.2.0',
@@ -284,9 +308,9 @@
'dev_requirement' => false, 'dev_requirement' => false,
), ),
'symfony/deprecation-contracts' => array( 'symfony/deprecation-contracts' => array(
'pretty_version' => 'v3.2.1', 'pretty_version' => 'v3.4.0',
'version' => '3.2.1.0', 'version' => '3.4.0.0',
'reference' => 'e2d1534420bd723d0ef5aec58a22c5fe60ce6f5e', 'reference' => '7c3aff79d10325257a001fcf92d991f24fc967cf',
'type' => 'library', 'type' => 'library',
'install_path' => __DIR__ . '/../symfony/deprecation-contracts', 'install_path' => __DIR__ . '/../symfony/deprecation-contracts',
'aliases' => array(), 'aliases' => array(),
@@ -302,36 +326,36 @@
'dev_requirement' => false, 'dev_requirement' => false,
), ),
'symfony/polyfill-mbstring' => array( 'symfony/polyfill-mbstring' => array(
'pretty_version' => 'v1.24.0', 'pretty_version' => 'v1.29.0',
'version' => '1.24.0.0', 'version' => '1.29.0.0',
'reference' => '0abb51d2f102e00a4eefcf46ba7fec406d245825', 'reference' => '9773676c8a1bb1f8d4340a62efe641cf76eda7ec',
'type' => 'library', 'type' => 'library',
'install_path' => __DIR__ . '/../symfony/polyfill-mbstring', 'install_path' => __DIR__ . '/../symfony/polyfill-mbstring',
'aliases' => array(), 'aliases' => array(),
'dev_requirement' => false, 'dev_requirement' => false,
), ),
'symfony/polyfill-php80' => array( 'symfony/polyfill-php80' => array(
'pretty_version' => 'v1.24.0', 'pretty_version' => 'v1.29.0',
'version' => '1.24.0.0', 'version' => '1.29.0.0',
'reference' => '57b712b08eddb97c762a8caa32c84e037892d2e9', 'reference' => '87b68208d5c1188808dd7839ee1e6c8ec3b02f1b',
'type' => 'library', 'type' => 'library',
'install_path' => __DIR__ . '/../symfony/polyfill-php80', 'install_path' => __DIR__ . '/../symfony/polyfill-php80',
'aliases' => array(), 'aliases' => array(),
'dev_requirement' => false, 'dev_requirement' => false,
), ),
'symfony/translation' => array( 'symfony/translation' => array(
'pretty_version' => 'v6.0.5', 'pretty_version' => 'v6.4.3',
'version' => '6.0.5.0', 'version' => '6.4.3.0',
'reference' => 'e69501c71107cc3146b32aaa45f4edd0c3427875', 'reference' => '637c51191b6b184184bbf98937702bcf554f7d04',
'type' => 'library', 'type' => 'library',
'install_path' => __DIR__ . '/../symfony/translation', 'install_path' => __DIR__ . '/../symfony/translation',
'aliases' => array(), 'aliases' => array(),
'dev_requirement' => false, 'dev_requirement' => false,
), ),
'symfony/translation-contracts' => array( 'symfony/translation-contracts' => array(
'pretty_version' => 'v3.0.0', 'pretty_version' => 'v3.4.1',
'version' => '3.0.0.0', 'version' => '3.4.1.0',
'reference' => '1b6ea5a7442af5a12dba3dbd6d71034b5b234e77', 'reference' => '06450585bf65e978026bda220cdebca3f867fde7',
'type' => 'library', 'type' => 'library',
'install_path' => __DIR__ . '/../symfony/translation-contracts', 'install_path' => __DIR__ . '/../symfony/translation-contracts',
'aliases' => array(), 'aliases' => array(),
@@ -344,18 +368,18 @@
), ),
), ),
'symfony/var-dumper' => array( 'symfony/var-dumper' => array(
'pretty_version' => 'v6.0.5', 'pretty_version' => 'v6.4.3',
'version' => '6.0.5.0', 'version' => '6.4.3.0',
'reference' => '60d6a756d5f485df5e6e40b337334848f79f61ce', 'reference' => '0435a08f69125535336177c29d56af3abc1f69da',
'type' => 'library', 'type' => 'library',
'install_path' => __DIR__ . '/../symfony/var-dumper', 'install_path' => __DIR__ . '/../symfony/var-dumper',
'aliases' => array(), 'aliases' => array(),
'dev_requirement' => false, 'dev_requirement' => false,
), ),
'tightenco/collect' => array( 'tightenco/collect' => array(
'pretty_version' => 'v8.83.2', 'pretty_version' => 'v9.52.7',
'version' => '8.83.2.0', 'version' => '9.52.7.0',
'reference' => 'd9c66d586ec2d216d8a31283d73f8df1400cc722', 'reference' => 'b15143cd11fe01a700fcc449df61adc64452fa6d',
'type' => 'library', 'type' => 'library',
'install_path' => __DIR__ . '/../tightenco/collect', 'install_path' => __DIR__ . '/../tightenco/collect',
'aliases' => array(), 'aliases' => array(),
@@ -7,7 +7,10 @@ assignees: ''
--- ---
<!-- Please update the below information with your environment. --> <!--
Please update the below information with your environment.
Issues filed without the below information will be closed.
-->
**Environment:** **Environment:**
- LDAP Server Type: [e.g. ActiveDirectory / OpenLDAP / FreeIPA] - LDAP Server Type: [e.g. ActiveDirectory / OpenLDAP / FreeIPA]
- PHP Version: [e.g. 7.3 / 7.4 / 8.0] - PHP Version: [e.g. 7.3 / 7.4 / 8.0]
@@ -11,7 +11,10 @@ assignees: ''
<!-- https://github.com/sponsors/stevebauman --> <!-- https://github.com/sponsors/stevebauman -->
<!-- Thank you for your understanding. --> <!-- Thank you for your understanding. -->
<!-- Please update the below information with your environment. --> <!--
Please update the below information with your environment.
Issues filed without the below information will be closed.
-->
**Environment:** **Environment:**
- LDAP Server Type: [e.g. ActiveDirectory / OpenLDAP / FreeIPA] - LDAP Server Type: [e.g. ActiveDirectory / OpenLDAP / FreeIPA]
- PHP Version: [e.g. 7.3 / 7.4 / 8.0] - PHP Version: [e.g. 7.3 / 7.4 / 8.0]
@@ -0,0 +1,62 @@
name: run-integration-tests
on:
push:
pull_request:
schedule:
- cron: "0 0 * * *"
jobs:
run-tests:
runs-on: ${{ matrix.os }}
services:
ldap:
image: osixia/openldap:1.4.0
env:
LDAP_TLS_VERIFY_CLIENT: try
LDAP_OPENLDAP_UID: 1000
LDAP_OPENLDAP_GID: 1000
LDAP_ORGANISATION: Local
LDAP_DOMAIN: local.com
LDAP_ADMIN_PASSWORD: secret
ports:
- 389:389
- 636:636
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
php: [8.1, 8.0, 7.4]
name: ${{ matrix.os }} - P${{ matrix.php }}
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Cache dependencies
uses: actions/cache@v2
with:
path: ~/.composer/cache/files
key: dependencies-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }}
- name: Set ldap.conf file permissions
run: sudo chown -R $USER:$USER /etc/ldap/ldap.conf
- name: Create ldap.conf file disabling TLS verification
run: sudo echo "TLS_REQCERT never" > "/etc/ldap/ldap.conf"
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: ldap, json
coverage: none
- name: Install dependencies
run: composer update --prefer-dist --no-interaction
- name: Execute tests
run: vendor/bin/phpunit --testsuite Integration
@@ -9,20 +9,20 @@ on:
jobs: jobs:
run-tests: run-tests:
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
name: ${{ matrix.os }} - P${{ matrix.php }}
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
os: [ubuntu-latest, windows-latest] os: [ubuntu-latest, windows-latest]
php: [8.1, 8.0, 7.4, 7.3] php: [8.1, 8.0, 7.4, 7.3]
name: ${{ matrix.os }} - P${{ matrix.php }}
steps: steps:
- name: Checkout code - name: Checkout code
uses: actions/checkout@v4 uses: actions/checkout@v2
- name: Cache dependencies - name: Cache dependencies
uses: actions/cache@v3 uses: actions/cache@v2
with: with:
path: ~/.composer/cache/files path: ~/.composer/cache/files
key: dependencies-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }} key: dependencies-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }}
@@ -38,41 +38,4 @@ jobs:
run: composer update --prefer-dist --no-interaction run: composer update --prefer-dist --no-interaction
- name: Execute tests - name: Execute tests
run: vendor/bin/phpunit run: vendor/bin/phpunit --testsuite Unit
run-analysis:
runs-on: ${{ matrix.os }}
name: Static code analysis (PHP ${{ matrix.php }})
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
php: [8.0]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Cache dependencies
uses: actions/cache@v3
with:
path: ~/.composer/cache/files
key: dependencies-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }}
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: ldap, json
coverage: none
tools: psalm
- name: Validate composer.json
run: composer validate
- name: Install dependencies
run: composer update --prefer-dist --no-interaction
- name: Run Psalm
run: psalm
@@ -1,8 +1 @@
preset: laravel preset: laravel
enabled:
- phpdoc_align
- phpdoc_separation
- unalign_double_arrow
disabled:
- laravel_phpdoc_alignment
- laravel_phpdoc_separation
@@ -32,11 +32,12 @@
"php": ">=7.3", "php": ">=7.3",
"ext-ldap": "*", "ext-ldap": "*",
"ext-json": "*", "ext-json": "*",
"psr/log": "*", "psr/log": "^1.0|^2.0|^3.0",
"psr/simple-cache": "^1.0|^2.0", "psr/simple-cache": "^1.0|^2.0",
"nesbot/carbon": "^1.0|^2.0", "nesbot/carbon": "^1.0|^2.0",
"tightenco/collect": "^5.6|^6.0|^7.0|^8.0", "tightenco/collect": "^5.6|^6.0|^7.0|^8.0|^9.0",
"illuminate/contracts": "^5.0|^6.0|^7.0|^8.0|^9.0" "illuminate/contracts": "^5.0|^6.0|^7.0|^8.0|^9.0|^10.0",
"symfony/polyfill-php80": "^1.25"
}, },
"require-dev": { "require-dev": {
"phpunit/phpunit": "^9.0", "phpunit/phpunit": "^9.0",
@@ -0,0 +1,35 @@
version: '3'
services:
ldap:
image: osixia/openldap:1.4.0
container_name: ldap
restart: always
hostname: local.com
environment:
LDAP_TLS_VERIFY_CLIENT: try
LDAP_OPENLDAP_UID: 1000
LDAP_OPENLDAP_GID: 1000
LDAP_ORGANISATION: Local
LDAP_DOMAIN : local.com
LDAP_ADMIN_PASSWORD: secret
ports:
- "389:389"
- "636:636"
networks:
- local
ldapadmin:
image: osixia/phpldapadmin:0.9.0
container_name: ldapadmin
environment:
PHPLDAPADMIN_LDAP_HOSTS: ldap
restart: always
ports:
- "6443:443"
networks:
- local
networks:
local:
driver: bridge
@@ -10,8 +10,11 @@
stopOnFailure="false" stopOnFailure="false"
> >
<testsuites> <testsuites>
<testsuite name="LdapRecord Test Suite"> <testsuite name="Unit">
<directory suffix="Test.php">./tests/</directory> <directory suffix="Test.php">./tests/Unit</directory>
</testsuite>
<testsuite name="Integration">
<directory suffix="Test.php">./tests/Integration</directory>
</testsuite> </testsuite>
</testsuites> </testsuites>
</phpunit> </phpunit>
@@ -1,15 +0,0 @@
<?xml version="1.0"?>
<psalm
errorLevel="7"
resolveFromConfigFile="true"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
>
<projectFiles>
<directory name="src" />
<ignoreFiles>
<directory name="vendor" />
</ignoreFiles>
</projectFiles>
</psalm>
+2 -2
View File
@@ -6,7 +6,7 @@
<p align="center"> <p align="center">
<a href="https://github.com/DirectoryTree/LdapRecord/actions"> <a href="https://github.com/DirectoryTree/LdapRecord/actions">
<img src="https://img.shields.io/github/workflow/status/directorytree/ldaprecord/run-tests.svg?style=flat-square"> <img src="https://img.shields.io/github/actions/workflow/status/directorytree/ldaprecord/run-tests.yml?branch=master&style=flat-square">
</a> </a>
<a href="https://scrutinizer-ci.com/g/DirectoryTree/LdapRecord/?branch=master"> <a href="https://scrutinizer-ci.com/g/DirectoryTree/LdapRecord/?branch=master">
<img src="https://img.shields.io/scrutinizer/g/DirectoryTree/LdapRecord/master.svg?style=flat-square"/> <img src="https://img.shields.io/scrutinizer/g/DirectoryTree/LdapRecord/master.svg?style=flat-square"/>
@@ -45,7 +45,7 @@
**Up and Running Fast** **Up and Running Fast**
Connect to your LDAP servers and start running queries at lightning speed. Connect to your LDAP servers and start running queries in a matter of minutes.
💡 **Fluent Filter Builder** 💡 **Fluent Filter Builder**
@@ -53,7 +53,6 @@ class Guard
* @param string $username * @param string $username
* @param string $password * @param string $password
* @param bool $stayBound * @param bool $stayBound
*
* @return bool * @return bool
* *
* @throws UsernameRequiredException * @throws UsernameRequiredException
@@ -149,7 +148,6 @@ class Guard
* Set the event dispatcher instance. * Set the event dispatcher instance.
* *
* @param DispatcherInterface $dispatcher * @param DispatcherInterface $dispatcher
*
* @return void * @return void
*/ */
public function setDispatcher(DispatcherInterface $dispatcher) public function setDispatcher(DispatcherInterface $dispatcher)
@@ -162,7 +160,6 @@ class Guard
* *
* @param string $username * @param string $username
* @param string $password * @param string $password
*
* @return void * @return void
*/ */
protected function fireAttemptingEvent($username, $password) protected function fireAttemptingEvent($username, $password)
@@ -177,7 +174,6 @@ class Guard
* *
* @param string $username * @param string $username
* @param string $password * @param string $password
*
* @return void * @return void
*/ */
protected function firePassedEvent($username, $password) protected function firePassedEvent($username, $password)
@@ -192,7 +188,6 @@ class Guard
* *
* @param string $username * @param string $username
* @param string $password * @param string $password
*
* @return void * @return void
*/ */
protected function fireFailedEvent($username, $password) protected function fireFailedEvent($username, $password)
@@ -207,7 +202,6 @@ class Guard
* *
* @param string $username * @param string $username
* @param string $password * @param string $password
*
* @return void * @return void
*/ */
protected function fireBindingEvent($username, $password) protected function fireBindingEvent($username, $password)
@@ -222,7 +216,6 @@ class Guard
* *
* @param string $username * @param string $username
* @param string $password * @param string $password
*
* @return void * @return void
*/ */
protected function fireBoundEvent($username, $password) protected function fireBoundEvent($username, $password)
@@ -76,7 +76,6 @@ class DomainConfiguration
* *
* @param string $option * @param string $option
* @param mixed $default * @param mixed $default
*
* @return void * @return void
*/ */
public static function extend($option, $default = null) public static function extend($option, $default = null)
@@ -123,7 +122,6 @@ class DomainConfiguration
* Returns the value for the specified configuration options. * Returns the value for the specified configuration options.
* *
* @param string $key * @param string $key
*
* @return mixed * @return mixed
* *
* @throws ConfigurationException When the option specified does not exist. * @throws ConfigurationException When the option specified does not exist.
@@ -141,7 +139,6 @@ class DomainConfiguration
* Checks if a configuration option exists. * Checks if a configuration option exists.
* *
* @param string $key * @param string $key
*
* @return bool * @return bool
*/ */
public function has($key) public function has($key)
@@ -154,7 +151,6 @@ class DomainConfiguration
* *
* @param string $key * @param string $key
* @param mixed $value * @param mixed $value
*
* @return bool * @return bool
* *
* @throws ConfigurationException When an option value given is an invalid type. * @throws ConfigurationException When an option value given is an invalid type.
@@ -88,7 +88,7 @@ class Connection
/** /**
* Constructor. * Constructor.
* *
* @param array $config * @param array|DomainConfiguration $config
* @param LdapInterface|null $ldap * @param LdapInterface|null $ldap
*/ */
public function __construct($config = [], LdapInterface $ldap = null) public function __construct($config = [], LdapInterface $ldap = null)
@@ -109,15 +109,18 @@ class Connection
/** /**
* Set the connection configuration. * Set the connection configuration.
* *
* @param array $config * @param array|DomainConfiguration $config
*
* @return $this * @return $this
* *
* @throws Configuration\ConfigurationException * @throws Configuration\ConfigurationException
*/ */
public function setConfiguration($config = []) public function setConfiguration($config = [])
{ {
$this->configuration = new DomainConfiguration($config); if (! $config instanceof DomainConfiguration) {
$config = new DomainConfiguration($config);
}
$this->configuration = $config;
$this->hosts = $this->configuration->get('hosts'); $this->hosts = $this->configuration->get('hosts');
@@ -130,7 +133,6 @@ class Connection
* Set the LDAP connection. * Set the LDAP connection.
* *
* @param LdapInterface $ldap * @param LdapInterface $ldap
*
* @return $this * @return $this
*/ */
public function setLdapConnection(LdapInterface $ldap) public function setLdapConnection(LdapInterface $ldap)
@@ -144,7 +146,6 @@ class Connection
* Set the event dispatcher. * Set the event dispatcher.
* *
* @param DispatcherInterface $dispatcher * @param DispatcherInterface $dispatcher
*
* @return $this * @return $this
*/ */
public function setDispatcher(DispatcherInterface $dispatcher) public function setDispatcher(DispatcherInterface $dispatcher)
@@ -193,7 +194,6 @@ class Connection
* Set the cache store. * Set the cache store.
* *
* @param CacheInterface $store * @param CacheInterface $store
*
* @return $this * @return $this
*/ */
public function setCache(CacheInterface $store) public function setCache(CacheInterface $store)
@@ -240,7 +240,6 @@ class Connection
* *
* @param string|null $username * @param string|null $username
* @param string|null $password * @param string|null $password
*
* @return Connection * @return Connection
* *
* @throws Auth\BindException * @throws Auth\BindException
@@ -298,6 +297,16 @@ class Connection
$this->initialize(); $this->initialize();
} }
/**
* Clone the connection.
*
* @return static
*/
public function replicate()
{
return new static($this->configuration, new $this->ldap);
}
/** /**
* Disconnect from the LDAP server. * Disconnect from the LDAP server.
* *
@@ -312,7 +321,6 @@ class Connection
* Dispatch an event. * Dispatch an event.
* *
* @param object $event * @param object $event
*
* @return void * @return void
*/ */
public function dispatch($event) public function dispatch($event)
@@ -336,7 +344,6 @@ class Connection
* Perform the operation on the LDAP connection. * Perform the operation on the LDAP connection.
* *
* @param Closure $operation * @param Closure $operation
*
* @return mixed * @return mixed
*/ */
public function run(Closure $operation) public function run(Closure $operation)
@@ -359,11 +366,27 @@ class Connection
} }
} }
/**
* Perform the operation on an isolated LDAP connection.
*
* @param Closure $operation
* @return mixed
*/
public function isolate(Closure $operation)
{
$connection = $this->replicate();
try {
return $operation($connection);
} finally {
$connection->disconnect();
}
}
/** /**
* Attempt to get an exception for the cause of failure. * Attempt to get an exception for the cause of failure.
* *
* @param LdapRecordException $e * @param LdapRecordException $e
*
* @return mixed * @return mixed
*/ */
protected function getExceptionForCauseOfFailure(LdapRecordException $e) protected function getExceptionForCauseOfFailure(LdapRecordException $e)
@@ -384,7 +407,6 @@ class Connection
* Run the operation callback on the current LDAP connection. * Run the operation callback on the current LDAP connection.
* *
* @param Closure $operation * @param Closure $operation
*
* @return mixed * @return mixed
* *
* @throws LdapRecordException * @throws LdapRecordException
@@ -441,7 +463,6 @@ class Connection
* *
* @param LdapRecordException $e * @param LdapRecordException $e
* @param Closure $operation * @param Closure $operation
*
* @return mixed * @return mixed
* *
* @throws LdapRecordException * @throws LdapRecordException
@@ -462,7 +483,6 @@ class Connection
* Retry the operation on the current host. * Retry the operation on the current host.
* *
* @param Closure $operation * @param Closure $operation
*
* @return mixed * @return mixed
* *
* @throws LdapRecordException * @throws LdapRecordException
@@ -485,7 +505,6 @@ class Connection
* *
* @param LdapRecordException $e * @param LdapRecordException $e
* @param Closure $operation * @param Closure $operation
*
* @return mixed * @return mixed
* *
* @throws LdapRecordException * @throws LdapRecordException
@@ -83,7 +83,6 @@ class ConnectionManager
* *
* @param string $method * @param string $method
* @param mixed $args * @param mixed $args
*
* @return mixed * @return mixed
*/ */
public function __call($method, $args) public function __call($method, $args)
@@ -106,7 +105,6 @@ class ConnectionManager
* *
* @param Connection $connection * @param Connection $connection
* @param string|null $name * @param string|null $name
*
* @return $this * @return $this
*/ */
public function add(Connection $connection, $name = null) public function add(Connection $connection, $name = null)
@@ -124,7 +122,6 @@ class ConnectionManager
* Remove a connection. * Remove a connection.
* *
* @param $name * @param $name
*
* @return $this * @return $this
*/ */
public function remove($name) public function remove($name)
@@ -148,7 +145,6 @@ class ConnectionManager
* Get a connection by name or return the default. * Get a connection by name or return the default.
* *
* @param string|null $name * @param string|null $name
*
* @return Connection * @return Connection
* *
* @throws ContainerException If the given connection does not exist. * @throws ContainerException If the given connection does not exist.
@@ -186,7 +182,6 @@ class ConnectionManager
* Checks if the connection exists. * Checks if the connection exists.
* *
* @param string $name * @param string $name
*
* @return bool * @return bool
*/ */
public function exists($name) public function exists($name)
@@ -198,7 +193,6 @@ class ConnectionManager
* Set the default connection name. * Set the default connection name.
* *
* @param string $name * @param string $name
*
* @return $this * @return $this
*/ */
public function setDefault($name = null) public function setDefault($name = null)
@@ -238,7 +232,6 @@ class ConnectionManager
* Set the event logger to use. * Set the event logger to use.
* *
* @param LoggerInterface $logger * @param LoggerInterface $logger
*
* @return void * @return void
*/ */
public function setLogger(LoggerInterface $logger) public function setLogger(LoggerInterface $logger)
@@ -300,7 +293,6 @@ class ConnectionManager
* Set the event dispatcher. * Set the event dispatcher.
* *
* @param DispatcherInterface $dispatcher * @param DispatcherInterface $dispatcher
*
* @return void * @return void
*/ */
public function setDispatcher(DispatcherInterface $dispatcher) public function setDispatcher(DispatcherInterface $dispatcher)
@@ -50,7 +50,6 @@ class Container
* *
* @param string $method * @param string $method
* @param mixed $args * @param mixed $args
*
* @return mixed * @return mixed
*/ */
public static function __callStatic($method, $args) public static function __callStatic($method, $args)
@@ -72,7 +71,6 @@ class Container
* Set the container instance. * Set the container instance.
* *
* @param Container|null $container * @param Container|null $container
*
* @return Container|null * @return Container|null
*/ */
public static function setInstance(self $container = null) public static function setInstance(self $container = null)
@@ -105,7 +103,6 @@ class Container
* *
* @param string $method * @param string $method
* @param mixed $args * @param mixed $args
*
* @return mixed * @return mixed
*/ */
public function __call($method, $args) public function __call($method, $args)
@@ -8,7 +8,6 @@ trait DetectsErrors
* Determine if the error was caused by a lost connection. * Determine if the error was caused by a lost connection.
* *
* @param string $error * @param string $error
*
* @return bool * @return bool
*/ */
protected function causedByLostConnection($error) protected function causedByLostConnection($error)
@@ -20,7 +19,6 @@ trait DetectsErrors
* Determine if the error was caused by lack of pagination support. * Determine if the error was caused by lack of pagination support.
* *
* @param string $error * @param string $error
*
* @return bool * @return bool
*/ */
protected function causedByPaginationSupport($error) protected function causedByPaginationSupport($error)
@@ -32,7 +30,6 @@ trait DetectsErrors
* Determine if the error was caused by a size limit warning. * Determine if the error was caused by a size limit warning.
* *
* @param $error * @param $error
*
* @return bool * @return bool
*/ */
protected function causedBySizeLimit($error) protected function causedBySizeLimit($error)
@@ -44,7 +41,6 @@ trait DetectsErrors
* Determine if the error was caused by a "No such object" warning. * Determine if the error was caused by a "No such object" warning.
* *
* @param string $error * @param string $error
*
* @return bool * @return bool
*/ */
protected function causedByNoSuchObject($error) protected function causedByNoSuchObject($error)
@@ -57,13 +53,12 @@ trait DetectsErrors
* *
* @param string $error * @param string $error
* @param string|array $messages * @param string|array $messages
*
* @return bool * @return bool
*/ */
protected function errorContainsMessage($error, $messages = []) protected function errorContainsMessage($error, $messages = [])
{ {
foreach ((array) $messages as $message) { foreach ((array) $messages as $message) {
if (strpos($error, $message) !== false) { if (str_contains((string) $error, $message)) {
return true; return true;
} }
} }
@@ -12,7 +12,6 @@ trait EscapesValues
* @param string $value * @param string $value
* @param string $ignore * @param string $ignore
* @param int $flags * @param int $flags
*
* @return EscapedValue * @return EscapedValue
*/ */
public function escape($value, $ignore = '', $flags = 0) public function escape($value, $ignore = '', $flags = 0)
@@ -46,7 +46,7 @@ class Dispatcher implements DispatcherInterface
public function listen($events, $listener) public function listen($events, $listener)
{ {
foreach ((array) $events as $event) { foreach ((array) $events as $event) {
if (strpos($event, '*') !== false) { if (str_contains((string) $event, '*')) {
$this->setupWildcardListen($event, $listener); $this->setupWildcardListen($event, $listener);
} else { } else {
$this->listeners[$event][] = $this->makeListener($listener); $this->listeners[$event][] = $this->makeListener($listener);
@@ -59,7 +59,6 @@ class Dispatcher implements DispatcherInterface
* *
* @param string $event * @param string $event
* @param mixed $listener * @param mixed $listener
*
* @return void * @return void
*/ */
protected function setupWildcardListen($event, $listener) protected function setupWildcardListen($event, $listener)
@@ -136,7 +135,6 @@ class Dispatcher implements DispatcherInterface
* *
* @param mixed $event * @param mixed $event
* @param mixed $payload * @param mixed $payload
*
* @return array * @return array
*/ */
protected function parseEventAndPayload($event, $payload) protected function parseEventAndPayload($event, $payload)
@@ -169,7 +167,6 @@ class Dispatcher implements DispatcherInterface
* Get the wildcard listeners for the event. * Get the wildcard listeners for the event.
* *
* @param string $eventName * @param string $eventName
*
* @return array * @return array
*/ */
protected function getWildcardListeners($eventName) protected function getWildcardListeners($eventName)
@@ -192,7 +189,6 @@ class Dispatcher implements DispatcherInterface
* *
* @param string $wildcard * @param string $wildcard
* @param string $eventName * @param string $eventName
*
* @return bool * @return bool
*/ */
protected function wildcardContainsEvent($wildcard, $eventName) protected function wildcardContainsEvent($wildcard, $eventName)
@@ -231,7 +227,6 @@ class Dispatcher implements DispatcherInterface
* *
* @param string $eventName * @param string $eventName
* @param array $listeners * @param array $listeners
*
* @return array * @return array
*/ */
protected function addInterfaceListeners($eventName, array $listeners = []) protected function addInterfaceListeners($eventName, array $listeners = [])
@@ -252,7 +247,6 @@ class Dispatcher implements DispatcherInterface
* *
* @param \Closure|string $listener * @param \Closure|string $listener
* @param bool $wildcard * @param bool $wildcard
*
* @return \Closure * @return \Closure
*/ */
public function makeListener($listener, $wildcard = false) public function makeListener($listener, $wildcard = false)
@@ -275,7 +269,6 @@ class Dispatcher implements DispatcherInterface
* *
* @param string $listener * @param string $listener
* @param bool $wildcard * @param bool $wildcard
*
* @return \Closure * @return \Closure
*/ */
protected function createClassListener($listener, $wildcard = false) protected function createClassListener($listener, $wildcard = false)
@@ -296,7 +289,6 @@ class Dispatcher implements DispatcherInterface
* Create the class based event callable. * Create the class based event callable.
* *
* @param string $listener * @param string $listener
*
* @return callable * @return callable
*/ */
protected function createClassCallable($listener) protected function createClassCallable($listener)
@@ -310,12 +302,11 @@ class Dispatcher implements DispatcherInterface
* Parse the class listener into class and method. * Parse the class listener into class and method.
* *
* @param string $listener * @param string $listener
*
* @return array * @return array
*/ */
protected function parseListenerCallback($listener) protected function parseListenerCallback($listener)
{ {
return strpos($listener, '@') !== false return str_contains((string) $listener, '@')
? explode('@', $listener, 2) ? explode('@', $listener, 2)
: [$listener, 'handle']; : [$listener, 'handle'];
} }
@@ -325,7 +316,7 @@ class Dispatcher implements DispatcherInterface
*/ */
public function forget($event) public function forget($event)
{ {
if (strpos($event, '*') !== false) { if (str_contains((string) $event, '*')) {
unset($this->wildcards[$event]); unset($this->wildcards[$event]);
} else { } else {
unset($this->listeners[$event]); unset($this->listeners[$event]);
@@ -9,7 +9,6 @@ interface DispatcherInterface
* *
* @param string|array $events * @param string|array $events
* @param mixed $listener * @param mixed $listener
*
* @return void * @return void
*/ */
public function listen($events, $listener); public function listen($events, $listener);
@@ -18,7 +17,6 @@ interface DispatcherInterface
* Determine if a given event has listeners. * Determine if a given event has listeners.
* *
* @param string $eventName * @param string $eventName
*
* @return bool * @return bool
*/ */
public function hasListeners($eventName); public function hasListeners($eventName);
@@ -28,7 +26,6 @@ interface DispatcherInterface
* *
* @param string|object $event * @param string|object $event
* @param mixed $payload * @param mixed $payload
*
* @return array|null * @return array|null
*/ */
public function until($event, $payload = []); public function until($event, $payload = []);
@@ -39,7 +36,6 @@ interface DispatcherInterface
* @param string|object $event * @param string|object $event
* @param mixed $payload * @param mixed $payload
* @param bool $halt * @param bool $halt
*
* @return mixed * @return mixed
*/ */
public function fire($event, $payload = [], $halt = false); public function fire($event, $payload = [], $halt = false);
@@ -50,7 +46,6 @@ interface DispatcherInterface
* @param string|object $event * @param string|object $event
* @param mixed $payload * @param mixed $payload
* @param bool $halt * @param bool $halt
*
* @return array|null * @return array|null
*/ */
public function dispatch($event, $payload = [], $halt = false); public function dispatch($event, $payload = [], $halt = false);
@@ -59,7 +54,6 @@ interface DispatcherInterface
* Get all of the listeners for a given event name. * Get all of the listeners for a given event name.
* *
* @param string $eventName * @param string $eventName
*
* @return array * @return array
*/ */
public function getListeners($eventName); public function getListeners($eventName);
@@ -68,7 +62,6 @@ interface DispatcherInterface
* Remove a set of listeners from the dispatcher. * Remove a set of listeners from the dispatcher.
* *
* @param string $event * @param string $event
*
* @return void * @return void
*/ */
public function forget($event); public function forget($event);
@@ -32,7 +32,6 @@ class Logger
* Logs the given event. * Logs the given event.
* *
* @param mixed $event * @param mixed $event
*
* @return void * @return void
*/ */
public function log($event) public function log($event)
@@ -54,7 +53,6 @@ class Logger
* Logs an authentication event. * Logs an authentication event.
* *
* @param AuthEvent $event * @param AuthEvent $event
*
* @return void * @return void
*/ */
public function auth(AuthEvent $event) public function auth(AuthEvent $event)
@@ -82,7 +80,6 @@ class Logger
* Logs a model event. * Logs a model event.
* *
* @param ModelEvent $event * @param ModelEvent $event
*
* @return void * @return void
*/ */
public function model(ModelEvent $event) public function model(ModelEvent $event)
@@ -107,7 +104,6 @@ class Logger
* Logs a query event. * Logs a query event.
* *
* @param QueryEvent $event * @param QueryEvent $event
*
* @return void * @return void
*/ */
public function query(QueryEvent $event) public function query(QueryEvent $event)
@@ -134,7 +130,6 @@ class Logger
* Returns the operational name of the given event. * Returns the operational name of the given event.
* *
* @param mixed $event * @param mixed $event
*
* @return string * @return string
*/ */
protected function getOperationName($event) protected function getOperationName($event)
@@ -26,7 +26,6 @@ class NullDispatcher implements DispatcherInterface
* *
* @param string|array $events * @param string|array $events
* @param mixed $listener * @param mixed $listener
*
* @return void * @return void
*/ */
public function listen($events, $listener) public function listen($events, $listener)
@@ -38,7 +37,6 @@ class NullDispatcher implements DispatcherInterface
* Determine if a given event has listeners. * Determine if a given event has listeners.
* *
* @param string $eventName * @param string $eventName
*
* @return bool * @return bool
*/ */
public function hasListeners($eventName) public function hasListeners($eventName)
@@ -51,7 +49,6 @@ class NullDispatcher implements DispatcherInterface
* *
* @param string|object $event * @param string|object $event
* @param mixed $payload * @param mixed $payload
*
* @return null * @return null
*/ */
public function until($event, $payload = []) public function until($event, $payload = [])
@@ -65,7 +62,6 @@ class NullDispatcher implements DispatcherInterface
* @param string|object $event * @param string|object $event
* @param mixed $payload * @param mixed $payload
* @param bool $halt * @param bool $halt
*
* @return null * @return null
*/ */
public function fire($event, $payload = [], $halt = false) public function fire($event, $payload = [], $halt = false)
@@ -79,7 +75,6 @@ class NullDispatcher implements DispatcherInterface
* @param string|object $event * @param string|object $event
* @param mixed $payload * @param mixed $payload
* @param bool $halt * @param bool $halt
*
* @return null * @return null
*/ */
public function dispatch($event, $payload = [], $halt = false) public function dispatch($event, $payload = [], $halt = false)
@@ -91,7 +86,6 @@ class NullDispatcher implements DispatcherInterface
* Get all of the listeners for a given event name. * Get all of the listeners for a given event name.
* *
* @param string $eventName * @param string $eventName
*
* @return array * @return array
*/ */
public function getListeners($eventName) public function getListeners($eventName)
@@ -103,7 +97,6 @@ class NullDispatcher implements DispatcherInterface
* Remove a set of listeners from the dispatcher. * Remove a set of listeners from the dispatcher.
* *
* @param string $event * @param string $event
*
* @return void * @return void
*/ */
public function forget($event) public function forget($event)
@@ -149,7 +149,6 @@ trait HandlesConnection
* Convert warnings to exceptions for the given operation. * Convert warnings to exceptions for the given operation.
* *
* @param Closure $operation * @param Closure $operation
*
* @return mixed * @return mixed
* *
* @throws LdapRecordException * @throws LdapRecordException
@@ -191,7 +190,6 @@ trait HandlesConnection
* Determine if the failed operation should be bypassed. * Determine if the failed operation should be bypassed.
* *
* @param string $method * @param string $method
*
* @return bool * @return bool
*/ */
protected function shouldBypassFailure($method) protected function shouldBypassFailure($method)
@@ -203,7 +201,6 @@ trait HandlesConnection
* Determine if the error should be bypassed. * Determine if the error should be bypassed.
* *
* @param string $error * @param string $error
*
* @return bool * @return bool
*/ */
protected function shouldBypassError($error) protected function shouldBypassError($error)
@@ -228,7 +225,6 @@ trait HandlesConnection
* *
* @param string|array $hosts * @param string|array $hosts
* @param string $port * @param string $port
*
* @return string * @return string
*/ */
protected function makeConnectionUris($hosts, $port) protected function makeConnectionUris($hosts, $port)
@@ -251,7 +247,6 @@ trait HandlesConnection
* *
* @param array|string $hosts * @param array|string $hosts
* @param string $port * @param string $port
*
* @return array * @return array
*/ */
protected function assembleHostUris($hosts, $port) protected function assembleHostUris($hosts, $port)
@@ -4,7 +4,6 @@ namespace LdapRecord;
use LDAP\Connection as RawLdapConnection; use LDAP\Connection as RawLdapConnection;
/** @psalm-suppress UndefinedClass */
class Ldap implements LdapInterface class Ldap implements LdapInterface
{ {
use HandlesConnection, DetectsErrors; use HandlesConnection, DetectsErrors;
@@ -25,7 +24,6 @@ class Ldap implements LdapInterface
* @see http://php.net/manual/en/function.ldap-first-entry.php * @see http://php.net/manual/en/function.ldap-first-entry.php
* *
* @param resource $searchResults * @param resource $searchResults
*
* @return resource * @return resource
*/ */
public function getFirstEntry($searchResults) public function getFirstEntry($searchResults)
@@ -41,7 +39,6 @@ class Ldap implements LdapInterface
* @see http://php.net/manual/en/function.ldap-next-entry.php * @see http://php.net/manual/en/function.ldap-next-entry.php
* *
* @param resource $entry * @param resource $entry
*
* @return resource * @return resource
*/ */
public function getNextEntry($entry) public function getNextEntry($entry)
@@ -57,7 +54,6 @@ class Ldap implements LdapInterface
* @see http://php.net/manual/en/function.ldap-get-attributes.php * @see http://php.net/manual/en/function.ldap-get-attributes.php
* *
* @param resource $entry * @param resource $entry
*
* @return array|false * @return array|false
*/ */
public function getAttributes($entry) public function getAttributes($entry)
@@ -73,7 +69,6 @@ class Ldap implements LdapInterface
* @see http://php.net/manual/en/function.ldap-count-entries.php * @see http://php.net/manual/en/function.ldap-count-entries.php
* *
* @param resource $searchResults * @param resource $searchResults
*
* @return int * @return int
*/ */
public function countEntries($searchResults) public function countEntries($searchResults)
@@ -91,7 +86,6 @@ class Ldap implements LdapInterface
* @param string $dn * @param string $dn
* @param string $attribute * @param string $attribute
* @param string $value * @param string $value
*
* @return mixed * @return mixed
*/ */
public function compare($dn, $attribute, $value) public function compare($dn, $attribute, $value)
@@ -134,7 +128,6 @@ class Ldap implements LdapInterface
* *
* @param $entry * @param $entry
* @param $attribute * @param $attribute
*
* @return array * @return array
*/ */
public function getValuesLen($entry, $attribute) public function getValuesLen($entry, $attribute)
@@ -168,7 +161,6 @@ class Ldap implements LdapInterface
* @see http://php.net/manual/en/function.ldap-set-rebind-proc.php * @see http://php.net/manual/en/function.ldap-set-rebind-proc.php
* *
* @param callable $callback * @param callable $callback
*
* @return bool * @return bool
*/ */
public function setRebindCallback(callable $callback) public function setRebindCallback(callable $callback)
@@ -304,7 +296,7 @@ class Ldap implements LdapInterface
public function bind($username, $password) public function bind($username, $password)
{ {
return $this->bound = $this->executeFailableOperation(function () use ($username, $password) { return $this->bound = $this->executeFailableOperation(function () use ($username, $password) {
return ldap_bind($this->connection, $username, html_entity_decode($password)); return ldap_bind($this->connection, $username, $password ? html_entity_decode($password) : null);
}); });
} }
@@ -463,7 +455,6 @@ class Ldap implements LdapInterface
* Extract the diagnostic code from the message. * Extract the diagnostic code from the message.
* *
* @param string $message * @param string $message
*
* @return string|bool * @return string|bool
*/ */
public function extractDiagnosticCode($message) public function extractDiagnosticCode($message)
@@ -9,28 +9,28 @@ interface LdapInterface
* *
* @var string * @var string
*/ */
const PROTOCOL_SSL = 'ldaps://'; public const PROTOCOL_SSL = 'ldaps://';
/** /**
* The standard LDAP protocol string. * The standard LDAP protocol string.
* *
* @var string * @var string
*/ */
const PROTOCOL = 'ldap://'; public const PROTOCOL = 'ldap://';
/** /**
* The LDAP SSL port number. * The LDAP SSL port number.
* *
* @var string * @var string
*/ */
const PORT_SSL = 636; public const PORT_SSL = 636;
/** /**
* The standard LDAP port number. * The standard LDAP port number.
* *
* @var string * @var string
*/ */
const PORT = 389; public const PORT = 389;
/** /**
* Various useful server control OID's. * Various useful server control OID's.
@@ -38,37 +38,36 @@ interface LdapInterface
* @see https://ldap.com/ldap-oid-reference-guide/ * @see https://ldap.com/ldap-oid-reference-guide/
* @see http://msdn.microsoft.com/en-us/library/cc223359.aspx * @see http://msdn.microsoft.com/en-us/library/cc223359.aspx
*/ */
const OID_SERVER_START_TLS = '1.3.6.1.4.1.1466.20037'; public const OID_SERVER_START_TLS = '1.3.6.1.4.1.1466.20037';
const OID_SERVER_PAGED_RESULTS = '1.2.840.113556.1.4.319'; public const OID_SERVER_PAGED_RESULTS = '1.2.840.113556.1.4.319';
const OID_SERVER_SHOW_DELETED = '1.2.840.113556.1.4.417'; public const OID_SERVER_SHOW_DELETED = '1.2.840.113556.1.4.417';
const OID_SERVER_SORT = '1.2.840.113556.1.4.473'; public const OID_SERVER_SORT = '1.2.840.113556.1.4.473';
const OID_SERVER_CROSSDOM_MOVE_TARGET = '1.2.840.113556.1.4.521'; public const OID_SERVER_CROSSDOM_MOVE_TARGET = '1.2.840.113556.1.4.521';
const OID_SERVER_NOTIFICATION = '1.2.840.113556.1.4.528'; public const OID_SERVER_NOTIFICATION = '1.2.840.113556.1.4.528';
const OID_SERVER_EXTENDED_DN = '1.2.840.113556.1.4.529'; public const OID_SERVER_EXTENDED_DN = '1.2.840.113556.1.4.529';
const OID_SERVER_LAZY_COMMIT = '1.2.840.113556.1.4.619'; public const OID_SERVER_LAZY_COMMIT = '1.2.840.113556.1.4.619';
const OID_SERVER_SD_FLAGS = '1.2.840.113556.1.4.801'; public const OID_SERVER_SD_FLAGS = '1.2.840.113556.1.4.801';
const OID_SERVER_TREE_DELETE = '1.2.840.113556.1.4.805'; public const OID_SERVER_TREE_DELETE = '1.2.840.113556.1.4.805';
const OID_SERVER_DIRSYNC = '1.2.840.113556.1.4.841'; public const OID_SERVER_DIRSYNC = '1.2.840.113556.1.4.841';
const OID_SERVER_VERIFY_NAME = '1.2.840.113556.1.4.1338'; public const OID_SERVER_VERIFY_NAME = '1.2.840.113556.1.4.1338';
const OID_SERVER_DOMAIN_SCOPE = '1.2.840.113556.1.4.1339'; public const OID_SERVER_DOMAIN_SCOPE = '1.2.840.113556.1.4.1339';
const OID_SERVER_SEARCH_OPTIONS = '1.2.840.113556.1.4.1340'; public const OID_SERVER_SEARCH_OPTIONS = '1.2.840.113556.1.4.1340';
const OID_SERVER_PERMISSIVE_MODIFY = '1.2.840.113556.1.4.1413'; public const OID_SERVER_PERMISSIVE_MODIFY = '1.2.840.113556.1.4.1413';
const OID_SERVER_ASQ = '1.2.840.113556.1.4.1504'; public const OID_SERVER_ASQ = '1.2.840.113556.1.4.1504';
const OID_SERVER_FAST_BIND = '1.2.840.113556.1.4.1781'; public const OID_SERVER_FAST_BIND = '1.2.840.113556.1.4.1781';
const OID_SERVER_CONTROL_VLVREQUEST = '2.16.840.1.113730.3.4.9'; public const OID_SERVER_CONTROL_VLVREQUEST = '2.16.840.1.113730.3.4.9';
/** /**
* Query OID's. * Query OID's.
* *
* @see https://ldapwiki.com/wiki/LDAP_MATCHING_RULE_IN_CHAIN * @see https://ldapwiki.com/wiki/LDAP_MATCHING_RULE_IN_CHAIN
*/ */
const OID_MATCHING_RULE_IN_CHAIN = '1.2.840.113556.1.4.1941'; public const OID_MATCHING_RULE_IN_CHAIN = '1.2.840.113556.1.4.1941';
/** /**
* Set the current connection to use SSL. * Set the current connection to use SSL.
* *
* @param bool $enabled * @param bool $enabled
*
* @return $this * @return $this
*/ */
public function ssl(); public function ssl();
@@ -84,7 +83,6 @@ interface LdapInterface
* Set the current connection to use TLS. * Set the current connection to use TLS.
* *
* @param bool $enabled * @param bool $enabled
*
* @return $this * @return $this
*/ */
public function tls(); public function tls();
@@ -139,7 +137,6 @@ interface LdapInterface
* @see http://php.net/manual/en/function.ldap-get-entries.php * @see http://php.net/manual/en/function.ldap-get-entries.php
* *
* @param resource $searchResults * @param resource $searchResults
*
* @return array * @return array
*/ */
public function getEntries($searchResults); public function getEntries($searchResults);
@@ -171,7 +168,6 @@ interface LdapInterface
* *
* @param int $option * @param int $option
* @param mixed $value * @param mixed $value
*
* @return bool * @return bool
*/ */
public function setOption($option, $value); public function setOption($option, $value);
@@ -180,7 +176,6 @@ interface LdapInterface
* Set options on the current connection. * Set options on the current connection.
* *
* @param array $options * @param array $options
*
* @return void * @return void
*/ */
public function setOptions(array $options = []); public function setOptions(array $options = []);
@@ -192,7 +187,6 @@ interface LdapInterface
* *
* @param int $option * @param int $option
* @param mixed $value * @param mixed $value
*
* @return mixed * @return mixed
*/ */
public function getOption($option, &$value = null); public function getOption($option, &$value = null);
@@ -215,7 +209,6 @@ interface LdapInterface
* *
* @param string|array $hosts * @param string|array $hosts
* @param int $port * @param int $port
*
* @return resource|false * @return resource|false
*/ */
public function connect($hosts = [], $port = 389); public function connect($hosts = [], $port = 389);
@@ -244,7 +237,6 @@ interface LdapInterface
* @param int $time * @param int $time
* @param int $deref * @param int $deref
* @param array $serverControls * @param array $serverControls
*
* @return resource * @return resource
*/ */
public function search($dn, $filter, array $fields, $onlyAttributes = false, $size = 0, $time = 0, $deref = LDAP_DEREF_NEVER, $serverControls = []); public function search($dn, $filter, array $fields, $onlyAttributes = false, $size = 0, $time = 0, $deref = LDAP_DEREF_NEVER, $serverControls = []);
@@ -262,7 +254,6 @@ interface LdapInterface
* @param int $time * @param int $time
* @param int $deref * @param int $deref
* @param array $serverControls * @param array $serverControls
*
* @return resource * @return resource
*/ */
public function listing($dn, $filter, array $fields, $onlyAttributes = false, $size = 0, $time = 0, $deref = LDAP_DEREF_NEVER, $serverControls = []); public function listing($dn, $filter, array $fields, $onlyAttributes = false, $size = 0, $time = 0, $deref = LDAP_DEREF_NEVER, $serverControls = []);
@@ -280,7 +271,6 @@ interface LdapInterface
* @param int $time * @param int $time
* @param int $deref * @param int $deref
* @param array $serverControls * @param array $serverControls
*
* @return resource * @return resource
*/ */
public function read($dn, $filter, array $fields, $onlyAttributes = false, $size = 0, $time = 0, $deref = LDAP_DEREF_NEVER, $serverControls = []); public function read($dn, $filter, array $fields, $onlyAttributes = false, $size = 0, $time = 0, $deref = LDAP_DEREF_NEVER, $serverControls = []);
@@ -296,7 +286,6 @@ interface LdapInterface
* @param ?string $errorMessage * @param ?string $errorMessage
* @param ?array $referrals * @param ?array $referrals
* @param ?array $serverControls * @param ?array $serverControls
*
* @return bool * @return bool
*/ */
public function parseResult($result, &$errorCode, &$dn, &$errorMessage, &$referrals, &$serverControls = []); public function parseResult($result, &$errorCode, &$dn, &$errorMessage, &$referrals, &$serverControls = []);
@@ -309,7 +298,6 @@ interface LdapInterface
* *
* @param string $username * @param string $username
* @param string $password * @param string $password
*
* @return bool * @return bool
* *
* @throws LdapRecordException * @throws LdapRecordException
@@ -323,7 +311,6 @@ interface LdapInterface
* *
* @param string $dn * @param string $dn
* @param array $entry * @param array $entry
*
* @return bool * @return bool
* *
* @throws LdapRecordException * @throws LdapRecordException
@@ -336,7 +323,6 @@ interface LdapInterface
* @see http://php.net/manual/en/function.ldap-delete.php * @see http://php.net/manual/en/function.ldap-delete.php
* *
* @param string $dn * @param string $dn
*
* @return bool * @return bool
* *
* @throws LdapRecordException * @throws LdapRecordException
@@ -352,7 +338,6 @@ interface LdapInterface
* @param string $newRdn * @param string $newRdn
* @param string $newParent * @param string $newParent
* @param bool $deleteOldRdn * @param bool $deleteOldRdn
*
* @return bool * @return bool
* *
* @throws LdapRecordException * @throws LdapRecordException
@@ -366,7 +351,6 @@ interface LdapInterface
* *
* @param string $dn * @param string $dn
* @param array $entry * @param array $entry
*
* @return bool * @return bool
* *
* @throws LdapRecordException * @throws LdapRecordException
@@ -380,7 +364,6 @@ interface LdapInterface
* *
* @param string $dn * @param string $dn
* @param array $values * @param array $values
*
* @return bool * @return bool
* *
* @throws LdapRecordException * @throws LdapRecordException
@@ -394,7 +377,6 @@ interface LdapInterface
* *
* @param string $dn * @param string $dn
* @param array $entry * @param array $entry
*
* @return bool * @return bool
* *
* @throws LdapRecordException * @throws LdapRecordException
@@ -408,7 +390,6 @@ interface LdapInterface
* *
* @param string $dn * @param string $dn
* @param array $entry * @param array $entry
*
* @return bool * @return bool
* *
* @throws LdapRecordException * @throws LdapRecordException
@@ -422,7 +403,6 @@ interface LdapInterface
* *
* @param string $dn * @param string $dn
* @param array $entry * @param array $entry
*
* @return bool * @return bool
* *
* @throws LdapRecordException * @throws LdapRecordException
@@ -437,7 +417,6 @@ interface LdapInterface
* @param int $pageSize * @param int $pageSize
* @param bool $isCritical * @param bool $isCritical
* @param string $cookie * @param string $cookie
*
* @return bool * @return bool
*/ */
public function controlPagedResult($pageSize = 1000, $isCritical = false, $cookie = ''); public function controlPagedResult($pageSize = 1000, $isCritical = false, $cookie = '');
@@ -449,7 +428,6 @@ interface LdapInterface
* *
* @param resource $result * @param resource $result
* @param string $cookie * @param string $cookie
*
* @return bool * @return bool
*/ */
public function controlPagedResultResponse($result, &$cookie); public function controlPagedResultResponse($result, &$cookie);
@@ -460,7 +438,6 @@ interface LdapInterface
* @see https://www.php.net/manual/en/function.ldap-free-result.php * @see https://www.php.net/manual/en/function.ldap-free-result.php
* *
* @param resource $result * @param resource $result
*
* @return bool * @return bool
*/ */
public function freeResult($result); public function freeResult($result);
@@ -480,7 +457,6 @@ interface LdapInterface
* @see http://php.net/manual/en/function.ldap-err2str.php * @see http://php.net/manual/en/function.ldap-err2str.php
* *
* @param int $number * @param int $number
*
* @return string * @return string
*/ */
public function err2Str($number); public function err2Str($number);
@@ -18,7 +18,6 @@ class LdapRecordException extends Exception
* *
* @param Exception $e * @param Exception $e
* @param DetailedError|null $error * @param DetailedError|null $error
*
* @return $this * @return $this
*/ */
public static function withDetailedError(Exception $e, DetailedError $error = null) public static function withDetailedError(Exception $e, DetailedError $error = null)
@@ -30,7 +29,6 @@ class LdapRecordException extends Exception
* Set the detailed error. * Set the detailed error.
* *
* @param DetailedError|null $error * @param DetailedError|null $error
*
* @return $this * @return $this
*/ */
public function setDetailedError(DetailedError $error = null) public function setDetailedError(DetailedError $error = null)
@@ -12,7 +12,6 @@ trait HasPrimaryGroup
* @param mixed $related * @param mixed $related
* @param string $relationKey * @param string $relationKey
* @param string $foreignKey * @param string $foreignKey
*
* @return HasOnePrimaryGroup * @return HasOnePrimaryGroup
*/ */
public function hasOnePrimaryGroup($related, $relationKey, $foreignKey = 'primarygroupid') public function hasOnePrimaryGroup($related, $relationKey, $foreignKey = 'primarygroupid')
@@ -9,6 +9,7 @@ use LdapRecord\Models\Entry as BaseEntry;
use LdapRecord\Models\Events\Updated; use LdapRecord\Models\Events\Updated;
use LdapRecord\Models\Types\ActiveDirectory; use LdapRecord\Models\Types\ActiveDirectory;
use LdapRecord\Query\Model\ActiveDirectoryBuilder; use LdapRecord\Query\Model\ActiveDirectoryBuilder;
use LdapRecord\Support\Arr;
/** @mixin ActiveDirectoryBuilder */ /** @mixin ActiveDirectoryBuilder */
class Entry extends BaseEntry implements ActiveDirectory class Entry extends BaseEntry implements ActiveDirectory
@@ -50,20 +51,46 @@ class Entry extends BaseEntry implements ActiveDirectory
/** /**
* @inheritdoc * @inheritdoc
*/ */
public function getConvertedSid() public function getConvertedSid($sid = null)
{ {
try { try {
return (string) new Sid($this->getObjectSid()); return (string) $this->newObjectSid(
$sid ?? $this->getObjectSid()
);
} catch (InvalidArgumentException $e) { } catch (InvalidArgumentException $e) {
return; return;
} }
} }
/**
* @inheritdoc
*/
public function getBinarySid($sid = null)
{
try {
return $this->newObjectSid(
$sid ?? $this->getObjectSid()
)->getBinary();
} catch (InvalidArgumentException $e) {
return;
}
}
/**
* Make a new object Sid instance.
*
* @param string $value
* @return Sid
*/
protected function newObjectSid($value)
{
return new Sid($value);
}
/** /**
* Create a new query builder. * Create a new query builder.
* *
* @param Connection $connection * @param Connection $connection
*
* @return ActiveDirectoryBuilder * @return ActiveDirectoryBuilder
*/ */
public function newQueryBuilder(Connection $connection) public function newQueryBuilder(Connection $connection)
@@ -85,7 +112,6 @@ class Entry extends BaseEntry implements ActiveDirectory
* Restore a deleted object. * Restore a deleted object.
* *
* @param string|null $newParentDn * @param string|null $newParentDn
*
* @return bool * @return bool
* *
* @throws \LdapRecord\LdapRecordException * @throws \LdapRecord\LdapRecordException
@@ -114,24 +140,6 @@ class Entry extends BaseEntry implements ActiveDirectory
$this->save(['isDeleted' => null]); $this->save(['isDeleted' => null]);
} }
/**
* Get the RootDSE (AD schema) record from the directory.
*
* @param string|null $connection
*
* @return static
*
* @throws \LdapRecord\Models\ModelNotFoundException
*/
public static function getRootDse($connection = null)
{
return static::on($connection ?? (new static())->getConnectionName())
->in(null)
->read()
->whereHas('objectclass')
->firstOrFail();
}
/** /**
* Get the objects restore location. * Get the objects restore location.
* *
@@ -143,22 +151,50 @@ class Entry extends BaseEntry implements ActiveDirectory
} }
/** /**
* Converts attributes for JSON serialization. * Convert the attributes for JSON serialization.
* *
* @param array $attributes * @param array $attributes
*
* @return array * @return array
*/ */
protected function convertAttributesForJson(array $attributes = []) protected function convertAttributesForJson(array $attributes = [])
{ {
$attributes = parent::convertAttributesForJson($attributes); $attributes = parent::convertAttributesForJson($attributes);
if ($this->hasAttribute($this->sidKey)) { // If the model has a SID set, we need to convert it to its
// If the model has a SID set, we need to convert it due to it being in // string format, due to it being in binary. Otherwise
// binary. Otherwise we will receive a JSON serialization exception. // we will receive a JSON serialization exception.
return array_replace($attributes, [ if (isset($attributes[$this->sidKey])) {
$this->sidKey => [$this->getConvertedSid()], $attributes[$this->sidKey] = [$this->getConvertedSid(
]); Arr::first($attributes[$this->sidKey])
)];
}
return $attributes;
}
/**
* Convert the attributes from JSON serialization.
*
* @param array $attributes
* @return array
*/
protected function convertAttributesFromJson(array $attributes = [])
{
$attributes = parent::convertAttributesFromJson($attributes);
// Here we are converting the model's GUID and SID attributes
// back to their original values from serialization, so that
// their original value may be used and compared against.
if (isset($attributes[$this->guidKey])) {
$attributes[$this->guidKey] = [$this->getBinaryGuid(
Arr::first($attributes[$this->guidKey])
)];
}
if (isset($attributes[$this->sidKey])) {
$attributes[$this->sidKey] = [$this->getBinarySid(
Arr::first($attributes[$this->sidKey])
)];
} }
return $attributes; return $attributes;
@@ -11,7 +11,6 @@ class HasOnePrimaryGroup extends HasOne
* Get the foreign model by the given value. * Get the foreign model by the given value.
* *
* @param string $value * @param string $value
*
* @return Model|null * @return Model|null
*/ */
protected function getForeignModelByValue($value) protected function getForeignModelByValue($value)
@@ -27,7 +26,6 @@ class HasOnePrimaryGroup extends HasOne
* Retrieves the last RID from the models Object SID. * Retrieves the last RID from the models Object SID.
* *
* @param Model $model * @param Model $model
*
* @return string * @return string
*/ */
protected function getForeignValueFromModel(Model $model) protected function getForeignValueFromModel(Model $model)
@@ -13,7 +13,6 @@ class HasServerRoleAttribute implements Scope
* *
* @param Builder $query * @param Builder $query
* @param Model $model * @param Model $model
*
* @return void * @return void
*/ */
public function apply(Builder $query, Model $model) public function apply(Builder $query, Model $model)
@@ -14,7 +14,6 @@ class InConfigurationContext implements Scope
* *
* @param Builder $query * @param Builder $query
* @param Model $model * @param Model $model
*
* @return void * @return void
* *
* @throws \LdapRecord\Models\ModelNotFoundException * @throws \LdapRecord\Models\ModelNotFoundException
@@ -28,7 +27,6 @@ class InConfigurationContext implements Scope
* Get the LDAP server configuration naming context distinguished name. * Get the LDAP server configuration naming context distinguished name.
* *
* @param Model $model * @param Model $model
*
* @return mixed * @return mixed
* *
* @throws \LdapRecord\Models\ModelNotFoundException * @throws \LdapRecord\Models\ModelNotFoundException
@@ -13,7 +13,6 @@ class RejectComputerObjectClass implements Scope
* *
* @param Builder $query * @param Builder $query
* @param Model $model * @param Model $model
*
* @return void * @return void
*/ */
public function apply(Builder $query, Model $model) public function apply(Builder $query, Model $model)
@@ -6,6 +6,7 @@ use Carbon\Carbon;
use Illuminate\Contracts\Auth\Authenticatable; use Illuminate\Contracts\Auth\Authenticatable;
use LdapRecord\Models\ActiveDirectory\Concerns\HasPrimaryGroup; use LdapRecord\Models\ActiveDirectory\Concerns\HasPrimaryGroup;
use LdapRecord\Models\ActiveDirectory\Scopes\RejectComputerObjectClass; use LdapRecord\Models\ActiveDirectory\Scopes\RejectComputerObjectClass;
use LdapRecord\Models\Attributes\AccountControl;
use LdapRecord\Models\Concerns\CanAuthenticate; use LdapRecord\Models\Concerns\CanAuthenticate;
use LdapRecord\Models\Concerns\HasPassword; use LdapRecord\Models\Concerns\HasPassword;
use LdapRecord\Query\Model\Builder; use LdapRecord\Query\Model\Builder;
@@ -71,6 +72,38 @@ class User extends Entry implements Authenticatable
static::addGlobalScope(new RejectComputerObjectClass()); static::addGlobalScope(new RejectComputerObjectClass());
} }
/**
* Determine if the user's account is enabled.
*
* @return bool
*/
public function isEnabled()
{
return ! $this->isDisabled();
}
/**
* Determine if the user's account is disabled.
*
* @return bool
*/
public function isDisabled()
{
return $this->accountControl()->has(AccountControl::ACCOUNTDISABLE);
}
/**
* Get the user's account control.
*
* @return AccountControl
*/
public function accountControl()
{
return new AccountControl(
$this->getFirstAttribute('userAccountControl')
);
}
/** /**
* The groups relationship. * The groups relationship.
* *
@@ -111,7 +144,6 @@ class User extends Entry implements Authenticatable
* Scopes the query to exchange mailbox users. * Scopes the query to exchange mailbox users.
* *
* @param Builder $query * @param Builder $query
*
* @return Builder * @return Builder
*/ */
public function scopeWhereHasMailbox(Builder $query) public function scopeWhereHasMailbox(Builder $query)
@@ -123,7 +155,6 @@ class User extends Entry implements Authenticatable
* Scopes the query to users having a lockout value set. * Scopes the query to users having a lockout value set.
* *
* @param Builder $query * @param Builder $query
*
* @return Builder * @return Builder
*/ */
public function scopeWhereHasLockout(Builder $query) public function scopeWhereHasLockout(Builder $query)
@@ -139,7 +170,6 @@ class User extends Entry implements Authenticatable
* *
* @param string|int $localTimezone * @param string|int $localTimezone
* @param int|null $durationInMinutes * @param int|null $durationInMinutes
*
* @return bool * @return bool
*/ */
public function isLockedOut($localTimezone, $durationInMinutes = null) public function isLockedOut($localTimezone, $durationInMinutes = null)
@@ -6,49 +6,49 @@ use ReflectionClass;
class AccountControl class AccountControl
{ {
const SCRIPT = 1; public const SCRIPT = 1;
const ACCOUNTDISABLE = 2; public const ACCOUNTDISABLE = 2;
const HOMEDIR_REQUIRED = 8; public const HOMEDIR_REQUIRED = 8;
const LOCKOUT = 16; public const LOCKOUT = 16;
const PASSWD_NOTREQD = 32; public const PASSWD_NOTREQD = 32;
const PASSWD_CANT_CHANGE = 64; public const PASSWD_CANT_CHANGE = 64;
const ENCRYPTED_TEXT_PWD_ALLOWED = 128; public const ENCRYPTED_TEXT_PWD_ALLOWED = 128;
const TEMP_DUPLICATE_ACCOUNT = 256; public const TEMP_DUPLICATE_ACCOUNT = 256;
const NORMAL_ACCOUNT = 512; public const NORMAL_ACCOUNT = 512;
const INTERDOMAIN_TRUST_ACCOUNT = 2048; public const INTERDOMAIN_TRUST_ACCOUNT = 2048;
const WORKSTATION_TRUST_ACCOUNT = 4096; public const WORKSTATION_TRUST_ACCOUNT = 4096;
const SERVER_TRUST_ACCOUNT = 8192; public const SERVER_TRUST_ACCOUNT = 8192;
const DONT_EXPIRE_PASSWORD = 65536; public const DONT_EXPIRE_PASSWORD = 65536;
const MNS_LOGON_ACCOUNT = 131072; public const MNS_LOGON_ACCOUNT = 131072;
const SMARTCARD_REQUIRED = 262144; public const SMARTCARD_REQUIRED = 262144;
const TRUSTED_FOR_DELEGATION = 524288; public const TRUSTED_FOR_DELEGATION = 524288;
const NOT_DELEGATED = 1048576; public const NOT_DELEGATED = 1048576;
const USE_DES_KEY_ONLY = 2097152; public const USE_DES_KEY_ONLY = 2097152;
const DONT_REQ_PREAUTH = 4194304; public const DONT_REQ_PREAUTH = 4194304;
const PASSWORD_EXPIRED = 8388608; public const PASSWORD_EXPIRED = 8388608;
const TRUSTED_TO_AUTH_FOR_DELEGATION = 16777216; public const TRUSTED_TO_AUTH_FOR_DELEGATION = 16777216;
const PARTIAL_SECRETS_ACCOUNT = 67108864; public const PARTIAL_SECRETS_ACCOUNT = 67108864;
/** /**
* The account control flag values. * The account control flag values.
@@ -93,7 +93,6 @@ class AccountControl
* Add the flag to the account control values. * Add the flag to the account control values.
* *
* @param int $flag * @param int $flag
*
* @return $this * @return $this
*/ */
public function add($flag) public function add($flag)
@@ -109,7 +108,6 @@ class AccountControl
* Remove the flag from the account control. * Remove the flag from the account control.
* *
* @param int $flag * @param int $flag
*
* @return $this * @return $this
*/ */
public function remove($flag) public function remove($flag)
@@ -123,7 +121,6 @@ class AccountControl
* Extract and apply the flag. * Extract and apply the flag.
* *
* @param int $flag * @param int $flag
*
* @return void * @return void
*/ */
public function apply($flag) public function apply($flag)
@@ -135,7 +132,6 @@ class AccountControl
* Determine if the account control contains the given UAC flag(s). * Determine if the account control contains the given UAC flag(s).
* *
* @param int $flag * @param int $flag
*
* @return bool * @return bool
*/ */
public function has($flag) public function has($flag)
@@ -155,7 +151,6 @@ class AccountControl
* Determine if the account control does not contain the given UAC flag(s). * Determine if the account control does not contain the given UAC flag(s).
* *
* @param int $flag * @param int $flag
*
* @return bool * @return bool
*/ */
public function doesntHave($flag) public function doesntHave($flag)
@@ -442,7 +437,6 @@ class AccountControl
* Set the account control values. * Set the account control values.
* *
* @param array<int, int> $flags * @param array<int, int> $flags
*
* @return void * @return void
*/ */
public function setValues(array $flags) public function setValues(array $flags)
@@ -484,7 +478,6 @@ class AccountControl
* Extracts the given flag into an array of flags used. * Extracts the given flag into an array of flags used.
* *
* @param int $flag * @param int $flag
*
* @return array * @return array
*/ */
public function extractFlags($flag) public function extractFlags($flag)
@@ -40,7 +40,6 @@ class DistinguishedName
* Alias of the "build" method. * Alias of the "build" method.
* *
* @param string|null $value * @param string|null $value
*
* @return DistinguishedNameBuilder * @return DistinguishedNameBuilder
*/ */
public static function of($value = null) public static function of($value = null)
@@ -52,7 +51,6 @@ class DistinguishedName
* Get a new DN builder object from the given DN. * Get a new DN builder object from the given DN.
* *
* @param string|null $value * @param string|null $value
*
* @return DistinguishedNameBuilder * @return DistinguishedNameBuilder
*/ */
public static function build($value = null) public static function build($value = null)
@@ -64,7 +62,6 @@ class DistinguishedName
* Make a new distinguished name instance. * Make a new distinguished name instance.
* *
* @param string|null $value * @param string|null $value
*
* @return static * @return static
*/ */
public static function make($value = null) public static function make($value = null)
@@ -76,7 +73,6 @@ class DistinguishedName
* Determine if the given value is a valid distinguished name. * Determine if the given value is a valid distinguished name.
* *
* @param string $value * @param string $value
*
* @return bool * @return bool
*/ */
public static function isValid($value) public static function isValid($value)
@@ -88,7 +84,6 @@ class DistinguishedName
* Explode a distinguished name into relative distinguished names. * Explode a distinguished name into relative distinguished names.
* *
* @param string $dn * @param string $dn
*
* @return array * @return array
*/ */
public static function explode($dn) public static function explode($dn)
@@ -112,7 +107,6 @@ class DistinguishedName
* Un-escapes a hexadecimal string into its original string representation. * Un-escapes a hexadecimal string into its original string representation.
* *
* @param string $value * @param string $value
*
* @return string * @return string
*/ */
public static function unescape($value) public static function unescape($value)
@@ -126,7 +120,6 @@ class DistinguishedName
* Explode the RDN into an attribute and value. * Explode the RDN into an attribute and value.
* *
* @param string $rdn * @param string $rdn
*
* @return array * @return array
*/ */
public static function explodeRdn($rdn) public static function explodeRdn($rdn)
@@ -138,7 +131,6 @@ class DistinguishedName
* Implode the component attribute and value into an RDN. * Implode the component attribute and value into an RDN.
* *
* @param string $rdn * @param string $rdn
*
* @return string * @return string
*/ */
public static function makeRdn(array $component) public static function makeRdn(array $component)
@@ -160,7 +152,6 @@ class DistinguishedName
* Set the underlying value. * Set the underlying value.
* *
* @param string|null $value * @param string|null $value
*
* @return $this * @return $this
*/ */
public function set($value) public function set($value)
@@ -338,7 +329,6 @@ class DistinguishedName
* Determine if the current distinguished name is a parent of the given child. * Determine if the current distinguished name is a parent of the given child.
* *
* @param DistinguishedName $child * @param DistinguishedName $child
*
* @return bool * @return bool
*/ */
public function isParentOf(self $child) public function isParentOf(self $child)
@@ -350,7 +340,6 @@ class DistinguishedName
* Determine if the current distinguished name is a child of the given parent. * Determine if the current distinguished name is a child of the given parent.
* *
* @param DistinguishedName $parent * @param DistinguishedName $parent
*
* @return bool * @return bool
*/ */
public function isChildOf(self $parent) public function isChildOf(self $parent)
@@ -371,7 +360,6 @@ class DistinguishedName
* Determine if the current distinguished name is an ancestor of the descendant. * Determine if the current distinguished name is an ancestor of the descendant.
* *
* @param DistinguishedName $descendant * @param DistinguishedName $descendant
*
* @return bool * @return bool
*/ */
public function isAncestorOf(self $descendant) public function isAncestorOf(self $descendant)
@@ -383,7 +371,6 @@ class DistinguishedName
* Determine if the current distinguished name is a descendant of the ancestor. * Determine if the current distinguished name is a descendant of the ancestor.
* *
* @param DistinguishedName $ancestor * @param DistinguishedName $ancestor
*
* @return bool * @return bool
*/ */
public function isDescendantOf(self $ancestor) public function isDescendantOf(self $ancestor)
@@ -409,7 +396,6 @@ class DistinguishedName
* *
* @param array $values * @param array $values
* @param array $other * @param array $other
*
* @return bool * @return bool
*/ */
protected function compare(array $values, array $other) protected function compare(array $values, array $other)
@@ -421,7 +407,6 @@ class DistinguishedName
* Recase the array values. * Recase the array values.
* *
* @param array $values * @param array $values
*
* @return array * @return array
*/ */
protected function recase(array $values) protected function recase(array $values)
@@ -433,7 +418,6 @@ class DistinguishedName
* Normalize the string value. * Normalize the string value.
* *
* @param string $value * @param string $value
*
* @return string * @return string
*/ */
protected function normalize($value) protected function normalize($value)
@@ -40,7 +40,6 @@ class DistinguishedNameBuilder
* *
* @param string $method * @param string $method
* @param array $args * @param array $args
*
* @return mixed * @return mixed
*/ */
public function __call($method, $args) public function __call($method, $args)
@@ -63,7 +62,6 @@ class DistinguishedNameBuilder
* *
* @param string|array $attribute * @param string|array $attribute
* @param string|null $value * @param string|null $value
*
* @return $this * @return $this
*/ */
public function prepend($attribute, $value = null) public function prepend($attribute, $value = null)
@@ -81,7 +79,6 @@ class DistinguishedNameBuilder
* *
* @param string|array $attribute * @param string|array $attribute
* @param string|null $value * @param string|null $value
*
* @return $this * @return $this
*/ */
public function append($attribute, $value = null) public function append($attribute, $value = null)
@@ -99,7 +96,6 @@ class DistinguishedNameBuilder
* *
* @param string|array $attribute * @param string|array $attribute
* @param string|null $value * @param string|null $value
*
* @return array * @return array
*/ */
protected function componentize($attribute, $value = null) protected function componentize($attribute, $value = null)
@@ -126,7 +122,6 @@ class DistinguishedNameBuilder
* Make a componentized array by exploding the value if it's a string. * Make a componentized array by exploding the value if it's a string.
* *
* @param string $value * @param string $value
*
* @return array * @return array
*/ */
protected function makeComponentizedArray($value) protected function makeComponentizedArray($value)
@@ -139,7 +134,6 @@ class DistinguishedNameBuilder
* *
* @param string|array $attribute * @param string|array $attribute
* @param string|null $value * @param string|null $value
*
* @return array * @return array
*/ */
protected function makeAppendableComponent($attribute, $value = null) protected function makeAppendableComponent($attribute, $value = null)
@@ -152,7 +146,6 @@ class DistinguishedNameBuilder
* *
* @param int $amount * @param int $amount
* @param array $removed * @param array $removed
*
* @return $this * @return $this
*/ */
public function pop($amount = 1, &$removed = []) public function pop($amount = 1, &$removed = [])
@@ -169,7 +162,6 @@ class DistinguishedNameBuilder
* *
* @param int $amount * @param int $amount
* @param array $removed * @param array $removed
*
* @return $this * @return $this
*/ */
public function shift($amount = 1, &$removed = []) public function shift($amount = 1, &$removed = [])
@@ -197,7 +189,6 @@ class DistinguishedNameBuilder
* Get the components of the DN. * Get the components of the DN.
* *
* @param null|string $type * @param null|string $type
*
* @return array * @return array
*/ */
public function components($type = null) public function components($type = null)
@@ -211,7 +202,6 @@ class DistinguishedNameBuilder
* Get the components of a particular type. * Get the components of a particular type.
* *
* @param string $type * @param string $type
*
* @return array * @return array
*/ */
protected function componentsOfType($type) protected function componentsOfType($type)
@@ -73,7 +73,6 @@ class EscapedValue
* Set the characters to exclude from being escaped. * Set the characters to exclude from being escaped.
* *
* @param string $characters * @param string $characters
*
* @return $this * @return $this
*/ */
public function ignore($characters) public function ignore($characters)
@@ -51,7 +51,6 @@ class Guid
* Determines if the specified GUID is valid. * Determines if the specified GUID is valid.
* *
* @param string $guid * @param string $guid
*
* @return bool * @return bool
*/ */
public static function isValid($guid) public static function isValid($guid)
@@ -129,7 +128,6 @@ class Guid
* Returns the string variant of a binary GUID. * Returns the string variant of a binary GUID.
* *
* @param string $binary * @param string $binary
*
* @return string|null * @return string|null
*/ */
protected function binaryGuidToString($binary) protected function binaryGuidToString($binary)
@@ -147,7 +145,6 @@ class Guid
* @param string $hex The full hex string. * @param string $hex The full hex string.
* @param array $sections An array of start and length (unless octet is true, then length is always 2). * @param array $sections An array of start and length (unless octet is true, then length is always 2).
* @param bool $octet Whether this is for octet string form. * @param bool $octet Whether this is for octet string form.
*
* @return string The concatenated sections in upper-case. * @return string The concatenated sections in upper-case.
*/ */
protected function parseSection($hex, array $sections, $octet = false) protected function parseSection($hex, array $sections, $octet = false)
@@ -8,7 +8,6 @@ class MbString
* Get the integer value of a specific character. * Get the integer value of a specific character.
* *
* @param $string * @param $string
*
* @return int * @return int
*/ */
public static function ord($string) public static function ord($string)
@@ -28,7 +27,6 @@ class MbString
* Get the character for a specific integer value. * Get the character for a specific integer value.
* *
* @param $int * @param $int
*
* @return string * @return string
*/ */
public static function chr($int) public static function chr($int)
@@ -44,7 +42,6 @@ class MbString
* Split a string into its individual characters and return it as an array. * Split a string into its individual characters and return it as an array.
* *
* @param string $value * @param string $value
*
* @return string[] * @return string[]
*/ */
public static function split($value) public static function split($value)
@@ -56,7 +53,6 @@ class MbString
* Detects if the given string is UTF 8. * Detects if the given string is UTF 8.
* *
* @param $string * @param $string
*
* @return string|false * @return string|false
*/ */
public static function isUtf8($string) public static function isUtf8($string)
@@ -8,15 +8,14 @@ use ReflectionMethod;
class Password class Password
{ {
const CRYPT_SALT_TYPE_MD5 = 1; public const CRYPT_SALT_TYPE_MD5 = 1;
const CRYPT_SALT_TYPE_SHA256 = 5; public const CRYPT_SALT_TYPE_SHA256 = 5;
const CRYPT_SALT_TYPE_SHA512 = 6; public const CRYPT_SALT_TYPE_SHA512 = 6;
/** /**
* Make an encoded password for transmission over LDAP. * Make an encoded password for transmission over LDAP.
* *
* @param string $password * @param string $password
*
* @return string * @return string
*/ */
public static function encode($password) public static function encode($password)
@@ -29,7 +28,6 @@ class Password
* *
* @param string $password * @param string $password
* @param null|string $salt * @param null|string $salt
*
* @return string * @return string
*/ */
public static function smd5($password, $salt = null) public static function smd5($password, $salt = null)
@@ -42,7 +40,6 @@ class Password
* *
* @param string $password * @param string $password
* @param null|string $salt * @param null|string $salt
*
* @return string * @return string
*/ */
public static function ssha($password, $salt = null) public static function ssha($password, $salt = null)
@@ -55,7 +52,6 @@ class Password
* *
* @param string $password * @param string $password
* @param null|string $salt * @param null|string $salt
*
* @return string * @return string
*/ */
public static function ssha256($password, $salt = null) public static function ssha256($password, $salt = null)
@@ -68,7 +64,6 @@ class Password
* *
* @param string $password * @param string $password
* @param null|string $salt * @param null|string $salt
*
* @return string * @return string
*/ */
public static function ssha384($password, $salt = null) public static function ssha384($password, $salt = null)
@@ -81,7 +76,6 @@ class Password
* *
* @param string $password * @param string $password
* @param null|string $salt * @param null|string $salt
*
* @return string * @return string
*/ */
public static function ssha512($password, $salt = null) public static function ssha512($password, $salt = null)
@@ -93,7 +87,6 @@ class Password
* Make a non-salted SHA password. * Make a non-salted SHA password.
* *
* @param string $password * @param string $password
*
* @return string * @return string
*/ */
public static function sha($password) public static function sha($password)
@@ -105,7 +98,6 @@ class Password
* Make a non-salted SHA256 password. * Make a non-salted SHA256 password.
* *
* @param string $password * @param string $password
*
* @return string * @return string
*/ */
public static function sha256($password) public static function sha256($password)
@@ -117,7 +109,6 @@ class Password
* Make a non-salted SHA384 password. * Make a non-salted SHA384 password.
* *
* @param string $password * @param string $password
*
* @return string * @return string
*/ */
public static function sha384($password) public static function sha384($password)
@@ -129,7 +120,6 @@ class Password
* Make a non-salted SHA512 password. * Make a non-salted SHA512 password.
* *
* @param string $password * @param string $password
*
* @return string * @return string
*/ */
public static function sha512($password) public static function sha512($password)
@@ -141,7 +131,6 @@ class Password
* Make a non-salted md5 password. * Make a non-salted md5 password.
* *
* @param string $password * @param string $password
*
* @return string * @return string
*/ */
public static function md5($password) public static function md5($password)
@@ -149,12 +138,22 @@ class Password
return '{MD5}'.static::makeHash($password, 'md5'); return '{MD5}'.static::makeHash($password, 'md5');
} }
/**
* Make a non-salted NThash password.
*
* @param string $password
* @return string
*/
public static function nthash($password)
{
return '{NTHASH}'.strtoupper(hash('md4', iconv('UTF-8', 'UTF-16LE', $password)));
}
/** /**
* Crypt password with an MD5 salt. * Crypt password with an MD5 salt.
* *
* @param string $password * @param string $password
* @param string $salt * @param string $salt
*
* @return string * @return string
*/ */
public static function md5Crypt($password, $salt = null) public static function md5Crypt($password, $salt = null)
@@ -167,7 +166,6 @@ class Password
* *
* @param string $password * @param string $password
* @param string $salt * @param string $salt
*
* @return string * @return string
*/ */
public static function sha256Crypt($password, $salt = null) public static function sha256Crypt($password, $salt = null)
@@ -180,7 +178,6 @@ class Password
* *
* @param string $password * @param string $password
* @param string $salt * @param string $salt
*
* @return string * @return string
*/ */
public static function sha512Crypt($password, $salt = null) public static function sha512Crypt($password, $salt = null)
@@ -195,7 +192,6 @@ class Password
* @param string $method The hash function to use. * @param string $method The hash function to use.
* @param string|null $algo The algorithm to use for hashing. * @param string|null $algo The algorithm to use for hashing.
* @param string|null $salt The salt to append onto the hash. * @param string|null $salt The salt to append onto the hash.
*
* @return string * @return string
*/ */
protected static function makeHash($password, $method, $algo = null, $salt = null) protected static function makeHash($password, $method, $algo = null, $salt = null)
@@ -211,7 +207,6 @@ class Password
* @param string $password * @param string $password
* @param int $type * @param int $type
* @param null|string $salt * @param null|string $salt
*
* @return string * @return string
*/ */
protected static function makeCrypt($password, $type, $salt = null) protected static function makeCrypt($password, $type, $salt = null)
@@ -223,7 +218,6 @@ class Password
* Make a salt for the crypt() method using the given type. * Make a salt for the crypt() method using the given type.
* *
* @param int $type * @param int $type
*
* @return string * @return string
*/ */
protected static function makeCryptSalt($type) protected static function makeCryptSalt($type)
@@ -243,7 +237,6 @@ class Password
* Determine the crypt prefix and length. * Determine the crypt prefix and length.
* *
* @param int $type * @param int $type
*
* @return array * @return array
* *
* @throws InvalidArgumentException * @throws InvalidArgumentException
@@ -266,7 +259,6 @@ class Password
* Attempt to retrieve the hash method used for the password. * Attempt to retrieve the hash method used for the password.
* *
* @param string $password * @param string $password
*
* @return string|void * @return string|void
*/ */
public static function getHashMethod($password) public static function getHashMethod($password)
@@ -282,7 +274,6 @@ class Password
* Attempt to retrieve the hash method and algorithm used for the password. * Attempt to retrieve the hash method and algorithm used for the password.
* *
* @param string $password * @param string $password
*
* @return array|void * @return array|void
*/ */
public static function getHashMethodAndAlgo($password) public static function getHashMethodAndAlgo($password)
@@ -320,7 +311,6 @@ class Password
* Determine if the hash method requires a salt to be given. * Determine if the hash method requires a salt to be given.
* *
* @param string $method * @param string $method
*
* @return bool * @return bool
* *
* @throws \ReflectionException * @throws \ReflectionException
@@ -18,7 +18,6 @@ class Sid
* Determines if the specified SID is valid. * Determines if the specified SID is valid.
* *
* @param string $sid * @param string $sid
*
* @return bool * @return bool
*/ */
public static function isValid($sid) public static function isValid($sid)
@@ -91,7 +90,6 @@ class Sid
* Returns the string variant of a binary SID. * Returns the string variant of a binary SID.
* *
* @param string $binary * @param string $binary
*
* @return string|null * @return string|null
*/ */
protected function binarySidToString($binary) protected function binarySidToString($binary)
@@ -7,7 +7,7 @@ class TSProperty
/** /**
* Nibble control values. The first value for each is if the nibble is <= 9, otherwise the second value is used. * Nibble control values. The first value for each is if the nibble is <= 9, otherwise the second value is used.
*/ */
const NIBBLE_CONTROL = [ public const NIBBLE_CONTROL = [
'X' => ['001011', '011010'], 'X' => ['001011', '011010'],
'Y' => ['001110', '011010'], 'Y' => ['001110', '011010'],
]; ];
@@ -15,12 +15,12 @@ class TSProperty
/** /**
* The nibble header. * The nibble header.
*/ */
const NIBBLE_HEADER = '1110'; public const NIBBLE_HEADER = '1110';
/** /**
* Conversion factor needed for time values in the TSPropertyArray (stored in microseconds). * Conversion factor needed for time values in the TSPropertyArray (stored in microseconds).
*/ */
const TIME_CONVERSION = 60 * 1000; public const TIME_CONVERSION = 60 * 1000;
/** /**
* A simple map to help determine how the property needs to be decoded/encoded from/to its binary value. * A simple map to help determine how the property needs to be decoded/encoded from/to its binary value.
@@ -98,7 +98,6 @@ class TSProperty
* Set the name for the TSProperty. * Set the name for the TSProperty.
* *
* @param string $name * @param string $name
*
* @return TSProperty * @return TSProperty
*/ */
public function setName($name) public function setName($name)
@@ -122,7 +121,6 @@ class TSProperty
* Set the value for the TSProperty. * Set the value for the TSProperty.
* *
* @param string|int $value * @param string|int $value
*
* @return TSProperty * @return TSProperty
*/ */
public function setValue($value) public function setValue($value)
@@ -188,7 +186,6 @@ class TSProperty
* *
* @param string $propName * @param string $propName
* @param string|int $propValue * @param string|int $propValue
*
* @return string * @return string
*/ */
protected function getEncodedValueForProp($propName, $propValue) protected function getEncodedValueForProp($propName, $propValue)
@@ -212,7 +209,6 @@ class TSProperty
* *
* @param string $propName * @param string $propName
* @param string $propValue * @param string $propValue
*
* @return string|int * @return string|int
*/ */
protected function getDecodedValueForProp($propName, $propValue) protected function getDecodedValueForProp($propName, $propValue)
@@ -240,7 +236,6 @@ class TSProperty
* *
* @param string $hex * @param string $hex
* @param bool $string Whether or not this is simple string data. * @param bool $string Whether or not this is simple string data.
*
* @return string * @return string
*/ */
protected function decodePropValue($hex, $string = false) protected function decodePropValue($hex, $string = false)
@@ -274,7 +269,6 @@ class TSProperty
* *
* @param string $value * @param string $value
* @param bool $string * @param bool $string
*
* @return string * @return string
*/ */
protected function encodePropValue($value, $string = false) protected function encodePropValue($value, $string = false)
@@ -316,7 +310,6 @@ class TSProperty
* *
* @param string $bits * @param string $bits
* @param bool $len * @param bool $len
*
* @return string * @return string
*/ */
protected function packBitString($bits, $len) protected function packBitString($bits, $len)
@@ -339,7 +332,6 @@ class TSProperty
* *
* @param string $nibble * @param string $nibble
* @param string $control * @param string $control
*
* @return string * @return string
*/ */
protected function nibbleControl($nibble, $control) protected function nibbleControl($nibble, $control)
@@ -364,7 +356,6 @@ class TSProperty
* *
* @param string $nibbleType Either X or Y * @param string $nibbleType Either X or Y
* @param string $nibble * @param string $nibble
*
* @return string * @return string
*/ */
protected function getNibbleWithControl($nibbleType, $nibble) protected function getNibbleWithControl($nibbleType, $nibble)
@@ -386,7 +377,6 @@ class TSProperty
* *
* @param int $int * @param int $int
* @param int $padLength The hex string must be padded to this length (with zeros). * @param int $padLength The hex string must be padded to this length (with zeros).
*
* @return string * @return string
*/ */
protected function dec2hex($int, $padLength = 2) protected function dec2hex($int, $padLength = 2)
@@ -9,14 +9,14 @@ class TSPropertyArray
/** /**
* Represents that the TSPropertyArray data is valid. * Represents that the TSPropertyArray data is valid.
*/ */
const VALID_SIGNATURE = 'P'; public const VALID_SIGNATURE = 'P';
/** /**
* The default values for the TSPropertyArray structure. * The default values for the TSPropertyArray structure.
* *
* @var array * @var array
*/ */
const DEFAULTS = [ public const DEFAULTS = [
'CtxCfgPresent' => 2953518677, 'CtxCfgPresent' => 2953518677,
'CtxWFProfilePath' => '', 'CtxWFProfilePath' => '',
'CtxWFProfilePathW' => '', 'CtxWFProfilePathW' => '',
@@ -94,7 +94,6 @@ class TSPropertyArray
* Check if a specific TSProperty exists by its property name. * Check if a specific TSProperty exists by its property name.
* *
* @param string $propName * @param string $propName
*
* @return bool * @return bool
*/ */
public function has($propName) public function has($propName)
@@ -106,7 +105,6 @@ class TSPropertyArray
* Get a TSProperty object by its property name (ie. CtxWFProfilePath). * Get a TSProperty object by its property name (ie. CtxWFProfilePath).
* *
* @param string $propName * @param string $propName
*
* @return TSProperty * @return TSProperty
*/ */
public function get($propName) public function get($propName)
@@ -120,7 +118,6 @@ class TSPropertyArray
* Add a TSProperty object. If it already exists, it will be overwritten. * Add a TSProperty object. If it already exists, it will be overwritten.
* *
* @param TSProperty $tsProperty * @param TSProperty $tsProperty
*
* @return $this * @return $this
*/ */
public function add(TSProperty $tsProperty) public function add(TSProperty $tsProperty)
@@ -134,7 +131,6 @@ class TSPropertyArray
* Remove a TSProperty by its property name (ie. CtxMinEncryptionLevel). * Remove a TSProperty by its property name (ie. CtxMinEncryptionLevel).
* *
* @param string $propName * @param string $propName
*
* @return $this * @return $this
*/ */
public function remove($propName) public function remove($propName)
@@ -153,7 +149,6 @@ class TSPropertyArray
* *
* @param string $propName * @param string $propName
* @param mixed $propValue * @param mixed $propValue
*
* @return $this * @return $this
*/ */
public function set($propName, $propValue) public function set($propName, $propValue)
@@ -225,7 +220,6 @@ class TSPropertyArray
/** /**
* @param string $propName * @param string $propName
*
* @return TSProperty * @return TSProperty
*/ */
protected function getTsPropObj($propName) protected function getTsPropObj($propName)
@@ -237,7 +231,6 @@ class TSPropertyArray
* Get an associative array with all of the userParameters property names and values. * Get an associative array with all of the userParameters property names and values.
* *
* @param string $userParameters * @param string $userParameters
*
* @return void * @return void
*/ */
protected function decodeUserParameters($userParameters) protected function decodeUserParameters($userParameters)
@@ -260,7 +253,7 @@ class TSPropertyArray
// Reserved data length + (count and sig length == 4) + the added lengths of the TSPropertyArray // Reserved data length + (count and sig length == 4) + the added lengths of the TSPropertyArray
// This saves anything after that variable TSPropertyArray data, so as to not squash anything stored there // This saves anything after that variable TSPropertyArray data, so as to not squash anything stored there
if (strlen($userParameters) > (96 + 4 + $length)) { if (strlen($userParameters) > (96 + 4 + $length)) {
$this->postBinary = hex2bin(substr($userParameters, (96 + 4 + $length))); $this->postBinary = hex2bin(substr($userParameters, 96 + 4 + $length));
} }
} }
@@ -272,7 +265,6 @@ class TSPropertyArray
* *
* @param string $tsPropertyArray * @param string $tsPropertyArray
* @param int $tsPropCount * @param int $tsPropCount
*
* @return int The length of the data in the TSPropertyArray * @return int The length of the data in the TSPropertyArray
*/ */
protected function addTSPropData($tsPropertyArray, $tsPropCount) protected function addTSPropData($tsPropertyArray, $tsPropCount)
@@ -5,11 +5,14 @@ namespace LdapRecord\Models\Attributes;
use Carbon\Carbon; use Carbon\Carbon;
use Carbon\CarbonInterface; use Carbon\CarbonInterface;
use DateTime; use DateTime;
use DateTimeZone;
use LdapRecord\LdapRecordException; use LdapRecord\LdapRecordException;
use LdapRecord\Utilities; use LdapRecord\Utilities;
class Timestamp class Timestamp
{ {
public const WINDOWS_INT_MAX = 9223372036854775807;
/** /**
* The current timestamp type. * The current timestamp type.
* *
@@ -60,7 +63,6 @@ class Timestamp
* Converts the value to an LDAP date string. * Converts the value to an LDAP date string.
* *
* @param mixed $value * @param mixed $value
*
* @return float|string * @return float|string
* *
* @throws LdapRecordException * @throws LdapRecordException
@@ -108,20 +110,18 @@ class Timestamp
* Determine if the value given is in Windows Integer (NTFS Filetime) format. * Determine if the value given is in Windows Integer (NTFS Filetime) format.
* *
* @param int|string $value * @param int|string $value
*
* @return bool * @return bool
*/ */
protected function valueIsWindowsIntegerType($value) protected function valueIsWindowsIntegerType($value)
{ {
return is_numeric($value) && strlen((string) $value) === 18; return is_numeric($value) && in_array(strlen((string) $value), [18, 19]);
} }
/** /**
* Converts the LDAP timestamp value to a Carbon instance. * Converts the LDAP timestamp value to a Carbon instance.
* *
* @param mixed $value * @param mixed $value
* * @return Carbon|int|false
* @return Carbon|false
* *
* @throws LdapRecordException * @throws LdapRecordException
*/ */
@@ -154,13 +154,12 @@ class Timestamp
* Converts standard LDAP timestamps to a date time object. * Converts standard LDAP timestamps to a date time object.
* *
* @param string $value * @param string $value
*
* @return DateTime|false * @return DateTime|false
*/ */
protected function convertLdapTimeToDateTime($value) protected function convertLdapTimeToDateTime($value)
{ {
return DateTime::createFromFormat( return DateTime::createFromFormat(
strpos($value, 'Z') !== false ? 'YmdHis\Z' : 'YmdHisT', str_contains((string) $value, 'Z') ? 'YmdHis\Z' : 'YmdHisT',
$value $value
); );
} }
@@ -169,7 +168,6 @@ class Timestamp
* Converts date objects to a standard LDAP timestamp. * Converts date objects to a standard LDAP timestamp.
* *
* @param DateTime $date * @param DateTime $date
*
* @return string * @return string
*/ */
protected function convertDateTimeToLdapTime(DateTime $date) protected function convertDateTimeToLdapTime(DateTime $date)
@@ -183,14 +181,14 @@ class Timestamp
* Converts standard windows timestamps to a date time object. * Converts standard windows timestamps to a date time object.
* *
* @param string $value * @param string $value
*
* @return DateTime|false * @return DateTime|false
*/ */
protected function convertWindowsTimeToDateTime($value) protected function convertWindowsTimeToDateTime($value)
{ {
return DateTime::createFromFormat( return DateTime::createFromFormat(
strpos($value, '0Z') !== false ? 'YmdHis.0\Z' : 'YmdHis.0T', str_contains((string) $value, '0Z') ? 'YmdHis.0\Z' : 'YmdHis.0T',
$value $value,
new DateTimeZone('UTC')
); );
} }
@@ -198,7 +196,6 @@ class Timestamp
* Converts date objects to a windows timestamp. * Converts date objects to a windows timestamp.
* *
* @param DateTime $date * @param DateTime $date
*
* @return string * @return string
*/ */
protected function convertDateTimeToWindows(DateTime $date) protected function convertDateTimeToWindows(DateTime $date)
@@ -212,19 +209,24 @@ class Timestamp
* Converts standard windows integer dates to a date time object. * Converts standard windows integer dates to a date time object.
* *
* @param int $value * @param int $value
* * @return DateTime|int|false
* @return DateTime|false
* *
* @throws \Exception * @throws \Exception
*/ */
protected function convertWindowsIntegerTimeToDateTime($value) protected function convertWindowsIntegerTimeToDateTime($value)
{ {
// ActiveDirectory dates that contain integers may return if (is_null($value) || $value === '') {
// "0" when they are not set. We will validate that here.
if (! $value) {
return false; return false;
} }
if ($value == 0) {
return (int) $value;
}
if ($value == static::WINDOWS_INT_MAX) {
return (int) $value;
}
return (new DateTime())->setTimestamp( return (new DateTime())->setTimestamp(
Utilities::convertWindowsTimeToUnixTime($value) Utilities::convertWindowsTimeToUnixTime($value)
); );
@@ -234,7 +236,6 @@ class Timestamp
* Converts date objects to a windows integer timestamp. * Converts date objects to a windows integer timestamp.
* *
* @param DateTime $date * @param DateTime $date
*
* @return float * @return float
*/ */
protected function convertDateTimeToWindowsInteger(DateTime $date) protected function convertDateTimeToWindowsInteger(DateTime $date)
@@ -11,9 +11,9 @@ class BatchModification
/** /**
* The array keys to be used in batch modifications. * The array keys to be used in batch modifications.
*/ */
const KEY_ATTRIB = 'attrib'; public const KEY_ATTRIB = 'attrib';
const KEY_MODTYPE = 'modtype'; public const KEY_MODTYPE = 'modtype';
const KEY_VALUES = 'values'; public const KEY_VALUES = 'values';
/** /**
* The attribute of the modification. * The attribute of the modification.
@@ -61,7 +61,6 @@ class BatchModification
* Set the original value of the attribute before modification. * Set the original value of the attribute before modification.
* *
* @param array|string $original * @param array|string $original
*
* @return $this * @return $this
*/ */
public function setOriginal($original = []) public function setOriginal($original = [])
@@ -85,7 +84,6 @@ class BatchModification
* Set the attribute of the modification. * Set the attribute of the modification.
* *
* @param string $attribute * @param string $attribute
*
* @return $this * @return $this
*/ */
public function setAttribute($attribute) public function setAttribute($attribute)
@@ -109,7 +107,6 @@ class BatchModification
* Set the values of the modification. * Set the values of the modification.
* *
* @param array $values * @param array $values
*
* @return $this * @return $this
*/ */
public function setValues(array $values = []) public function setValues(array $values = [])
@@ -128,7 +125,6 @@ class BatchModification
* Normalize all of the attribute values. * Normalize all of the attribute values.
* *
* @param array|string $values * @param array|string $values
*
* @return array * @return array
*/ */
protected function normalizeAttributeValues($values = []) protected function normalizeAttributeValues($values = [])
@@ -153,7 +149,6 @@ class BatchModification
* Set the type of the modification. * Set the type of the modification.
* *
* @param int|null $type * @param int|null $type
*
* @return $this * @return $this
*/ */
public function setType($type = null) public function setType($type = null)
@@ -292,7 +287,6 @@ class BatchModification
* Determines if the given modtype is valid. * Determines if the given modtype is valid.
* *
* @param int $type * @param int $type
*
* @return bool * @return bool
*/ */
protected function isValidType($type) protected function isValidType($type)
@@ -9,11 +9,22 @@ use LdapRecord\Support\Arr;
class Collection extends QueryCollection class Collection extends QueryCollection
{ {
/**
* Get a collection of the model's distinguished names.
*
* @return static
*/
public function modelDns()
{
return $this->map(function (Model $model) {
return $model->getDn();
});
}
/** /**
* Determine if the collection contains all of the given models, or any models. * Determine if the collection contains all of the given models, or any models.
* *
* @param mixed $models * @param mixed $models
*
* @return bool * @return bool
*/ */
public function exists($models = null) public function exists($models = null)
@@ -50,7 +61,6 @@ class Collection extends QueryCollection
* @param mixed $key * @param mixed $key
* @param mixed $operator * @param mixed $operator
* @param mixed $value * @param mixed $value
*
* @return bool * @return bool
*/ */
public function contains($key, $operator = null, $value = null) public function contains($key, $operator = null, $value = null)
@@ -79,7 +89,6 @@ class Collection extends QueryCollection
* Get the provided models as an array. * Get the provided models as an array.
* *
* @param mixed $models * @param mixed $models
*
* @return array * @return array
*/ */
protected function getArrayableModels($models = null) protected function getArrayableModels($models = null)
@@ -94,15 +103,14 @@ class Collection extends QueryCollection
* *
* @param Model|string $model * @param Model|string $model
* @param Model $related * @param Model $related
*
* @return bool * @return bool
*/ */
protected function compareModelWithRelated($model, $related) protected function compareModelWithRelated($model, $related)
{ {
if (is_string($model)) { if (is_string($model)) {
return $this->isValidDn($model) return $this->isValidDn($model)
? $related->getDn() == $model ? strcasecmp($related->getDn(), $model) === 0
: $related->getName() == $model; : strcasecmp($related->getName(), $model) === 0;
} }
return $related->is($model); return $related->is($model);
@@ -112,7 +120,6 @@ class Collection extends QueryCollection
* Determine if the given string is a valid distinguished name. * Determine if the given string is a valid distinguished name.
* *
* @param string $dn * @param string $dn
*
* @return bool * @return bool
*/ */
protected function isValidDn($dn) protected function isValidDn($dn)
@@ -2,6 +2,7 @@
namespace LdapRecord\Models\Concerns; namespace LdapRecord\Models\Concerns;
/** @mixin \LdapRecord\Models\Model */
trait CanAuthenticate trait CanAuthenticate
{ {
/** /**
@@ -17,7 +18,7 @@ trait CanAuthenticate
/** /**
* Get the unique identifier for the user. * Get the unique identifier for the user.
* *
* @return mixed * @return string
*/ */
public function getAuthIdentifier() public function getAuthIdentifier()
{ {
@@ -48,7 +49,6 @@ trait CanAuthenticate
* Set the token value for the "remember me" session. * Set the token value for the "remember me" session.
* *
* @param string $value * @param string $value
*
* @return void * @return void
*/ */
public function setRememberToken($value) public function setRememberToken($value)
@@ -74,6 +74,18 @@ trait HasAttributes
*/ */
protected static $mutatorCache = []; protected static $mutatorCache = [];
/**
* Convert the model's original attributes to an array.
*
* @return array
*/
public function originalToArray()
{
return $this->encodeAttributes(
$this->convertAttributesForJson($this->original)
);
}
/** /**
* Convert the model's attributes to an array. * Convert the model's attributes to an array.
* *
@@ -111,11 +123,38 @@ trait HasAttributes
return $this->encodeAttributes($attributes); return $this->encodeAttributes($attributes);
} }
/**
* Convert the model's serialized original attributes to their original form.
*
* @param array $attributes
* @return array
*/
public function arrayToOriginal(array $attributes)
{
return $this->decodeAttributes(
$this->convertAttributesFromJson($attributes)
);
}
/**
* Convert the model's serialized attributes to their original form.
*
* @param array $attributes
* @return array
*/
public function arrayToAttributes(array $attributes)
{
$attributes = $this->restoreDateAttributesFromArray($attributes);
return $this->decodeAttributes(
$this->convertAttributesFromJson($attributes)
);
}
/** /**
* Add the date attributes to the attributes array. * Add the date attributes to the attributes array.
* *
* @param array $attributes * @param array $attributes
*
* @return array * @return array
*/ */
protected function addDateAttributesToArray(array $attributes) protected function addDateAttributesToArray(array $attributes)
@@ -135,11 +174,31 @@ trait HasAttributes
return $attributes; return $attributes;
} }
/**
* Restore the date attributes to their true value from serialized attributes.
*
* @param array $attributes
* @return array
*/
protected function restoreDateAttributesFromArray(array $attributes)
{
foreach ($this->getDates() as $attribute => $type) {
if (! isset($attributes[$attribute])) {
continue;
}
$date = $this->fromDateTime($type, $attributes[$attribute]);
$attributes[$attribute] = Arr::wrap($date);
}
return $attributes;
}
/** /**
* Prepare a date for array / JSON serialization. * Prepare a date for array / JSON serialization.
* *
* @param DateTimeInterface $date * @param DateTimeInterface $date
*
* @return string * @return string
*/ */
protected function serializeDate(DateTimeInterface $date) protected function serializeDate(DateTimeInterface $date)
@@ -162,10 +221,24 @@ trait HasAttributes
} }
/** /**
* Encode the given value for proper serialization. * Recursively UTF-8 decode the given attributes.
*
* @param array $attributes
* @return array
*/
public function decodeAttributes($attributes)
{
array_walk_recursive($attributes, function (&$value) {
$value = $this->decodeValue($value);
});
return $attributes;
}
/**
* Encode the value for serialization.
* *
* @param string $value * @param string $value
*
* @return string * @return string
*/ */
protected function encodeValue($value) protected function encodeValue($value)
@@ -173,7 +246,26 @@ trait HasAttributes
// If we are able to detect the encoding, we will // If we are able to detect the encoding, we will
// encode only the attributes that need to be, // encode only the attributes that need to be,
// so that we do not double encode values. // so that we do not double encode values.
return MbString::isLoaded() && MbString::isUtf8($value) ? $value : utf8_encode($value); if (MbString::isLoaded() && MbString::isUtf8($value)) {
return $value;
}
return utf8_encode($value);
}
/**
* Decode the value from serialization.
*
* @param string $value
* @return string
*/
protected function decodeValue($value)
{
if (MbString::isLoaded() && MbString::isUtf8($value)) {
return mb_convert_encoding($value, 'UTF-8', 'ISO-8859-1');
}
return $value;
} }
/** /**
@@ -181,7 +273,6 @@ trait HasAttributes
* *
* @param array $attributes * @param array $attributes
* @param array $mutatedAttributes * @param array $mutatedAttributes
*
* @return array * @return array
*/ */
protected function addMutatedAttributesToArray(array $attributes, array $mutatedAttributes) protected function addMutatedAttributesToArray(array $attributes, array $mutatedAttributes)
@@ -222,7 +313,6 @@ trait HasAttributes
* Fills the entry with the supplied attributes. * Fills the entry with the supplied attributes.
* *
* @param array $attributes * @param array $attributes
*
* @return $this * @return $this
*/ */
public function fill(array $attributes = []) public function fill(array $attributes = [])
@@ -239,7 +329,6 @@ trait HasAttributes
* *
* @param int|string $key * @param int|string $key
* @param mixed $default * @param mixed $default
*
* @return mixed * @return mixed
*/ */
public function getAttribute($key, $default = null) public function getAttribute($key, $default = null)
@@ -256,7 +345,6 @@ trait HasAttributes
* *
* @param string $key * @param string $key
* @param mixed $default * @param mixed $default
*
* @return mixed * @return mixed
*/ */
public function getAttributeValue($key, $default = null) public function getAttributeValue($key, $default = null)
@@ -283,7 +371,6 @@ trait HasAttributes
* Determine if the given attribute is a date. * Determine if the given attribute is a date.
* *
* @param string $key * @param string $key
*
* @return bool * @return bool
*/ */
public function isDateAttribute($key) public function isDateAttribute($key)
@@ -312,7 +399,6 @@ trait HasAttributes
* *
* @param string $type * @param string $type
* @param mixed $value * @param mixed $value
*
* @return float|string * @return float|string
* *
* @throws LdapRecordException * @throws LdapRecordException
@@ -327,7 +413,6 @@ trait HasAttributes
* *
* @param mixed $value * @param mixed $value
* @param string $type * @param string $type
*
* @return Carbon|false * @return Carbon|false
* *
* @throws LdapRecordException * @throws LdapRecordException
@@ -342,7 +427,6 @@ trait HasAttributes
* *
* @param string $key * @param string $key
* @param array|string|null $types * @param array|string|null $types
*
* @return bool * @return bool
*/ */
public function hasCast($key, $types = null) public function hasCast($key, $types = null)
@@ -368,7 +452,6 @@ trait HasAttributes
* Determine whether a value is JSON castable for inbound manipulation. * Determine whether a value is JSON castable for inbound manipulation.
* *
* @param string $key * @param string $key
*
* @return bool * @return bool
*/ */
protected function isJsonCastable($key) protected function isJsonCastable($key)
@@ -380,7 +463,6 @@ trait HasAttributes
* Get the type of cast for a model attribute. * Get the type of cast for a model attribute.
* *
* @param string $key * @param string $key
*
* @return string * @return string
*/ */
protected function getCastType($key) protected function getCastType($key)
@@ -400,7 +482,6 @@ trait HasAttributes
* Determine if the cast is a decimal. * Determine if the cast is a decimal.
* *
* @param string $cast * @param string $cast
*
* @return bool * @return bool
*/ */
protected function isDecimalCast($cast) protected function isDecimalCast($cast)
@@ -412,7 +493,6 @@ trait HasAttributes
* Determine if the cast is a datetime. * Determine if the cast is a datetime.
* *
* @param string $cast * @param string $cast
*
* @return bool * @return bool
*/ */
protected function isDateTimeCast($cast) protected function isDateTimeCast($cast)
@@ -424,7 +504,6 @@ trait HasAttributes
* Determine if the given attribute must be casted. * Determine if the given attribute must be casted.
* *
* @param string $key * @param string $key
*
* @return bool * @return bool
*/ */
protected function isCastedAttribute($key) protected function isCastedAttribute($key)
@@ -437,7 +516,6 @@ trait HasAttributes
* *
* @param string $key * @param string $key
* @param array|null $value * @param array|null $value
*
* @return mixed * @return mixed
*/ */
protected function castAttribute($key, $value) protected function castAttribute($key, $value)
@@ -492,7 +570,6 @@ trait HasAttributes
* *
* @param string $key * @param string $key
* @param mixed $value * @param mixed $value
*
* @return string * @return string
*/ */
protected function castAttributeAsJson($key, $value) protected function castAttributeAsJson($key, $value)
@@ -523,7 +600,6 @@ trait HasAttributes
* Encode the given value as JSON. * Encode the given value as JSON.
* *
* @param mixed $value * @param mixed $value
*
* @return string * @return string
*/ */
protected function asJson($value) protected function asJson($value)
@@ -536,7 +612,6 @@ trait HasAttributes
* *
* @param string $value * @param string $value
* @param bool $asObject * @param bool $asObject
*
* @return mixed * @return mixed
*/ */
public function fromJson($value, $asObject = false) public function fromJson($value, $asObject = false)
@@ -548,7 +623,6 @@ trait HasAttributes
* Decode the given float. * Decode the given float.
* *
* @param mixed $value * @param mixed $value
*
* @return mixed * @return mixed
*/ */
public function fromFloat($value) public function fromFloat($value)
@@ -569,7 +643,6 @@ trait HasAttributes
* Cast the value to a boolean. * Cast the value to a boolean.
* *
* @param mixed $value * @param mixed $value
*
* @return bool * @return bool
*/ */
protected function asBoolean($value) protected function asBoolean($value)
@@ -584,7 +657,6 @@ trait HasAttributes
* *
* @param float $value * @param float $value
* @param int $decimals * @param int $decimals
*
* @return string * @return string
*/ */
protected function asDecimal($value, $decimals) protected function asDecimal($value, $decimals)
@@ -606,7 +678,6 @@ trait HasAttributes
* Get an attribute array of all arrayable values. * Get an attribute array of all arrayable values.
* *
* @param array $values * @param array $values
*
* @return array * @return array
*/ */
protected function getArrayableItems(array $values) protected function getArrayableItems(array $values)
@@ -652,7 +723,6 @@ trait HasAttributes
* Set the date format used by the model for serialization. * Set the date format used by the model for serialization.
* *
* @param string $format * @param string $format
*
* @return $this * @return $this
*/ */
public function setDateFormat($format) public function setDateFormat($format)
@@ -666,7 +736,6 @@ trait HasAttributes
* Get an attribute from the $attributes array. * Get an attribute from the $attributes array.
* *
* @param string $key * @param string $key
*
* @return mixed * @return mixed
*/ */
protected function getAttributeFromArray($key) protected function getAttributeFromArray($key)
@@ -689,7 +758,6 @@ trait HasAttributes
* *
* @param string $key * @param string $key
* @param mixed $default * @param mixed $default
*
* @return mixed * @return mixed
*/ */
public function getFirstAttribute($key, $default = null) public function getFirstAttribute($key, $default = null)
@@ -714,7 +782,6 @@ trait HasAttributes
* *
* @param string $key * @param string $key
* @param mixed $value * @param mixed $value
*
* @return $this * @return $this
*/ */
public function setAttribute($key, $value) public function setAttribute($key, $value)
@@ -745,7 +812,6 @@ trait HasAttributes
* *
* @param string $key * @param string $key
* @param mixed $value * @param mixed $value
*
* @return $this * @return $this
*/ */
public function setRawAttribute($key, $value) public function setRawAttribute($key, $value)
@@ -762,7 +828,6 @@ trait HasAttributes
* *
* @param string $key * @param string $key
* @param mixed $value * @param mixed $value
*
* @return $this * @return $this
*/ */
public function setFirstAttribute($key, $value) public function setFirstAttribute($key, $value)
@@ -775,7 +840,6 @@ trait HasAttributes
* *
* @param string $key * @param string $key
* @param mixed $value * @param mixed $value
*
* @return $this * @return $this
*/ */
public function addAttributeValue($key, $value) public function addAttributeValue($key, $value)
@@ -792,7 +856,6 @@ trait HasAttributes
* Determine if a get mutator exists for an attribute. * Determine if a get mutator exists for an attribute.
* *
* @param string $key * @param string $key
*
* @return bool * @return bool
*/ */
public function hasGetMutator($key) public function hasGetMutator($key)
@@ -804,7 +867,6 @@ trait HasAttributes
* Determine if a set mutator exists for an attribute. * Determine if a set mutator exists for an attribute.
* *
* @param string $key * @param string $key
*
* @return bool * @return bool
*/ */
public function hasSetMutator($key) public function hasSetMutator($key)
@@ -817,7 +879,6 @@ trait HasAttributes
* *
* @param string $key * @param string $key
* @param mixed $value * @param mixed $value
*
* @return mixed * @return mixed
*/ */
protected function setMutatedAttributeValue($key, $value) protected function setMutatedAttributeValue($key, $value)
@@ -830,7 +891,6 @@ trait HasAttributes
* *
* @param string $key * @param string $key
* @param mixed $value * @param mixed $value
*
* @return mixed * @return mixed
*/ */
protected function getMutatedAttributeValue($key, $value) protected function getMutatedAttributeValue($key, $value)
@@ -844,7 +904,6 @@ trait HasAttributes
* Hyphenated attributes will use pascal cased methods. * Hyphenated attributes will use pascal cased methods.
* *
* @param string $key * @param string $key
*
* @return mixed * @return mixed
*/ */
protected function getMutatorMethodName($key) protected function getMutatorMethodName($key)
@@ -859,7 +918,6 @@ trait HasAttributes
* *
* @param string $key * @param string $key
* @param mixed $value * @param mixed $value
*
* @return array * @return array
*/ */
protected function mutateAttributeForArray($key, $value) protected function mutateAttributeForArray($key, $value)
@@ -875,7 +933,6 @@ trait HasAttributes
* Used when constructing an existing LDAP record. * Used when constructing an existing LDAP record.
* *
* @param array $attributes * @param array $attributes
*
* @return $this * @return $this
*/ */
public function setRawAttributes(array $attributes = []) public function setRawAttributes(array $attributes = [])
@@ -917,7 +974,6 @@ trait HasAttributes
* *
* @param array $attributes * @param array $attributes
* @param array $keys * @param array $keys
*
* @return array * @return array
*/ */
public function filterRawAttributes(array $attributes = [], array $keys = ['count', 'dn']) public function filterRawAttributes(array $attributes = [], array $keys = ['count', 'dn'])
@@ -939,7 +995,6 @@ trait HasAttributes
* Determine if the model has the given attribute. * Determine if the model has the given attribute.
* *
* @param int|string $key * @param int|string $key
*
* @return bool * @return bool
*/ */
public function hasAttribute($key) public function hasAttribute($key)
@@ -992,7 +1047,6 @@ trait HasAttributes
* Determine if the given attribute is dirty. * Determine if the given attribute is dirty.
* *
* @param string $key * @param string $key
*
* @return bool * @return bool
*/ */
public function isDirty($key) public function isDirty($key)
@@ -1014,7 +1068,6 @@ trait HasAttributes
* Set the accessors to append to model arrays. * Set the accessors to append to model arrays.
* *
* @param array $appends * @param array $appends
*
* @return $this * @return $this
*/ */
public function setAppends(array $appends) public function setAppends(array $appends)
@@ -1028,7 +1081,6 @@ trait HasAttributes
* Return whether the accessor attribute has been appended. * Return whether the accessor attribute has been appended.
* *
* @param string $attribute * @param string $attribute
*
* @return bool * @return bool
*/ */
public function hasAppended($attribute) public function hasAppended($attribute)
@@ -1040,7 +1092,6 @@ trait HasAttributes
* Returns a normalized attribute key. * Returns a normalized attribute key.
* *
* @param string $key * @param string $key
*
* @return string * @return string
*/ */
public function normalizeAttributeKey($key) public function normalizeAttributeKey($key)
@@ -1057,7 +1108,6 @@ trait HasAttributes
* Determine if the new and old values for a given key are equivalent. * Determine if the new and old values for a given key are equivalent.
* *
* @param string $key * @param string $key
*
* @return bool * @return bool
*/ */
protected function originalIsEquivalent($key) protected function originalIsEquivalent($key)
@@ -1098,7 +1148,6 @@ trait HasAttributes
* Extract and cache all the mutated attributes of a class. * Extract and cache all the mutated attributes of a class.
* *
* @param string $class * @param string $class
*
* @return void * @return void
*/ */
public static function cacheMutatedAttributes($class) public static function cacheMutatedAttributes($class)
@@ -1114,7 +1163,6 @@ trait HasAttributes
* Get all of the attribute mutator methods. * Get all of the attribute mutator methods.
* *
* @param mixed $class * @param mixed $class
*
* @return array * @return array
*/ */
protected static function getMutatorMethods($class) protected static function getMutatorMethods($class)
@@ -4,15 +4,17 @@ namespace LdapRecord\Models\Concerns;
use Closure; use Closure;
use LdapRecord\Events\NullDispatcher; use LdapRecord\Events\NullDispatcher;
use LdapRecord\Models\Events;
use LdapRecord\Models\Events\Event; use LdapRecord\Models\Events\Event;
use LdapRecord\Support\Arr;
/** @mixin \LdapRecord\Models\Model */
trait HasEvents trait HasEvents
{ {
/** /**
* Execute the callback without raising any events. * Execute the callback without raising any events.
* *
* @param Closure $callback * @param Closure $callback
*
* @return mixed * @return mixed
*/ */
protected static function withoutEvents(Closure $callback) protected static function withoutEvents(Closure $callback)
@@ -37,10 +39,37 @@ trait HasEvents
} }
/** /**
* Fires the specified model event. * Dispatch the given model events.
*
* @param string|array $events
* @param array $args
* @return void
*/
protected function dispatch($events, array $args = [])
{
foreach (Arr::wrap($events) as $name) {
$this->fireCustomModelEvent($name, $args);
}
}
/**
* Fire a custom model event.
*
* @param string $name
* @param array $args
* @return mixed
*/
protected function fireCustomModelEvent($name, array $args = [])
{
$event = implode('\\', [Events::class, ucfirst($name)]);
return $this->fireModelEvent(new $event($this, ...$args));
}
/**
* Fire a model event.
* *
* @param Event $event * @param Event $event
*
* @return mixed * @return mixed
*/ */
protected function fireModelEvent(Event $event) protected function fireModelEvent(Event $event)
@@ -49,11 +78,10 @@ trait HasEvents
} }
/** /**
* Listens to a model event. * Listen to a model event.
* *
* @param string $event * @param string $event
* @param Closure $listener * @param Closure $listener
*
* @return mixed * @return mixed
*/ */
protected function listenForModelEvent($event, Closure $listener) protected function listenForModelEvent($event, Closure $listener)
@@ -6,6 +6,7 @@ use Closure;
use InvalidArgumentException; use InvalidArgumentException;
use LdapRecord\Models\Scope; use LdapRecord\Models\Scope;
/** @mixin \LdapRecord\Models\Model */
trait HasGlobalScopes trait HasGlobalScopes
{ {
/** /**
@@ -13,7 +14,6 @@ trait HasGlobalScopes
* *
* @param Scope|Closure|string $scope * @param Scope|Closure|string $scope
* @param Closure|null $implementation * @param Closure|null $implementation
*
* @return mixed * @return mixed
* *
* @throws InvalidArgumentException * @throws InvalidArgumentException
@@ -35,7 +35,6 @@ trait HasGlobalScopes
* Determine if a model has a global scope. * Determine if a model has a global scope.
* *
* @param Scope|string $scope * @param Scope|string $scope
*
* @return bool * @return bool
*/ */
public static function hasGlobalScope($scope) public static function hasGlobalScope($scope)
@@ -47,7 +46,6 @@ trait HasGlobalScopes
* Get a global scope registered with the model. * Get a global scope registered with the model.
* *
* @param Scope|string $scope * @param Scope|string $scope
*
* @return Scope|Closure|null * @return Scope|Closure|null
*/ */
public static function getGlobalScope($scope) public static function getGlobalScope($scope)
@@ -6,6 +6,7 @@ use LdapRecord\ConnectionException;
use LdapRecord\LdapRecordException; use LdapRecord\LdapRecordException;
use LdapRecord\Models\Attributes\Password; use LdapRecord\Models\Attributes\Password;
/** @mixin \LdapRecord\Models\Model */
trait HasPassword trait HasPassword
{ {
/** /**
@@ -109,7 +110,6 @@ trait HasPassword
* @param string $oldPassword * @param string $oldPassword
* @param string $newPassword * @param string $newPassword
* @param string $attribute * @param string $attribute
*
* @return void * @return void
*/ */
protected function setChangedPassword($oldPassword, $newPassword, $attribute) protected function setChangedPassword($oldPassword, $newPassword, $attribute)
@@ -138,7 +138,6 @@ trait HasPassword
* *
* @param string $password * @param string $password
* @param string $attribute * @param string $attribute
*
* @return void * @return void
*/ */
protected function setPassword($password, $attribute) protected function setPassword($password, $attribute)
@@ -158,7 +157,6 @@ trait HasPassword
* @param string $method * @param string $method
* @param string $password * @param string $password
* @param string $salt * @param string $salt
*
* @return string * @return string
* *
* @throws LdapRecordException * @throws LdapRecordException
@@ -204,7 +202,6 @@ trait HasPassword
* Attempt to retrieve the password's salt. * Attempt to retrieve the password's salt.
* *
* @param string $method * @param string $method
*
* @return string|null * @return string|null
*/ */
public function getPasswordSalt($method) public function getPasswordSalt($method)
@@ -5,6 +5,7 @@ namespace LdapRecord\Models\Concerns;
use LdapRecord\Models\Relations\HasMany; use LdapRecord\Models\Relations\HasMany;
use LdapRecord\Models\Relations\HasManyIn; use LdapRecord\Models\Relations\HasManyIn;
use LdapRecord\Models\Relations\HasOne; use LdapRecord\Models\Relations\HasOne;
use LdapRecord\Models\Relations\Relation;
use LdapRecord\Support\Arr; use LdapRecord\Support\Arr;
trait HasRelationships trait HasRelationships
@@ -15,7 +16,6 @@ trait HasRelationships
* @param mixed $related * @param mixed $related
* @param string $relationKey * @param string $relationKey
* @param string $foreignKey * @param string $foreignKey
*
* @return HasOne * @return HasOne
*/ */
public function hasOne($related, $relationKey, $foreignKey = 'dn') public function hasOne($related, $relationKey, $foreignKey = 'dn')
@@ -29,7 +29,6 @@ trait HasRelationships
* @param mixed $related * @param mixed $related
* @param string $relationKey * @param string $relationKey
* @param string $foreignKey * @param string $foreignKey
*
* @return HasMany * @return HasMany
*/ */
public function hasMany($related, $relationKey, $foreignKey = 'dn') public function hasMany($related, $relationKey, $foreignKey = 'dn')
@@ -43,7 +42,6 @@ trait HasRelationships
* @param mixed $related * @param mixed $related
* @param string $relationKey * @param string $relationKey
* @param string $foreignKey * @param string $foreignKey
*
* @return HasManyIn * @return HasManyIn
*/ */
public function hasManyIn($related, $relationKey, $foreignKey = 'dn') public function hasManyIn($related, $relationKey, $foreignKey = 'dn')
@@ -51,6 +49,29 @@ trait HasRelationships
return new HasManyIn($this->newQuery(), $this, $related, $relationKey, $foreignKey, $this->guessRelationshipName()); return new HasManyIn($this->newQuery(), $this, $related, $relationKey, $foreignKey, $this->guessRelationshipName());
} }
/**
* Get a relationship by its name.
*
* @param string $relationName
* @return Relation|null
*/
public function getRelation($relationName)
{
if (! method_exists($this, $relationName)) {
return;
}
if (! $relation = $this->{$relationName}()) {
return;
}
if (! $relation instanceof Relation) {
return;
}
return $relation;
}
/** /**
* Get the relationships name. * Get the relationships name.
* *
@@ -2,6 +2,7 @@
namespace LdapRecord\Models\Concerns; namespace LdapRecord\Models\Concerns;
/** @mixin \LdapRecord\Models\Model */
trait HasScopes trait HasScopes
{ {
/** /**
@@ -6,6 +6,8 @@ namespace LdapRecord\Models\Concerns;
* @author Taylor Otwell * @author Taylor Otwell
* *
* @see https://laravel.com * @see https://laravel.com
*
* @mixin \LdapRecord\Models\Model
*/ */
trait HidesAttributes trait HidesAttributes
{ {
@@ -39,7 +41,6 @@ trait HidesAttributes
* Set the hidden attributes for the model. * Set the hidden attributes for the model.
* *
* @param array $hidden * @param array $hidden
*
* @return $this * @return $this
*/ */
public function setHidden(array $hidden) public function setHidden(array $hidden)
@@ -53,7 +54,6 @@ trait HidesAttributes
* Add hidden attributes for the model. * Add hidden attributes for the model.
* *
* @param array|string|null $attributes * @param array|string|null $attributes
*
* @return void * @return void
*/ */
public function addHidden($attributes = null) public function addHidden($attributes = null)
@@ -80,7 +80,6 @@ trait HidesAttributes
* Set the visible attributes for the model. * Set the visible attributes for the model.
* *
* @param array $visible * @param array $visible
*
* @return $this * @return $this
*/ */
public function setVisible(array $visible) public function setVisible(array $visible)
@@ -94,7 +93,6 @@ trait HidesAttributes
* Add visible attributes for the model. * Add visible attributes for the model.
* *
* @param array|string|null $attributes * @param array|string|null $attributes
*
* @return void * @return void
*/ */
public function addVisible($attributes = null) public function addVisible($attributes = null)
@@ -109,7 +107,6 @@ trait HidesAttributes
* Make the given, typically hidden, attributes visible. * Make the given, typically hidden, attributes visible.
* *
* @param array|string $attributes * @param array|string $attributes
*
* @return $this * @return $this
*/ */
public function makeVisible($attributes) public function makeVisible($attributes)
@@ -127,7 +124,6 @@ trait HidesAttributes
* Make the given, typically visible, attributes hidden. * Make the given, typically visible, attributes hidden.
* *
* @param array|string $attributes * @param array|string $attributes
*
* @return $this * @return $this
*/ */
public function makeHidden($attributes) public function makeHidden($attributes)
@@ -0,0 +1,47 @@
<?php
namespace LdapRecord\Models\Concerns;
/** @mixin HasAttributes */
trait SerializesAndRestoresPropertyValues
{
/**
* Get the property value prepared for serialization.
*
* @param string $property
* @param mixed $value
* @return mixed
*/
protected function getSerializedPropertyValue($property, $value)
{
if ($property === 'original') {
return $this->originalToArray();
}
if ($property === 'attributes') {
return $this->attributesToArray();
}
return $value;
}
/**
* Get the unserialized property value after deserialization.
*
* @param string $property
* @param mixed $value
* @return mixed
*/
protected function getUnserializedPropertyValue($property, $value)
{
if ($property === 'original') {
return $this->arrayToOriginal($value);
}
if ($property === 'attributes') {
return $this->arrayToAttributes($value);
}
return $value;
}
}
@@ -0,0 +1,143 @@
<?php
namespace LdapRecord\Models\Concerns;
use ReflectionClass;
use ReflectionProperty;
trait SerializesProperties
{
use SerializesAndRestoresPropertyValues;
/**
* Prepare the attributes for serialization.
*
* @return array
*/
public function __sleep()
{
$properties = (new ReflectionClass($this))->getProperties();
foreach ($properties as $property) {
$property->setValue($this, $this->getSerializedPropertyValue(
$property->getName(),
$this->getPropertyValue($property)
));
}
return array_values(array_filter(array_map(function ($p) {
return $p->isStatic() ? null : $p->getName();
}, $properties)));
}
/**
* Restore the attributes after serialization.
*
* @return void
*/
public function __wakeup()
{
foreach ((new ReflectionClass($this))->getProperties() as $property) {
if ($property->isStatic()) {
continue;
}
$property->setValue($this, $this->getUnserializedPropertyValue(
$property->getName(),
$this->getPropertyValue($property)
));
}
}
/**
* Prepare the model for serialization.
*
* @return array
*/
public function __serialize()
{
$values = [];
$properties = (new ReflectionClass($this))->getProperties();
$class = get_class($this);
foreach ($properties as $property) {
if ($property->isStatic()) {
continue;
}
$property->setAccessible(true);
if (! $property->isInitialized($this)) {
continue;
}
$name = $property->getName();
if ($property->isPrivate()) {
$name = "\0{$class}\0{$name}";
} elseif ($property->isProtected()) {
$name = "\0*\0{$name}";
}
$values[$name] = $this->getSerializedPropertyValue(
$property->getName(),
$this->getPropertyValue($property)
);
}
return $values;
}
/**
* Restore the model after serialization.
*
* @param array $values
* @return void
*/
public function __unserialize(array $values)
{
$properties = (new ReflectionClass($this))->getProperties();
$class = get_class($this);
foreach ($properties as $property) {
if ($property->isStatic()) {
continue;
}
$name = $property->getName();
if ($property->isPrivate()) {
$name = "\0{$class}\0{$name}";
} elseif ($property->isProtected()) {
$name = "\0*\0{$name}";
}
if (! array_key_exists($name, $values)) {
continue;
}
$property->setAccessible(true);
$property->setValue(
$this,
$this->getUnserializedPropertyValue($property->getName(), $values[$name])
);
}
}
/**
* Get the property value for the given property.
*
* @param ReflectionProperty $property
* @return mixed
*/
protected function getPropertyValue(ReflectionProperty $property)
{
$property->setAccessible(true);
return $property->getValue($this);
}
}
@@ -12,7 +12,6 @@ trait DetectsResetIntegers
* value to an 'unset' or 'cleared' state. * value to an 'unset' or 'cleared' state.
* *
* @param mixed $value * @param mixed $value
*
* @return bool * @return bool
*/ */
protected function valueIsResetInteger($value) protected function valueIsResetInteger($value)
@@ -3,8 +3,9 @@
namespace LdapRecord\Models\DirectoryServer; namespace LdapRecord\Models\DirectoryServer;
use LdapRecord\Models\Model; use LdapRecord\Models\Model;
use LdapRecord\Models\Types\DirectoryServer;
class Entry extends Model class Entry extends Model implements DirectoryServer
{ {
/** /**
* The attribute key that contains the models object GUID. * The attribute key that contains the models object GUID.
@@ -45,7 +45,6 @@ class Entry extends BaseEntry implements FreeIPA
* Create a new query builder. * Create a new query builder.
* *
* @param Connection $connection * @param Connection $connection
*
* @return FreeIpaBuilder * @return FreeIpaBuilder
*/ */
public function newQueryBuilder(Connection $connection) public function newQueryBuilder(Connection $connection)
@@ -13,7 +13,6 @@ class AddEntryUuidToSelects implements Scope
* *
* @param Builder $query * @param Builder $query
* @param Model $model * @param Model $model
*
* @return void * @return void
*/ */
public function apply(Builder $query, Model $model) public function apply(Builder $query, Model $model)
@@ -11,8 +11,6 @@ use LdapRecord\Container;
use LdapRecord\EscapesValues; use LdapRecord\EscapesValues;
use LdapRecord\Models\Attributes\DistinguishedName; use LdapRecord\Models\Attributes\DistinguishedName;
use LdapRecord\Models\Attributes\Guid; use LdapRecord\Models\Attributes\Guid;
use LdapRecord\Models\Events\Renamed;
use LdapRecord\Models\Events\Renaming;
use LdapRecord\Query\Model\Builder; use LdapRecord\Query\Model\Builder;
use LdapRecord\Support\Arr; use LdapRecord\Support\Arr;
use UnexpectedValueException; use UnexpectedValueException;
@@ -27,6 +25,7 @@ abstract class Model implements ArrayAccess, Arrayable, JsonSerializable
use Concerns\HasGlobalScopes; use Concerns\HasGlobalScopes;
use Concerns\HidesAttributes; use Concerns\HidesAttributes;
use Concerns\HasRelationships; use Concerns\HasRelationships;
use Concerns\SerializesProperties;
/** /**
* Indicates if the model exists in the directory. * Indicates if the model exists in the directory.
@@ -165,7 +164,6 @@ abstract class Model implements ArrayAccess, Arrayable, JsonSerializable
* *
* @param string $method * @param string $method
* @param array $parameters * @param array $parameters
*
* @return mixed * @return mixed
*/ */
public function __call($method, $parameters) public function __call($method, $parameters)
@@ -182,7 +180,6 @@ abstract class Model implements ArrayAccess, Arrayable, JsonSerializable
* *
* @param string $method * @param string $method
* @param array $parameters * @param array $parameters
*
* @return mixed * @return mixed
*/ */
public static function __callStatic($method, $parameters) public static function __callStatic($method, $parameters)
@@ -204,7 +201,6 @@ abstract class Model implements ArrayAccess, Arrayable, JsonSerializable
* Set the models distinguished name. * Set the models distinguished name.
* *
* @param string $dn * @param string $dn
*
* @return $this * @return $this
*/ */
public function setDn($dn) public function setDn($dn)
@@ -218,7 +214,6 @@ abstract class Model implements ArrayAccess, Arrayable, JsonSerializable
* A mutator for setting the models distinguished name. * A mutator for setting the models distinguished name.
* *
* @param string $dn * @param string $dn
*
* @return $this * @return $this
*/ */
public function setDnAttribute($dn) public function setDnAttribute($dn)
@@ -230,7 +225,6 @@ abstract class Model implements ArrayAccess, Arrayable, JsonSerializable
* A mutator for setting the models distinguished name. * A mutator for setting the models distinguished name.
* *
* @param string $dn * @param string $dn
*
* @return $this * @return $this
*/ */
public function setDistinguishedNameAttribute($dn) public function setDistinguishedNameAttribute($dn)
@@ -262,7 +256,6 @@ abstract class Model implements ArrayAccess, Arrayable, JsonSerializable
* Set the connection associated with the model. * Set the connection associated with the model.
* *
* @param string $name * @param string $name
*
* @return $this * @return $this
*/ */
public function setConnection($name) public function setConnection($name)
@@ -272,11 +265,21 @@ abstract class Model implements ArrayAccess, Arrayable, JsonSerializable
return $this; return $this;
} }
/**
* Make a new model instance.
*
* @param array $attributes
* @return static
*/
public static function make($attributes = [])
{
return new static($attributes);
}
/** /**
* Begin querying the model on a given connection. * Begin querying the model on a given connection.
* *
* @param string|null $connection * @param string|null $connection
*
* @return Builder * @return Builder
*/ */
public static function on($connection = null) public static function on($connection = null)
@@ -292,7 +295,6 @@ abstract class Model implements ArrayAccess, Arrayable, JsonSerializable
* Get all the models from the directory. * Get all the models from the directory.
* *
* @param array|mixed $attributes * @param array|mixed $attributes
*
* @return Collection|static[] * @return Collection|static[]
*/ */
public static function all($attributes = ['*']) public static function all($attributes = ['*'])
@@ -301,15 +303,45 @@ abstract class Model implements ArrayAccess, Arrayable, JsonSerializable
} }
/** /**
* Make a new model instance. * Get the RootDSE (AD schema) record from the directory.
* *
* @param array $attributes * @param string|null $connection
* @return Model
* *
* @return static * @throws \LdapRecord\Models\ModelNotFoundException
*/ */
public static function make($attributes = []) public static function getRootDse($connection = null)
{ {
return new static($attributes); $model = static::getRootDseModel();
return $model::on($connection ?? (new $model)->getConnectionName())
->in(null)
->read()
->whereHas('objectclass')
->firstOrFail();
}
/**
* Get the root DSE model.
*
* @return class-string<Model>
*/
protected static function getRootDseModel()
{
$instance = (new static);
switch (true) {
case $instance instanceof Types\ActiveDirectory:
return ActiveDirectory\Entry::class;
case $instance instanceof Types\DirectoryServer:
return OpenLDAP\Entry::class;
case $instance instanceof Types\OpenLDAP:
return OpenLDAP\Entry::class;
case $instance instanceof Types\FreeIPA:
return FreeIPA\Entry::class;
default:
return Entry::class;
}
} }
/** /**
@@ -350,7 +382,6 @@ abstract class Model implements ArrayAccess, Arrayable, JsonSerializable
* Create a new query builder. * Create a new query builder.
* *
* @param Connection $connection * @param Connection $connection
*
* @return Builder * @return Builder
*/ */
public function newQueryBuilder(Connection $connection) public function newQueryBuilder(Connection $connection)
@@ -362,7 +393,6 @@ abstract class Model implements ArrayAccess, Arrayable, JsonSerializable
* Create a new model instance. * Create a new model instance.
* *
* @param array $attributes * @param array $attributes
*
* @return static * @return static
*/ */
public function newInstance(array $attributes = []) public function newInstance(array $attributes = [])
@@ -374,7 +404,6 @@ abstract class Model implements ArrayAccess, Arrayable, JsonSerializable
* Resolve a connection instance. * Resolve a connection instance.
* *
* @param string|null $connection * @param string|null $connection
*
* @return Connection * @return Connection
*/ */
public static function resolveConnection($connection = null) public static function resolveConnection($connection = null)
@@ -406,7 +435,6 @@ abstract class Model implements ArrayAccess, Arrayable, JsonSerializable
* Set the connection container. * Set the connection container.
* *
* @param Container $container * @param Container $container
*
* @return void * @return void
*/ */
public static function setConnectionContainer(Container $container) public static function setConnectionContainer(Container $container)
@@ -428,7 +456,6 @@ abstract class Model implements ArrayAccess, Arrayable, JsonSerializable
* Register the query scopes for this builder instance. * Register the query scopes for this builder instance.
* *
* @param Builder $builder * @param Builder $builder
*
* @return Builder * @return Builder
*/ */
public function registerModelScopes($builder) public function registerModelScopes($builder)
@@ -444,7 +471,6 @@ abstract class Model implements ArrayAccess, Arrayable, JsonSerializable
* Register the global model scopes. * Register the global model scopes.
* *
* @param Builder $builder * @param Builder $builder
*
* @return Builder * @return Builder
*/ */
public function registerGlobalScopes($builder) public function registerGlobalScopes($builder)
@@ -460,7 +486,6 @@ abstract class Model implements ArrayAccess, Arrayable, JsonSerializable
* Apply the model object class scopes to the given builder instance. * Apply the model object class scopes to the given builder instance.
* *
* @param Builder $query * @param Builder $query
*
* @return void * @return void
*/ */
public function applyObjectClassScopes(Builder $query) public function applyObjectClassScopes(Builder $query)
@@ -486,7 +511,6 @@ abstract class Model implements ArrayAccess, Arrayable, JsonSerializable
* @param string|null $attribute * @param string|null $attribute
* @param string|int|null $type * @param string|int|null $type
* @param array $values * @param array $values
*
* @return BatchModification * @return BatchModification
*/ */
public function newBatchModification($attribute = null, $type = null, $values = []) public function newBatchModification($attribute = null, $type = null, $values = [])
@@ -498,7 +522,6 @@ abstract class Model implements ArrayAccess, Arrayable, JsonSerializable
* Returns a new collection with the specified items. * Returns a new collection with the specified items.
* *
* @param mixed $items * @param mixed $items
*
* @return Collection * @return Collection
*/ */
public function newCollection($items = []) public function newCollection($items = [])
@@ -509,9 +532,8 @@ abstract class Model implements ArrayAccess, Arrayable, JsonSerializable
/** /**
* Dynamically retrieve attributes on the object. * Dynamically retrieve attributes on the object.
* *
* @param mixed $key * @param string $key
* * @return mixed
* @return bool
*/ */
public function __get($key) public function __get($key)
{ {
@@ -521,9 +543,8 @@ abstract class Model implements ArrayAccess, Arrayable, JsonSerializable
/** /**
* Dynamically set attributes on the object. * Dynamically set attributes on the object.
* *
* @param mixed $key * @param string $key
* @param mixed $value * @param mixed $value
*
* @return $this * @return $this
*/ */
public function __set($key, $value) public function __set($key, $value)
@@ -535,7 +556,6 @@ abstract class Model implements ArrayAccess, Arrayable, JsonSerializable
* Determine if the given offset exists. * Determine if the given offset exists.
* *
* @param string $offset * @param string $offset
*
* @return bool * @return bool
*/ */
#[\ReturnTypeWillChange] #[\ReturnTypeWillChange]
@@ -548,7 +568,6 @@ abstract class Model implements ArrayAccess, Arrayable, JsonSerializable
* Get the value for a given offset. * Get the value for a given offset.
* *
* @param string $offset * @param string $offset
*
* @return mixed * @return mixed
*/ */
#[\ReturnTypeWillChange] #[\ReturnTypeWillChange]
@@ -562,7 +581,6 @@ abstract class Model implements ArrayAccess, Arrayable, JsonSerializable
* *
* @param string $offset * @param string $offset
* @param mixed $value * @param mixed $value
*
* @return void * @return void
*/ */
#[\ReturnTypeWillChange] #[\ReturnTypeWillChange]
@@ -575,7 +593,6 @@ abstract class Model implements ArrayAccess, Arrayable, JsonSerializable
* Unset the value at the given offset. * Unset the value at the given offset.
* *
* @param string $offset * @param string $offset
*
* @return void * @return void
*/ */
#[\ReturnTypeWillChange] #[\ReturnTypeWillChange]
@@ -588,7 +605,6 @@ abstract class Model implements ArrayAccess, Arrayable, JsonSerializable
* Determine if an attribute exists on the model. * Determine if an attribute exists on the model.
* *
* @param string $key * @param string $key
*
* @return bool * @return bool
*/ */
public function __isset($key) public function __isset($key)
@@ -600,7 +616,6 @@ abstract class Model implements ArrayAccess, Arrayable, JsonSerializable
* Unset an attribute on the model. * Unset an attribute on the model.
* *
* @param string $key * @param string $key
*
* @return void * @return void
*/ */
public function __unset($key) public function __unset($key)
@@ -630,26 +645,36 @@ abstract class Model implements ArrayAccess, Arrayable, JsonSerializable
} }
/** /**
* Converts extra attributes for JSON serialization. * Convert the attributes for JSON serialization.
* *
* @param array $attributes * @param array $attributes
*
* @return array * @return array
*/ */
protected function convertAttributesForJson(array $attributes = []) protected function convertAttributesForJson(array $attributes = [])
{ {
// If the model has a GUID set, we need to convert // If the model has a GUID set, we need to convert it to its
// it due to it being in binary. Otherwise we'll // string format, due to it being in binary. Otherwise
// receive a JSON serialization exception. // we will receive a JSON serialization exception.
if ($this->hasAttribute($this->guidKey)) { if (isset($attributes[$this->guidKey])) {
return array_replace($attributes, [ $attributes[$this->guidKey] = [$this->getConvertedGuid(
$this->guidKey => [$this->getConvertedGuid()], Arr::first($attributes[$this->guidKey])
]); )];
} }
return $attributes; return $attributes;
} }
/**
* Convert the attributes from JSON serialization.
*
* @param array $attributes
* @return array
*/
protected function convertAttributesFromJson(array $attributes = [])
{
return $attributes;
}
/** /**
* Reload a fresh model instance from the directory. * Reload a fresh model instance from the directory.
* *
@@ -668,7 +693,6 @@ abstract class Model implements ArrayAccess, Arrayable, JsonSerializable
* Determine if two models have the same distinguished name and belong to the same connection. * Determine if two models have the same distinguished name and belong to the same connection.
* *
* @param Model|null $model * @param Model|null $model
*
* @return bool * @return bool
*/ */
public function is($model) public function is($model)
@@ -682,7 +706,6 @@ abstract class Model implements ArrayAccess, Arrayable, JsonSerializable
* Determine if two models are not the same. * Determine if two models are not the same.
* *
* @param Model|null $model * @param Model|null $model
*
* @return bool * @return bool
*/ */
public function isNot($model) public function isNot($model)
@@ -694,7 +717,6 @@ abstract class Model implements ArrayAccess, Arrayable, JsonSerializable
* Hydrate a new collection of models from search results. * Hydrate a new collection of models from search results.
* *
* @param array $records * @param array $records
*
* @return Collection * @return Collection
*/ */
public function hydrate($records) public function hydrate($records)
@@ -710,7 +732,6 @@ abstract class Model implements ArrayAccess, Arrayable, JsonSerializable
* Converts the current model into the given model. * Converts the current model into the given model.
* *
* @param Model $into * @param Model $into
*
* @return Model * @return Model
*/ */
public function convert(self $into) public function convert(self $into)
@@ -761,7 +782,6 @@ abstract class Model implements ArrayAccess, Arrayable, JsonSerializable
* Set the models batch modifications. * Set the models batch modifications.
* *
* @param array $modifications * @param array $modifications
*
* @return $this * @return $this
*/ */
public function setModifications(array $modifications = []) public function setModifications(array $modifications = [])
@@ -779,7 +799,6 @@ abstract class Model implements ArrayAccess, Arrayable, JsonSerializable
* Adds a batch modification to the model. * Adds a batch modification to the model.
* *
* @param array|BatchModification $mod * @param array|BatchModification $mod
*
* @return $this * @return $this
* *
* @throws InvalidArgumentException * @throws InvalidArgumentException
@@ -825,7 +844,6 @@ abstract class Model implements ArrayAccess, Arrayable, JsonSerializable
* Get the name of the model, or the given DN. * Get the name of the model, or the given DN.
* *
* @param string|null $dn * @param string|null $dn
*
* @return string|null * @return string|null
*/ */
public function getName($dn = null) public function getName($dn = null)
@@ -837,7 +855,6 @@ abstract class Model implements ArrayAccess, Arrayable, JsonSerializable
* Get the head attribute of the model, or the given DN. * Get the head attribute of the model, or the given DN.
* *
* @param string|null $dn * @param string|null $dn
*
* @return string|null * @return string|null
*/ */
public function getHead($dn = null) public function getHead($dn = null)
@@ -849,7 +866,6 @@ abstract class Model implements ArrayAccess, Arrayable, JsonSerializable
* Get the RDN of the model, of the given DN. * Get the RDN of the model, of the given DN.
* *
* @param string|null * @param string|null
*
* @return string|null * @return string|null
*/ */
public function getRdn($dn = null) public function getRdn($dn = null)
@@ -861,7 +877,6 @@ abstract class Model implements ArrayAccess, Arrayable, JsonSerializable
* Get the parent distinguished name of the model, or the given DN. * Get the parent distinguished name of the model, or the given DN.
* *
* @param string|null * @param string|null
*
* @return string|null * @return string|null
*/ */
public function getParentDn($dn = null) public function getParentDn($dn = null)
@@ -873,7 +888,6 @@ abstract class Model implements ArrayAccess, Arrayable, JsonSerializable
* Create a new Distinguished Name object. * Create a new Distinguished Name object.
* *
* @param string|null $dn * @param string|null $dn
*
* @return DistinguishedName * @return DistinguishedName
*/ */
public function newDn($dn = null) public function newDn($dn = null)
@@ -910,28 +924,58 @@ abstract class Model implements ArrayAccess, Arrayable, JsonSerializable
*/ */
public function getObjectClasses() public function getObjectClasses()
{ {
return $this->getAttribute('objectclass') ?: []; return $this->getAttribute('objectclass', static::$objectClasses);
} }
/** /**
* Get the model's string GUID. * Get the model's string GUID.
* *
* @param string|null $guid
* @return string|null * @return string|null
*/ */
public function getConvertedGuid() public function getConvertedGuid($guid = null)
{ {
try { try {
return (string) new Guid($this->getObjectGuid()); return (string) $this->newObjectGuid(
$guid ?? $this->getObjectGuid()
);
} catch (InvalidArgumentException $e) { } catch (InvalidArgumentException $e) {
return; return;
} }
} }
/**
* Get the model's binary GUID.
*
* @param string|null $guid
* @return string|null
*/
public function getBinaryGuid($guid = null)
{
try {
return $this->newObjectGuid(
$guid ?? $this->getObjectGuid()
)->getBinary();
} catch (InvalidArgumentException $e) {
return;
}
}
/**
* Make a new object Guid instance.
*
* @param string $value
* @return Guid
*/
protected function newObjectGuid($value)
{
return new Guid($value);
}
/** /**
* Determine if the current model is a direct descendant of the given. * Determine if the current model is a direct descendant of the given.
* *
* @param static|string $parent * @param static|string $parent
*
* @return bool * @return bool
*/ */
public function isChildOf($parent) public function isChildOf($parent)
@@ -945,7 +989,6 @@ abstract class Model implements ArrayAccess, Arrayable, JsonSerializable
* Determine if the current model is a direct ascendant of the given. * Determine if the current model is a direct ascendant of the given.
* *
* @param static|string $child * @param static|string $child
*
* @return bool * @return bool
*/ */
public function isParentOf($child) public function isParentOf($child)
@@ -959,7 +1002,6 @@ abstract class Model implements ArrayAccess, Arrayable, JsonSerializable
* Determine if the current model is a descendant of the given. * Determine if the current model is a descendant of the given.
* *
* @param static|string $model * @param static|string $model
*
* @return bool * @return bool
*/ */
public function isDescendantOf($model) public function isDescendantOf($model)
@@ -971,7 +1013,6 @@ abstract class Model implements ArrayAccess, Arrayable, JsonSerializable
* Determine if the current model is a ancestor of the given. * Determine if the current model is a ancestor of the given.
* *
* @param static|string $model * @param static|string $model
*
* @return bool * @return bool
*/ */
public function isAncestorOf($model) public function isAncestorOf($model)
@@ -984,7 +1025,6 @@ abstract class Model implements ArrayAccess, Arrayable, JsonSerializable
* *
* @param static|string $dn * @param static|string $dn
* @param static|string $parentDn * @param static|string $parentDn
*
* @return bool * @return bool
*/ */
protected function dnIsInside($dn, $parentDn) protected function dnIsInside($dn, $parentDn)
@@ -998,7 +1038,6 @@ abstract class Model implements ArrayAccess, Arrayable, JsonSerializable
* Set the base DN of where the model should be created in. * Set the base DN of where the model should be created in.
* *
* @param static|string $dn * @param static|string $dn
*
* @return $this * @return $this
*/ */
public function inside($dn) public function inside($dn)
@@ -1012,7 +1051,6 @@ abstract class Model implements ArrayAccess, Arrayable, JsonSerializable
* Save the model to the directory without raising any events. * Save the model to the directory without raising any events.
* *
* @param array $attributes * @param array $attributes
*
* @return void * @return void
* *
* @throws \LdapRecord\LdapRecordException * @throws \LdapRecord\LdapRecordException
@@ -1028,7 +1066,6 @@ abstract class Model implements ArrayAccess, Arrayable, JsonSerializable
* Save the model to the directory. * Save the model to the directory.
* *
* @param array $attributes The attributes to update or create for the current entry. * @param array $attributes The attributes to update or create for the current entry.
*
* @return void * @return void
* *
* @throws \LdapRecord\LdapRecordException * @throws \LdapRecord\LdapRecordException
@@ -1037,11 +1074,13 @@ abstract class Model implements ArrayAccess, Arrayable, JsonSerializable
{ {
$this->fill($attributes); $this->fill($attributes);
$this->fireModelEvent(new Events\Saving($this)); $this->dispatch('saving');
$this->exists ? $this->performUpdate() : $this->performInsert(); $this->exists ? $this->performUpdate() : $this->performInsert();
$this->fireModelEvent(new Events\Saved($this)); $this->dispatch('saved');
$this->modifications = [];
$this->in = null; $this->in = null;
} }
@@ -1071,7 +1110,7 @@ abstract class Model implements ArrayAccess, Arrayable, JsonSerializable
$this->setDn($this->getCreatableDn()); $this->setDn($this->getCreatableDn());
} }
$this->fireModelEvent(new Events\Creating($this)); $this->dispatch('creating');
// Here we perform the insert of new object in the directory, // Here we perform the insert of new object in the directory,
// but filter out any empty attributes before sending them // but filter out any empty attributes before sending them
@@ -1079,7 +1118,7 @@ abstract class Model implements ArrayAccess, Arrayable, JsonSerializable
// attributes have been given empty or null values. // attributes have been given empty or null values.
$query->insert($this->getDn(), array_filter($this->getAttributes())); $query->insert($this->getDn(), array_filter($this->getAttributes()));
$this->fireModelEvent(new Events\Created($this)); $this->dispatch('created');
$this->syncOriginal(); $this->syncOriginal();
@@ -1101,22 +1140,19 @@ abstract class Model implements ArrayAccess, Arrayable, JsonSerializable
return; return;
} }
$this->fireModelEvent(new Events\Updating($this)); $this->dispatch('updating');
$this->newQuery()->update($this->dn, $modifications); $this->newQuery()->update($this->dn, $modifications);
$this->fireModelEvent(new Events\Updated($this)); $this->dispatch('updated');
$this->syncOriginal(); $this->syncOriginal();
$this->modifications = [];
} }
/** /**
* Create the model in the directory. * Create the model in the directory.
* *
* @param array $attributes The attributes for the new entry. * @param array $attributes The attributes for the new entry.
*
* @return Model * @return Model
* *
* @throws \LdapRecord\LdapRecordException * @throws \LdapRecord\LdapRecordException
@@ -1135,7 +1171,6 @@ abstract class Model implements ArrayAccess, Arrayable, JsonSerializable
* *
* @param string $attribute The attribute to create * @param string $attribute The attribute to create
* @param mixed $value The value of the new attribute * @param mixed $value The value of the new attribute
*
* @return void * @return void
* *
* @throws ModelDoesNotExistException * @throws ModelDoesNotExistException
@@ -1143,18 +1178,21 @@ abstract class Model implements ArrayAccess, Arrayable, JsonSerializable
*/ */
public function createAttribute($attribute, $value) public function createAttribute($attribute, $value)
{ {
$this->requireExistence(); $this->assertExists();
$this->dispatch(['saving', 'updating']);
$this->newQuery()->insertAttributes($this->dn, [$attribute => (array) $value]); $this->newQuery()->insertAttributes($this->dn, [$attribute => (array) $value]);
$this->addAttributeValue($attribute, $value); $this->addAttributeValue($attribute, $value);
$this->dispatch(['updated', 'saved']);
} }
/** /**
* Update the model. * Update the model.
* *
* @param array $attributes The attributes to update for the current entry. * @param array $attributes The attributes to update for the current entry.
*
* @return void * @return void
* *
* @throws ModelDoesNotExistException * @throws ModelDoesNotExistException
@@ -1162,7 +1200,7 @@ abstract class Model implements ArrayAccess, Arrayable, JsonSerializable
*/ */
public function update(array $attributes = []) public function update(array $attributes = [])
{ {
$this->requireExistence(); $this->assertExists();
$this->save($attributes); $this->save($attributes);
} }
@@ -1172,7 +1210,6 @@ abstract class Model implements ArrayAccess, Arrayable, JsonSerializable
* *
* @param string $attribute The attribute to modify * @param string $attribute The attribute to modify
* @param mixed $value The new value for the attribute * @param mixed $value The new value for the attribute
*
* @return void * @return void
* *
* @throws ModelDoesNotExistException * @throws ModelDoesNotExistException
@@ -1180,11 +1217,15 @@ abstract class Model implements ArrayAccess, Arrayable, JsonSerializable
*/ */
public function updateAttribute($attribute, $value) public function updateAttribute($attribute, $value)
{ {
$this->requireExistence(); $this->assertExists();
$this->dispatch(['saving', 'updating']);
$this->newQuery()->updateAttributes($this->dn, [$attribute => (array) $value]); $this->newQuery()->updateAttributes($this->dn, [$attribute => (array) $value]);
$this->addAttributeValue($attribute, $value); $this->addAttributeValue($attribute, $value);
$this->dispatch(['updated', 'saved']);
} }
/** /**
@@ -1192,7 +1233,6 @@ abstract class Model implements ArrayAccess, Arrayable, JsonSerializable
* *
* @param Collection|array|string $dns * @param Collection|array|string $dns
* @param bool $recursive * @param bool $recursive
*
* @return int * @return int
* *
* @throws \LdapRecord\LdapRecordException * @throws \LdapRecord\LdapRecordException
@@ -1201,11 +1241,17 @@ abstract class Model implements ArrayAccess, Arrayable, JsonSerializable
{ {
$count = 0; $count = 0;
$dns = is_string($dns) ? (array) $dns : $dns;
$instance = new static(); $instance = new static();
foreach ($dns as $dn) { if ($dns instanceof Collection) {
$dns = $dns->modelDns()->toArray();
}
// Here we are iterating through each distinguished name and locating
// the associated model. While it's more resource intensive, we must
// do this in case of leaf nodes being given alongside any parent
// node, ensuring they can be deleted inside of the directory.
foreach ((array) $dns as $dn) {
if (! $model = $instance->find($dn)) { if (! $model = $instance->find($dn)) {
continue; continue;
} }
@@ -1225,7 +1271,6 @@ abstract class Model implements ArrayAccess, Arrayable, JsonSerializable
* not exist or does not contain a distinguished name. * not exist or does not contain a distinguished name.
* *
* @param bool $recursive Whether to recursively delete leaf nodes (models that are children). * @param bool $recursive Whether to recursively delete leaf nodes (models that are children).
*
* @return void * @return void
* *
* @throws ModelDoesNotExistException * @throws ModelDoesNotExistException
@@ -1233,9 +1278,9 @@ abstract class Model implements ArrayAccess, Arrayable, JsonSerializable
*/ */
public function delete($recursive = false) public function delete($recursive = false)
{ {
$this->requireExistence(); $this->assertExists();
$this->fireModelEvent(new Events\Deleting($this)); $this->dispatch('deleting');
if ($recursive) { if ($recursive) {
$this->deleteLeafNodes(); $this->deleteLeafNodes();
@@ -1248,7 +1293,7 @@ abstract class Model implements ArrayAccess, Arrayable, JsonSerializable
// developers can hook in and run further operations. // developers can hook in and run further operations.
$this->exists = false; $this->exists = false;
$this->fireModelEvent(new Events\Deleted($this)); $this->dispatch('deleted');
} }
/** /**
@@ -1263,8 +1308,8 @@ abstract class Model implements ArrayAccess, Arrayable, JsonSerializable
$this->newQueryWithoutScopes() $this->newQueryWithoutScopes()
->in($this->dn) ->in($this->dn)
->listing() ->listing()
->chunk(250, function ($models) { ->each(function (Model $model) {
$models->each->delete($recursive = true); $model->delete($recursive = true);
}); });
} }
@@ -1280,7 +1325,6 @@ abstract class Model implements ArrayAccess, Arrayable, JsonSerializable
* Delete an entire attribute: * Delete an entire attribute:
* *
* ["memberuid" => []] * ["memberuid" => []]
*
* @return void * @return void
* *
* @throws ModelDoesNotExistException * @throws ModelDoesNotExistException
@@ -1288,10 +1332,12 @@ abstract class Model implements ArrayAccess, Arrayable, JsonSerializable
*/ */
public function deleteAttribute($attributes) public function deleteAttribute($attributes)
{ {
$this->requireExistence(); $this->assertExists();
$attributes = $this->makeDeletableAttributes($attributes); $attributes = $this->makeDeletableAttributes($attributes);
$this->dispatch(['saving', 'updating']);
$this->newQuery()->deleteAttributes($this->dn, $attributes); $this->newQuery()->deleteAttributes($this->dn, $attributes);
foreach ($attributes as $attribute => $value) { foreach ($attributes as $attribute => $value) {
@@ -1311,6 +1357,8 @@ abstract class Model implements ArrayAccess, Arrayable, JsonSerializable
} }
} }
$this->dispatch(['updated', 'saved']);
$this->syncOriginal(); $this->syncOriginal();
} }
@@ -1318,7 +1366,6 @@ abstract class Model implements ArrayAccess, Arrayable, JsonSerializable
* Make a deletable attribute array. * Make a deletable attribute array.
* *
* @param string|array $attributes * @param string|array $attributes
*
* @return array * @return array
*/ */
protected function makeDeletableAttributes($attributes) protected function makeDeletableAttributes($attributes)
@@ -1341,7 +1388,6 @@ abstract class Model implements ArrayAccess, Arrayable, JsonSerializable
* *
* @param static|string $newParentDn The new parent of the current model. * @param static|string $newParentDn The new parent of the current model.
* @param bool $deleteOldRdn Whether to delete the old models relative distinguished name once renamed / moved. * @param bool $deleteOldRdn Whether to delete the old models relative distinguished name once renamed / moved.
*
* @return void * @return void
* *
* @throws UnexpectedValueException * @throws UnexpectedValueException
@@ -1350,7 +1396,7 @@ abstract class Model implements ArrayAccess, Arrayable, JsonSerializable
*/ */
public function move($newParentDn, $deleteOldRdn = true) public function move($newParentDn, $deleteOldRdn = true)
{ {
$this->requireExistence(); $this->assertExists();
if (! $rdn = $this->getRdn()) { if (! $rdn = $this->getRdn()) {
throw new UnexpectedValueException('Current model does not contain an RDN to move.'); throw new UnexpectedValueException('Current model does not contain an RDN to move.');
@@ -1365,7 +1411,6 @@ abstract class Model implements ArrayAccess, Arrayable, JsonSerializable
* @param string $rdn The models new relative distinguished name. Example: "cn=JohnDoe" * @param string $rdn The models new relative distinguished name. Example: "cn=JohnDoe"
* @param static|string|null $newParentDn The models new parent distinguished name (if moving). Leave this null if you are only renaming. Example: "ou=MovedUsers,dc=acme,dc=org" * @param static|string|null $newParentDn The models new parent distinguished name (if moving). Leave this null if you are only renaming. Example: "ou=MovedUsers,dc=acme,dc=org"
* @param bool|true $deleteOldRdn Whether to delete the old models relative distinguished name once renamed / moved. * @param bool|true $deleteOldRdn Whether to delete the old models relative distinguished name once renamed / moved.
*
* @return void * @return void
* *
* @throws ModelDoesNotExistException * @throws ModelDoesNotExistException
@@ -1373,7 +1418,7 @@ abstract class Model implements ArrayAccess, Arrayable, JsonSerializable
*/ */
public function rename($rdn, $newParentDn = null, $deleteOldRdn = true) public function rename($rdn, $newParentDn = null, $deleteOldRdn = true)
{ {
$this->requireExistence(); $this->assertExists();
if ($newParentDn instanceof self) { if ($newParentDn instanceof self) {
$newParentDn = $newParentDn->getDn(); $newParentDn = $newParentDn->getDn();
@@ -1400,7 +1445,7 @@ abstract class Model implements ArrayAccess, Arrayable, JsonSerializable
$rdn = $this->getUpdateableRdn($rdn); $rdn = $this->getUpdateableRdn($rdn);
} }
$this->fireModelEvent(new Renaming($this, $rdn, $newParentDn)); $this->dispatch('renaming', [$rdn, $newParentDn]);
$this->newQuery()->rename($this->dn, $rdn, $newParentDn, $deleteOldRdn); $this->newQuery()->rename($this->dn, $rdn, $newParentDn, $deleteOldRdn);
@@ -1420,7 +1465,7 @@ abstract class Model implements ArrayAccess, Arrayable, JsonSerializable
= $this->original[$modelNameAttribute] = $this->original[$modelNameAttribute]
= [reset($map[$modelNameAttribute])]; = [reset($map[$modelNameAttribute])];
$this->fireModelEvent(new Renamed($this)); $this->dispatch('renamed');
$this->wasRecentlyRenamed = true; $this->wasRecentlyRenamed = true;
} }
@@ -1429,7 +1474,6 @@ abstract class Model implements ArrayAccess, Arrayable, JsonSerializable
* Get an updateable RDN for the model. * Get an updateable RDN for the model.
* *
* @param string $name * @param string $name
*
* @return string * @return string
*/ */
public function getUpdateableRdn($name) public function getUpdateableRdn($name)
@@ -1442,7 +1486,6 @@ abstract class Model implements ArrayAccess, Arrayable, JsonSerializable
* *
* @param string|null $name * @param string|null $name
* @param string|null $attribute * @param string|null $attribute
*
* @return string * @return string
*/ */
public function getCreatableDn($name = null, $attribute = null) public function getCreatableDn($name = null, $attribute = null)
@@ -1458,7 +1501,6 @@ abstract class Model implements ArrayAccess, Arrayable, JsonSerializable
* *
* @param string|null $name * @param string|null $name
* @param string|null $attribute * @param string|null $attribute
*
* @return string * @return string
*/ */
public function getCreatableRdn($name = null, $attribute = null) public function getCreatableRdn($name = null, $attribute = null)
@@ -1486,7 +1528,6 @@ abstract class Model implements ArrayAccess, Arrayable, JsonSerializable
* Determines if the given modification is valid. * Determines if the given modification is valid.
* *
* @param mixed $mod * @param mixed $mod
*
* @return bool * @return bool
*/ */
protected function isValidModification($mod) protected function isValidModification($mod)
@@ -1528,11 +1569,25 @@ abstract class Model implements ArrayAccess, Arrayable, JsonSerializable
/** /**
* Throw an exception if the model does not exist. * Throw an exception if the model does not exist.
* *
* @deprecated
*
* @return void * @return void
* *
* @throws ModelDoesNotExistException * @throws ModelDoesNotExistException
*/ */
protected function requireExistence() protected function requireExistence()
{
return $this->assertExists();
}
/**
* Throw an exception if the model does not exist.
*
* @return void
*
* @throws ModelDoesNotExistException
*/
protected function assertExists()
{ {
if (! $this->exists || is_null($this->dn)) { if (! $this->exists || is_null($this->dn)) {
throw ModelDoesNotExistException::forModel($this); throw ModelDoesNotExistException::forModel($this);
@@ -17,7 +17,6 @@ class ModelDoesNotExistException extends LdapRecordException
* Create a new exception for the given model. * Create a new exception for the given model.
* *
* @param Model $model * @param Model $model
*
* @return ModelDoesNotExistException * @return ModelDoesNotExistException
*/ */
public static function forModel(Model $model) public static function forModel(Model $model)
@@ -29,7 +28,6 @@ class ModelDoesNotExistException extends LdapRecordException
* Set the model that does not exist. * Set the model that does not exist.
* *
* @param Model $model * @param Model $model
*
* @return ModelDoesNotExistException * @return ModelDoesNotExistException
*/ */
public function setModel(Model $model) public function setModel(Model $model)
@@ -35,7 +35,6 @@ class Entry extends BaseEntry implements OpenLDAP
* Create a new query builder. * Create a new query builder.
* *
* @param Connection $connection * @param Connection $connection
*
* @return OpenLdapBuilder * @return OpenLdapBuilder
*/ */
public function newQueryBuilder(Connection $connection) public function newQueryBuilder(Connection $connection)
@@ -13,4 +13,16 @@ class Group extends Entry
'top', 'top',
'groupofuniquenames', 'groupofuniquenames',
]; ];
/**
* The members relationship.
*
* Retrieves members that are apart of the group.
*
* @return \LdapRecord\Models\Relations\HasMany
*/
public function members()
{
return $this->hasMany([static::class, User::class], 'memberUid');
}
} }
@@ -13,7 +13,6 @@ class AddEntryUuidToSelects implements Scope
* *
* @param Builder $query * @param Builder $query
* @param Model $model * @param Model $model
*
* @return void * @return void
*/ */
public function apply(Builder $query, Model $model) public function apply(Builder $query, Model $model)
@@ -40,7 +40,7 @@ class User extends Entry implements Authenticatable
/** /**
* The groups relationship. * The groups relationship.
* *
* Retrieves groups that the user is apart of. * Retrieve groups that the user is a part of.
* *
* @return \LdapRecord\Models\Relations\HasMany * @return \LdapRecord\Models\Relations\HasMany
*/ */
@@ -5,9 +5,9 @@ namespace LdapRecord\Models\Relations;
use Closure; use Closure;
use LdapRecord\DetectsErrors; use LdapRecord\DetectsErrors;
use LdapRecord\LdapRecordException; use LdapRecord\LdapRecordException;
use LdapRecord\Models\Collection;
use LdapRecord\Models\Model; use LdapRecord\Models\Model;
use LdapRecord\Models\ModelNotFoundException; use LdapRecord\Models\ModelNotFoundException;
use LdapRecord\Query\Collection;
class HasMany extends OneToMany class HasMany extends OneToMany
{ {
@@ -53,7 +53,6 @@ class HasMany extends OneToMany
* *
* @param Model $using * @param Model $using
* @param string $usingKey * @param string $usingKey
*
* @return $this * @return $this
*/ */
public function using(Model $using, $usingKey) public function using(Model $using, $usingKey)
@@ -68,7 +67,6 @@ class HasMany extends OneToMany
* Set the pagination page size of the relation query. * Set the pagination page size of the relation query.
* *
* @param int $pageSize * @param int $pageSize
*
* @return $this * @return $this
*/ */
public function setPageSize($pageSize) public function setPageSize($pageSize)
@@ -82,7 +80,6 @@ class HasMany extends OneToMany
* Paginate the relation using the given page size. * Paginate the relation using the given page size.
* *
* @param int $pageSize * @param int $pageSize
*
* @return Collection * @return Collection
*/ */
public function paginate($pageSize = 1000) public function paginate($pageSize = 1000)
@@ -94,7 +91,6 @@ class HasMany extends OneToMany
* Paginate the relation using the page size once. * Paginate the relation using the page size once.
* *
* @param int $pageSize * @param int $pageSize
*
* @return Collection * @return Collection
*/ */
protected function paginateOnceUsing($pageSize) protected function paginateOnceUsing($pageSize)
@@ -108,18 +104,67 @@ class HasMany extends OneToMany
return $result; return $result;
} }
/**
* Execute a callback over each result while chunking.
*
* @param Closure $callback
* @param int $pageSize
* @return bool
*/
public function each(Closure $callback, $pageSize = 1000)
{
$this->chunk($pageSize, function ($results) use ($callback) {
foreach ($results as $key => $value) {
if ($callback($value, $key) === false) {
return false;
}
}
});
}
/** /**
* Chunk the relation results using the given callback. * Chunk the relation results using the given callback.
* *
* @param int $pageSize * @param int $pageSize
* @param Closure $callback * @param Closure $callback
* * @param array $loaded
* @return void * @return bool
*/ */
public function chunk($pageSize, Closure $callback) public function chunk($pageSize, Closure $callback)
{ {
$this->getRelationQuery()->chunk($pageSize, function ($entries) use ($callback) { return $this->chunkRelation($pageSize, $callback);
$callback($this->transformResults($entries)); }
/**
* Execute the callback over chunks of relation results.
*
* @param int $pageSize
* @param Closure $callback
* @param array $loaded
* @return bool
*/
protected function chunkRelation($pageSize, Closure $callback, $loaded = [])
{
return $this->getRelationQuery()->chunk($pageSize, function (Collection $results) use ($pageSize, $callback, $loaded) {
$models = $this->transformResults($results)->when($this->recursive, function (Collection $models) use ($loaded) {
return $models->reject(function (Model $model) use ($loaded) {
return in_array($model->getDn(), $loaded);
});
});
if ($callback($models) === false) {
return false;
}
$models->when($this->recursive, function (Collection $models) use ($pageSize, $callback, $loaded) {
$models->each(function (Model $model) use ($pageSize, $callback, $loaded) {
if ($relation = $model->getRelation($this->relationName)) {
$loaded[] = $model->getDn();
return $relation->recursive()->chunkRelation($pageSize, $callback, $loaded);
}
});
});
}); });
} }
@@ -169,7 +214,6 @@ class HasMany extends OneToMany
* Attach a model to the relation. * Attach a model to the relation.
* *
* @param Model|string $model * @param Model|string $model
*
* @return Model|string|false * @return Model|string|false
*/ */
public function attach($model) public function attach($model)
@@ -185,7 +229,6 @@ class HasMany extends OneToMany
* Build the attach callback. * Build the attach callback.
* *
* @param Model|string $model * @param Model|string $model
*
* @return \Closure * @return \Closure
*/ */
protected function buildAttachCallback($model) protected function buildAttachCallback($model)
@@ -209,7 +252,6 @@ class HasMany extends OneToMany
* Attach a collection of models to the parent instance. * Attach a collection of models to the parent instance.
* *
* @param iterable $models * @param iterable $models
*
* @return iterable * @return iterable
*/ */
public function attachMany($models) public function attachMany($models)
@@ -225,7 +267,6 @@ class HasMany extends OneToMany
* Detach the model from the relation. * Detach the model from the relation.
* *
* @param Model|string $model * @param Model|string $model
*
* @return Model|string|false * @return Model|string|false
*/ */
public function detach($model) public function detach($model)
@@ -237,11 +278,29 @@ class HasMany extends OneToMany
); );
} }
/**
* Detach the model or delete the parent if the relation is empty.
*
* @param Model|string $model
* @return void
*/
public function detachOrDeleteParent($model)
{
$count = $this->onceWithoutMerging(function () {
return $this->count();
});
if ($count <= 1) {
return $this->getParent()->delete();
}
return $this->detach($model);
}
/** /**
* Build the detach callback. * Build the detach callback.
* *
* @param Model|string $model * @param Model|string $model
*
* @return \Closure * @return \Closure
*/ */
protected function buildDetachCallback($model) protected function buildDetachCallback($model)
@@ -265,7 +324,6 @@ class HasMany extends OneToMany
* Get the attachable foreign value from the model. * Get the attachable foreign value from the model.
* *
* @param Model|string $model * @param Model|string $model
*
* @return string * @return string
*/ */
protected function getAttachableForeignValue($model) protected function getAttachableForeignValue($model)
@@ -283,7 +341,6 @@ class HasMany extends OneToMany
* Get the foreign model by the given value, or fail. * Get the foreign model by the given value, or fail.
* *
* @param string $model * @param string $model
*
* @return Model * @return Model
* *
* @throws ModelNotFoundException * @throws ModelNotFoundException
@@ -308,7 +365,6 @@ class HasMany extends OneToMany
* @param callable $operation * @param callable $operation
* @param string|array $bypass * @param string|array $bypass
* @param mixed $value * @param mixed $value
*
* @return mixed * @return mixed
* *
* @throws LdapRecordException * @throws LdapRecordException
@@ -341,4 +397,24 @@ class HasMany extends OneToMany
}); });
}); });
} }
/**
* Detach all relation models or delete the model if its relation is empty.
*
* @return Collection
*/
public function detachAllOrDelete()
{
return $this->onceWithoutMerging(function () {
return $this->get()->each(function (Model $model) {
$relation = $model->getRelation($this->relationName);
if ($relation && $relation->count() >= 1) {
$model->delete();
} else {
$this->detach($model);
}
});
});
}
} }
@@ -26,7 +26,6 @@ class HasOne extends Relation
* Attach a model instance to the parent model. * Attach a model instance to the parent model.
* *
* @param Model|string $model * @param Model|string $model
*
* @return Model|string * @return Model|string
* *
* @throws \LdapRecord\LdapRecordException * @throws \LdapRecord\LdapRecordException
@@ -50,7 +50,6 @@ abstract class OneToMany extends Relation
* Set the relation to load with its parent. * Set the relation to load with its parent.
* *
* @param Relation $relation * @param Relation $relation
*
* @return $this * @return $this
*/ */
public function with(Relation $relation) public function with(Relation $relation)
@@ -64,7 +63,6 @@ abstract class OneToMany extends Relation
* Whether to include recursive results. * Whether to include recursive results.
* *
* @param bool $enable * @param bool $enable
*
* @return $this * @return $this
*/ */
public function recursive($enable = true) public function recursive($enable = true)
@@ -101,7 +99,6 @@ abstract class OneToMany extends Relation
* Execute the callback excluding the merged query result. * Execute the callback excluding the merged query result.
* *
* @param callable $callback * @param callable $callback
*
* @return mixed * @return mixed
*/ */
protected function onceWithoutMerging($callback) protected function onceWithoutMerging($callback)
@@ -143,7 +140,6 @@ abstract class OneToMany extends Relation
* Get the results for the models relation recursively. * Get the results for the models relation recursively.
* *
* @param string[] $loaded The distinguished names of models already loaded * @param string[] $loaded The distinguished names of models already loaded
*
* @return Collection * @return Collection
*/ */
protected function getRecursiveResults(array $loaded = []) protected function getRecursiveResults(array $loaded = [])
@@ -174,13 +170,12 @@ abstract class OneToMany extends Relation
* *
* @param Model $model * @param Model $model
* @param array $loaded * @param array $loaded
*
* @return Collection * @return Collection
*/ */
protected function getRecursiveRelationResults(Model $model, array $loaded) protected function getRecursiveRelationResults(Model $model, array $loaded)
{ {
return method_exists($model, $this->relationName) return ($relation = $model->getRelation($this->relationName))
? $model->{$this->relationName}()->getRecursiveResults($loaded) ? $relation->getRecursiveResults($loaded)
: $model->newCollection(); : $model->newCollection();
} }
} }
@@ -2,6 +2,7 @@
namespace LdapRecord\Models\Relations; namespace LdapRecord\Models\Relations;
use Closure;
use LdapRecord\Models\Entry; use LdapRecord\Models\Entry;
use LdapRecord\Models\Model; use LdapRecord\Models\Model;
use LdapRecord\Query\Collection; use LdapRecord\Query\Collection;
@@ -10,6 +11,7 @@ use LdapRecord\Query\Model\Builder;
/** /**
* @method bool exists($models = null) Determine if the relation contains all of the given models, or any models * @method bool exists($models = null) Determine if the relation contains all of the given models, or any models
* @method bool contains($models) Determine if any of the given models are contained in the relation * @method bool contains($models) Determine if any of the given models are contained in the relation
* @method bool count() Retrieve the "count" result of the query.
*/ */
abstract class Relation abstract class Relation
{ {
@@ -28,7 +30,7 @@ abstract class Relation
protected $parent; protected $parent;
/** /**
* The related models. * The related model class names.
* *
* @var array * @var array
*/ */
@@ -55,12 +57,26 @@ abstract class Relation
*/ */
protected $default = Entry::class; protected $default = Entry::class;
/**
* The callback to use for resolving relation models.
*
* @var Closure
*/
protected static $modelResolver;
/**
* The methods that should be passed along to a relation collection.
*
* @var string[]
*/
protected $passthru = ['count', 'exists', 'contains'];
/** /**
* Constructor. * Constructor.
* *
* @param Builder $query * @param Builder $query
* @param Model $parent * @param Model $parent
* @param mixed $related * @param string|array $related
* @param string $relationKey * @param string $relationKey
* @param string $foreignKey * @param string $foreignKey
*/ */
@@ -72,6 +88,10 @@ abstract class Relation
$this->relationKey = $relationKey; $this->relationKey = $relationKey;
$this->foreignKey = $foreignKey; $this->foreignKey = $foreignKey;
static::$modelResolver = static::$modelResolver ?? function (array $modelObjectClasses, array $relationMap) {
return array_search($modelObjectClasses, $relationMap);
};
$this->initRelation(); $this->initRelation();
} }
@@ -80,12 +100,11 @@ abstract class Relation
* *
* @param string $method * @param string $method
* @param array $parameters * @param array $parameters
*
* @return mixed * @return mixed
*/ */
public function __call($method, $parameters) public function __call($method, $parameters)
{ {
if (in_array($method, ['exists', 'contains'])) { if (in_array($method, $this->passthru)) {
return $this->get('objectclass')->$method(...$parameters); return $this->get('objectclass')->$method(...$parameters);
} }
@@ -98,6 +117,45 @@ abstract class Relation
return $result; return $result;
} }
/**
* Set the callback to use for resolving models from relation results.
*
* @param Closure $callback
* @return void
*/
public static function resolveModelsUsing(Closure $callback)
{
static::$modelResolver = $callback;
}
/**
* Only return objects matching the related model's object classes.
*
* @return $this
*/
public function onlyRelated()
{
$relations = [];
foreach ($this->related as $related) {
$relations[$related] = $related::$objectClasses;
}
$relations = array_filter($relations);
if (empty($relations)) {
return $this;
}
$this->query->andFilter(function (Builder $query) use ($relations) {
foreach ($relations as $relation => $objectClasses) {
$query->whereIn('objectclass', $objectClasses);
}
});
return $this;
}
/** /**
* Get the results of the relationship. * Get the results of the relationship.
* *
@@ -109,7 +167,6 @@ abstract class Relation
* Execute the relationship query. * Execute the relationship query.
* *
* @param array|string $columns * @param array|string $columns
*
* @return Collection * @return Collection
*/ */
public function get($columns = ['*']) public function get($columns = ['*'])
@@ -123,7 +180,6 @@ abstract class Relation
* If the query columns are empty, the given columns are applied. * If the query columns are empty, the given columns are applied.
* *
* @param array $columns * @param array $columns
*
* @return Collection * @return Collection
*/ */
protected function getResultsWithColumns($columns) protected function getResultsWithColumns($columns)
@@ -139,7 +195,6 @@ abstract class Relation
* Get the first result of the relationship. * Get the first result of the relationship.
* *
* @param array|string $columns * @param array|string $columns
*
* @return Model|null * @return Model|null
*/ */
public function first($columns = ['*']) public function first($columns = ['*'])
@@ -162,6 +217,21 @@ abstract class Relation
return $this; return $this;
} }
/**
* Set the underlying query for the relation.
*
* @param Builder $query
* @return $this
*/
public function setQuery(Builder $query)
{
$this->query = $query;
$this->initRelation();
return $this;
}
/** /**
* Get the underlying query for the relation. * Get the underlying query for the relation.
* *
@@ -240,7 +310,6 @@ abstract class Relation
* Get the foreign model by the given value. * Get the foreign model by the given value.
* *
* @param string $value * @param string $value
*
* @return Model|null * @return Model|null
*/ */
protected function getForeignModelByValue($value) protected function getForeignModelByValue($value)
@@ -254,7 +323,6 @@ abstract class Relation
* Returns the escaped foreign key value for use in an LDAP filter from the model. * Returns the escaped foreign key value for use in an LDAP filter from the model.
* *
* @param Model $model * @param Model $model
*
* @return string * @return string
*/ */
protected function getEscapedForeignValueFromModel(Model $model) protected function getEscapedForeignValueFromModel(Model $model)
@@ -278,7 +346,6 @@ abstract class Relation
* Get the foreign key value from the model. * Get the foreign key value from the model.
* *
* @param Model $model * @param Model $model
*
* @return string * @return string
*/ */
protected function getForeignValueFromModel(Model $model) protected function getForeignValueFromModel(Model $model)
@@ -293,7 +360,6 @@ abstract class Relation
* *
* @param Model $model * @param Model $model
* @param string $attribute * @param string $attribute
*
* @return string|null * @return string|null
*/ */
protected function getFirstAttributeValue(Model $model, $attribute) protected function getFirstAttributeValue(Model $model, $attribute)
@@ -305,19 +371,20 @@ abstract class Relation
* Transforms the results by converting the models into their related. * Transforms the results by converting the models into their related.
* *
* @param Collection $results * @param Collection $results
*
* @return Collection * @return Collection
*/ */
protected function transformResults(Collection $results) protected function transformResults(Collection $results)
{ {
$related = []; $relationMap = [];
foreach ($this->related as $relation) { foreach ($this->related as $relation) {
$related[$relation] = $relation::$objectClasses; $relationMap[$relation] = $this->normalizeObjectClasses(
$relation::$objectClasses
);
} }
return $results->transform(function (Model $entry) use ($related) { return $results->transform(function (Model $entry) use ($relationMap) {
$model = $this->determineModelFromRelated($entry, $related); $model = $this->determineModelFromRelated($entry, $relationMap);
return class_exists($model) ? $entry->convert(new $model()) : $entry; return class_exists($model) ? $entry->convert(new $model()) : $entry;
}); });
@@ -334,21 +401,26 @@ abstract class Relation
} }
/** /**
* Determines the model from the given relations. * Determines the model from the given relation map.
* *
* @param Model $model * @param Model $model
* @param array $related * @param array $relationMap
* * @return class-string|bool
* @return string|bool
*/ */
protected function determineModelFromRelated(Model $model, array $related) protected function determineModelFromRelated(Model $model, array $relationMap)
{ {
// We must normalize all the related models object class // We must normalize all the related models object class
// names to the same case so we are able to properly // names to the same case so we are able to properly
// determine the owning model from search results. // determine the owning model from search results.
return array_search( $modelObjectClasses = $this->normalizeObjectClasses(
$this->normalizeObjectClasses($model->getObjectClasses()), $model->getObjectClasses()
array_map([$this, 'normalizeObjectClasses'], $related) );
return call_user_func(
static::$modelResolver,
$modelObjectClasses,
$relationMap,
$model,
); );
} }
@@ -356,7 +428,6 @@ abstract class Relation
* Sort and normalize the object classes. * Sort and normalize the object classes.
* *
* @param array $classes * @param array $classes
*
* @return array * @return array
*/ */
protected function normalizeObjectClasses($classes) protected function normalizeObjectClasses($classes)
@@ -11,7 +11,6 @@ interface Scope
* *
* @param Builder $query * @param Builder $query
* @param Model $model * @param Model $model
*
* @return void * @return void
*/ */
public function apply(Builder $query, Model $model); public function apply(Builder $query, Model $model);
@@ -23,7 +23,16 @@ interface ActiveDirectory extends TypeInterface
/** /**
* Returns the model's SID. * Returns the model's SID.
* *
* @param string|null $sid
* @return string|null * @return string|null
*/ */
public function getConvertedSid(); public function getConvertedSid($sid = null);
/**
* Returns the model's binary SID.
*
* @param string|null $sid
* @return string|null
*/
public function getBinarySid($sid = null);
} }
@@ -0,0 +1,8 @@
<?php
namespace LdapRecord\Models\Types;
interface DirectoryServer extends TypeInterface
{
//
}
@@ -54,7 +54,6 @@ class ArrayCacheStore implements CacheInterface
* Get the expiration time of the key. * Get the expiration time of the key.
* *
* @param int $seconds * @param int $seconds
*
* @return int * @return int
*/ */
protected function calculateExpiration($seconds) protected function calculateExpiration($seconds)
@@ -66,7 +65,6 @@ class ArrayCacheStore implements CacheInterface
* Get the UNIX timestamp for the given number of seconds. * Get the UNIX timestamp for the given number of seconds.
* *
* @param int $seconds * @param int $seconds
*
* @return int * @return int
*/ */
protected function toTimestamp($seconds) protected function toTimestamp($seconds)
@@ -20,7 +20,6 @@ use LdapRecord\Query\Pagination\Paginator;
use LdapRecord\Support\Arr; use LdapRecord\Support\Arr;
use LdapRecord\Utilities; use LdapRecord\Utilities;
/** @psalm-suppress UndefinedClass */
class Builder class Builder
{ {
use EscapesValues; use EscapesValues;
@@ -156,7 +155,6 @@ class Builder
* Set the current connection. * Set the current connection.
* *
* @param Connection $connection * @param Connection $connection
*
* @return $this * @return $this
*/ */
public function setConnection(Connection $connection) public function setConnection(Connection $connection)
@@ -170,7 +168,6 @@ class Builder
* Set the current filter grammar. * Set the current filter grammar.
* *
* @param Grammar $grammar * @param Grammar $grammar
*
* @return $this * @return $this
*/ */
public function setGrammar(Grammar $grammar) public function setGrammar(Grammar $grammar)
@@ -184,7 +181,6 @@ class Builder
* Set the cache to store query results. * Set the cache to store query results.
* *
* @param Cache|null $cache * @param Cache|null $cache
*
* @return $this * @return $this
*/ */
public function setCache(Cache $cache = null) public function setCache(Cache $cache = null)
@@ -198,7 +194,6 @@ class Builder
* Returns a new Query Builder instance. * Returns a new Query Builder instance.
* *
* @param string $baseDn * @param string $baseDn
*
* @return $this * @return $this
*/ */
public function newInstance($baseDn = null) public function newInstance($baseDn = null)
@@ -214,7 +209,6 @@ class Builder
* Returns a new nested Query Builder instance. * Returns a new nested Query Builder instance.
* *
* @param Closure|null $closure * @param Closure|null $closure
*
* @return $this * @return $this
*/ */
public function newNestedInstance(Closure $closure = null) public function newNestedInstance(Closure $closure = null)
@@ -232,7 +226,6 @@ class Builder
* Executes the LDAP query. * Executes the LDAP query.
* *
* @param string|array $columns * @param string|array $columns
*
* @return Collection|array * @return Collection|array
*/ */
public function get($columns = ['*']) public function get($columns = ['*'])
@@ -249,7 +242,6 @@ class Builder
* *
* @param array $columns * @param array $columns
* @param Closure $callback * @param Closure $callback
*
* @return mixed * @return mixed
*/ */
protected function onceWithColumns($columns, Closure $callback) protected function onceWithColumns($columns, Closure $callback)
@@ -337,7 +329,6 @@ class Builder
* Set the base distinguished name of the query. * Set the base distinguished name of the query.
* *
* @param Model|string $dn * @param Model|string $dn
*
* @return $this * @return $this
*/ */
public function setBaseDn($dn) public function setBaseDn($dn)
@@ -371,7 +362,6 @@ class Builder
* Set the distinguished name for the query. * Set the distinguished name for the query.
* *
* @param string|Model|null $dn * @param string|Model|null $dn
*
* @return $this * @return $this
*/ */
public function setDn($dn = null) public function setDn($dn = null)
@@ -385,7 +375,6 @@ class Builder
* Substitute the base DN string template for the current base. * Substitute the base DN string template for the current base.
* *
* @param Model|string $dn * @param Model|string $dn
*
* @return string * @return string
*/ */
protected function substituteBaseInDn($dn) protected function substituteBaseInDn($dn)
@@ -401,7 +390,6 @@ class Builder
* Alias for setting the distinguished name for the query. * Alias for setting the distinguished name for the query.
* *
* @param string|Model|null $dn * @param string|Model|null $dn
*
* @return $this * @return $this
*/ */
public function in($dn = null) public function in($dn = null)
@@ -413,7 +401,6 @@ class Builder
* Set the size limit of the current query. * Set the size limit of the current query.
* *
* @param int $limit * @param int $limit
*
* @return $this * @return $this
*/ */
public function limit($limit = 0) public function limit($limit = 0)
@@ -427,7 +414,6 @@ class Builder
* Returns a new query for the given model. * Returns a new query for the given model.
* *
* @param Model $model * @param Model $model
*
* @return ModelBuilder * @return ModelBuilder
*/ */
public function model(Model $model) public function model(Model $model)
@@ -442,7 +428,6 @@ class Builder
* Performs the specified query on the current LDAP connection. * Performs the specified query on the current LDAP connection.
* *
* @param string $query * @param string $query
*
* @return Collection|array * @return Collection|array
*/ */
public function query($query) public function query($query)
@@ -468,7 +453,6 @@ class Builder
* *
* @param int $pageSize * @param int $pageSize
* @param bool $isCritical * @param bool $isCritical
*
* @return Collection|array * @return Collection|array
*/ */
public function paginate($pageSize = 1000, $isCritical = false) public function paginate($pageSize = 1000, $isCritical = false)
@@ -499,7 +483,6 @@ class Builder
* @param string $filter * @param string $filter
* @param int $perPage * @param int $perPage
* @param bool $isCritical * @param bool $isCritical
*
* @return array * @return array
*/ */
protected function runPaginate($filter, $perPage, $isCritical) protected function runPaginate($filter, $perPage, $isCritical)
@@ -513,19 +496,20 @@ class Builder
* Execute a callback over each item while chunking. * Execute a callback over each item while chunking.
* *
* @param Closure $callback * @param Closure $callback
* @param int $count * @param int $pageSize
* * @param bool $isCritical
* @param bool $isolate
* @return bool * @return bool
*/ */
public function each(Closure $callback, $count = 1000) public function each(Closure $callback, $pageSize = 1000, $isCritical = false, $isolate = false)
{ {
return $this->chunk($count, function ($results) use ($callback) { return $this->chunk($pageSize, function ($results) use ($callback) {
foreach ($results as $key => $value) { foreach ($results as $key => $value) {
if ($callback($value, $key) === false) { if ($callback($value, $key) === false) {
return false; return false;
} }
} }
}); }, $isCritical, $isolate);
} }
/** /**
@@ -534,24 +518,28 @@ class Builder
* @param int $pageSize * @param int $pageSize
* @param Closure $callback * @param Closure $callback
* @param bool $isCritical * @param bool $isCritical
* * @param bool $isolate
* @return bool * @return bool
*/ */
public function chunk($pageSize, Closure $callback, $isCritical = false) public function chunk($pageSize, Closure $callback, $isCritical = false, $isolate = false)
{ {
$start = microtime(true); $start = microtime(true);
$query = $this->getQuery(); $chunk = function (Builder $query) use ($pageSize, $callback, $isCritical) {
$page = 1; $page = 1;
foreach ($this->runChunk($query, $pageSize, $isCritical) as $chunk) { foreach ($query->runChunk($this->getQuery(), $pageSize, $isCritical) as $chunk) {
if ($callback($this->process($chunk), $page) === false) { if ($callback($this->process($chunk), $page) === false) {
return false; return false;
} }
$page++; $page++;
} }
};
$isolate ? $this->connection->isolate(function (Connection $replicate) use ($chunk) {
$chunk($this->clone()->setConnection($replicate));
}) : $chunk($this);
$this->logQuery($this, 'chunk', $this->getElapsedTime($start)); $this->logQuery($this, 'chunk', $this->getElapsedTime($start));
@@ -564,8 +552,7 @@ class Builder
* @param string $filter * @param string $filter
* @param int $perPage * @param int $perPage
* @param bool $isCritical * @param bool $isCritical
* * @return \Generator
* @return array
*/ */
protected function runChunk($filter, $perPage, $isCritical) protected function runChunk($filter, $perPage, $isCritical)
{ {
@@ -574,11 +561,61 @@ class Builder
}); });
} }
/**
* Create a slice of the LDAP query into a page.
*
* @param int $page
* @param int $perPage
* @param string $orderBy
* @param string $orderByDir
* @return Slice
*/
public function slice($page = 1, $perPage = 100, $orderBy = 'cn', $orderByDir = 'asc')
{
$results = $this->forPage($page, $perPage, $orderBy, $orderByDir);
$total = $this->controlsResponse[LDAP_CONTROL_VLVRESPONSE]['value']['count'] ?? 0;
// Some LDAP servers seem to have an issue where the last result in a virtual
// list view will always be returned, regardless of the offset being larger
// than the result itself. In this case, we will manually return an empty
// response so that no objects are deceivingly included in the slice.
$objects = $page > max((int) ceil($total / $perPage), 1)
? ($this instanceof ModelBuilder ? $this->model->newCollection() : [])
: $results;
return new Slice($objects, $total, $perPage, $page);
}
/**
* Get the results of a query for a given page.
*
* @param int $page
* @param int $perPage
* @param string $orderBy
* @param string $orderByDir
* @return Collection|array
*/
public function forPage($page = 1, $perPage = 100, $orderBy = 'cn', $orderByDir = 'asc')
{
if (! $this->hasOrderBy()) {
$this->orderBy($orderBy, $orderByDir);
}
$this->addControl(LDAP_CONTROL_VLVREQUEST, true, [
'before' => 0,
'after' => $perPage - 1,
'offset' => ($page * $perPage) - $perPage + 1,
'count' => 0,
]);
return $this->get();
}
/** /**
* Processes and converts the given LDAP results into models. * Processes and converts the given LDAP results into models.
* *
* @param array $results * @param array $results
*
* @return array * @return array
*/ */
protected function process(array $results) protected function process(array $results)
@@ -596,7 +633,6 @@ class Builder
* Flattens LDAP paged results into a single array. * Flattens LDAP paged results into a single array.
* *
* @param array $pages * @param array $pages
*
* @return array * @return array
*/ */
protected function flattenPages(array $pages) protected function flattenPages(array $pages)
@@ -617,7 +653,6 @@ class Builder
* *
* @param string $query * @param string $query
* @param Closure $callback * @param Closure $callback
*
* @return mixed * @return mixed
*/ */
protected function getCachedResponse($query, Closure $callback) protected function getCachedResponse($query, Closure $callback)
@@ -639,7 +674,6 @@ class Builder
* Runs the query operation with the given filter. * Runs the query operation with the given filter.
* *
* @param string $filter * @param string $filter
*
* @return resource * @return resource
*/ */
public function run($filter) public function run($filter)
@@ -669,7 +703,6 @@ class Builder
* Parses the given LDAP resource by retrieving its entries. * Parses the given LDAP resource by retrieving its entries.
* *
* @param resource $resource * @param resource $resource
*
* @return array * @return array
*/ */
public function parse($resource) public function parse($resource)
@@ -709,12 +742,13 @@ class Builder
* Returns the cache key. * Returns the cache key.
* *
* @param string $query * @param string $query
*
* @return string * @return string
*/ */
protected function getCacheKey($query) protected function getCacheKey($query)
{ {
$host = $this->connection->getLdapConnection()->getHost(); $host = $this->connection->run(function (LdapInterface $ldap) {
return $ldap->getHost();
});
$key = $host $key = $host
.$this->type .$this->type
@@ -731,7 +765,6 @@ class Builder
* Returns the first entry in a search result. * Returns the first entry in a search result.
* *
* @param array|string $columns * @param array|string $columns
*
* @return Model|null * @return Model|null
*/ */
public function first($columns = ['*']) public function first($columns = ['*'])
@@ -747,7 +780,6 @@ class Builder
* If no entry is found, an exception is thrown. * If no entry is found, an exception is thrown.
* *
* @param array|string $columns * @param array|string $columns
*
* @return Model|array * @return Model|array
* *
* @throws ObjectNotFoundException * @throws ObjectNotFoundException
@@ -765,7 +797,6 @@ class Builder
* Return the first entry in a result, or execute the callback. * Return the first entry in a result, or execute the callback.
* *
* @param Closure $callback * @param Closure $callback
*
* @return Model|mixed * @return Model|mixed
*/ */
public function firstOr(Closure $callback) public function firstOr(Closure $callback)
@@ -777,7 +808,6 @@ class Builder
* Execute the query and get the first result if it's the sole matching record. * Execute the query and get the first result if it's the sole matching record.
* *
* @param array|string $columns * @param array|string $columns
*
* @return Model|array * @return Model|array
* *
* @throws ObjectsNotFoundException * @throws ObjectsNotFoundException
@@ -822,7 +852,6 @@ class Builder
* Execute the given callback if no rows exist for the current query. * Execute the given callback if no rows exist for the current query.
* *
* @param Closure $callback * @param Closure $callback
*
* @return bool|mixed * @return bool|mixed
*/ */
public function existsOr(Closure $callback) public function existsOr(Closure $callback)
@@ -849,7 +878,6 @@ class Builder
* @param string $attribute * @param string $attribute
* @param string $value * @param string $value
* @param array|string $columns * @param array|string $columns
*
* @return Model|static|null * @return Model|static|null
*/ */
public function findBy($attribute, $value, $columns = ['*']) public function findBy($attribute, $value, $columns = ['*'])
@@ -869,7 +897,6 @@ class Builder
* @param string $attribute * @param string $attribute
* @param string $value * @param string $value
* @param array|string $columns * @param array|string $columns
*
* @return Model * @return Model
* *
* @throws ObjectNotFoundException * @throws ObjectNotFoundException
@@ -882,9 +909,8 @@ class Builder
/** /**
* Find many records by distinguished name. * Find many records by distinguished name.
* *
* @param array $dns * @param string|array $dns
* @param array $columns * @param array $columns
*
* @return array|Collection * @return array|Collection
*/ */
public function findMany($dns, $columns = ['*']) public function findMany($dns, $columns = ['*'])
@@ -895,7 +921,7 @@ class Builder
$objects = []; $objects = [];
foreach ($dns as $dn) { foreach ((array) $dns as $dn) {
if (! is_null($object = $this->find($dn, $columns))) { if (! is_null($object = $this->find($dn, $columns))) {
$objects[] = $object; $objects[] = $object;
} }
@@ -910,7 +936,6 @@ class Builder
* @param string $attribute * @param string $attribute
* @param array $values * @param array $values
* @param array $columns * @param array $columns
*
* @return Collection * @return Collection
*/ */
public function findManyBy($attribute, array $values = [], $columns = ['*']) public function findManyBy($attribute, array $values = [], $columns = ['*'])
@@ -929,7 +954,6 @@ class Builder
* *
* @param string|array $dn * @param string|array $dn
* @param array|string $columns * @param array|string $columns
*
* @return Model|static|array|Collection|null * @return Model|static|array|Collection|null
*/ */
public function find($dn, $columns = ['*']) public function find($dn, $columns = ['*'])
@@ -952,7 +976,6 @@ class Builder
* *
* @param string $dn * @param string $dn
* @param array|string $columns * @param array|string $columns
*
* @return Model|static * @return Model|static
* *
* @throws ObjectNotFoundException * @throws ObjectNotFoundException
@@ -969,7 +992,6 @@ class Builder
* Adds the inserted fields to query on the current LDAP connection. * Adds the inserted fields to query on the current LDAP connection.
* *
* @param array|string $columns * @param array|string $columns
*
* @return $this * @return $this
*/ */
public function select($columns = ['*']) public function select($columns = ['*'])
@@ -987,7 +1009,6 @@ class Builder
* Add a new select column to the query. * Add a new select column to the query.
* *
* @param array|mixed $column * @param array|mixed $column
*
* @return $this * @return $this
*/ */
public function addSelect($column) public function addSelect($column)
@@ -1004,7 +1025,6 @@ class Builder
* *
* @param string $attribute * @param string $attribute
* @param string $direction * @param string $direction
*
* @return $this * @return $this
*/ */
public function orderBy($attribute, $direction = 'asc') public function orderBy($attribute, $direction = 'asc')
@@ -1018,7 +1038,6 @@ class Builder
* Add an order by descending control to the query. * Add an order by descending control to the query.
* *
* @param string $attribute * @param string $attribute
*
* @return $this * @return $this
*/ */
public function orderByDesc($attribute) public function orderByDesc($attribute)
@@ -1026,11 +1045,20 @@ class Builder
return $this->orderBy($attribute, 'desc'); return $this->orderBy($attribute, 'desc');
} }
/**
* Determine if the query has a sotr request control header.
*
* @return bool
*/
public function hasOrderBy()
{
return $this->hasControl(LDAP_CONTROL_SORTREQUEST);
}
/** /**
* Adds a raw filter to the current query. * Adds a raw filter to the current query.
* *
* @param array|string $filters * @param array|string $filters
*
* @return $this * @return $this
*/ */
public function rawFilter($filters = []) public function rawFilter($filters = [])
@@ -1048,7 +1076,6 @@ class Builder
* Adds a nested 'and' filter to the current query. * Adds a nested 'and' filter to the current query.
* *
* @param Closure $closure * @param Closure $closure
*
* @return $this * @return $this
*/ */
public function andFilter(Closure $closure) public function andFilter(Closure $closure)
@@ -1064,7 +1091,6 @@ class Builder
* Adds a nested 'or' filter to the current query. * Adds a nested 'or' filter to the current query.
* *
* @param Closure $closure * @param Closure $closure
*
* @return $this * @return $this
*/ */
public function orFilter(Closure $closure) public function orFilter(Closure $closure)
@@ -1080,7 +1106,6 @@ class Builder
* Adds a nested 'not' filter to the current query. * Adds a nested 'not' filter to the current query.
* *
* @param Closure $closure * @param Closure $closure
*
* @return $this * @return $this
*/ */
public function notFilter(Closure $closure) public function notFilter(Closure $closure)
@@ -1100,7 +1125,6 @@ class Builder
* @param string $value * @param string $value
* @param string $boolean * @param string $boolean
* @param bool $raw * @param bool $raw
*
* @return $this * @return $this
* *
* @throws InvalidArgumentException * @throws InvalidArgumentException
@@ -1141,7 +1165,6 @@ class Builder
* @param string $field * @param string $field
* @param string $value * @param string $value
* @param bool $raw * @param bool $raw
*
* @return string * @return string
*/ */
protected function prepareWhereValue($field, $value, $raw = false) protected function prepareWhereValue($field, $value, $raw = false)
@@ -1157,7 +1180,6 @@ class Builder
* @param string|array $field * @param string|array $field
* @param string $operator * @param string $operator
* @param string $value * @param string $value
*
* @return $this * @return $this
*/ */
public function whereRaw($field, $operator = null, $value = null) public function whereRaw($field, $operator = null, $value = null)
@@ -1170,7 +1192,6 @@ class Builder
* *
* @param string $field * @param string $field
* @param string $value * @param string $value
*
* @return $this * @return $this
*/ */
public function whereEquals($field, $value) public function whereEquals($field, $value)
@@ -1183,7 +1204,6 @@ class Builder
* *
* @param string $field * @param string $field
* @param string $value * @param string $value
*
* @return $this * @return $this
*/ */
public function whereNotEquals($field, $value) public function whereNotEquals($field, $value)
@@ -1196,7 +1216,6 @@ class Builder
* *
* @param string $field * @param string $field
* @param string $value * @param string $value
*
* @return $this * @return $this
*/ */
public function whereApproximatelyEquals($field, $value) public function whereApproximatelyEquals($field, $value)
@@ -1208,7 +1227,6 @@ class Builder
* Adds a 'where has' clause to the current query. * Adds a 'where has' clause to the current query.
* *
* @param string $field * @param string $field
*
* @return $this * @return $this
*/ */
public function whereHas($field) public function whereHas($field)
@@ -1220,7 +1238,6 @@ class Builder
* Adds a 'where not has' clause to the current query. * Adds a 'where not has' clause to the current query.
* *
* @param string $field * @param string $field
*
* @return $this * @return $this
*/ */
public function whereNotHas($field) public function whereNotHas($field)
@@ -1233,7 +1250,6 @@ class Builder
* *
* @param string $field * @param string $field
* @param string $value * @param string $value
*
* @return $this * @return $this
*/ */
public function whereContains($field, $value) public function whereContains($field, $value)
@@ -1246,7 +1262,6 @@ class Builder
* *
* @param string $field * @param string $field
* @param string $value * @param string $value
*
* @return $this * @return $this
*/ */
public function whereNotContains($field, $value) public function whereNotContains($field, $value)
@@ -1259,7 +1274,6 @@ class Builder
* *
* @param string $field * @param string $field
* @param array $values * @param array $values
*
* @return $this * @return $this
*/ */
public function whereIn($field, array $values) public function whereIn($field, array $values)
@@ -1276,7 +1290,6 @@ class Builder
* *
* @param string $field * @param string $field
* @param array $values * @param array $values
*
* @return $this * @return $this
*/ */
public function whereBetween($field, array $values) public function whereBetween($field, array $values)
@@ -1292,7 +1305,6 @@ class Builder
* *
* @param string $field * @param string $field
* @param string $value * @param string $value
*
* @return $this * @return $this
*/ */
public function whereStartsWith($field, $value) public function whereStartsWith($field, $value)
@@ -1305,7 +1317,6 @@ class Builder
* *
* @param string $field * @param string $field
* @param string $value * @param string $value
*
* @return $this * @return $this
*/ */
public function whereNotStartsWith($field, $value) public function whereNotStartsWith($field, $value)
@@ -1318,7 +1329,6 @@ class Builder
* *
* @param string $field * @param string $field
* @param string $value * @param string $value
*
* @return $this * @return $this
*/ */
public function whereEndsWith($field, $value) public function whereEndsWith($field, $value)
@@ -1331,7 +1341,6 @@ class Builder
* *
* @param string $field * @param string $field
* @param string $value * @param string $value
*
* @return $this * @return $this
*/ */
public function whereNotEndsWith($field, $value) public function whereNotEndsWith($field, $value)
@@ -1365,7 +1374,6 @@ class Builder
* @param string $oid * @param string $oid
* @param bool $isCritical * @param bool $isCritical
* @param mixed $value * @param mixed $value
*
* @return $this * @return $this
*/ */
public function addControl($oid, $isCritical = false, $value = null) public function addControl($oid, $isCritical = false, $value = null)
@@ -1379,7 +1387,6 @@ class Builder
* Determine if the server control exists on the query. * Determine if the server control exists on the query.
* *
* @param string $oid * @param string $oid
*
* @return bool * @return bool
*/ */
public function hasControl($oid) public function hasControl($oid)
@@ -1393,7 +1400,6 @@ class Builder
* @param array|string $field * @param array|string $field
* @param string|null $operator * @param string|null $operator
* @param string|null $value * @param string|null $value
*
* @return $this * @return $this
*/ */
public function orWhere($field, $operator = null, $value = null) public function orWhere($field, $operator = null, $value = null)
@@ -1409,7 +1415,6 @@ class Builder
* @param string $field * @param string $field
* @param string $operator * @param string $operator
* @param string $value * @param string $value
*
* @return $this * @return $this
*/ */
public function orWhereRaw($field, $operator = null, $value = null) public function orWhereRaw($field, $operator = null, $value = null)
@@ -1421,7 +1426,6 @@ class Builder
* Adds an 'or where has' clause to the current query. * Adds an 'or where has' clause to the current query.
* *
* @param string $field * @param string $field
*
* @return $this * @return $this
*/ */
public function orWhereHas($field) public function orWhereHas($field)
@@ -1433,7 +1437,6 @@ class Builder
* Adds a 'where not has' clause to the current query. * Adds a 'where not has' clause to the current query.
* *
* @param string $field * @param string $field
*
* @return $this * @return $this
*/ */
public function orWhereNotHas($field) public function orWhereNotHas($field)
@@ -1446,7 +1449,6 @@ class Builder
* *
* @param string $field * @param string $field
* @param string $value * @param string $value
*
* @return $this * @return $this
*/ */
public function orWhereEquals($field, $value) public function orWhereEquals($field, $value)
@@ -1459,7 +1461,6 @@ class Builder
* *
* @param string $field * @param string $field
* @param string $value * @param string $value
*
* @return $this * @return $this
*/ */
public function orWhereNotEquals($field, $value) public function orWhereNotEquals($field, $value)
@@ -1472,7 +1473,6 @@ class Builder
* *
* @param string $field * @param string $field
* @param string $value * @param string $value
*
* @return $this * @return $this
*/ */
public function orWhereApproximatelyEquals($field, $value) public function orWhereApproximatelyEquals($field, $value)
@@ -1485,7 +1485,6 @@ class Builder
* *
* @param string $field * @param string $field
* @param string $value * @param string $value
*
* @return $this * @return $this
*/ */
public function orWhereContains($field, $value) public function orWhereContains($field, $value)
@@ -1498,7 +1497,6 @@ class Builder
* *
* @param string $field * @param string $field
* @param string $value * @param string $value
*
* @return $this * @return $this
*/ */
public function orWhereNotContains($field, $value) public function orWhereNotContains($field, $value)
@@ -1511,7 +1509,6 @@ class Builder
* *
* @param string $field * @param string $field
* @param string $value * @param string $value
*
* @return $this * @return $this
*/ */
public function orWhereStartsWith($field, $value) public function orWhereStartsWith($field, $value)
@@ -1524,7 +1521,6 @@ class Builder
* *
* @param string $field * @param string $field
* @param string $value * @param string $value
*
* @return $this * @return $this
*/ */
public function orWhereNotStartsWith($field, $value) public function orWhereNotStartsWith($field, $value)
@@ -1537,7 +1533,6 @@ class Builder
* *
* @param string $field * @param string $field
* @param string $value * @param string $value
*
* @return $this * @return $this
*/ */
public function orWhereEndsWith($field, $value) public function orWhereEndsWith($field, $value)
@@ -1550,7 +1545,6 @@ class Builder
* *
* @param string $field * @param string $field
* @param string $value * @param string $value
*
* @return $this * @return $this
*/ */
public function orWhereNotEndsWith($field, $value) public function orWhereNotEndsWith($field, $value)
@@ -1563,7 +1557,6 @@ class Builder
* *
* @param string $type The type of filter to add. * @param string $type The type of filter to add.
* @param array $bindings The bindings of the filter. * @param array $bindings The bindings of the filter.
*
* @return $this * @return $this
* *
* @throws InvalidArgumentException * @throws InvalidArgumentException
@@ -1592,7 +1585,6 @@ class Builder
* Extract any missing required binding keys. * Extract any missing required binding keys.
* *
* @param array $bindings * @param array $bindings
*
* @return array * @return array
*/ */
protected function missingBindingKeys($bindings) protected function missingBindingKeys($bindings)
@@ -1705,7 +1697,6 @@ class Builder
* Whether to mark the current query as nested. * Whether to mark the current query as nested.
* *
* @param bool $nested * @param bool $nested
*
* @return $this * @return $this
*/ */
public function nested($nested = true) public function nested($nested = true)
@@ -1722,7 +1713,6 @@ class Builder
* *
* @param DateTimeInterface $until When to expire the query cache. * @param DateTimeInterface $until When to expire the query cache.
* @param bool $flush Whether to force-flush the query cache. * @param bool $flush Whether to force-flush the query cache.
*
* @return $this * @return $this
*/ */
public function cache(DateTimeInterface $until = null, $flush = false) public function cache(DateTimeInterface $until = null, $flush = false)
@@ -1759,7 +1749,6 @@ class Builder
* *
* @param string $dn * @param string $dn
* @param array $attributes * @param array $attributes
*
* @return bool * @return bool
* *
* @throws LdapRecordException * @throws LdapRecordException
@@ -1786,7 +1775,6 @@ class Builder
* *
* @param string $dn * @param string $dn
* @param array $attributes * @param array $attributes
*
* @return bool * @return bool
*/ */
public function insertAttributes($dn, array $attributes) public function insertAttributes($dn, array $attributes)
@@ -1801,7 +1789,6 @@ class Builder
* *
* @param string $dn * @param string $dn
* @param array $modifications * @param array $modifications
*
* @return bool * @return bool
*/ */
public function update($dn, array $modifications) public function update($dn, array $modifications)
@@ -1816,7 +1803,6 @@ class Builder
* *
* @param string $dn * @param string $dn
* @param array $attributes * @param array $attributes
*
* @return bool * @return bool
*/ */
public function updateAttributes($dn, array $attributes) public function updateAttributes($dn, array $attributes)
@@ -1830,7 +1816,6 @@ class Builder
* Delete an entry from the directory. * Delete an entry from the directory.
* *
* @param string $dn * @param string $dn
*
* @return bool * @return bool
*/ */
public function delete($dn) public function delete($dn)
@@ -1845,7 +1830,6 @@ class Builder
* *
* @param string $dn * @param string $dn
* @param array $attributes * @param array $attributes
*
* @return bool * @return bool
*/ */
public function deleteAttributes($dn, array $attributes) public function deleteAttributes($dn, array $attributes)
@@ -1862,7 +1846,6 @@ class Builder
* @param string $rdn * @param string $rdn
* @param string $newParentDn * @param string $newParentDn
* @param bool $deleteOldRdn * @param bool $deleteOldRdn
*
* @return bool * @return bool
*/ */
public function rename($dn, $rdn, $newParentDn, $deleteOldRdn = true) public function rename($dn, $rdn, $newParentDn, $deleteOldRdn = true)
@@ -1872,12 +1855,21 @@ class Builder
}); });
} }
/**
* Clone the query.
*
* @return static
*/
public function clone()
{
return clone $this;
}
/** /**
* Handle dynamic method calls on the query builder. * Handle dynamic method calls on the query builder.
* *
* @param string $method * @param string $method
* @param array $parameters * @param array $parameters
*
* @return mixed * @return mixed
* *
* @throws BadMethodCallException * @throws BadMethodCallException
@@ -1903,7 +1895,6 @@ class Builder
* *
* @param string $method * @param string $method
* @param array $parameters * @param array $parameters
*
* @return $this * @return $this
*/ */
public function dynamicWhere($method, $parameters) public function dynamicWhere($method, $parameters)
@@ -1946,7 +1937,6 @@ class Builder
* @param array $wheres * @param array $wheres
* @param string $boolean * @param string $boolean
* @param bool $raw * @param bool $raw
*
* @return $this * @return $this
*/ */
protected function addArrayOfWheres($wheres, $boolean, $raw) protected function addArrayOfWheres($wheres, $boolean, $raw)
@@ -1979,7 +1969,6 @@ class Builder
* @param string $connector * @param string $connector
* @param array $parameters * @param array $parameters
* @param int $index * @param int $index
*
* @return void * @return void
*/ */
protected function addDynamic($segment, $connector, $parameters, $index) protected function addDynamic($segment, $connector, $parameters, $index)
@@ -1999,7 +1988,6 @@ class Builder
* @param Builder $query * @param Builder $query
* @param string $type * @param string $type
* @param null|float $time * @param null|float $time
*
* @return void * @return void
*/ */
protected function logQuery($query, $type, $time = null) protected function logQuery($query, $type, $time = null)
@@ -2031,7 +2019,6 @@ class Builder
* Fires the given query event. * Fires the given query event.
* *
* @param QueryExecuted $event * @param QueryExecuted $event
*
* @return void * @return void
*/ */
protected function fireQueryEvent(QueryExecuted $event) protected function fireQueryEvent(QueryExecuted $event)
@@ -2043,7 +2030,6 @@ class Builder
* Get the elapsed time since a given starting point. * Get the elapsed time since a given starting point.
* *
* @param int $start * @param int $start
*
* @return float * @return float
*/ */
protected function getElapsedTime($start) protected function getElapsedTime($start)
@@ -32,7 +32,6 @@ class Cache
* Get an item from the cache. * Get an item from the cache.
* *
* @param string $key * @param string $key
*
* @return mixed * @return mixed
*/ */
public function get($key) public function get($key)
@@ -46,7 +45,6 @@ class Cache
* @param string $key * @param string $key
* @param mixed $value * @param mixed $value
* @param DateTimeInterface|DateInterval|int|null $ttl * @param DateTimeInterface|DateInterval|int|null $ttl
*
* @return bool * @return bool
*/ */
public function put($key, $value, $ttl = null) public function put($key, $value, $ttl = null)
@@ -66,7 +64,6 @@ class Cache
* @param string $key * @param string $key
* @param DateTimeInterface|DateInterval|int|null $ttl * @param DateTimeInterface|DateInterval|int|null $ttl
* @param Closure $callback * @param Closure $callback
*
* @return mixed * @return mixed
*/ */
public function remember($key, $ttl, Closure $callback) public function remember($key, $ttl, Closure $callback)
@@ -86,7 +83,6 @@ class Cache
* Delete an item from the cache. * Delete an item from the cache.
* *
* @param string $key * @param string $key
*
* @return bool * @return bool
*/ */
public function delete($key) public function delete($key)
@@ -0,0 +1,100 @@
<?php
namespace LdapRecord\Query\Filter;
use LdapRecord\Support\Str;
class ConditionNode extends Node
{
/**
* The condition's attribute.
*
* @var string
*/
protected $attribute;
/**
* The condition's operator.
*
* @var string
*/
protected $operator;
/**
* The condition's value.
*
* @var string
*/
protected $value;
/**
* The available condition operators.
*
* @var array
*/
protected $operators = ['>=', '<=', '~=', '='];
/**
* Constructor.
*
* @param string $filter
*/
public function __construct($filter)
{
$this->raw = $filter;
[$this->attribute, $this->value] = $this->extractComponents($filter);
}
/**
* Get the condition's attribute.
*
* @return string
*/
public function getAttribute()
{
return $this->attribute;
}
/**
* Get the condition's operator.
*
* @return string
*/
public function getOperator()
{
return $this->operator;
}
/**
* Get the condition's value.
*
* @return string
*/
public function getValue()
{
return $this->value;
}
/**
* Extract the condition components from the filter.
*
* @param string $filter
* @return array
*/
protected function extractComponents($filter)
{
$components = Str::whenContains(
$filter,
$this->operators,
function ($operator, $filter) {
return explode($this->operator = $operator, $filter, 2);
},
function ($filter) {
throw new ParserException("Invalid query condition. No operator found in [$filter]");
},
);
return $components;
}
}

Some files were not shown because too many files have changed in this diff Show More