diff --git a/.codeclimate.yml b/.codeclimate.yml deleted file mode 100644 index 383d22f98..000000000 --- a/.codeclimate.yml +++ /dev/null @@ -1,50 +0,0 @@ -# -# This file is part of phpFastCache. -# -# @license MIT License (MIT) -# -# For full copyright and license information, please see the docs/CREDITS.txt file. -# -# @author Georges.L (Geolim4) -# @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors -# - -engines: - duplication: - enabled: false - checks: - Similar code: - enabled: false - UnusedFormalParameter: - enabled: false - Controversial/CamelCaseClassName: - enabled: false - config: - languages: - - ruby - - javascript - - python - - php - fixme: - enabled: true - phpmd: - enabled: true - config: - file_extensions: - - php - - inc - rulesets: "phpmd.xml" -ratings: - paths: - - "**.inc" - - "**.js" - - "**.jsx" - - "**.module" - - "**.php" - - "**.py" - - "**.rb" -exclude_paths: -- "bin/**" -- "examples/**" -- "docs/**" -- "tests/**" diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 000000000..c0f45b08d --- /dev/null +++ b/.editorconfig @@ -0,0 +1,16 @@ +# @see http://editorconfig.org/ + +# This is the top-most .editorconfig file; do not search in parent directories. +root = true + +# All files. +[*] +end_of_line = LF +indent_style = space +indent_size = 2 +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true + +[index.html] +indent_size = 4 diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 00ae99827..000000000 --- a/.gitattributes +++ /dev/null @@ -1,21 +0,0 @@ -/tests export-ignore -/docs/examples export-ignore -/bin export-ignore -/.github export-ignore -.gitattributes export-ignore -.gitignore export-ignore -.gitmodules export-ignore -.scrutinizer.yml export-ignore -.codeclimate.yml export-ignore -CONTRIBUTING.md export-ignore -CODE_OF_CONDUCT.md export-ignore -CODING_GUIDELINE.md export-ignore -phpunit.xml.dist export-ignore -phpcs.xml.dist export-ignore -composer.lock export-ignore -quality.bat export-ignore -phpstan.neon export-ignore -phpstan_lite.neon export-ignore -phpcs.xml export-ignore -phpmd.xml export-ignore -CNAME export-ignore diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml deleted file mode 100644 index 96d4bd046..000000000 --- a/.github/FUNDING.yml +++ /dev/null @@ -1,4 +0,0 @@ -# These are supported funding model platforms - -github: [geolim4] -patreon: geolim4 diff --git a/.github/ISSUE_TEMPLATE/bug-report-extension.yml b/.github/ISSUE_TEMPLATE/bug-report-extension.yml deleted file mode 100644 index 04174ccce..000000000 --- a/.github/ISSUE_TEMPLATE/bug-report-extension.yml +++ /dev/null @@ -1,151 +0,0 @@ -name: "Report a bug for a Phpfastcache Extension" -title: " - " -description: Create a report to help us improve a Phpfastcache extension -labels: ["Needs triage 🔎"] -assignees: ["Geolim4"] -body: - - type: markdown - attributes: - value: | - ### Before you start - - **Are you looking for development help?** - ↩ Please note that we cannot provide assistance on web development. We recommend asking around on a dedicated help forum like StackOverflow. - - ### Issue etiquette - - When opening an issue, please: - - Follow the project's [Code of Conduct](https://github.com/PHPSocialNetwork/phpfastcache/blob/master/CODE_OF_CONDUCT.md) as well as the [GitHub Community Guidelines](https://docs.github.com/en/site-policy/github-terms/github-community-guidelines). - - Check for an [existing issue](https://github.com/PHPSocialNetwork/phpfastcache/issues) first. If someone else has opened an issue describing the same problem, please upvote their issue rather than creating another one. - - Keep issues relevant to the project. Irrelevant issues will be automatically closed and marked as spam, and repeated offenses may result in exclusion from our organization. - - Provide as much detail as possible. The more detail you are able to provide, the better! - - Write issues primarily in English. While translation tools are available, we will be able to provide better assistance with pre-translated content. You are more than welcome to include a version of the issue body in your preferred language alongside the English version. - - **Make sure that you searched an answer on our [wiki](https://github.com/PHPSocialNetwork/phpfastcache/wiki)** - - --- - - type: dropdown - id: extension - attributes: - label: Which extension is this issue about ? - options: - - Arangodb - - Couchbasev4 - - Couchdb - - Dynamodb - - Firestore - - Mongodb - - Ravendb - - Solr - validations: - required: true - - type: dropdown - id: type - attributes: - label: What type of issue is this? - options: - - Incorrect/unexpected/unexplainable behavior - - Exception/Error/Warning/Notice/Deprecation - - PSR-6/16 standard violation - - Wiki/Documentation/Readme typo/fault or lack of documentation - - Incompatibility (be specific) - - Other (Please Specify) - validations: - required: true - - type: input - id: os - attributes: - label: Operating system + version - description: "The operating system with version, ex: Ubuntu 18.04 or Windows 10" - validations: - required: true - - type: input - id: php - attributes: - label: PHP version - description: | - The PHP version you're running Phpfastcache on. - _Can be retrieved using command line `php -v | sed -n 1p`_ - validations: - required: true - - type: input - id: connector - attributes: - label: Connector/Database version (if applicable) - description: | - The connector and/or SDK version + the database version if applicable, ex: - - Couchbase 7.1.0 + PECL Extension 3.2.2 - - Redis 7.0.0 + PECL Extension 5.3.7 - - MongoDB 5.0.2 Community + mongodb/mongodb version x.x.x - - etc - - **Be as much detailed as you can be !** - validations: - required: false - - type: input - id: extension_exact_version - attributes: - label: Extension version (NOT THE PHPFASTCACHE VERSION) - description: | - Please keep in mind that some versions are partially or no longer supported. - - See our [global support timeline](https://github.com/PHPSocialNetwork/phpfastcache/wiki/%5BV4%CB%96%5D-Global-support-timeline) ⌚ - validations: - required: true - - type: input - id: pfc_exact_version - attributes: - label: Phpfastcache version - description: | - Please keep in mind that some versions are partially or no longer supported. - - See our [global support timeline](https://github.com/PHPSocialNetwork/phpfastcache/wiki/%5BV4%CB%96%5D-Global-support-timeline) ⌚ - validations: - required: true - - type: textarea - id: problem - attributes: - label: Describe the issue you're facing - description: Provide as much detail as possible. The more detail you are able to provide, the better! - validations: - required: true - - type: textarea - id: expected - attributes: - label: Expected behavior - description: If applicable, please describe the behavior you expected - validations: - required: false - - type: textarea - id: code_sample - attributes: - label: Code sample (optional) - description: If applicable, please provide a code sample - - type: textarea - id: suggestion - attributes: - label: Suggestion to fix the issue (optional) - description: Do you have an suggestion on how to fix this issue ? - - type: textarea - id: references - attributes: - label: References (optional) - description: Can you link to any release notes, bugs, pull requests, or Stack-Overflow link related to this? - - type: textarea - id: more_info - attributes: - label: Do you have anything more you want to share? (optional) - description: For example, screenshots, screen recordings, or sample code, logs, etc. - - type: checkboxes - id: wiki_confirmation - attributes: - label: Have you searched in our Wiki before posting ? - description: Our Wiki contains tons of information, make sure you've searched over it before posting this issue. - options: - - label: I have searched over the Wiki - required: true - - type: markdown - attributes: - value: | - --- - You've finished 👏 - The following fields are prefilled and should not be modified. Please click **Submit new issue**. diff --git a/.github/ISSUE_TEMPLATE/bug-report.yml b/.github/ISSUE_TEMPLATE/bug-report.yml deleted file mode 100644 index 3c6f1c129..000000000 --- a/.github/ISSUE_TEMPLATE/bug-report.yml +++ /dev/null @@ -1,324 +0,0 @@ -name: "Report a bug" -title: " - " -description: Create a report to help us improve Phpfastcache -labels: ["Needs triage 🔎"] -assignees: ["Geolim4"] -body: - - type: markdown - attributes: - value: | - ### Before you start - - **Are you looking for development help?** - ↩ Please note that we cannot provide assistance on web development. We recommend asking around on a dedicated help forum like StackOverflow. - - ### Issue etiquette - - When opening an issue, please: - - Follow the project's [Code of Conduct](https://github.com/PHPSocialNetwork/phpfastcache/blob/master/CODE_OF_CONDUCT.md) as well as the [GitHub Community Guidelines](https://docs.github.com/en/site-policy/github-terms/github-community-guidelines). - - Check for an [existing issue](https://github.com/PHPSocialNetwork/phpfastcache/issues) first. If someone else has opened an issue describing the same problem, please upvote their issue rather than creating another one. - - Keep issues relevant to the project. Irrelevant issues will be automatically closed and marked as spam, and repeated offenses may result in exclusion from our organization. - - Provide as much detail as possible. The more detail you are able to provide, the better! - - Write issues primarily in English. While translation tools are available, we will be able to provide better assistance with pre-translated content. You are more than welcome to include a version of the issue body in your preferred language alongside the English version. - - **Make sure that you searched an answer on our [wiki](https://github.com/PHPSocialNetwork/phpfastcache/wiki)** - - --- - - type: dropdown - id: type - attributes: - label: What type of issue is this? - options: - - Incorrect/unexpected/unexplainable behavior - - Exception/Error/Warning/Notice/Deprecation - - PSR-6/16 standard violation - - Wiki/Documentation/Readme typo/fault or lack of documentation - - Incompatibility (be specific) - - Other (Please Specify) - validations: - required: true - - type: input - id: os - attributes: - label: Operating system + version - description: "The operating system with version, ex: Ubuntu 18.04 or Windows 10" - validations: - required: true - - type: input - id: php - attributes: - label: PHP version - description: | - The PHP version you're running Phpfastcache on. - _Can be retrieved using command line `php -v | sed -n 1p`_ - validations: - required: true - - type: input - id: connector - attributes: - label: Connector/Database version (if applicable) - description: | - The connector and/or SDK version + the database version if applicable, ex: - - Couchbase 7.1.0 + PECL Extension 3.2.2 - - Redis 7.0.0 + PECL Extension 5.3.7 - - MongoDB 5.0.2 Community + mongodb/mongodb - - etc - - **Be as much detailed as you can be !** - validations: - required: false - - type: dropdown - id: pfc_exact_version - attributes: - label: Phpfastcache version - description: | - Please keep in mind that some versions are partially or no longer supported: - - Phpfastcache v9 ✅ - - Phpfastcache v8 (Security fixes only) 🔶 - - Phpfastcache v7 (End of life) ❌ - - Phpfastcache v6 (End of life) ❌ - - Phpfastcache v5 (End of life) ❌ - - Phpfastcache >= v4 (End of life) ❌ - - See our [global support timeline](https://github.com/PHPSocialNetwork/phpfastcache/wiki/%5BV4%CB%96%5D-Global-support-timeline) ⌚ - multiple: false - options: - - 9.2.0 ✅ - - 9.1.3 ✅ - - 9.1.2 🔶 - - 9.1.1 ❌ - - 9.1.0 ❌ - - 9.1.0-dev ❌ - - 9.0.2 ❌ - - 9.0.1 ❌ - - 9.0.0-rc ❌ - - 9.0.0-beta5 ❌ - - 9.0.0-beta4 ❌ - - 9.0.0-beta3 ❌ - - 9.0.0-beta2 ❌ - - 9.0.0-beta ❌ - - 9.0.0-alpha3 ❌ - - 9.0.0-alpha2 ❌ - - 9.0.0-alpha ❌ - - 9.0.0-dev ❌ - - 9.0.0 ❌ - - 8.1.4 🔶 - - 8.1.3 ❌ - - 8.1.2 ❌ - - 8.1.1 ❌ - - 8.1.0 ❌ - - 8.0.8 ❌ - - 8.0.7 ❌ - - 8.0.6 ❌ - - 8.0.5 ❌ - - 8.0.4 ❌ - - 8.0.3 ❌ - - 8.0.2 ❌ - - 8.0.1 ❌ - - 8.0.0-rc2 ❌ - - 8.0.0-rc ❌ - - 8.0.0-beta ❌ - - 8.0.0-alpha ❌ - - 8.0.0-dev ❌ - - 8.0.0 ❌ - - 7.1.2 ❌ - - 7.1.1 ❌ - - 7.1.0 ❌ - - 7.0.5 ❌ - - 7.0.4 ❌ - - 7.0.3 ❌ - - 7.0.2 ❌ - - 7.0.1 ❌ - - 7.0.0-beta3 ❌ - - 7.0.0-beta2 ❌ - - 7.0.0-beta ❌ - - 7.0.0-alpha3 ❌ - - 7.0.0-alpha2 ❌ - - 7.0.0-alpha ❌ - - 7.0.0-RC4 ❌ - - 7.0.0-RC3 ❌ - - 7.0.0-RC2 ❌ - - 7.0.0-RC ❌ - - 7.0.0 ❌ - - 6.1.5 ❌ - - 6.1.4 ❌ - - 6.1.3 ❌ - - 6.1.2 ❌ - - 6.1.1 ❌ - - 6.1.0 ❌ - - 6.0.8 ❌ - - 6.0.7 ❌ - - 6.0.6 ❌ - - 6.0.5 ❌ - - 6.0.4 ❌ - - 6.0.3 ❌ - - 6.0.2 ❌ - - 6.0.1 ❌ - - 6.0.0-rc4 ❌ - - 6.0.0-rc3 ❌ - - 6.0.0-rc2 ❌ - - 6.0.0-rc1 ❌ - - 6.0.0-beta2 ❌ - - 6.0.0-beta1 ❌ - - 6.0.0-alpha2 ❌ - - 6.0.0-alpha ❌ - - 6.0.0 ❌ - - 5.0.9 ❌ - - 5.0.8 ❌ - - 5.0.7 ❌ - - 5.0.6 ❌ - - 5.0.5 ❌ - - 5.0.4 ❌ - - 5.0.3 ❌ - - 5.0.21 ❌ - - 5.0.20 ❌ - - 5.0.2 ❌ - - 5.0.19 ❌ - - 5.0.18 ❌ - - 5.0.17 ❌ - - 5.0.16 ❌ - - 5.0.15 ❌ - - 5.0.14 ❌ - - 5.0.13 ❌ - - 5.0.12 ❌ - - 5.0.11 ❌ - - 5.0.10 ❌ - - 5.0.1 ❌ - - 5.0.0-rc3 ❌ - - 5.0.0-rc2 ❌ - - 5.0.0-rc1 ❌ - - 5.0.0-beta2 ❌ - - 5.0.0-beta1 ❌ - - 5.0.0-alpha2 ❌ - - 5.0.0-alpha1 ❌ - - 5.0.0 ❌ - - 4.3.9 ❌ - - 4.3.8 ❌ - - 4.3.7 ❌ - - 4.3.6 ❌ - - 4.3.5 ❌ - - 4.3.4 ❌ - - 4.3.3 ❌ - - 4.3.2 ❌ - - 4.3.18 ❌ - - 4.3.17 ❌ - - 4.3.16 ❌ - - 4.3.15 ❌ - - 4.3.14 ❌ - - 4.3.13 ❌ - - 4.3.12 ❌ - - 4.3.11 ❌ - - 4.3.10 ❌ - - 4.3.1 ❌ - - 4.3 ❌ - - 4.2.4 ❌ - - 4.2.3 ❌ - - 4.2.2 ❌ - - 4.2.1 ❌ - - 4.1.1 ❌ - - 4.1.0 ❌ - - 4.1 ❌ - - 4.0.9 ❌ - - 4.0.8 ❌ - - 4.0.7 ❌ - - 4.0.6 ❌ - - 4.0.5 ❌ - - 4.0.4 ❌ - - 4.0.3-beta1 ❌ - - 4.0.3 ❌ - - 4.0.2beta1 ❌ - - 4.0.2-beta1 ❌ - - 4.0.2 ❌ - - 4.0.18 ❌ - - 4.0.17 ❌ - - 4.0.16 ❌ - - 4.0.15 ❌ - - 4.0.14 ❌ - - 4.0.13 ❌ - - 4.0.12 ❌ - - 4.0.11 ❌ - - 4.0.10 ❌ - - 4.0.1 ❌ - - 4.0 ❌ - - 3.1.1 ❌ - - 3.1.0 ❌ - - 3.0.9 ❌ - - 3.0.8 ❌ - - 3.0.7 ❌ - - 3.0.6 ❌ - - 3.0.5 ❌ - - 3.0.4 ❌ - - 3.0.3 ❌ - - 3.0.28 ❌ - - 3.0.27 ❌ - - 3.0.26 ❌ - - 3.0.25 ❌ - - 3.0.24 ❌ - - 3.0.23 ❌ - - 3.0.22 ❌ - - 3.0.21 ❌ - - 3.0.20 ❌ - - 3.0.2 ❌ - - 3.0.19 ❌ - - 3.0.18 ❌ - - 3.0.17 ❌ - - 3.0.16 ❌ - - 3.0.15 ❌ - - 3.0.14 ❌ - - 3.0.13 ❌ - - 3.0.12 ❌ - - 3.0.11 ❌ - - 3.0.10 ❌ - - 3.0.1 ❌ - - 3.0.0 ❌ - - 2.4.3 ❌ - - 2.4.2 ❌ - validations: - required: true - - type: textarea - id: problem - attributes: - label: Describe the issue you're facing - description: Provide as much detail as possible. The more detail you are able to provide, the better! - validations: - required: true - - type: textarea - id: expected - attributes: - label: Expected behavior - description: If applicable, please describe the behavior you expected - validations: - required: false - - type: textarea - id: code_sample - attributes: - label: Code sample (optional) - description: If applicable, please provide a code sample - - type: textarea - id: suggestion - attributes: - label: Suggestion to fix the issue (optional) - description: Do you have an suggestion on how to fix this issue ? - - type: textarea - id: references - attributes: - label: References (optional) - description: Can you link to any release notes, bugs, pull requests, or Stack-Overflow link related to this? - - type: textarea - id: more_info - attributes: - label: Do you have anything more you want to share? (optional) - description: For example, screenshots, screen recordings, or sample code, logs, etc. - - type: checkboxes - id: wiki_confirmation - attributes: - label: Have you searched in our Wiki before posting ? - description: Our Wiki contains tons of information, make sure you've searched over it before posting this issue. - options: - - label: I have searched over the Wiki - required: true - - type: markdown - attributes: - value: | - --- - You're finished 👏 - The following fields are prefilled and should not be modified. Please click **Submit new issue**. diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml deleted file mode 100644 index d262db2fe..000000000 --- a/.github/ISSUE_TEMPLATE/config.yml +++ /dev/null @@ -1,5 +0,0 @@ -blank_issues_enabled: false -contact_links: - - name: GitHub Support - url: https://github.com/PHPSocialNetwork/phpfastcache/issues - about: Please ask and answer questions here. diff --git a/.github/ISSUE_TEMPLATE/feature-request.yml b/.github/ISSUE_TEMPLATE/feature-request.yml deleted file mode 100644 index 6e3323dc0..000000000 --- a/.github/ISSUE_TEMPLATE/feature-request.yml +++ /dev/null @@ -1,64 +0,0 @@ -name: "Request a feature" -title: "" -description: Suggest an idea for Phpfastcache -labels: ["Needs triage 🔎"] -assignees: ["Geolim4"] -body: - - type: markdown - attributes: - value: | - ### Before you start - - **Are you looking for development help?** - ↩ Please note that we cannot provide assistance on web development. We recommend asking around on a dedicated help forum like StackOverflow. - - ### Issue etiquette - - When opening an feature request, please: - - Follow the project's [Code of Conduct](https://github.com/PHPSocialNetwork/phpfastcache/blob/master/CODE_OF_CONDUCT.md) as well as the [GitHub Community Guidelines](https://docs.github.com/en/site-policy/github-terms/github-community-guidelines). - - Check for an [existing feature request](https://github.com/PHPSocialNetwork/phpfastcache/issues) first. If someone else has opened a similar feature request, please upvote their feature request rather than creating another one. - - Keep suggestions relevant to the project. Irrelevant suggestions will be automatically closed and marked as spam, and repeated offenses may result in exclusion from our organization. - - Provide as much detail as possible. The more detail you are able to provide, the better! - - **Make sure that a request feature may be denied or accepted and if id does it can take a while before being implemented.** - - --- - - type: dropdown - id: type - attributes: - label: What type of feature would you like? - options: - - New backend support - - Code improvement (be specific) - - New PSR standard implementation - - Wiki/Documentation/Readme improvement - - Other (Please Specify) - validations: - required: true - - type: textarea - id: feature_request - attributes: - label: The feature request - description: Describe the feature request you'd like to have - validations: - required: true - - type: textarea - id: code_sample - attributes: - label: Code sample (optional) - description: If applicable, please provide a code sample - - type: textarea - id: references - attributes: - label: References (optional) - description: Can you link to any release notes, ideas, pull requests, or Stack-Overflow link related to this? - - type: textarea - id: more_info - attributes: - label: Do you have anything more you want to share? (optional) - description: For example, screenshots, screen recordings, or sample code, logs, etc. - - type: markdown - attributes: - value: | - --- - You're finished 👏 - The following fields are prefilled and should not be modified. Please click **Submit new feature request**. diff --git a/.github/ISSUE_TEMPLATE/simple-question.yml b/.github/ISSUE_TEMPLATE/simple-question.yml deleted file mode 100644 index 054e1e49e..000000000 --- a/.github/ISSUE_TEMPLATE/simple-question.yml +++ /dev/null @@ -1,46 +0,0 @@ -name: "Ask a question" -title: "" -description: Ask a question about Phpfastcache -labels: ["Needs triage 🔎"] -assignees: ["Geolim4"] -body: - - type: markdown - attributes: - value: | - ### Before you start - - **Are you looking for development help?** - ↩ Please note that we cannot provide assistance on web development. We recommend asking around on a dedicated help forum like StackOverflow. - - ### Issue etiquette - - When opening a new ticket, please: - - Follow the project's [Code of Conduct](https://github.com/PHPSocialNetwork/phpfastcache/blob/master/CODE_OF_CONDUCT.md) as well as the [GitHub Community Guidelines](https://docs.github.com/en/site-policy/github-terms/github-community-guidelines). - - Check for an [existing question](https://github.com/PHPSocialNetwork/phpfastcache/issues) first. If someone else has opened a similar question, please upvote their question rather than creating another one. - - Keep questions relevant to the project. Irrelevant questions will be automatically closed and marked as spam, and repeated offenses may result in exclusion from our organization. - - Provide as much detail as possible. The more detail you are able to provide, the better! - --- - - - type: textarea - id: the_question - attributes: - label: What's your question ? - description: Feel free to ask ! - validations: - required: true - - type: textarea - id: references - attributes: - label: References (optional) - description: Can you link to any release notes, ideas, pull requests, or Stack-Overflow link related to this? - - type: textarea - id: more_info - attributes: - label: Do you have anything more you want to share? (optional) - description: For example, screenshots, screen recordings, or sample code, logs, etc. - - type: markdown - attributes: - value: | - --- - You're finished 👏 - The following fields are prefilled and should not be modified. Please click **Submit**. diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index e7cf7ce18..000000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,24 +0,0 @@ -## Proposed changes - -Describe the big picture of your changes here to communicate to the maintainers why we should accept this pull request.\ -If it fixes a bug or resolves a feature request, be sure to link to that issue. - -## Types of changes - -What types of changes does your code introduce to Phpfastcache? -_Put an `x` in the boxes that apply_ - -- [ ] Bugfix (non-breaking change which fixes an issue) -- [ ] Improvement (non-breaking change which improves an existing code/behavior) -- [ ] Deprecated third party dependency update -- [ ] New feature (non-breaking change which adds functionality) -- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) -- [ ] Documentation/Typo/Resource update that does not involve any code modification - -## Agreement - -I have read the [CONTRIBUTING](https://github.com/PHPSocialNetwork/phpfastcache/blob/master/CONTRIBUTING.md) and [CODING GUIDELINE](https://github.com/PHPSocialNetwork/phpfastcache/blob/master/CODING_GUIDELINE.md) docs - -## Further comments - -If this is a relatively large or complex change, kick off the discussion by explaining why you chose the solution you did and what alternatives you considered, etc... diff --git a/.github/stale.yml b/.github/stale.yml deleted file mode 100644 index 14cfee5e6..000000000 --- a/.github/stale.yml +++ /dev/null @@ -1,19 +0,0 @@ -# Number of days of inactivity before an issue becomes stale -daysUntilStale: 15 -# Number of days of inactivity before a stale issue is closed -daysUntilClose: 7 -# Issues with these labels will never be considered stale -exemptLabels: - - "[-_-] In Process" - - ">_< Working & Scheduled" -# Label to use when marking an issue as stale -staleLabel: ">_< Wontfix" -# Comment to post when marking an issue as stale. Set to `false` to disable -markComment: > - This issue has been automatically marked as stale because it has not had - recent activity. It will be closed if no further activity occurs. Thank you - for your contributions. -# Comment to post when closing a stale issue. Set to `false` to disable -closeComment: > - This issue has now been automatically closed because of complete inactivity. Feel free to comment otu below to keep it open. Thank you - for your contributions. diff --git a/.github/workflows/greetings.yml b/.github/workflows/greetings.yml deleted file mode 100644 index 06f6392cd..000000000 --- a/.github/workflows/greetings.yml +++ /dev/null @@ -1,30 +0,0 @@ -name: Greetings - -# on: [pull_request, issues] Not working ATM due to lack of permissions error: https://github.com/actions/first-interaction/issues/10 -on: [issues] - -jobs: - greeting: - runs-on: ubuntu-latest - steps: - - uses: actions/first-interaction@v1 - with: - repo-token: ${{ secrets.GITHUB_TOKEN }} - issue-message: | - Hello curious contributor ! - Since it seems to be your first contribution, make sure that you've been: - - Reading and searching out our [WIKI](https://github.com/PHPSocialNetwork/phpfastcache/wiki) - - Reading and agreed with our [Code Of Conduct](https://github.com/PHPSocialNetwork/phpfastcache/blob/master/CODE_OF_CONDUCT.md) - - Reading and understood our [Coding Guideline](https://github.com/PHPSocialNetwork/phpfastcache/blob/master/CODING_GUIDELINE.md) - - Reading our [README](https://github.com/PHPSocialNetwork/phpfastcache/blob/master/README.md) - If everything looks unclear to you, tell us what 😄 - The Phpfastcache Team - pr-message: | - Hello curious contributor ! - Since it seems to be your first contribution, make sure that you've been: - - Reading and searching out our [WIKI](https://github.com/PHPSocialNetwork/phpfastcache/wiki) - - Reading and agreed with our [Code Of Conduct](https://github.com/PHPSocialNetwork/phpfastcache/blob/master/CODE_OF_CONDUCT.md) - - Reading and understood our [Coding Guideline](https://github.com/PHPSocialNetwork/phpfastcache/blob/master/CODING_GUIDELINE.md) - - Reading our [README](https://github.com/PHPSocialNetwork/phpfastcache/blob/master/README.md) - If everything looks unclear to you, tell us what 😄 - The Phpfastcache Team \ No newline at end of file diff --git a/.github/workflows/testsv2.yml b/.github/workflows/testsv2.yml deleted file mode 100644 index 103fff81e..000000000 --- a/.github/workflows/testsv2.yml +++ /dev/null @@ -1,73 +0,0 @@ -name: Phpfastcache Tests -on: [push, pull_request] -jobs: - run: - environment: github-ci - runs-on: ${{ matrix.operating-system }} - timeout-minutes: 60 - strategy: - matrix: - operating-system: [ubuntu-22.04] - php-versions: ['8.0', '8.1', '8.2', '8.3'] - name: PHP ${{ matrix.php-versions }} quality/tests on ${{ matrix.operating-system }} - env: - extensions: mbstring, intl, pdo_sqlite, json, redis, couchbase-3.2.2 - key: cache-v1 - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Install Couchbase Server - run: ./bin/ci/scripts/install_couchbase.sh - - - name: Setup cache environment - id: extcache - uses: shivammathur/cache-extensions@v1 - with: - php-version: ${{ matrix.php-versions }} - extensions: ${{ env.extensions }} - key: ${{ env.key }} - - - name: Cache extensions - uses: actions/cache@v3 - with: - path: ${{ steps.extcache.outputs.dir }} - key: ${{ steps.extcache.outputs.key }} - restore-keys: ${{ steps.extcache.outputs.key }} - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - coverage: none - php-version: ${{ matrix.php-versions }} - extensions: ${{ env.extensions }} - ini-values: apc.enabled=1, apc.shm_size=32M, apc.ttl=7200, apc.enable_cli=1, apc.serializer=php - - - name: Setup Memcached server - uses: niden/actions-memcached@v7 - - - name: Setup Redis server - uses: zhulik/redis-action@v1.0.0 - with: - redis version: '5' - - - name: Validate composer.json and composer.lock - run: composer validate --strict - - - name: Cache Composer packages - id: composer-cache - uses: actions/cache@v3 - with: - path: vendor - key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }} - restore-keys: | - ${{ runner.os }}-php- - - - name: Install dependencies - run: ./bin/ci/scripts/install_dependencies.sh - - - name: Run quality tools - run: composer run-script quality - - - name: Run tests - run: composer run-script tests diff --git a/.gitignore b/.gitignore index 8ec31aa2b..0b9f9c62c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,236 +1,3 @@ -################# -## Eclipse -################# - -*.pydevproject -.project -.metadata -tmp/ -*.tmp -*.bak -*.swp -*~.nib -local.properties -.classpath -.settings/ -.loadpath - -.idea -.gitignore .idea/ -.run/ - -# External tool builders -.externalToolBuilders/ - -# Locally stored "Eclipse launch configurations" -*.launch - -# CDT-specific -.cproject - -# PDT-specific -.buildpath - - -################# -## Visual Studio -################# - -## Ignore Visual Studio temporary files, build results, and -## files generated by popular Visual Studio add-ons. - -# User-specific files -*.suo -*.user -*.sln.docstates - -# Build results - -[Dd]ebug/ -[Rr]elease/ -x64/ -build/ -[Oo]bj/ - -# MSTest test Results -[Tt]est[Rr]esult*/ -[Bb]uild[Ll]og.* - -*_i.c -*_p.c -*.ilk -*.meta -*.obj -*.pch -*.pdb -*.pgc -*.pgd -*.rsp -*.sbr -*.tlb -*.tli -*.tlh -*.tmp_proj -*.log -*.vspscc -*.vssscc -.builds -*.pidb -*.scc - -# Visual C++ cache files -ipch/ -*.aps -*.ncb -*.opensdf -*.sdf -*.cachefile - -# Visual Studio profiler -*.psess -*.vsp -*.vspx - -# Guidance Automation Toolkit -*.gpState - -# ReSharper is a .NET coding add-in -_ReSharper*/ -*.[Rr]e[Ss]harper - -# TeamCity is a build add-in -_TeamCity* - -# DotCover is a Code Coverage Tool -*.dotCover - -# NCrunch -*.ncrunch* -.*crunch*.local.xml - -# Installshield output folder -[Ee]xpress/ - -# DocProject is a documentation generator add-in -DocProject/buildhelp/ -DocProject/Help/*.HxT -DocProject/Help/*.HxC -DocProject/Help/*.hhc -DocProject/Help/*.hhk -DocProject/Help/*.hhp -DocProject/Help/Html2 -DocProject/Help/html - -# Click-Once directory -publish/ - -# Publish Web Output -*.Publish.xml -*.pubxml -*.publishproj - -# NuGet Packages Directory -## TODO: If you have NuGet Package Restore enabled, uncomment the next line -#packages/ - -# Windows Azure Build Output -csx -*.build.csdef - -# Windows Store app package directory -AppPackages/ - -# Others -sql/ -*.Cache -ClientBin/ -[Ss]tyle[Cc]op.* -~$* -*~ -*.dbmdl -*.[Pp]ublish.xml -*.pfx -*.publishsettings - -# RIA/Silverlight projects -Generated_Code/ - -# Backup & report files from converting an old project file to a newer -# Visual Studio version. Backup files are not needed, because we have git ;-) -_UpgradeReport_Files/ -Backup*/ -UpgradeLog*.XML -UpgradeLog*.htm - -# SQL Server files -App_Data/*.mdf -App_Data/*.ldf - -############# -## Windows detritus -############# - -# Windows image file caches -Thumbs.db -ehthumbs.db - -# Folder config file -Desktop.ini - -# Recycle Bin used on file shares -$RECYCLE.BIN/ - -# Mac crap -.DS_Store - - -############# -## Python -############# - -*.py[cod] - -# Packages -*.egg -*.egg-info -dist/ -eggs/ -parts/ -# var/ -sdist/ -develop-eggs/ -.installed.cfg - -# Installer logs -pip-log.txt - -# Unit test / coverage reports -.coverage -.tox - -#Translations -*.mo - -#Mr Developer -.mr.developer.cfg -*.name -.idea/encodings.xml -.idea/misc.xml -.idea/modules.xml -.idea/phpFastCache.iml -.idea/scopes/scope_settings.xml -.idea/vcs.xml -.idea/workspace.xml - -################# -## NetBeans -################# -nbproject/ - -#Composer -vendor/ -# composer.lock -composer.phar +/vendor/ /cache/ -/composer.lock diff --git a/.idea/codeStyleSettings.xml b/.idea/codeStyleSettings.xml new file mode 100644 index 000000000..c4c954319 --- /dev/null +++ b/.idea/codeStyleSettings.xml @@ -0,0 +1,9 @@ + + + + + + \ No newline at end of file diff --git a/.idea/composerJson.xml b/.idea/composerJson.xml new file mode 100644 index 000000000..4199499cf --- /dev/null +++ b/.idea/composerJson.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/copyright/profiles_settings.xml b/.idea/copyright/profiles_settings.xml new file mode 100644 index 000000000..e7bedf337 --- /dev/null +++ b/.idea/copyright/profiles_settings.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/.idea/deployment.xml b/.idea/deployment.xml new file mode 100644 index 000000000..166216345 --- /dev/null +++ b/.idea/deployment.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/dictionaries/Geolim4.xml b/.idea/dictionaries/Geolim4.xml new file mode 100644 index 000000000..2cd5d2653 --- /dev/null +++ b/.idea/dictionaries/Geolim4.xml @@ -0,0 +1,7 @@ + + + + versioning + + + \ No newline at end of file diff --git a/.idea/encodings.xml b/.idea/encodings.xml new file mode 100644 index 000000000..97626ba45 --- /dev/null +++ b/.idea/encodings.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 000000000..feaf71fc3 --- /dev/null +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,102 @@ + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 000000000..4199499cf --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 000000000..bcce2038b --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/php.xml b/.idea/php.xml new file mode 100644 index 000000000..5fb3cb7d5 --- /dev/null +++ b/.idea/php.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/phpfastcache-website.iml b/.idea/phpfastcache-website.iml new file mode 100644 index 000000000..c956989b2 --- /dev/null +++ b/.idea/phpfastcache-website.iml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/phpfastcache.iml b/.idea/phpfastcache.iml new file mode 100644 index 000000000..900635780 --- /dev/null +++ b/.idea/phpfastcache.iml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 000000000..94a25f7f4 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/webResources.xml b/.idea/webResources.xml new file mode 100644 index 000000000..daf8375ff --- /dev/null +++ b/.idea/webResources.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.scrutinizer.yml b/.scrutinizer.yml deleted file mode 100644 index 9ccb97acf..000000000 --- a/.scrutinizer.yml +++ /dev/null @@ -1,62 +0,0 @@ -# -# This file is part of phpFastCache. -# -# @license MIT License (MIT) -# -# For full copyright and license information, please see the docs/CREDITS.txt file. -# -# @author Georges.L (Geolim4) -# @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors -# - -build: - dependencies: - override: - - "composer require -W --ignore-platform-reqs phpfastcache/phpssdb:^1.2 predis/predis:^2.0" - nodes: - analysis: - project_setup: - override: true - tests: - override: [php-scrutinizer-run] - environment: - php: - version: 8.0.0 - ini: - date.timezone: 'Europe/Paris' - pecl_extensions: - # - couchbase - # - grpc - - redis - - memcache -checks: - php: true -coding_style: - php: - spaces: - around_operators: - concatenation: true -filter: - excluded_paths: - - .github/* - - bin/* - - docs/* - - examples/* - - var/* - - vendor/* - - tests/* -tools: - external_code_coverage: false - php_code_coverage: true - php_code_sniffer: - config: - standard: PSR12 - enabled: true - filter: - paths: - - lib/* - php_mess_detector: - enabled: true - filter: - paths: - - lib/* diff --git a/CHANGELOG.md b/CHANGELOG.md deleted file mode 100644 index 8a6f275ae..000000000 --- a/CHANGELOG.md +++ /dev/null @@ -1,196 +0,0 @@ -## 9.2.4 -##### 30 april 2025 -- __Core__ - - PHP 8.4 compatibility (@khoaofgod, @CHANCENY) -- __Drivers__ - - Redis: Refactor Redis driver to read all keys efficiently (@mapcentia) - -## 9.2.3 -##### 11 january 2024 -- __Drivers__ - - **Added support of `Ravendb` as an extension with its own [sub-repository](https://github.com/PHPSocialNetwork/ravendb-extension).** - - Deprecated `\Phpfastcache\Entities\DriverStatistic::getData()`. Will be removed as of v10. - - Deprecated `\Phpfastcache\Entities\DriverStatistic::setData()`. Will be removed as of v10. - - Added `\Phpfastcache\Entities\DriverStatistic::getCount(): int|null`. If applicable will return the count of cache objects stored in driver database/collection. Null otherwise. - - Added `\Phpfastcache\Entities\DriverStatistic::setCount()` - -## 9.2.2 -##### 11 january 2024 -- __Core__ - - Added optional prefix to `\Phpfastcache\Core\Pool\CacheItemPoolTrait::getKeys()` - -## 9.2.1 -##### 07 january 2024 -- __Misc__ - - Added additional check in cache manager for extensions - -## 9.2.0 -##### 07 january 2024 -- __API__ - - Upgraded Phpfastcache API to `4.3.0` ([see changes](CHANGELOG_API.md)) -- __Extensions__ (💡 New in 9.2) - - Created an extension mechanism to allow some drivers to be loaded independently, see [README.md](README.md) - - Added support of `Couchbasev4` as an extension with its own [sub-repository](https://github.com/PHPSocialNetwork/couchbasev4-extension). - - **IMPORTANT**: *AS OF v9.2* the following drivers has been **MOVED** to their own sub-repositories as a standalone extension: `Arangodb`, `Couchdb`, `Dynamodb`, `Firestore`, `Mongodb`, `Solr`. However `Couchbasev3` will stay in the core for compatibility reasons but will be deprecated. - - **IMPORTANT**: *AS OF v10* extensions will have their namespaces permanently moved from `Phpfastcache\Drivers\EXT_NAME\{Config, Driver, Event, Item}` to `Phpfastcache\Extensions\Drivers\EXT_NAME\{Config, Driver, Event, Item}`. For now an alias is ensuring compatibility. -- __Events__ - - EventManager is now scoped to its own poll if retrieved through `ExtendedCacheItemPoolTrait::->getEventManager()`. Global EventManager `EventManager::getInstance()` remains unchanged, see [EVENTS.md](./docs/EVENTS.md). - - `EventManagerInterface::on()` now also accepts a single `string $events`. - - Alias `\Phpfastcache\PhpfastcacheEventManager` of `\Phpfastcache\EventManager` has been added to improve your code import readability. - - Deprecated `\Phpfastcache\Event\EventManagerDispatcherInterface::hasEventManager` to be removed for v10. -- __Drivers__ - - Implemented #906 // **Added `RedisCluster` driver support** - - Driver `Memstatic` has changed its name to `Memory` for more consistency. - - Driver `Wincache` is now deprecated and will be removed as of v10 due to the lack of updates to PHP 8 [as officially stated by PHP](https://www.php.net/manual/en/install.windows.recommended.php). -- __Pool__ - - Added `ExtendedCacheItemPoolTrait::getAllItems` to allow you to retrieve all items in the cache. This method have some limitations, ([see more in the Wiki](https://github.com/PHPSocialNetwork/phpfastcache/wiki/%5BV5%CB%96%5D-Fetching-all-keys)). -- __Core__ - - Configuration methods`ConfigurationOption::isPreventCacheSlams()`, `ConfigurationOption::setPreventCacheSlams()`, `ConfigurationOption::getCacheSlamsTimeout()`, `ConfigurationOption::setCacheSlamsTimeout()` are deprecated. ([See changes](CHANGELOG_API.md)). - - Fixed #907 // Internal "driver decode()" method will now throw an if the string data looks corrupted. - - Internal: Implemented multiple keys fetch (*if supported by the backend*) to improve the performances behind all `getItems()` calls. Currently only supported in some backends, but it may evolve in the future. - - Internal: Implemented multiple keys delete (*if supported by the backend*) to improve the performances behind all `deleteItems()` calls. Currently only supported in some backends, but it may evolve in the future. - - `\Phpfastcache\CacheContract::get()` now accepts a `\Stringable $cacheKey` argument. -- __Tags__ - - Added `\Phpfastcache\Core\Item\TaggableCacheItemInterface::isTagged(): bool` -- __Misc__ - - Fixed multiple code typo & updated README.md - -## 9.1.3 -##### 12 february 2023 -- __Core__ - - Fixed #893 // getItemsByTag() - empty after one item has expired -- __Misc__ - - Fixed multiple code typo & updated README.md - -## 9.1.2 -##### 09 june 2022 -- __API__ - - Upgraded Phpfastcache API to `4.2.0` ([see changes](CHANGELOG_API.md)) -- __Core__ - - Rewrote some core code to improve code maintainability & readability following Scrutinizer and Phpstan recommendations - - Fixed an issue with tags not properly reinitialized when a backend driver returns an expired cache item -- __Drivers__ - - Fixed #866 // Deprecated Method Cassandra\ExecutionOptions starting of Cassandra 1.3 -- __Misc__ - - Increased PHPSTAN level to 6 - - Fixed multiple fails of Travis CI - - Migrated Github issue templates from Markdown to YAML configurations - -## 9.1.1 -##### 15 april 2022 -- __Core__ - - Fixed #860 // Cache item throw an error on reading with DateTimeImmutable date objects - - Fixed an issue with tags not properly reinitialized when a backend driver returns an expired cache item -- __Drivers__ - - Fixed #862 // Multiple driver errors caused by invalid return type of `driverRead()` (reported by @ShockedPlot7560 and @aemla) - -## 9.1.0 -##### 04 april 2022 -- __API__ - - Upgraded Phpfastcache API to `4.1.0` ([see changes](CHANGELOG_API.md)) -- __Core__ - - Added `\Phpfastcache\Helper\UninstanciableObjectTrait` trait which will contains base locked constructor for any classes that are nor meant to be instanciated. - - Deprecated `\Phpfastcache\Config\Config::class` - - Removed/reworked/improved dead/unreachable/redundant/obsolete code, thanks to `Phpstan` -- __Drivers__ - - **Added `Solr` driver support** -- __Events__ - - Added `\Phpfastcache\Event\EventInterface` for `\Phpfastcache\Event\Event` and subclasses below - - Added `\Phpfastcache\Drivers\Arangodb\Event` for Arangodb events - - Added `\Phpfastcache\Drivers\Dynamodb\Event` for Dynamodb events - - Added `\Phpfastcache\Drivers\Solr\Event` for Solr events - - Moved the following constant from `\Phpfastcache\Event\Event` to their respective drivers: `ARANGODB_CONNECTION`, `ARANGODB_COLLECTION_PARAMS`, `DYNAMODB_CREATE_TABLE` -- __Cluster__ - - Fixed #855 // ClusterReplication drivers are saving erroneous expiration date in low-level backends -- __Misc__ - - Full PSR-12 compliance is now enforced by PHPCS - - Multiple typo fixes (@mbiebl) - - Updated composer suggestions and CI builder dependencies - -## 9.0.2 -##### 04 march 2022 -- __Core__ - - Updated CacheContract::__invoke() signature - - Added new option to allow EventManager override + improved EventManager tests (EventManager::setInstance()) -- __Drivers__ - - Fixed #853 // Configuration validation issue with Memcached socket (path) -- __Misc__ - - Fixed typo and some types hint - -## 9.0.1 -##### 14 november 2021 -- __Core__ - - Added `\Phpfastcache\Event\Event` class for centralizing event name with reusable constants. -- __Item__ - - `\Psr\Cache\CacheItemInterface::set` will also no longer accepts resource object anymore as method unique parameter -- __Misc__ - - Fixed typos in [README.md](./README.md) - -## 9.0.0 -##### 31 october 2021 -- __Migration guide__ - - Read the [migration guide](./docs/migration/MigratingFromV8ToV9.md) to upgrade from V8 to V9 -- __PSR-6__ - - Upgraded `psr/cache` dependency to `^2.0||^3.0` (for PHP-8 types) - - `\Psr\Cache\CacheItemInterface::get()` slightly changed to fully comply with missing PSR-6 specification: If the cache item is **NOT** hit, this method will return `NULL`. -- __PSR-16__ - - Upgraded `psr/simple-cache` dependency to `^2.0||^3.0` (for PHP-8 types) -- __API__ - - Upgraded Phpfastcache API to `4.0.0` ([see changes](CHANGELOG_API.md)) - - Renamed `Api::getPhpFastCacheVersion()` to `Api::getPhpfastcacheVersion()` - - Renamed `Api::getPhpFastCacheChangelog()` to `Api::getPhpfastcacheChangelog()` - - Renamed `Api::getPhpFastCacheGitHeadHash()` to `Api::getPhpfastcacheGitHeadHash()` -- __Cluster__ - - Renamed `\Phpfastcache\Cluster\AggregatorInterface::aggregateNewDriver()` to `\Phpfastcache\Cluster\AggregatorInterface::aggregateDriverByName()` -- __Exceptions__ - - Added `PhpfastcacheEventManagerException` for EventManager-related exceptions -- __Global__ - - Removed magics methods from CacheManager `CacheManager::DriverName()`, use `CacheManager::getInstance('DriverName')` instead - - `\Phpfastcache\Proxy\PhpfastcacheAbstractProxy` now implements `\Phpfastcache\Proxy\PhpfastcacheAbstractProxyInterface` - - Slightly increased performances on some critical points of the library - - Removed "BadPracticeOMeter" notice in CacheManager - - Removed many code duplicate (like in `\Phpfastcache\Driver\[DRIVER_NAME]\Item` classes) - - Reworked traits inter-dependencies for better logic and less polymorphic calls in pool/item traits - - Upgrading library to use benefits of PHP 8 new features (see below) - - Typed every class properties of the library - - Migrated many Closure to arrow functions - - Updated parameters & return type hint to use benefit of covariance and contravariance - - Removed embedded Autoload, Phpfastcache is now only Composer-compatible. - - Removed embedded dependencies (`psr/cache`, `psr/simple-cache`) -- __Helpers__ - - Deprecated `\Phpfastcache\Helper\CacheConditionalHelper`, use `\Phpfastcache\CacheContract` instead - - The `\Phpfastcache\CacheContract` class is now also callable directly without calling `get()` method -- __Config/Options__ - - Configuration object will now be locked once the cache pool instance is running. - - Updated `ConfigurationOption` which is no longer an `ArrayObject` class, therefore array-syntax is no longer available. - - Removed configuration entry `htaccess` for files-based drivers. - - Removed `IOConfigurationOptionTrait::getHtaccess()` - - Removed `IOConfigurationOptionTrait::setHtaccess()` -- __Tests__ - - Added PHPMD, PHPCS and PHPSTAN coverages to increase quality of the project - - Updated tests to work with new core/drivers changes - - Removed Autoload test since its support has been removed and now only managed by Composer - - Increased tests reliability and code coverage for better catching any eventual regression -- __Item__ - - `\Psr\Cache\CacheItemInterface::set` will not accept `\Closure` object anymore as method unique parameter -- __Drivers__ - - Added `Arangodb` driver support - - Added `Dynamodb` (AWS) driver support - - Added `Firestore` (GCP) driver support - - Removed `Cookie` driver because of its potential dangerosity - - Removed `Couchbase` (SDK 2 support dropped) driver which is now replaced by `Couchbasev3` (SDK 3) - - Removed `Devtrue` and `Devfalse` drivers - - Added `Devrandom` with configurable factor chance and data length - - Renamed classes `\Phpfastcache\Cluster\Drivers\[STATEGY]\[CLUSTER_NAME]Cluster` to `\Phpfastcache\Cluster\Drivers\[STATEGY]\Driver` for better driver naming across the project -- __Events__ - - Added `\Phpfastcache\Event\EventReferenceParameter` class and more events such as driver-specific events, see [EVENTS.md](./docs/EVENTS.md) file for more information - - Event callbacks will now receive the `eventName` as an extra _last_ callback parameter (except for `onEveryEvents` callbacks) - - Added `EventManagerInterface::on(array $eventNames, $callback)` method, to subscribe to multiple events in once with the same callback - - Added method named `unbindAllEventCallbacks(): bool` to `EventManagerInterface` to allow you to unbind/clear all event from an event instance - - Updated argument type #2 (`$items`) of `onCacheSaveMultipleItems()` event from `ExtendedCacheItemInterface[]` to `EventReferenceParameter($items)` - - Updated argument type #2 (`$items`) of `onCacheCommitItem()` event from `ExtendedCacheItemInterface[]` to `EventReferenceParameter($items)` - - Updated argument type #2 (`$value`) of `onCacheItemSet()` event from `mixed` to `EventReferenceParameter(mixed $value)` -- __Misc__ - - Increased minimum PHP compatibility in composer to `^8.0` - - Updated copyright headers on every file to include the many project contributors - - Globally renamed every occurrence of `PhpFastCache` to `Phpcastcache` diff --git a/CHANGELOG_API.md b/CHANGELOG_API.md deleted file mode 100644 index 8b90b13da..000000000 --- a/CHANGELOG_API.md +++ /dev/null @@ -1,144 +0,0 @@ -## 4.3.0 -- Created method `ExtendedCacheItemPoolTrait::getAllItems(string $pattern = ''): iterable` which will return all the items stored in the cache. This method have some limitations, ([see more in the Wiki](https://github.com/PHPSocialNetwork/phpfastcache/wiki/%5BV5%CB%96%5D-Fetching-all-keys)). -- Deprecated `ConfigurationOption::isPreventCacheSlams()` for future removal, use `IOConfigurationOption::isPreventCacheSlams()` instead. -- Deprecated `ConfigurationOption::setPreventCacheSlams()` for future removal, use `IOConfigurationOption::setPreventCacheSlams()` instead. -- Deprecated `ConfigurationOption::getCacheSlamsTimeout()` for future removal, use `IOConfigurationOption::getCacheSlamsTimeout()` instead. -- Deprecated `ConfigurationOption::setCacheSlamsTimeout()` for future removal, use `IOConfigurationOption::setCacheSlamsTimeout()` instead. -- Deprecated `\Phpfastcache\Event\EventManagerDispatcherInterface::hasEventManager` to be removed for v10. -- Created `IOConfigurationOption::isPreventCacheSlams()`. This method will **only be available** for `Files, Sqlite, Leveldb` drivers. -- Created `IOConfigurationOption::setPreventCacheSlams()`. This method will **only be available** for `Files, Sqlite, Leveldb` drivers. -- Created `IOConfigurationOption::getCacheSlamsTimeout()`. This method will **only be available** for `Files, Sqlite, Leveldb` drivers. -- Created `IOConfigurationOption::setCacheSlamsTimeout()`. This method will **only be available** for `Files, Sqlite, Leveldb` drivers. -- Method `EventManagerInterface::on(array|string $events, callable $callback)` now also accepts a single `string $events`. -- Added `\Phpfastcache\Core\Item\TaggableCacheItemInterface::isTagged`. - - -## 4.2.0 -- Created method `\Phpfastcache\Cluster\AggregatablePoolInterface::isAggregatedBy(): ?ClusterPoolInterface` which will return the aggregator object for Cluster aggregators -- Created method `\Phpfastcache\Cluster\AggregatablePoolInterface::setAggregatedBy(ClusterPoolInterface $clusterPool): static` which will allow to set the aggregator object - -## 4.1.0 -- Created `\Phpfastcache\Event\EventInterface` which will be used for `Phpfastcache\Event\Event` and any `Phpfastcache\Drivers\xxxxxxx\Event` classes -- Extended `CacheItemPoolInterface::save()` with `ExtendedCacheItemPoolInterface::save()` for re-typing -- Method `ExtendedCacheItemPoolInterface::getConfig()` now returns `ConfigurationOptionInterface` instead of `ConfigurationOption` -- Method `ExtendedCacheItemPoolInterface::getDefaultConfig()` now returns `ConfigurationOptionInterface` instead of `ConfigurationOption` -- Method `EventManagerInterface::getInstance()` now returns `EventManagerInterface` instead of `static` - -## 4.0.0 -- **[BC Break]** Upgraded `psr/cache` dependency to `^3.0` which required `ExtendedCacheItemPoolInterface` and `ExtendedCacheItemInterface` updates -- **[BC Break]** Increased minimum PHP compatibility to `^8.0` which also required `TaggableCacheItemPoolInterface` and `TaggableCacheItemInterface` updates -- **[BC Break]** Updated `ExtendedCacheItemPoolInterface::saveMultiple(ExtendedCacheItemInterface...$items)` which no longer accept argument #0 to be itself an array of `ExtendedCacheItemInterface` objects -- **[BC Break]** Updated `ExtendedCacheItemPoolInterface::getConfigClass()` signature: it is now a **static** method -- Added `ExtendedCacheItemPoolInterface::getItemClass()` -- Added `ExtendedCacheItemInterface::hasTag(string $tag)` to test if a cache item is tagged with the provided tag -- Added `ExtendedCacheItemInterface::hasTag(string $tag)` to test if a cache item is tagged with the provided tag -- Added `ExtendedCacheItemInterface::cloneInto(ExtendedCacheItemInterface $itemTarget, ?ExtendedCacheItemPoolInterface $itemPoolTarget = null)` to clone a cache item into another with an optional pool object -- Referenced `TaggableCacheItemPoolInterface::TAG_STRATEGY_*` constants to `TaggableCacheItemInterface::TAG_STRATEGY_*` for more code usability - -## 3.0.0 -- **[BC Break]** Removed `ExtendedCacheItemPoolInterface::appendItemsByTagsAll()` (replaced by strategy `TaggableCacheItemPoolInterface::TAG_STRATEGY_ALL`) -- **[BC Break]** Removed `ExtendedCacheItemPoolInterface::decrementItemsByTagsAll()` (replaced by strategy `TaggableCacheItemPoolInterface::TAG_STRATEGY_ALL`) -- **[BC Break]** Removed `ExtendedCacheItemPoolInterface::deleteItemsByTagsAll()` (replaced by strategy `TaggableCacheItemPoolInterface::TAG_STRATEGY_ALL`) -- **[BC Break]** Removed `ExtendedCacheItemPoolInterface::getItemsByTagsAll()` (replaced by strategy `TaggableCacheItemPoolInterface::TAG_STRATEGY_ALL`) -- **[BC Break]** Removed `ExtendedCacheItemPoolInterface::incrementItemsByTagsAll()` (replaced by strategy `TaggableCacheItemPoolInterface::TAG_STRATEGY_ALL`) -- **[BC Break]** Removed `ExtendedCacheItemPoolInterface::prependItemsByTagsAll()` (replaced by strategy `TaggableCacheItemPoolInterface::TAG_STRATEGY_ALL`) -- **[BC Break]** Removed deprecated method `ExtendedCacheItemPoolInterface::getConfigOption()` (Use getConfig()->getOptionName() instead) -- **[BC Break]** Removed deprecated method `ExtendedCacheItemPoolInterface::isUsableInAutoContext()` (Since "Auto" driver has been removed) -- Added strategy`TaggableCacheItemPoolInterface::TAG_STRATEGY_ONE` usable in every `**byTags**` methods. -- Added strategy`TaggableCacheItemPoolInterface::TAG_STRATEGY_ALL` usable in every `**byTags**` methods. -- Added strategy`TaggableCacheItemPoolInterface::TAG_STRATEGY_ONLY` usable in every `**byTags**` methods. - -## 3.0.0-rc -- **[BC Break]** Moved `\Phpfastcache\Event\EventInterface` to`\Phpfastcache\Event\EventManagerInterface` -- Moved (by extends) ExtendedCacheItemPoolInterface::setEventManager() in `\Phpfastcache\Event\EventManagerDispatcherInterface:setEventManager()` -- Moved (by extends) ExtendedCacheItemInterface::doesItemBelongToThatDriverBackend() in `\Phpfastcache\Event\EventManagerDispatcherInterface::setEventManager()` -- Added `\Phpfastcache\Event\EventManagerDispatcherInterface` -- Added `ExtendedCacheItemInterface::doesItemBelongToThatDriverBackend()` -- Added `\Phpfastcache\Event\EventManagerInterface:onEveryEvents()` - -## 2.0.4 -- Added ExtendedCacheItemPoolInterface::getConfigClass() that returns the config class name - -## 2.0.3 -- Updated ExtendedCacheItemPoolInterface::setEventManager() first argument that now MUST implement `\Phpfastcache\Event\EventInterface` -- Updated ExtendedCacheItemInterface::setEventManager() first argument that now MUST implement `\Phpfastcache\Event\EventInterface` - -## 2.0.2 -- Added ExtendedCacheItemPoolInterface::isUsableInAutoContext() to check if the driver is allowed to be used in 'Auto' context. - -## 2.0.1 -- Implemented additional atomic methods: -- Added ExtendedCacheItemInterface::isNull() to test if the data is null or not despite the hit/miss status. -- Added ExtendedCacheItemInterface::isEmpty() to test if the data is empty or not despite the hit/miss status. -- Added ExtendedCacheItemInterface::getLength() get the data length if the data is a string, array, or objects that implement \Countable interface. - -## 2.0.0 -- Introduced BC breaks: -- Updated ExtendedCacheItemPoolInterface to be compliant with the new \$config object introduced in V7. -- ExtendedCacheItemPoolInterface::getConfig() no longer returns an array but a ConfigurationOption object -- ExtendedCacheItemPoolInterface::getDefaultConfig() no longer returns an array but a ConfigurationOption object -- Removed ExtendedCacheItemInterface::getUncommittedData() that is no longer used in the V7 - -## 1.3.0 -- Implemented full PHP7 type hint support for ExtendedCacheItemPoolInterface and ExtendedCacheItemInterface -- Added instance ID getter (introduced in V7): - - ExtendedCacheItemPoolInterface::getInstanceId() -- The method ExtendedCacheItemPoolInterface::getDefaultConfig() will now returns a \phpFastCache\Util\ArrayObject - -## 1.2.5 -- Implemented additional simple helper method to direct access to a config option: - - ExtendedCacheItemPoolInterface::getConfigOption() - -## 1.2.4 -- Implemented additional simple helper method to provide basic information about the driver: - - ExtendedCacheItemPoolInterface::getHelp() - -## 1.2.3 -- Implemented additional saving method form multiple items: - ExtendedCacheItemPoolInterface::saveMultiple() - -## 1.2.2 -- Implemented additional tags methods such as: - - ExtendedCacheItemPoolInterface::getItemsByTagsAll() - - ExtendedCacheItemPoolInterface::incrementItemsByTagsAll() - - ExtendedCacheItemPoolInterface::decrementItemsByTagsAll() - - ExtendedCacheItemPoolInterface::deleteItemsByTagsAll() - - ExtendedCacheItemPoolInterface::appendItemsByTagsAll() - - ExtendedCacheItemPoolInterface::prependItemsByTagsAll() - -## 1.2.1 -- Implemented Event manager methods such as: - - ExtendedCacheItemInterface::setEventManager() - - ExtendedCacheItemPoolInterface::setEventManager() - -## 1.2.0 -- Implemented Item advanced time methods such as: - - ExtendedCacheItemInterface::setExpirationDate() (Alias of CacheItemInterface::ExpireAt() for more code logic) - - ExtendedCacheItemInterface::getCreationDate() * - - ExtendedCacheItemInterface::getModificationDate() * - - ExtendedCacheItemInterface::setCreationDate(\DateTimeInterface) * - - ExtendedCacheItemInterface::setModificationDate() * - - \* Require configuration directive "itemDetailedDate" to be enabled - -## 1.1.3 -- Added an additional CacheItemInterface method: - - ExtendedCacheItemInterface::getEncodedKey() - -## 1.1.2 -- Implemented [de|a]ttaching methods to improve memory management - - ExtendedCacheItemPoolInterface::detachItem() - - ExtendedCacheItemPoolInterface::detachAllItems() - - ExtendedCacheItemPoolInterface::attachItem() - - ExtendedCacheItemPoolInterface::isAttached() - -## 1.1.1 -- Implemented JsonSerializable interface to ExtendedCacheItemInterface - -## 1.1.0 -- Implemented JSON methods such as: - - ExtendedCacheItemPoolInterface::getItemsAsJsonString() - - ExtendedCacheItemPoolInterface::getItemsByTagsAsJsonString() - - ExtendedCacheItemInterface::getDataAsJsonString() - -## 1.0.0 -- First initial version diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md deleted file mode 100644 index 3395a8a26..000000000 --- a/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,46 +0,0 @@ -# Contributor Covenant Code of Conduct - -## Our Pledge - -In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation. - -## Our Standards - -Examples of behavior that contributes to creating a positive environment include: - -* Using welcoming and inclusive language -* Being respectful of differing viewpoints and experiences -* Gracefully accepting constructive criticism -* Focusing on what is best for the community -* Showing empathy towards other community members - -Examples of unacceptable behavior by participants include: - -* The use of sexualized language or imagery and unwelcome sexual attention or advances -* Trolling, insulting/derogatory comments, and personal or political attacks -* Public or private harassment -* Publishing others' private information, such as a physical or electronic address, without explicit permission -* Other conduct which could reasonably be considered inappropriate in a professional setting - -## Our Responsibilities - -Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior. - -Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. - -## Scope - -This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers. - -## Enforcement - -Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at team@phpfastcache.com. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately. - -Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership. - -## Attribution - -This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version] - -[homepage]: http://contributor-covenant.org -[version]: http://contributor-covenant.org/version/1/4/ diff --git a/CODING_GUIDELINE.md b/CODING_GUIDELINE.md deleted file mode 100644 index d68d256cd..000000000 --- a/CODING_GUIDELINE.md +++ /dev/null @@ -1,59 +0,0 @@ -CODING GUIDELINE -------------------- - -Fork the project, create a feature branch, and send us a pull request. -Preferably on a distinct branch. - -To ensure a consistent code base, you should make sure the code follows -the [PSR-12: Extended Coding Style](https://www.php-fig.org/psr/psr-12/). You can also -run [php-cs-fixer](https://github.com/FriendsOfPHP/PHP-CS-Fixer) with the -configuration file that can be found in the project root directory. - -If you would like to help, take a look at the [list of open issues](https://github.com/PHPSocialNetwork/phpfastcache/issues). - -PHPFASTCACHE's specialties -------------------- -As of the V7 your contributions MUST comply the following standards: - -### PHP CORE FUNCTIONS -- To improve Opcode efficiency, you MUST prefix core function by a '\\' - - E.g: `$var = \str_replace('value', '', $var);` - -### PHP CORE CONSTANTS -- To improve Opcode efficiency, you MUST prefix core constants by a '\\' - - E.g: `$dateFormat = \DATE_ISO8601` - -### PHP CORE CLASSES -- Do not import non-namespaced classes, use an absolute path instead: - - E.g: `$date = new \DateTime();` - -### CODE STYLE -- Unneeded/inconsistent `else` statements have to be shortened. - - E.g: - ```php - acme = $acme; - return $this; - } else { - throw new phpFastCacheInvalidArgumentException('Invalid acme instance'); - } -} - ``` - - This example can be safely replaced by this one: -```php - acme = $acme; - return $this; - } - - throw new phpFastCacheInvalidArgumentException('Invalid acme instance'); -} - ``` -[Read this thread on StackExchange for more information](https://softwareengineering.stackexchange.com/questions/122485/elegant-ways-to-handle-ifif-else-else) -This list is non-exhaustive and will may subject to evolve at any time. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md deleted file mode 100644 index d269e87f2..000000000 --- a/CONTRIBUTING.md +++ /dev/null @@ -1,38 +0,0 @@ -Contributing to PhpFastCache -======================== - -Please note that this project is released with a -[Contributor Code of Conduct](https://www.contributor-covenant.org/version/1/4/code-of-conduct/). -By participating in this project you agree to abide by its terms. - -Reporting Issues ----------------- - -When reporting issues, please try to be as descriptive as possible, and include -as much relevant information as you can. A step by step guide on how to -reproduce the issue will greatly increase the chances of your issue being -resolved in a timely manner. - -Contributing policy -------------------- - -Our contributing policy is described in our [Coding Guideline](https://github.com/PHPSocialNetwork/phpfastcache/blob/master/CODING_GUIDELINE.md) - -Developer notes -------------------- -If you want to contribute to the repository you will need to install/configure some things first. - -To run tests follow the steps: -1) Run `./bin/ci/scripts/install_dependencies.sh` -2) Run `./vendor/bin/phpcs lib/ --report=summary` -3) Run `./vendor/bin/phpmd lib/ ansi phpmd.xml` -4) Run `./vendor/bin/phpstan analyse lib/ -c phpstan_lite.neon 2>&1` -5) Run `php -f ./bin/ci/run_tests.php` - -If you are on Windows environment simply run the file `quality.bat` located at the root of the project to run the step 2, 3 and 4 in once. - -The last command will run all the unit tests of the project. -If an error appears, fix it then you can submit your pull request. - -Some tests will be skipped if you don't have special dependencies installed (Arangodb, Couchbase, Couchdb, Firestore credential and SDK, Dynamodb credential, etc.).\ -So don't worry if those tests are skipped as long as they **pass** on the GitHub and Travis CIs. diff --git a/EXTENSIONS.MD b/EXTENSIONS.MD deleted file mode 100644 index 71d569465..000000000 --- a/EXTENSIONS.MD +++ /dev/null @@ -1,20 +0,0 @@ -## As of the 9.2 an extension concept has been introduced. - -It's pretty new but allow Phpfastcache to split up its drivers into sub-repository with a simple additional call to make. - -The 9.2 make the beginning of a new external extensions: - -- `Arangodb` -- `Couchbasev4` -- `Couchdb` -- `Dynamodb` -- `Firestore` -- `Mongodb` -- `Solr` - -There's only 2 steps: - -1) Add it to your composer: `composer install phpfastcache/couchbasev4-extension` -2) Call the CacheManager: `CacheManager::getInstance('Couchbasev4')` - -However `Couchbasev3` will stay in the core for compatibility reason but will be **deprecated**. diff --git a/LICENCE b/LICENCE deleted file mode 100644 index 6b5101b33..000000000 --- a/LICENCE +++ /dev/null @@ -1,20 +0,0 @@ -Copyright (c) 2023 Phpfastcache & its Extensions - -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. diff --git a/README.md b/README.md deleted file mode 100644 index b45d56622..000000000 --- a/README.md +++ /dev/null @@ -1,319 +0,0 @@ -[![Total Downloads](https://img.shields.io/packagist/dt/phpfastcache/phpfastcache.svg?maxAge=86400)](https://packagist.org/packages/phpfastcache/phpfastcache) [![Latest Stable Version](https://img.shields.io/packagist/v/phpfastcache/phpfastcache.svg?maxAge=86400)](https://packagist.org/packages/phpfastcache/phpfastcache) [![PHPSTAN](https://img.shields.io/badge/PHPSTAN-L6-blue.svg?maxAge=86400)](https://github.com/PHPSocialNetwork/phpfastcache/blob/master/phpstan.neon) [![Cache Interface](https://img.shields.io/badge/CI-PSR6-orange.svg?maxAge=86400)](https://github.com/php-fig/cache) [![Extended Coding Style](https://img.shields.io/badge/ECS-PSR12-orange.svg?maxAge=86400)](https://www.php-fig.org/psr/psr-12/) [![Simple Cache](https://img.shields.io/badge/SC-PSR16-orange.svg?maxAge=86400)](https://github.com/php-fig/simple-cache) -[![Code Climate](https://codeclimate.com/github/PHPSocialNetwork/phpfastcache/badges/gpa.svg)](https://codeclimate.com/github/PHPSocialNetwork/phpfastcache) [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/PHPSocialNetwork/phpfastcache/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/PHPSocialNetwork/phpfastcache/?branch=master) [![Build status](https://github.com/PHPSocialNetwork/phpfastcache/actions/workflows/testsv2.yml/badge.svg)](https://github.com/PHPSocialNetwork/phpfastcache/actions/workflows/testsv2.yml) [![Semver compliant](https://img.shields.io/badge/Semver-2.0.0-yellow.svg?maxAge=86400)](https://semver.org/spec/v2.0.0.html) [![License](https://img.shields.io/packagist/l/phpfastcache/phpfastcache.svg?maxAge=86400)](https://packagist.org/packages/phpfastcache/phpfastcache) [![Patreon](https://img.shields.io/badge/Support%20us%20on-Patreon-f96854.svg?maxAge=86400)](https://www.patreon.com/geolim4) - -#### :warning: Please note that the V9 is mostly a PHP 8 type aware update of Phpfastcache with some significant changes ! -> As the V9 is **relatively** not compatible with previous versions, please read carefully the [migration guide](./docs/migration/MigratingFromV8ToV9.md) to ensure you the smoothest migration possible. -One of the biggest changes is the configuration system which is now an object that replace the primitive array that we used to implement back then. -Also, please note that the V9 requires at least PHP 8 or higher to works properly. - ---------------------------- -Simple Yet Powerful PHP Caching Class ---------------------------- -More information in [Wiki](https://github.com/PHPSocialNetwork/phpfastcache/wiki) -The simplicity of abstraction: One class for many backend cache. You don't need to rewrite your code many times again. - -### Supported drivers at this day * -:bulb: Feel free to propose a driver by making a new **[Pull Request](https://github.com/PHPSocialNetwork/phpfastcache/compare)**, they are welcome ! - -| Regular drivers | High performances drivers | Development drivers _(Core)_ | Cluster-Aggregated drivers _(Core)_ | -|--------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------|--------------------------------------------|---------------------------------------| -| `Apcu` _(Core)_
_(APC support removed)_ | `Arangodb` _([Extension](https://github.com/PHPSocialNetwork/arangodb-extension))_ | `Devnull` | `FullReplicationCluster` | -| `Dynamodb` _([Extension](https://github.com/PHPSocialNetwork/dynamodb-extension))_ | `Cassandra`
_(PHP extension is no more maintained by Datastax, might be deprecated in v10)_ | `Devrandom` | `SemiReplicationCluster` | -| `Files` _(Core)_ | `CouchBasev3` _(Core)_
_(Will be deprecated as of v10)_ | `Memory`
(Previously named `Memstatic`) | `MasterSlaveReplicationCluster` | -| `Firestore` _([Extension](https://github.com/PHPSocialNetwork/firestore-extension))_ | `CouchBasev4` _([Extension](https://github.com/PHPSocialNetwork/couchbasev4-extension))_ | | `RandomReplicationCluster` | -| `Leveldb` _(Core)_ | `Couchdb` _([Extension](https://github.com/PHPSocialNetwork/couchdb-extension))_ | | | -| `Memcache(d)` _(Core)_ | `Mongodb` _([Extension](https://github.com/PHPSocialNetwork/mongodb-extension))_ | | | -| `Solr` _([Extension](https://github.com/PHPSocialNetwork/solr-extension))_ | `Predis` _(Core)_ | | | -| `Sqlite` _(Core)_ | `Ravendb` _([Extension](https://github.com/PHPSocialNetwork/ravendb-extension)) | | | -| ` Wincache` _(Core)_
(**Deprecated** as of v9.2, will be removed as of v10) | `Relay` ([By end of 2024](https://relay.so/)) | -| `Zend Disk Cache` _(Core)_ | `Redis`/`RedisCluster` _(Core)_ | | | -| | `Ssdb` _(Core)_ | | | -| | `Zend Memory Cache` _(Core)_ | | | - -\* Driver descriptions available in [DOCS/DRIVERS.md](./docs/DRIVERS.md) - -:new: As of v9.2 a new Couchbase extension has been released: [Couchbasev4](https://github.com/PHPSocialNetwork/couchbasev4-extension) -Also a new driver extension has been added: `Ravendb`. The driver will be **actively developed** in the feature to allow better fine-grained configuration. -This new extension **is the beginning of a new era** for Phpfastcache along with some others:\ -Many drivers has been moved from the core to their own sub-repository as a standalone extension: `Arangodb`, `Couchdb`, `Dynamodb`, `Firestore`, `Mongodb`, `Solr`.\ -They can be easily added through composer, ex: `composer install phpfastcache/couchbasev4-extension` -However `Couchbasev3` **will stay in the core** for compatibility reasons but will be deprecated. - ---------------------------- -Because caching does not mean weaken your code ---------------------------- -Phpfastcache has been developed over the years with 3 main goals: - -- Performance: We optimized and still optimize the code to provide you the lightest library as possible -- Security: Because caching strategies can sometimes comes with unwanted vulnerabilities, we do our best to provide you a sage & strong library as possible -- Portability: No matter what operating system you're working on, we did our best to provide you the most cross-platform code as possible - ---------------------------- -Rich Development API ---------------------------- - -Phpfastcache provides you a lot of useful APIs: - -### Item API (ExtendedCacheItemInterface) - -| Method | Return | Description | -|-------------------------------------------------|------------------------------|---------------------------------------------------------------------------------------------------------------------------------------| -| `addTag($tagName)` | `ExtendedCacheItemInterface` | Adds a tag | -| `addTags(array $tagNames)` | `ExtendedCacheItemInterface` | Adds multiple tags | -| `append($data)` | `ExtendedCacheItemInterface` | Appends data to a string or an array (push) | -| `decrement($step = 1)` | `ExtendedCacheItemInterface` | Redundant joke... | -| `expiresAfter($ttl)` | `ExtendedCacheItemInterface` | Allows you to extends the lifetime of an entry without altering its value (formerly known as touch()) | -| `expiresAt($expiration)` | `ExtendedCacheItemInterface` | Sets the expiration time for this cache item (as a DateTimeInterface object) | -| `get()` | `mixed` | The getter, obviously, returns your cache object | -| `getCreationDate()` | `\DatetimeInterface` | Gets the creation date for this cache item (as a DateTimeInterface object) * | -| `getDataAsJsonString()` | `string` | Return the data as a well-formatted json string | -| `getEncodedKey()` | `string` | Returns the final and internal item identifier (key), generally used for debug purposes | -| `getExpirationDate()` | `ExtendedCacheItemInterface` | Gets the expiration date as a Datetime object | -| `getKey()` | `string` | Returns the item identifier (key) | -| `getLength()` | `int` | Gets the data length if the data is a string, array, or objects that implement `\Countable` interface. | -| `getModificationDate()` | `\DatetimeInterface` | Gets the modification date for this cache item (as a DateTimeInterface object) * | -| `getTags()` | `string[]` | Gets the tags | -| `hasTag(string $tagName)` | `bool` | Check if the cache item contain one specific tag | -| `hasTags(array $tagNames, int $strategy): bool` | `bool` | Check if the cache item contain one or more specific tag with optional strategy (default to TAG_STRATEGY_ONE) | -| `isTagged(): bool` | `bool` | Check if the cache item has at least one tag (v9.2) | -| `getTagsAsString($separator = ', ')` | `string` | Gets the data as a string separated by $separator | -| `getTtl()` | `int` | Gets the remaining Time To Live as an integer | -| `increment($step = 1)` | `ExtendedCacheItemInterface` | To allow us to count on an integer item | -| `isEmpty()` | `bool` | Checks if the data is empty or not despite the hit/miss status. | -| `isExpired()` | `bool` | Checks if your cache entry is expired | -| `isHit()` | `bool` | Checks if your cache entry exists and is still valid, it's the equivalent of isset() | -| `isNull()` | `bool` | Checks if the data is null or not despite the hit/miss status. | -| `prepend($data)` | `ExtendedCacheItemInterface` | Prepends data to a string or an array (unshift) | -| `removeTag($tagName)` | `ExtendedCacheItemInterface` | Removes a tag | -| `removeTags(array $tagNames)` | `ExtendedCacheItemInterface` | Removes multiple tags | -| `set($value)` | `ExtendedCacheItemInterface` | The setter, for those who missed it, can be anything except resources or non-serializer object (ex: PDO objects, file pointers, etc). | -| `setCreationDate($expiration)` | `\DatetimeInterface` | Sets the creation date for this cache item (as a DateTimeInterface object) * | -| `setEventManager($evtMngr)` | `ExtendedCacheItemInterface` | Sets the event manager | -| `setExpirationDate()` | `ExtendedCacheItemInterface` | Alias of expireAt() (for more code logic) | -| `setModificationDate($expiration)` | `\DatetimeInterface` | Sets the modification date for this cache item (as a DateTimeInterface object) * | -| `setTags(array $tags)` | `ExtendedCacheItemInterface` | Sets multiple tags | -\* Require configuration directive "itemDetailedDate" to be enabled, else a \LogicException will be thrown - -### ItemPool API (ExtendedCacheItemPoolInterface) -| Methods (By Alphabetic Order) | Return | Description | -|---------------------------------------------------------------|----------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| `appendItemsByTag($tagName, $data)` | `bool` | Appends items by a tag | -| `appendItemsByTags(array $tagNames, $data)` | `bool` | Appends items by one of multiple tag names | -| `attachItem($item)` | `void` | (Re-)attaches an item to the pool | -| `clear()` | `bool` | Allows you to completely empty the cache and restart from the beginning | -| `commit()` | `bool` | Persists any deferred cache items | -| `decrementItemsByTag($tagName, $step = 1)` | `bool` | Decrements items by a tag | -| `decrementItemsByTags(array $tagNames, $step = 1)` | `bool` | Decrements items by one of multiple tag names | -| `deleteItem($key)` | `bool` | Deletes an item | -| `deleteItems(array $keys)` | `bool` | Deletes one or more items | -| `deleteItemsByTag($tagName)` | `bool` | Deletes items by a tag | -| `deleteItemsByTags(array $tagNames, int $strategy)` | `bool` | Deletes items by one of multiple tag names | -| `detachItem($item)` | `void` | Detaches an item from the pool | -| `getConfig()` | `ConfigurationOption` | Returns the configuration object | -| `getConfigOption($optionName);` | `mixed` | Returns a configuration value by its key `$optionName` | -| `getDefaultConfig()` | `ConfigurationOption` | Returns the default configuration object (not altered by the object instance) | -| `getDriverName()` | `string` | Returns the current driver name (without the namespace) | -| `getEventManager()` | `EventManagerInterface` | Gets the event manager | -| `getHelp()` | `string` | Provides a very basic help for a specific driver | -| `getInstanceId()` | `string` | Returns the instance ID | -| `getItem($key)` | `ExtendedCacheItemInterface` | Retrieves an item and returns an empty item if not found | -| `getItems(array $keys)` | `ExtendedCacheItemInterface[]` | Retrieves one or more item and returns an array of items. As of v9.2 an internal improvement has been made to this method. | -| `getAllItems(string $pattern = '')` | `ExtendedCacheItemInterface[]` | *(v9.2)* Retrieves all cache items with a hard limit of 9999 items. Support [limited to some drivers](https://github.com/PHPSocialNetwork/phpfastcache/wiki/%5BV5%CB%96%5D-Fetching-all-keys) | -| `getItemsAsJsonString(array $keys)` | `string` | Returns A json string that represents an array of items | -| `getItemsByTag($tagName, $strategy)` | `ExtendedCacheItemInterface[]` | Returns items by a tag | -| `getItemsByTags(array $tagNames, $strategy)` | `ExtendedCacheItemInterface[]` | Returns items by one of multiple tag names | -| `getItemsByTagsAsJsonString(array $tagNames, $strategy)` | `string` | Returns A json string that represents an array of items corresponding | -| `getStats()` | `DriverStatistic` | Returns the cache statistics as an object, useful for checking disk space used by the cache etc. | -| `hasEventManager()` | `bool` | Check the event manager | -| `hasItem($key)` | `bool` | Tests if an item exists | -| `incrementItemsByTag($tagName, $step = 1, $strategy)` | `bool` | Increments items by a tag | -| `incrementItemsByTags(array $tagNames, $step = 1, $strategy)` | `bool` | Increments items by one of multiple tag names | -| `isAttached($item)` | `bool` | Verify if an item is (still) attached | -| `prependItemsByTag($tagName, $data, $strategy)` | `bool` | Prepends items by a tag | -| `prependItemsByTags(array $tagNames, $data, $strategy)` | `bool` | Prepends items by one of multiple tag names | -| `save(CacheItemInterface $item)` | `bool` | Persists a cache item immediately | -| `saveDeferred(CacheItemInterface $item)` | `bool` | Sets a cache item to be persisted later | -| `saveMultiple(...$items)` | `bool` | Persists multiple cache items immediately | -| `setEventManager(EventManagerInterface $evtMngr)` | `ExtendedCacheItemPoolInterface` | Sets the event manager | - -:new: in **V8**: Multiple strategies (`$strategy`) are now supported for tagging: -- `TaggableCacheItemPoolInterface::TAG_STRATEGY_ONE` allows you to get cache item(s) by at least **ONE** of the specified matching tag(s). **Default behavior.** -- `TaggableCacheItemPoolInterface::TAG_STRATEGY_ALL` allows you to get cache item(s) by **ALL** of the specified matching tag(s) (the cache item *can* have additional tag(s)) -- `TaggableCacheItemPoolInterface::TAG_STRATEGY_ONLY` allows you to get cache item(s) by **ONLY** the specified matching tag(s) (the cache item *cannot* have additional tag(s)) - -It also supports multiple calls, Tagging, Setup Folder for caching. Look at our examples folders for more information. - -### Phpfastcache versioning API -Phpfastcache provides a class that gives you basic information about your Phpfastcache installation -- Get the API version (Item+Pool interface) with `Phpfastcache\Api::GetVersion();` -- Get the API changelog (Item+Pool interface) `Phpfastcache\Api::getChangelog();` -- Get the Phpfastcache version with `Phpfastcache\Api::getPhpfastcacheVersion();` -- Get the Phpfastcache changelog `Phpfastcache\Api::getPhpfastcacheChangelog();` - ---------------------------- -Want to keep it simple ? ---------------------------- -:sweat_smile: Good news, as of the V6, a Psr16 adapter is provided to keep the cache simplest using very basic getters/setters: - -- `get($key, $default = null);` -- `set($key, $value, $ttl = null);` -- `delete($key);` -- `clear();` -- `getMultiple($keys, $default = null);` -- `setMultiple($values, $ttl = null);` -- `deleteMultiple($keys);` -- `has($key);` - -Basic usage: -```php -has('test-key')){ - // Setter action - $data = 'lorem ipsum'; - $Psr16Adapter->set('test-key', 'lorem ipsum', 300);// 5 minutes -}else{ - // Getter action - $data = $Psr16Adapter->get('test-key'); -} - - -/** -* Do your stuff with $data -*/ -``` - -Internally, the Psr16 adapter calls the Phpfastcache Api via the cache manager. - ---------------------------- -Introducing to events ---------------------------- - -:mega: As of the V6, Phpfastcache provides an event mechanism. -You can subscribe to an event by passing a Closure to an active event: - -```php -onCacheGetItem(function(ExtendedCacheItemPoolInterface $itemPool, ExtendedCacheItemInterface $item){ - $item->set('[HACKED BY EVENT] ' . $item->get()); -}); - -``` - -An event callback can get unbind but you MUST provide a name to the callback previously: - -```php -onCacheGetItem(function(ExtendedCacheItemPoolInterface $itemPool, ExtendedCacheItemInterface $item){ - $item->set('[HACKED BY EVENT] ' . $item->get()); -}, 'myCallbackName'); - - -/** -* Unbind the event callback -*/ -EventManager::getInstance()->unbindEventCallback('onCacheGetItem', 'myCallbackName'); - -``` -:new: As of the **V8** you can simply subscribe to **every** event of Phpfastcache. - -More information about the implementation and the events are available on the [Wiki](https://github.com/PHPSocialNetwork/phpfastcache/wiki/%5BV6%CB%96%5D-Introducing-to-events) - ---------------------------- -Introducing new helpers ---------------------------- -:books: As of the V6, Phpfastcache provides some helpers to make your code easier. - -- (:warning: Removed in v8, [why ?](https://github.com/PHPSocialNetwork/phpfastcache/wiki/%5BV6%CB%96%5D-Act-on-all-instances)) ~~The [ActOnAll Helper](https://github.com/PHPSocialNetwork/phpfastcache/wiki/%5BV6%CB%96%5D-Act-on-all-instances) to help you to act on multiple instance at once.~~ -- The [CacheConditional Helper](https://github.com/PHPSocialNetwork/phpfastcache/wiki/%5BV6%CB%96%5D-Cache-Conditional) to help you to make the basic conditional statement more easier. -- The [Psr16 adapter](https://github.com/PHPSocialNetwork/phpfastcache/wiki/%5BV6%CB%96%5D-Psr16-adapter) - -May more will come in the future, feel free to contribute ! - ---------------------------- -Introducing aggregated cluster support ---------------------------- -Check out the [WIKI](https://github.com/PHPSocialNetwork/phpfastcache/wiki/%5BV8%CB%96%5D-Aggregated-cache-cluster) to learn how to implement aggregated cache clustering feature. - ---------------------------- -As Fast To Implement As Opening a Beer ---------------------------- - - -#### :thumbsup: Step 1: Include phpFastCache in your project with composer: - - -```bash -composer require phpfastcache/phpfastcache -``` - -#### :construction: Step 2: Setup your website code to implement the phpFastCache calls (with Composer) -```php - '/var/www/phpfastcache.com/dev/tmp', // or in windows "C:/tmp/" -])); - -// In your class, function, you can call the Cache -$InstanceCache = CacheManager::getInstance('files'); - -/** - * Try to get $products from Caching First - * product_page is "identity keyword"; - */ -$key = "product_page"; -$CachedString = $InstanceCache->getItem($key); - -$your_product_data = [ - 'First product', - 'Second product', - 'Third product' - /* ... */ -]; - -if (!$CachedString->isHit()) { - $CachedString->set($your_product_data)->expiresAfter(5);//in seconds, also accepts Datetime - $InstanceCache->save($CachedString); // Save the cache item just like you do with doctrine and entities - - echo 'FIRST LOAD // WROTE OBJECT TO CACHE // RELOAD THE PAGE AND SEE // '; - echo $CachedString->get(); - -} else { - echo 'READ FROM CACHE // '; - echo $CachedString->get()[0];// Will print 'First product' -} - -/** - * use your products here or return them; - */ -echo implode('
', $CachedString->get());// Will echo your product list - -``` - -#### :zap: Step 3: Enjoy ! Your website is now faster than lightning ! -For curious developers, there is a lot of other examples available [here](./docs/examples). - -#### :boom: Phpfastcache support -Found an issue or have an idea ? Come **[here](https://github.com/PHPSocialNetwork/phpfastcache/issues)** and let us know ! diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 838b0dc8d..000000000 --- a/SECURITY.md +++ /dev/null @@ -1,26 +0,0 @@ -# Security Policy -If you discover any vulnerability please be aware of the following table of supported versions below. -Then feel free to contact me at the email address provided in the bottom of that page. - -## Supported Versions -| Version | End of support | End of life | -|---------|------------------|------------------| -| 10.0 | *In development* | *In development* | -| 9.2 | December 2025 | December 2026 | -| 9.1 | December 2024 | December 2025 | -| 9.0 | December 2023 | December 2024 | -| 8.x | July 2023 | July 2024 | -| 7.1 | July 2021 | July 2022 | -| 7.0 | July 2019 | July 2020 | -| 6.0 | July 2020 | July 2021 | -| 5.0 | July 2018 | July 2019 | -| 4.0 | July 2017 | January 2018 | -| < 4.0 | N/A | N/A | - -More details on the [Wiki](https://github.com/PHPSocialNetwork/phpfastcache/wiki/%5BV4%CB%96%5D-Global-support-timeline) - -## Reporting a Vulnerability -If you discover any security vulnerability contact me at contact#at#geolim4.com with a subject formatted like that:\ -`[PHPFASTCACHE][VULNERABILITY] Your mail subject goes here` - -Thanks in advance for taking the time to report me that in private. diff --git a/ajax/pages/authors.html b/ajax/pages/authors.html new file mode 100644 index 000000000..c24f1480a --- /dev/null +++ b/ajax/pages/authors.html @@ -0,0 +1,124 @@ +
+
+
+
+
+

...Georges.L

+
+ +
+
+
+

Senior software engineer

+
+
+
    +
  • Senior software engineer / Tech Lead
    + Smile S.A, 2019 - Present +
  • +
  • Lead Developer
    + ImagesCreations, 2017 - 2019 +
  • +
  • Junior Web Developer / A.M Manager
    + Vigicorp, 2014 - 2017 +
  • +
  • Lead Developer
    + ImagesCreations, 2017 - Present +
  • +
  • PhpFastCache Co-Founder (V5 and later)
    + January 2016 - Present +
  • +
  • Extension team member
    + phpBB, 2013 - 2015 +
  • +
  • Bug Bounty hunter
    + Undisclosed companies, Summer 2016 - Present +
  • +
+
+ +
+
+
+
+
+
+
+

...Khoa.B

+
+ +
+
+
+

Senior PHP Web Developer

+
+
+
    +
  • Senior Web Developer
    + Molekula, Jan 2012 - 2013 +
  • +
  • Senior Web Developer
    + Alilang Fashion, Apr 2011 - 2014 +
  • +
  • Front-End Developer
    + VirtualPoint, Oct 2010 - Apr 2011 +
  • +
  • PhpFastCache Original Founder
    + April 2013 - Present +
  • +
  • Main Programmer / Server Administrator
    + EDM Tunes, May 2012 - Present +
  • +
+
+ +
+
+
+
+
+
diff --git a/ajax/pages/readme.html b/ajax/pages/readme.html new file mode 100644 index 000000000..6618e551c --- /dev/null +++ b/ajax/pages/readme.html @@ -0,0 +1,14 @@ + \ No newline at end of file diff --git a/bin/ci/php_common.ini b/bin/ci/php_common.ini deleted file mode 100644 index 49b897ccd..000000000 --- a/bin/ci/php_common.ini +++ /dev/null @@ -1,8 +0,0 @@ -extension="apcu.so" -extension="redis.so" -extension="mongodb.so" -apc.enabled=1 -apc.shm_size=32M -apc.ttl=7200 -apc.enable_cli=1 -apc.serializer=php diff --git a/bin/ci/scripts/install_couchbase.sh b/bin/ci/scripts/install_couchbase.sh deleted file mode 100755 index 5e88f757e..000000000 --- a/bin/ci/scripts/install_couchbase.sh +++ /dev/null @@ -1,79 +0,0 @@ -#!/bin/bash - -set -e - -# https://packages.couchbase.com/releases/7.1.1/couchbase-server-community_7.1.1-ubuntu18.04_amd64.deb -export CB_VERSION=7.1.1 -export CB_RELEASE_URL=https://packages.couchbase.com/releases -export CB_PACKAGE=couchbase-server-community_7.1.1-ubuntu18.04_amd64.deb - -# Community Edition requires that all nodes provision all services or data service only -export SERVICES="kv,n1ql,index,fts" - -export USERNAME=test -export PASSWORD=phpfastcache - -export MEMORY_QUOTA=256 -export INDEX_MEMORY_QUOTA=256 -export FTS_MEMORY_QUOTA=256 - - -# Check if couchbase server is up -check_db() { - curl --silent http://127.0.0.1:8091/pools > /dev/null - echo $? -} - -# Variable used in echo -i=1 -# Echo with -numbered_echo() { - echo "[$i] $*" - i=$(($i+1)) -} - -echo "# Prepare Couchbase dependencies" -sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys A3FAA648D9223EDA -sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 1616981CC4A088B2 -echo "deb https://packages.couchbase.com/ubuntu bionic bionic/main" | sudo tee /etc/apt/sources.list.d/couchbase.list -echo "deb https://packages.couchbase.com/clients/c/repos/deb/ubuntu1804 bionic bionic/main" | sudo tee /etc/apt/sources.list.d/couchbase.list -sudo apt-get update -sudo apt-get install -yq libcouchbase3 libcouchbase-dev build-essential libssl1.1 runit wget python3-httplib2 chrpath tzdata lsof lshw sysstat net-tools numactl libtinfo5 - -echo "# Downloading couchbase v${CB_VERSION}" -wget -q -N $CB_RELEASE_URL/$CB_VERSION/$CB_PACKAGE -sudo dpkg -i ./$CB_PACKAGE && rm -f ./$CB_PACKAGE - -# Wait until it's ready -until [[ $(check_db) = 0 ]]; do - >&2 numbered_echo "Waiting for Couchbase Server to be available" - sleep 1 -done - -echo "# Couchbase Server Online" -echo "# Starting setup process" -echo "# 1) Setting up memory" -curl -i "http://127.0.0.1:8091/pools/default" \ - -d memoryQuota=${MEMORY_QUOTA} \ - -d indexMemoryQuota=${INDEX_MEMORY_QUOTA} \ - -d ftsMemoryQuota=${FTS_MEMORY_QUOTA} - -echo "# 2) Setting up services" -curl -i "http://127.0.0.1:8091/node/controller/setupServices" \ - -d services="${SERVICES}" - -echo "# 3) Setting up user credentials" -curl -i "http://127.0.0.1:8091/settings/web" \ - -d port=8091 \ - -d username=${USERNAME} \ - -d password=${PASSWORD} - -echo "# 4) Setting up the bucket" -curl -i "http://127.0.0.1:8091/pools/default/buckets" \ - -d name=phpfastcache \ - -d ramQuotaMB=256 \ - -d flushEnabled=1 \ - -u ${USERNAME}:${PASSWORD} \ - - -echo "# Couchbase running successfully" diff --git a/bin/ci/scripts/install_dependencies.sh b/bin/ci/scripts/install_dependencies.sh deleted file mode 100755 index 6ea43d5b9..000000000 --- a/bin/ci/scripts/install_dependencies.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env bash - -composer self-update -composer validate -composer install -composer require -W phpfastcache/phpssdb:^1.2 predis/predis:^2.0 diff --git a/bin/ci/scripts/install_ssdb.sh b/bin/ci/scripts/install_ssdb.sh deleted file mode 100755 index bd651d618..000000000 --- a/bin/ci/scripts/install_ssdb.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/bash - -set -e - -wget --no-check-certificate -O master.zip https://codeload.github.com/ideawu/ssdb/zip/master -unzip -q master -cd ssdb-master - -make > /dev/null 2>&1 -if [ $? -eq 0 ]; then - echo "[OK] Make command succeeded, running server..." - ./ssdb-server -d ssdb.conf -else - echo "[KO] Make command failed, the server will NOT be running" -fi diff --git a/bin/stubs/leveldb/README.md b/bin/stubs/leveldb/README.md deleted file mode 100644 index a2df6aed2..000000000 --- a/bin/stubs/leveldb/README.md +++ /dev/null @@ -1 +0,0 @@ -Please see: https://github.com/reeze/php-leveldb for more documentation \ No newline at end of file diff --git a/bin/stubs/leveldb/stub.php b/bin/stubs/leveldb/stub.php deleted file mode 100644 index 46afc176a..000000000 --- a/bin/stubs/leveldb/stub.php +++ /dev/null @@ -1,245 +0,0 @@ - true, // if the specified database does not exist will create a new one - 'error_if_exists' => false, // if the opened database exists will throw exception - 'paranoid_checks' => false, - 'block_cache_size' => 8 * (2 << 20), - 'write_buffer_size' => 4 << 20, - 'block_size' => 4096, - 'max_open_files' => 1000, - 'block_restart_interval' => 16, - 'compression' => LEVELDB_SNAPPY_COMPRESSION, - 'comparator' => null, // any callable parameter return 0, -1, 1 - ], array $read_options = [ - 'verify_check_sum' => false, - //may be set to true to force checksum verification of all data that is read from the file system on behalf of a particular read. By default, no such verification is done. - 'fill_cache' => true, - //When performing a bulk read, the application may set this to false to disable the caching so that the data processed by the bulk read does not end up displacing most of the cached contents. - ], array $write_options = [ - //Only one element named sync in the write option array. By default, each write to leveldb is asynchronous. - 'sync' => false, - ] - ) { - } - - /** - * @param string $key - * @param array $read_options - * - * @return string|bool - */ - public function get($key, array $read_options = []) - { - } - - /** - * Alias of LevelDB::put() - * - * @param string $key - * @param string $value - * @param array $write_options - */ - public function set($key, $value, array $write_options = []) - { - } - - /** - * @param string $key - * @param string $value - * @param array $write_options - */ - public function put($key, $value, array $write_options = []) - { - } - - /** - * @param string $key - * @param array $write_options - * - * @return bool - */ - public function delete($key, array $write_options = []) - { - } - - /** - * Executes all of the operations added in the write batch. - * - * @param LevelDBWriteBatch $batch - * @param array $write_options - */ - public function write(LevelDBWriteBatch $batch, array $write_options = []) - { - } - - /** - * Valid properties: - * - leveldb.stats: returns the status of the entire db - * - leveldb.num-files-at-level: returns the number of files for each level. For example, you can use leveldb.num-files-at-level0 the number of files for zero level. - * - leveldb.sstables: returns current status of sstables - * - * @param string $name - * - * @return mixed - */ - public function getProperty($name) - { - } - - public function getApproximateSizes($start, $limit) - { - } - - public function compactRange($start, $limit) - { - } - - /** - * @return bool - */ - public function close() - { - } - - /** - * @param array $options - * - * @return LevelDBIterator - */ - public function getIterator(array $options = []) - { - } - - /** - * @return LevelDBSnapshot - */ - public function getSnapshot() - { - } - - /** - * @return bool - */ - static public function destroy($name, array $options = []) - { - } - - /** - * @return bool - */ - static public function repair($name, array $options = []) - { - } -} - -class LevelDBIterator implements Iterator -{ - - public function __construct(LevelDB $db, array $read_options = []) - { - } - - public function valid() - { - } - - public function rewind() - { - } - - public function last() - { - } - - public function seek($key) - { - } - - public function next() - { - } - - public function prev() - { - } - - public function key() - { - } - - public function current() - { - } - - public function getError() - { - } - - public function destroy() - { - } - -} - -class LevelDBWriteBatch -{ - public function __construct($name, array $options = [], array $read_options = [], array $write_options = []) - { - } - - public function set($key, $value, array $write_options = []) - { - } - - public function put($key, $value, array $write_options = []) - { - } - - public function delete($key, array $write_options = []) - { - } - - public function clear() - { - } -} - -class LevelDBSnapshot -{ - public function __construct(LevelDB $db) - { - } - - public function release() - { - } - -} - -class LevelDBException extends Exception -{ - -} diff --git a/bin/stubs/zend/zenddisk.php b/bin/stubs/zend/zenddisk.php deleted file mode 100644 index 7e509b994..000000000 --- a/bin/stubs/zend/zenddisk.php +++ /dev/null @@ -1,75 +0,0 @@ -=8.0", - "psr/cache": "^2.0||^3.0", - "psr/simple-cache": "^2.0||^3.0", - "ext-mbstring": "*", - "ext-json": "*" - }, - "require-dev": { - "league/climate": "^3.8", - "ext-gettext": "*", - "phpmd/phpmd": "@stable", - "squizlabs/php_codesniffer": "@stable", - "phpstan/phpstan": "@stable", - "jetbrains/phpstorm-stubs": "dev-master", - "phpfastcache/phpfastcache-devtools": "dev-master" - }, - "suggest": { - "ext-apcu": "*", - "ext-curl": "*", - "ext-intl": "*", - "ext-memcached": "*", - "ext-cassandra": "*", - "ext-memcache": "*", - "ext-redis": "*", - "ext-sqlite": "*", - "ext-wincache": "*", - "ext-leveldb": "*", - "ext-couchbase": "^3.0", - "predis/predis": "^2.0", - "phpfastcache/phpssdb": "~1.1.0", - "phpfastcache/arangodb-extension": "^9.2", - "phpfastcache/couchbasev4-extension": "^9.2", - "phpfastcache/couchdb-extension": "^9.2", - "phpfastcache/dynamodb-extension": "^9.2", - "phpfastcache/firestore-extension": "^9.2", - "phpfastcache/mongodb-extension": "^9.2", - "phpfastcache/ravendb-extension": "^9.2", - "phpfastcache/solr-extension": "^9.2" - }, - "autoload": { - "psr-4": { - "Phpfastcache\\": "lib/Phpfastcache/" - } - }, - "scripts": { - "phpcs": "vendor/bin/phpcs lib/ --report=summary", - "phpcbf": "vendor/bin/phpcbf lib/ --report=summary", - "phpmd": "vendor/bin/phpmd lib/ ansi phpmd.xml", - "phpstan": "vendor/bin/phpstan analyse lib/ -l 6 -c phpstan.neon", - "quality": ["@phpcs", "@phpmd", "@phpstan"], - "tests": [ - "php tests/RunTests.php" - ] - }, - "support": { - "issues": "https://github.com/PHPSocialNetwork/phpfastcache/issues", - "wiki": "https://github.com/PHPSocialNetwork/phpfastcache/wiki", - "docs": "https://github.com/PHPSocialNetwork/phpfastcache/wiki", - "source": "https://github.com/PHPSocialNetwork/phpfastcache", - "security": "https://github.com/PHPSocialNetwork/phpfastcache/blob/master/SECURITY.md" - }, - "funding": [ - { - "type": "patreon", - "url": "https://www.patreon.com/geolim4" - } - ] -} diff --git a/css/app-responsive.css b/css/app-responsive.css new file mode 100644 index 000000000..4643f3723 --- /dev/null +++ b/css/app-responsive.css @@ -0,0 +1,166 @@ +@media screen and (min-width: 64em) +{ + .page-header .btn + { + padding: 0.75rem 1rem; + } +} + +@media screen and (min-width: 42em) and (max-width: 64em) +{ + .page-header .btn + { + padding: 0.6rem 0.9rem; + font-size: 0.9rem; + } +} + +@media screen and (max-width: 42em) +{ + .page-header .btn + { + display: block; + width: 100%; + padding: 0.75rem; + font-size: 0.9rem; + } + + .page-header .btn + .btn + { + margin-top: 1rem; + margin-left: 0; + } + + .page-header .installation + { + font-size: 1.3rem; + } +} + +@media screen and (min-width: 64em) +{ + .page-header + { + margin-top: 0; + padding: 4rem 6rem 3rem 6rem; + } +} + +@media screen and (min-width: 42em) and (max-width: 64em) +{ + .page-header + { + margin-top: 0; + padding: 3rem 4rem; + } +} + +@media screen and (max-width: 42em) +{ + .page-header + { + margin-top: 0; + padding: 2rem 1rem; + } +} + +@media screen and (min-width: 64em) +{ + .project-name + { + font-size: 3.25rem; + } +} + +@media screen and (min-width: 42em) and (max-width: 64em) +{ + .project-name + { + font-size: 2.25rem; + } +} + +@media screen and (max-width: 42em) +{ + .project-name + { + font-size: 1.75rem; + } +} + +@media screen and (min-width: 64em) +{ + .project-tagline + { + font-size: 1.25rem; + } +} + +@media screen and (min-width: 42em) and (max-width: 64em) +{ + .project-tagline + { + font-size: 1.15rem; + } +} + +@media screen and (max-width: 42em) +{ + .project-tagline + { + font-size: 1rem; + } +} + +@media screen and (min-width: 64em) +{ + .page-footer + { + max-width: 64rem; + padding: 2rem 0rem; + margin: 0 auto; + font-size: 1.1rem; + } +} + +@media screen and (min-width: 42em) and (max-width: 64em) +{ + .page-footer + { + padding: 2rem 4rem; + font-size: 1.1rem; + } +} + +@media screen and (max-width: 42em) +{ + .page-footer + { + padding: 2rem 1rem; + font-size: 1rem; + } +} + +@media screen and (min-width: 64em) +{ + .site-footer + { + font-size: 1rem; + } +} + +@media screen and (min-width: 42em) and (max-width: 64em) +{ + .site-footer + { + font-size: 1rem; + } +} + +@media screen and (max-width: 42em) +{ + .site-footer + { + font-size: 0.9rem; + } +} diff --git a/css/app.css b/css/app.css new file mode 100644 index 000000000..c921a5131 --- /dev/null +++ b/css/app.css @@ -0,0 +1,356 @@ +* +{ + box-sizing: border-box; +} + +body +{ + padding: 0; + margin: 0; + font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; + font-size: 16px; + line-height: 1.5; + color: #606C71; +} + +a +{ + color: #1E6BB8; + text-decoration: none; +} + +a:hover +{ + text-decoration: underline; +} + +abbr[title] +{ + text-decoration: none; +} + +.page-header .btn +{ + display: inline-block; + margin-bottom: 1rem; + color: rgba(255, 255, 255, 0.7); + background-color: rgba(255, 255, 255, 0.08); + border-color: rgba(255, 255, 255, 0.2); + border-style: solid; + border-width: 1px; + border-radius: 0.3rem; + transition: color 0.2s, background-color 0.2s, border-color 0.2s; +} + +.page-header .btn + .btn +{ + margin-left: 1rem; +} + +.page-header .btn:hover +{ + color: rgba(255, 255, 255, 0.8); + text-decoration: none; + background-color: rgba(255, 255, 255, 0.2); + border-color: rgba(255, 255, 255, 0.3); +} + +.page-header .version +{ + font-size: 18px; +} + +.page-header .installation +{ + font-size: 18px; +} + +.page-header .installation code +{ + opacity: 0.7; + background: #000; + color: #F90; + background-image: linear-gradient(900deg, #222, #333); +} + +@media screen and (min-width: 64em) +{ + .page-header .btn + { + padding: 0.75rem 1rem; + } +} + +@media screen and (min-width: 42em) and (max-width: 64em) +{ + .page-header .btn + { + padding: 0.6rem 0.9rem; + font-size: 0.9rem; + } +} + +@media screen and (max-width: 42em) +{ + .page-header .btn + { + display: block; + width: 100%; + padding: 0.75rem; + font-size: 0.9rem; + } + + .page-header .btn + .btn + { + margin-top: 1rem; + margin-left: 0; + } +} + +.page-header +{ + color: #FFF; + text-align: center; + background-color: #ee7d58; + /*background-image: linear-gradient(120deg, #4E00FF, #F90);*/ + background-image: url('./assets/head-bg.svg'); + background-size: cover; +} + +@media screen and (min-width: 64em) +{ + .page-header + { + margin-top: 0; + padding: 5rem 6rem; + } +} + +@media screen and (min-width: 42em) and (max-width: 64em) +{ + .page-header + { + margin-top: 0; + padding: 3rem 4rem; + } +} + +@media screen and (max-width: 42em) +{ + .page-header + { + margin-top: 0; + padding: 2rem 1rem; + } +} + +.project-name +{ + margin-top: 0; + margin-bottom: 0.1rem; +} + +@media screen and (min-width: 64em) +{ + .project-name + { + font-size: 3.25rem; + } +} + +@media screen and (min-width: 42em) and (max-width: 64em) +{ + .project-name + { + font-size: 2.25rem; + } +} + +@media screen and (max-width: 42em) +{ + .project-name + { + font-size: 1.75rem; + } +} + +.project-tagline +{ + margin-bottom: 2rem; + font-weight: normal; + opacity: 0.7; +} + +@media screen and (min-width: 64em) +{ + .project-tagline + { + font-size: 1.25rem; + } +} + +@media screen and (min-width: 42em) and (max-width: 64em) +{ + .project-tagline + { + font-size: 1.15rem; + } +} + +@media screen and (max-width: 42em) +{ + .project-tagline + { + font-size: 1rem; + } +} + +.site-footer +{ + padding-top: 2rem; + margin-top: 2rem; + border-top: solid 1px #EFF0F1; +} + +.site-footer-credits +{ + color: #819198; +} + +.panel-collapse +{ + word-wrap: break-word; +} + +/** + * Courtesy of + * https://codepen.io/rdallaire/pen/apoyx/ + */ +#return-to-top +{ + position: fixed; + bottom: 20px; + right: 20px; + background: rgb(0, 0, 0); + background: rgba(0, 0, 0, 0.7); + width: 50px; + height: 50px; + text-decoration: none; + -webkit-border-radius: 35px; + -moz-border-radius: 35px; + border-radius: 35px; + opacity: 0; + -webkit-transition: all 0.6s linear; + -moz-transition: all 0.6s ease; + -ms-transition: all 0.6s ease; + -o-transition: all 0.6s ease; + transition: all 0.6s ease; + pointer-events: none; +} + +#return-to-top.visible +{ + opacity: 1; + pointer-events: unset; +} + +#return-to-top i +{ + color: #FFF; + margin: 0; + position: relative; + left: 16px; + top: 13px; + font-size: 19px; + -webkit-transition: all 0.3s ease; + -moz-transition: all 0.3s ease; + -ms-transition: all 0.3s ease; + -o-transition: all 0.3s ease; + transition: all 0.3s ease; +} + +#return-to-top:hover +{ + background: rgba(0, 0, 0, 0.9); +} + +#return-to-top:hover i +{ + color: #FFF; + top: 5px; +} + +::-moz-selection +{ + color: #A6FF91; + background: #403C3B; +} + +::selection +{ + color: #A6FF91; + background: #403C3B; +} + +table th, table td { + padding: 6px 13px; + border: 1px solid #dfe2e5; +} + +table tr { + background-color: #fff; + border-top: 1px solid #c6cbd1; +} + +table tr:nth-child(2n) { + background-color: #f6f8fa; +} + +/** + * Helpers + */ +.tmar1 +{ + margin-top: 1rem; +} + +.tmar2 +{ + margin-top: 2rem; +} + +.rmar2 +{ + margin-right: 2rem; +} + +.fpad2 +{ + padding: 2rem; +} + +.hpad2 +{ + padding-left: 2rem; + padding-right: 2rem; +} + +.vpad1 +{ + padding-top: 1rem; + padding-bottom: 1rem; +} + +.vpad2 +{ + padding-top: 2rem; + padding-bottom: 2rem; +} + +span.unselectable +{ + pointer-events: none; + user-select: none; + -moz-user-select: none; + -webkit-user-select: none; +} diff --git a/css/assets/head-bg.svg b/css/assets/head-bg.svg new file mode 100644 index 000000000..05e136f65 --- /dev/null +++ b/css/assets/head-bg.svg @@ -0,0 +1 @@ + diff --git a/css/github-light.css b/css/github-light.css new file mode 100644 index 000000000..0c6b24d82 --- /dev/null +++ b/css/github-light.css @@ -0,0 +1,124 @@ +/* +The MIT License (MIT) + +Copyright (c) 2016 GitHub, Inc. + +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. + +*/ + +.pl-c /* comment */ { + color: #969896; +} + +.pl-c1 /* constant, variable.other.constant, support, meta.property-name, support.constant, support.variable, meta.module-reference, markup.raw, meta.diff.header */, +.pl-s .pl-v /* string variable */ { + color: #0086b3; +} + +.pl-e /* entity */, +.pl-en /* entity.name */ { + color: #795da3; +} + +.pl-smi /* variable.parameter.function, storage.modifier.package, storage.modifier.import, storage.type.java, variable.other */, +.pl-s .pl-s1 /* string source */ { + color: #333; +} + +.pl-ent /* entity.name.tag */ { + color: #63a35c; +} + +.pl-k /* keyword, storage, storage.type */ { + color: #a71d5d; +} + +.pl-s /* string */, +.pl-pds /* punctuation.definition.string, string.regexp.character-class */, +.pl-s .pl-pse .pl-s1 /* string punctuation.section.embedded source */, +.pl-sr /* string.regexp */, +.pl-sr .pl-cce /* string.regexp constant.character.escape */, +.pl-sr .pl-sre /* string.regexp source.ruby.embedded */, +.pl-sr .pl-sra /* string.regexp string.regexp.arbitrary-repitition */ { + color: #183691; +} + +.pl-v /* variable */ { + color: #ed6a43; +} + +.pl-id /* invalid.deprecated */ { + color: #b52a1d; +} + +.pl-ii /* invalid.illegal */ { + color: #f8f8f8; + background-color: #b52a1d; +} + +.pl-sr .pl-cce /* string.regexp constant.character.escape */ { + font-weight: bold; + color: #63a35c; +} + +.pl-ml /* markup.list */ { + color: #693a17; +} + +.pl-mh /* markup.heading */, +.pl-mh .pl-en /* markup.heading entity.name */, +.pl-ms /* meta.separator */ { + font-weight: bold; + color: #1d3e81; +} + +.pl-mq /* markup.quote */ { + color: #008080; +} + +.pl-mi /* markup.italic */ { + font-style: italic; + color: #333; +} + +.pl-mb /* markup.bold */ { + font-weight: bold; + color: #333; +} + +.pl-md /* markup.deleted, meta.diff.header.from-file */ { + color: #bd2c00; + background-color: #ffecec; +} + +.pl-mi1 /* markup.inserted, meta.diff.header.to-file */ { + color: #55a532; + background-color: #eaffea; +} + +.pl-mdr /* meta.diff.range */ { + font-weight: bold; + color: #795da3; +} + +.pl-mo /* meta.output */ { + color: #1d3e81; +} + diff --git a/css/normalize.css b/css/normalize.css new file mode 100644 index 000000000..30366a6e9 --- /dev/null +++ b/css/normalize.css @@ -0,0 +1,424 @@ +/*! normalize.css v3.0.2 | MIT License | git.io/normalize */ + +/** + * 1. Set default font family to sans-serif. + * 2. Prevent iOS text size adjust after orientation change, without disabling + * user zoom. + */ + +html { + font-family: sans-serif; /* 1 */ + -ms-text-size-adjust: 100%; /* 2 */ + -webkit-text-size-adjust: 100%; /* 2 */ +} + +/** + * Remove default margin. + */ + +body { + margin: 0; +} + +/* HTML5 display definitions + ========================================================================== */ + +/** + * Correct `block` display not defined for any HTML5 element in IE 8/9. + * Correct `block` display not defined for `details` or `summary` in IE 10/11 + * and Firefox. + * Correct `block` display not defined for `main` in IE 11. + */ + +article, +aside, +details, +figcaption, +figure, +footer, +header, +hgroup, +main, +menu, +nav, +section, +summary { + display: block; +} + +/** + * 1. Correct `inline-block` display not defined in IE 8/9. + * 2. Normalize vertical alignment of `progress` in Chrome, Firefox, and Opera. + */ + +audio, +canvas, +progress, +video { + display: inline-block; /* 1 */ + vertical-align: baseline; /* 2 */ +} + +/** + * Prevent modern browsers from displaying `audio` without controls. + * Remove excess height in iOS 5 devices. + */ + +audio:not([controls]) { + display: none; + height: 0; +} + +/** + * Address `[hidden]` styling not present in IE 8/9/10. + * Hide the `template` element in IE 8/9/11, Safari, and Firefox < 22. + */ + +[hidden], +template { + display: none; +} + +/* Links + ========================================================================== */ + +/** + * Remove the gray background color from active links in IE 10. + */ + +a { + background-color: transparent; +} + +/** + * Improve readability when focused and also mouse hovered in all browsers. + */ + +a:active, +a:hover { + outline: 0; +} + +/* Text-level semantics + ========================================================================== */ + +/** + * Address styling not present in IE 8/9/10/11, Safari, and Chrome. + */ + +abbr[title] { + border-bottom: 1px dotted; +} + +/** + * Address style set to `bolder` in Firefox 4+, Safari, and Chrome. + */ + +b, +strong { + font-weight: bold; +} + +/** + * Address styling not present in Safari and Chrome. + */ + +dfn { + font-style: italic; +} + +/** + * Address variable `h1` font-size and margin within `section` and `article` + * contexts in Firefox 4+, Safari, and Chrome. + */ + +h1 { + font-size: 2em; + margin: 0.67em 0; +} + +/** + * Address styling not present in IE 8/9. + */ + +mark { + background: #ff0; + color: #000; +} + +/** + * Address inconsistent and variable font size in all browsers. + */ + +small { + font-size: 80%; +} + +/** + * Prevent `sub` and `sup` affecting `line-height` in all browsers. + */ + +sub, +sup { + font-size: 75%; + line-height: 0; + position: relative; + vertical-align: baseline; +} + +sup { + top: -0.5em; +} + +sub { + bottom: -0.25em; +} + +/* Embedded content + ========================================================================== */ + +/** + * Remove border when inside `a` element in IE 8/9/10. + */ + +img { + border: 0; +} + +/** + * Correct overflow not hidden in IE 9/10/11. + */ + +svg:not(:root) { + overflow: hidden; +} + +/* Grouping content + ========================================================================== */ + +/** + * Address margin not present in IE 8/9 and Safari. + */ + +figure { + margin: 1em 40px; +} + +/** + * Address differences between Firefox and other browsers. + */ + +hr { + box-sizing: content-box; + height: 0; +} + +/** + * Contain overflow in all browsers. + */ + +pre { + overflow: auto; +} + +/** + * Address odd `em`-unit font size rendering in all browsers. + */ + +code, +kbd, +pre, +samp { + font-family: monospace, monospace; + font-size: 1em; +} + +/* Forms + ========================================================================== */ + +/** + * Known limitation: by default, Chrome and Safari on OS X allow very limited + * styling of `select`, unless a `border` property is set. + */ + +/** + * 1. Correct color not being inherited. + * Known issue: affects color of disabled elements. + * 2. Correct font properties not being inherited. + * 3. Address margins set differently in Firefox 4+, Safari, and Chrome. + */ + +button, +input, +optgroup, +select, +textarea { + color: inherit; /* 1 */ + font: inherit; /* 2 */ + margin: 0; /* 3 */ +} + +/** + * Address `overflow` set to `hidden` in IE 8/9/10/11. + */ + +button { + overflow: visible; +} + +/** + * Address inconsistent `text-transform` inheritance for `button` and `select`. + * All other form control elements do not inherit `text-transform` values. + * Correct `button` style inheritance in Firefox, IE 8/9/10/11, and Opera. + * Correct `select` style inheritance in Firefox. + */ + +button, +select { + text-transform: none; +} + +/** + * 1. Avoid the WebKit bug in Android 4.0.* where (2) destroys native `audio` + * and `video` controls. + * 2. Correct inability to style clickable `input` types in iOS. + * 3. Improve usability and consistency of cursor style between image-type + * `input` and others. + */ + +button, +html input[type="button"], /* 1 */ +input[type="reset"], +input[type="submit"] { + -webkit-appearance: button; /* 2 */ + cursor: pointer; /* 3 */ +} + +/** + * Re-set default cursor for disabled elements. + */ + +button[disabled], +html input[disabled] { + cursor: default; +} + +/** + * Remove inner padding and border in Firefox 4+. + */ + +button::-moz-focus-inner, +input::-moz-focus-inner { + border: 0; + padding: 0; +} + +/** + * Address Firefox 4+ setting `line-height` on `input` using `!important` in + * the UA stylesheet. + */ + +input { + line-height: normal; +} + +/** + * It's recommended that you don't attempt to style these elements. + * Firefox's implementation doesn't respect box-sizing, padding, or width. + * + * 1. Address box sizing set to `content-box` in IE 8/9/10. + * 2. Remove excess padding in IE 8/9/10. + */ + +input[type="checkbox"], +input[type="radio"] { + box-sizing: border-box; /* 1 */ + padding: 0; /* 2 */ +} + +/** + * Fix the cursor style for Chrome's increment/decrement buttons. For certain + * `font-size` values of the `input`, it causes the cursor style of the + * decrement button to change from `default` to `text`. + */ + +input[type="number"]::-webkit-inner-spin-button, +input[type="number"]::-webkit-outer-spin-button { + height: auto; +} + +/** + * 1. Address `appearance` set to `searchfield` in Safari and Chrome. + * 2. Address `box-sizing` set to `border-box` in Safari and Chrome + * (include `-moz` to future-proof). + */ + +input[type="search"] { + -webkit-appearance: textfield; /* 1 */ /* 2 */ + box-sizing: content-box; +} + +/** + * Remove inner padding and search cancel button in Safari and Chrome on OS X. + * Safari (but not Chrome) clips the cancel button when the search input has + * padding (and `textfield` appearance). + */ + +input[type="search"]::-webkit-search-cancel-button, +input[type="search"]::-webkit-search-decoration { + -webkit-appearance: none; +} + +/** + * Define consistent border, margin, and padding. + */ + +fieldset { + border: 1px solid #c0c0c0; + margin: 0 2px; + padding: 0.35em 0.625em 0.75em; +} + +/** + * 1. Correct `color` not being inherited in IE 8/9/10/11. + * 2. Remove padding so people aren't caught out if they zero out fieldsets. + */ + +legend { + border: 0; /* 1 */ + padding: 0; /* 2 */ +} + +/** + * Remove default vertical scrollbar in IE 8/9/10/11. + */ + +textarea { + overflow: auto; +} + +/** + * Don't inherit the `font-weight` (applied by a rule above). + * NOTE: the default cannot safely be changed in Chrome and Safari on OS X. + */ + +optgroup { + font-weight: bold; +} + +/* Tables + ========================================================================== */ + +/** + * Remove most spacing between table cells. + */ + +table { + border-collapse: collapse; + border-spacing: 0; +} + +td, +th { + padding: 0; +} diff --git a/css/onefile.css b/css/onefile.css new file mode 100644 index 000000000..8ab7ab370 --- /dev/null +++ b/css/onefile.css @@ -0,0 +1,1048 @@ +@media screen and (min-width: 64em) +{ + .page-header .btn + { + padding: 0.75rem 1rem; + } +} + +@media screen and (min-width: 42em) and (max-width: 64em) +{ + .page-header .btn + { + padding: 0.6rem 0.9rem; + font-size: 0.9rem; + } +} + +@media screen and (max-width: 42em) +{ + .page-header .btn + { + display: block; + width: 100%; + padding: 0.75rem; + font-size: 0.9rem; + } + + .page-header .btn + .btn + { + margin-top: 1rem; + margin-left: 0; + } + + .page-header .installation + { + font-size: 1.3rem; + } +} + +@media screen and (min-width: 64em) +{ + .page-header + { + margin-top: 0; + padding: 4rem 6rem 3rem 6rem; + } +} + +@media screen and (min-width: 42em) and (max-width: 64em) +{ + .page-header + { + margin-top: 0; + padding: 3rem 4rem; + } +} + +@media screen and (max-width: 42em) +{ + .page-header + { + margin-top: 0; + padding: 2rem 1rem; + } +} + +@media screen and (min-width: 64em) +{ + .project-name + { + font-size: 3.25rem; + } +} + +@media screen and (min-width: 42em) and (max-width: 64em) +{ + .project-name + { + font-size: 2.25rem; + } +} + +@media screen and (max-width: 42em) +{ + .project-name + { + font-size: 1.75rem; + } +} + +@media screen and (min-width: 64em) +{ + .project-tagline + { + font-size: 1.25rem; + } +} + +@media screen and (min-width: 42em) and (max-width: 64em) +{ + .project-tagline + { + font-size: 1.15rem; + } +} + +@media screen and (max-width: 42em) +{ + .project-tagline + { + font-size: 1rem; + } +} + +@media screen and (min-width: 64em) +{ + .page-footer + { + max-width: 64rem; + padding: 2rem 0rem; + margin: 0 auto; + font-size: 1.1rem; + } +} + +@media screen and (min-width: 42em) and (max-width: 64em) +{ + .page-footer + { + padding: 2rem 4rem; + font-size: 1.1rem; + } +} + +@media screen and (max-width: 42em) +{ + .page-footer + { + padding: 2rem 1rem; + font-size: 1rem; + } +} + +@media screen and (min-width: 64em) +{ + .site-footer + { + font-size: 1rem; + } +} + +@media screen and (min-width: 42em) and (max-width: 64em) +{ + .site-footer + { + font-size: 1rem; + } +} + +@media screen and (max-width: 42em) +{ + .site-footer + { + font-size: 0.9rem; + } +} + + +.pl-c /* comment */ { + color: #969896; +} + +.pl-c1 /* constant, variable.other.constant, support, meta.property-name, support.constant, support.variable, meta.module-reference, markup.raw, meta.diff.header */, +.pl-s .pl-v /* string variable */ { + color: #0086b3; +} + +.pl-e /* entity */, +.pl-en /* entity.name */ { + color: #795da3; +} + +.pl-smi /* variable.parameter.function, storage.modifier.package, storage.modifier.import, storage.type.java, variable.other */, +.pl-s .pl-s1 /* string source */ { + color: #333; +} + +.pl-ent /* entity.name.tag */ { + color: #63a35c; +} + +.pl-k /* keyword, storage, storage.type */ { + color: #a71d5d; +} + +.pl-s /* string */, +.pl-pds /* punctuation.definition.string, string.regexp.character-class */, +.pl-s .pl-pse .pl-s1 /* string punctuation.section.embedded source */, +.pl-sr /* string.regexp */, +.pl-sr .pl-cce /* string.regexp constant.character.escape */, +.pl-sr .pl-sre /* string.regexp source.ruby.embedded */, +.pl-sr .pl-sra /* string.regexp string.regexp.arbitrary-repitition */ { + color: #183691; +} + +.pl-v /* variable */ { + color: #ed6a43; +} + +.pl-id /* invalid.deprecated */ { + color: #b52a1d; +} + +.pl-ii /* invalid.illegal */ { + color: #f8f8f8; + background-color: #b52a1d; +} + +.pl-sr .pl-cce /* string.regexp constant.character.escape */ { + font-weight: bold; + color: #63a35c; +} + +.pl-ml /* markup.list */ { + color: #693a17; +} + +.pl-mh /* markup.heading */, +.pl-mh .pl-en /* markup.heading entity.name */, +.pl-ms /* meta.separator */ { + font-weight: bold; + color: #1d3e81; +} + + +* +{ + box-sizing: border-box; +} + +body +{ + padding: 0; + margin: 0; + font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; + font-size: 16px; + line-height: 1.5; + color: #606C71; +} + +a +{ + color: #1E6BB8; + text-decoration: none; +} + +a:hover +{ + text-decoration: underline; +} + +abbr[title] +{ + text-decoration: none; +} + +.page-header .btn +{ + display: inline-block; + margin-bottom: 1rem; + color: rgba(255, 255, 255, 0.7); + background-color: rgba(255, 255, 255, 0.08); + border-color: rgba(255, 255, 255, 0.2); + border-style: solid; + border-width: 1px; + border-radius: 0.3rem; + transition: color 0.2s, background-color 0.2s, border-color 0.2s; +} + +.page-header .btn + .btn +{ + margin-left: 1rem; +} + +.page-header .btn:hover +{ + color: rgba(255, 255, 255, 0.8); + text-decoration: none; + background-color: rgba(255, 255, 255, 0.2); + border-color: rgba(255, 255, 255, 0.3); +} + +.page-header .version +{ + font-size: 18px; +} + +.page-header .installation +{ + font-size: 18px; +} + +.page-header .installation code +{ + opacity: 0.7; + background: #000; + color: #F90; + background-image: linear-gradient(900deg, #222, #333); +} + +@media screen and (min-width: 64em) +{ + .page-header .btn + { + padding: 0.75rem 1rem; + } +} + +@media screen and (min-width: 42em) and (max-width: 64em) +{ + .page-header .btn + { + padding: 0.6rem 0.9rem; + font-size: 0.9rem; + } +} + +@media screen and (max-width: 42em) +{ + .page-header .btn + { + display: block; + width: 100%; + padding: 0.75rem; + font-size: 0.9rem; + } + + .page-header .btn + .btn + { + margin-top: 1rem; + margin-left: 0; + } +} + +.page-header +{ + color: #FFF; + text-align: center; + background-color: #159957; + background-image: linear-gradient(120deg, #4E00FF, #F90); +} + +@media screen and (min-width: 64em) +{ + .page-header + { + margin-top: 0; + padding: 5rem 6rem; + } +} + +@media screen and (min-width: 42em) and (max-width: 64em) +{ + .page-header + { + margin-top: 0; + padding: 3rem 4rem; + } +} + +@media screen and (max-width: 42em) +{ + .page-header + { + margin-top: 0; + padding: 2rem 1rem; + } +} + +.project-name +{ + margin-top: 0; + margin-bottom: 0.1rem; +} + +@media screen and (min-width: 64em) +{ + .project-name + { + font-size: 3.25rem; + } +} + +@media screen and (min-width: 42em) and (max-width: 64em) +{ + .project-name + { + font-size: 2.25rem; + } +} + +@media screen and (max-width: 42em) +{ + .project-name + { + font-size: 1.75rem; + } +} + +.project-tagline +{ + margin-bottom: 2rem; + font-weight: normal; + opacity: 0.7; +} + +@media screen and (min-width: 64em) +{ + .project-tagline + { + font-size: 1.25rem; + } +} + +@media screen and (min-width: 42em) and (max-width: 64em) +{ + .project-tagline + { + font-size: 1.15rem; + } +} + +@media screen and (max-width: 42em) +{ + .project-tagline + { + font-size: 1rem; + } +} + +.site-footer +{ + padding-top: 2rem; + margin-top: 2rem; + border-top: solid 1px #EFF0F1; +} + +.site-footer-credits +{ + color: #819198; +} + +.panel-collapse +{ + word-wrap: break-word; +} + +/** + * Courtesy of + * https://codepen.io/rdallaire/pen/apoyx/ + */ +#return-to-top +{ + position: fixed; + bottom: 20px; + right: 20px; + background: rgb(0, 0, 0); + background: rgba(0, 0, 0, 0.7); + width: 50px; + height: 50px; + text-decoration: none; + -webkit-border-radius: 35px; + -moz-border-radius: 35px; + border-radius: 35px; + opacity: 0; + -webkit-transition: all 0.6s linear; + -moz-transition: all 0.6s ease; + -ms-transition: all 0.6s ease; + -o-transition: all 0.6s ease; + transition: all 0.6s ease; + pointer-events: none; +} + +#return-to-top.visible +{ + opacity: 1; + pointer-events: unset; +} + +#return-to-top i +{ + color: #FFF; + margin: 0; + position: relative; + left: 16px; + top: 13px; + font-size: 19px; + -webkit-transition: all 0.3s ease; + -moz-transition: all 0.3s ease; + -ms-transition: all 0.3s ease; + -o-transition: all 0.3s ease; + transition: all 0.3s ease; +} + +#return-to-top:hover +{ + background: rgba(0, 0, 0, 0.9); +} + +#return-to-top:hover i +{ + color: #FFF; + top: 5px; +} + +::-moz-selection +{ + color: #A6FF91; + background: #403C3B; +} + +::selection +{ + color: #A6FF91; + background: #403C3B; +} + +table th, table td { + padding: 6px 13px; + border: 1px solid #dfe2e5; +} + +table tr { + background-color: #fff; + border-top: 1px solid #c6cbd1; +} + +table tr:nth-child(2n) { + background-color: #f6f8fa; +} + +/** + * Helpers + */ +.tmar1 +{ + margin-top: 1rem; +} + +.tmar2 +{ + margin-top: 2rem; +} + +.rmar2 +{ + margin-right: 2rem; +} + +.fpad2 +{ + padding: 2rem; +} + +.hpad2 +{ + padding-left: 2rem; + padding-right: 2rem; +} + +.vpad1 +{ + padding-top: 1rem; + padding-bottom: 1rem; +} + +.vpad2 +{ + padding-top: 2rem; + padding-bottom: 2rem; +} + +span.unselectable +{ + pointer-events: none; + user-select: none; + -moz-user-select: none; + -webkit-user-select: none; +} + +.pl-mq /* markup.quote */ { + color: #008080; +} + +.pl-mi /* markup.italic */ { + font-style: italic; + color: #333; +} + +.pl-mb /* markup.bold */ { + font-weight: bold; + color: #333; +} + +.pl-md /* markup.deleted, meta.diff.header.from-file */ { + color: #bd2c00; + background-color: #ffecec; +} + +.pl-mi1 /* markup.inserted, meta.diff.header.to-file */ { + color: #55a532; + background-color: #eaffea; +} + +.pl-mdr /* meta.diff.range */ { + font-weight: bold; + color: #795da3; +} + +/*! normalize.css v3.0.2 | MIT License | git.io/normalize */ + +/** + * 1. Set default font family to sans-serif. + * 2. Prevent iOS text size adjust after orientation change, without disabling + * user zoom. + */ + +html { + font-family: sans-serif; /* 1 */ + -ms-text-size-adjust: 100%; /* 2 */ + -webkit-text-size-adjust: 100%; /* 2 */ +} + +/** + * Remove default margin. + */ + +body { + margin: 0; +} + +/* HTML5 display definitions + ========================================================================== */ + +/** + * Correct `block` display not defined for any HTML5 element in IE 8/9. + * Correct `block` display not defined for `details` or `summary` in IE 10/11 + * and Firefox. + * Correct `block` display not defined for `main` in IE 11. + */ + +article, +aside, +details, +figcaption, +figure, +footer, +header, +hgroup, +main, +menu, +nav, +section, +summary { + display: block; +} + +/** + * 1. Correct `inline-block` display not defined in IE 8/9. + * 2. Normalize vertical alignment of `progress` in Chrome, Firefox, and Opera. + */ + +audio, +canvas, +progress, +video { + display: inline-block; /* 1 */ + vertical-align: baseline; /* 2 */ +} + +/** + * Prevent modern browsers from displaying `audio` without controls. + * Remove excess height in iOS 5 devices. + */ + +audio:not([controls]) { + display: none; + height: 0; +} + +/** + * Address `[hidden]` styling not present in IE 8/9/10. + * Hide the `template` element in IE 8/9/11, Safari, and Firefox < 22. + */ + +[hidden], +template { + display: none; +} + +/* Links + ========================================================================== */ + +/** + * Remove the gray background color from active links in IE 10. + */ + +a { + background-color: transparent; +} + +/** + * Improve readability when focused and also mouse hovered in all browsers. + */ + +a:active, +a:hover { + outline: 0; +} + +/* Text-level semantics + ========================================================================== */ + +/** + * Address styling not present in IE 8/9/10/11, Safari, and Chrome. + */ + +abbr[title] { + border-bottom: 1px dotted; +} + +/** + * Address style set to `bolder` in Firefox 4+, Safari, and Chrome. + */ + +b, +strong { + font-weight: bold; +} + +/** + * Address styling not present in Safari and Chrome. + */ + +dfn { + font-style: italic; +} + +/** + * Address variable `h1` font-size and margin within `section` and `article` + * contexts in Firefox 4+, Safari, and Chrome. + */ + +h1 { + font-size: 2em; + margin: 0.67em 0; +} + +/** + * Address styling not present in IE 8/9. + */ + +mark { + background: #ff0; + color: #000; +} + +/** + * Address inconsistent and variable font size in all browsers. + */ + +small { + font-size: 80%; +} + +/** + * Prevent `sub` and `sup` affecting `line-height` in all browsers. + */ + +sub, +sup { + font-size: 75%; + line-height: 0; + position: relative; + vertical-align: baseline; +} + +sup { + top: -0.5em; +} + +sub { + bottom: -0.25em; +} + +/* Embedded content + ========================================================================== */ + +/** + * Remove border when inside `a` element in IE 8/9/10. + */ + +img { + border: 0; +} + +/** + * Correct overflow not hidden in IE 9/10/11. + */ + +svg:not(:root) { + overflow: hidden; +} + +/* Grouping content + ========================================================================== */ + +/** + * Address margin not present in IE 8/9 and Safari. + */ + +figure { + margin: 1em 40px; +} + +/** + * Address differences between Firefox and other browsers. + */ + +hr { + box-sizing: content-box; + height: 0; +} + +/** + * Contain overflow in all browsers. + */ + +pre { + overflow: auto; +} + +/** + * Address odd `em`-unit font size rendering in all browsers. + */ + +code, +kbd, +pre, +samp { + font-family: monospace, monospace; + font-size: 1em; +} + +/* Forms + ========================================================================== */ + +/** + * Known limitation: by default, Chrome and Safari on OS X allow very limited + * styling of `select`, unless a `border` property is set. + */ + +/** + * 1. Correct color not being inherited. + * Known issue: affects color of disabled elements. + * 2. Correct font properties not being inherited. + * 3. Address margins set differently in Firefox 4+, Safari, and Chrome. + */ + +button, +input, +optgroup, +select, +textarea { + color: inherit; /* 1 */ + font: inherit; /* 2 */ + margin: 0; /* 3 */ +} + +/** + * Address `overflow` set to `hidden` in IE 8/9/10/11. + */ + +button { + overflow: visible; +} + +/** + * Address inconsistent `text-transform` inheritance for `button` and `select`. + * All other form control elements do not inherit `text-transform` values. + * Correct `button` style inheritance in Firefox, IE 8/9/10/11, and Opera. + * Correct `select` style inheritance in Firefox. + */ + +button, +select { + text-transform: none; +} + +/** + * 1. Avoid the WebKit bug in Android 4.0.* where (2) destroys native `audio` + * and `video` controls. + * 2. Correct inability to style clickable `input` types in iOS. + * 3. Improve usability and consistency of cursor style between image-type + * `input` and others. + */ + +button, +html input[type="button"], /* 1 */ +input[type="reset"], +input[type="submit"] { + -webkit-appearance: button; /* 2 */ + cursor: pointer; /* 3 */ +} + +/** + * Re-set default cursor for disabled elements. + */ + +button[disabled], +html input[disabled] { + cursor: default; +} + +/** + * Remove inner padding and border in Firefox 4+. + */ + +button::-moz-focus-inner, +input::-moz-focus-inner { + border: 0; + padding: 0; +} + +/** + * Address Firefox 4+ setting `line-height` on `input` using `!important` in + * the UA stylesheet. + */ + +input { + line-height: normal; +} + +/** + * It's recommended that you don't attempt to style these elements. + * Firefox's implementation doesn't respect box-sizing, padding, or width. + * + * 1. Address box sizing set to `content-box` in IE 8/9/10. + * 2. Remove excess padding in IE 8/9/10. + */ + +input[type="checkbox"], +input[type="radio"] { + box-sizing: border-box; /* 1 */ + padding: 0; /* 2 */ +} + +/** + * Fix the cursor style for Chrome's increment/decrement buttons. For certain + * `font-size` values of the `input`, it causes the cursor style of the + * decrement button to change from `default` to `text`. + */ + +input[type="number"]::-webkit-inner-spin-button, +input[type="number"]::-webkit-outer-spin-button { + height: auto; +} + +/** + * 1. Address `appearance` set to `searchfield` in Safari and Chrome. + * 2. Address `box-sizing` set to `border-box` in Safari and Chrome + * (include `-moz` to future-proof). + */ + +input[type="search"] { + -webkit-appearance: textfield; /* 1 */ /* 2 */ + box-sizing: content-box; +} + +/** + * Remove inner padding and search cancel button in Safari and Chrome on OS X. + * Safari (but not Chrome) clips the cancel button when the search input has + * padding (and `textfield` appearance). + */ + +input[type="search"]::-webkit-search-cancel-button, +input[type="search"]::-webkit-search-decoration { + -webkit-appearance: none; +} + +/** + * Define consistent border, margin, and padding. + */ + +fieldset { + border: 1px solid #c0c0c0; + margin: 0 2px; + padding: 0.35em 0.625em 0.75em; +} + +/** + * 1. Correct `color` not being inherited in IE 8/9/10/11. + * 2. Remove padding so people aren't caught out if they zero out fieldsets. + */ + +legend { + border: 0; /* 1 */ + padding: 0; /* 2 */ +} + +/** + * Remove default vertical scrollbar in IE 8/9/10/11. + */ + +textarea { + overflow: auto; +} + +/** + * Don't inherit the `font-weight` (applied by a rule above). + * NOTE: the default cannot safely be changed in Chrome and Safari on OS X. + */ + +optgroup { + font-weight: bold; +} + +/* Tables + ========================================================================== */ + +/** + * Remove most spacing between table cells. + */ + +table { + border-collapse: collapse; + border-spacing: 0; +} + +td, +th { + padding: 0; +} + + +.pl-mo /* meta.output */ { + color: #1d3e81; +} diff --git a/docs/CREDITS.md b/docs/CREDITS.md deleted file mode 100644 index ba84b803b..000000000 --- a/docs/CREDITS.md +++ /dev/null @@ -1,48 +0,0 @@ -## Phpfastcache Copyright (c) 2016 -https://www.phpfastcache.com - -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. - -__Phpfastcache Current Project Manager:__ Georges.L (Geolim4) / (v5, v6, v7, v8, v9) - -__Phpfastcache Former Project Founder:__ Khoa Bui (khoaofgod) / (> v4) - -__Phpfastcache Contributors:__ https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - -#### Hall of fame (Special thanks): - -- __Jetbrains__ * for providing us a free Phpstorm IDE licence for years -- __Scrutinizer-CI__ * for providing us a free Security Analysis -- __VersionEye__ * For being an awesome tool that helped us to watch version dependencies. You will be missed, thank you very much Robert. -- __Sabine van Lommen__ * from __Zend.com__ for providing us a free developer licence of Zend Server -- __Lucas (_hammermaps_)__ for the "Zend Data Cache" driver implementation -- __Anton (_git-webmaster_)__ for kindly providing us a Couchbase server for deep tests purposes. - -\* Thanks to the companies that provided us free access to their products to help us to build a better quality software every day. - -But above all, many thanks to these companies to support indisputably Open Source Projects. -Thanks to all the contributors that added their stone to the building. Each contribution made this project a bit better, every commit, every pull request you made contributed to make this project greater and better. - -#### Software licenses: - -- PHP License, version 3.0: - - Pear (c) 2001-2004 PHP Group, http://pear.php.net - -- MIT licenced: - - Predis (c) 2009-2015 Daniele Alessandri, https://clorophilla.net diff --git a/docs/DRIVERS.md b/docs/DRIVERS.md deleted file mode 100644 index 803a72105..000000000 --- a/docs/DRIVERS.md +++ /dev/null @@ -1,80 +0,0 @@ -### Drivers descriptions -* Apc **(REMOVED in v8)** - * The Alternative Php Cache (APC) driver. A memory cache for regular performances. -* Apcu - * The Alternative Php User Cache (APCU) driver. A memory cache for regular performances. -* Arangodb **(Added in v9)** - * A very high-performance NoSQL driver using a key-value pair system. - * :new: Is now a composer extension separated from the Phpfastcache core as of v9.2: `phpfastcache/arangodb-extension` -* Cassandra - * A very high-performance NoSQL driver using a key-value pair system. Please note that the Driver rely on php's Datastax extension: https://github.com/datastax/php-driver - * As of PHP an unofficial fork has been launched due to Datastax lack of maintenance: https://github.com/he4rt/scylladb-php-driver -* Cookie **(REMOVED in v9)** - * A cookie driver to store non-sensitive scalar (only) data. Limited storage up to 4Ko. -* Couchbase **(REMOVED in v9)** - * A very high-performance NoSQL driver using a key-value pair system, replaced by Couchbasev3 as of v8.0.8. -* Couchbasev3 **(Added in v8.0.8)** - * Same as Couchbase but for Couchbase PHP-SDK 3.0 support. - * Will be deprecated as of v10 -* Couchbasev4 **(Added in v9.2.0)** - * Couchbase PHP-SDK 4.x support. - * :new: It is now a [separated extension](https://github.com/PHPSocialNetwork/couchbasev4-extension) which is no longer part of the Phpfastcache's core. -* Couchdb - * A very high-performance NoSQL driver using a key-value pair system. - * :new: Is now a composer extension separated from the Phpfastcache core as of v9.2: `phpfastcache/couchdb-extension` -* Devfalse **(REMOVED in v9)** - * A development driver that return false for everything except driverCheck(). -* Devnull - * A development driver that return null for driverRead() and driverIsHit() (get actions) and true for other action such as driverDelete, DriverClear() etc. -* Devtrue **(REMOVED in v9)** - * A development driver that return true for everything including driverCheck(). -* Devrandom **(Added in v8.0.8)** - * A development driver with configurable factor chance and data length. -* Dynamodb **(Added in v9)** - * An AWS cloud NoSQL driver using a key-value pair system. Be careful when flushing the table as it will delete and recreate the table due to a Dynamodb limitation. - * :new: Is now a composer extension separated from the Phpfastcache core as of v9.2: `phpfastcache/dynamodb-extension` -* Files - * A file driver that use serialization for storing data for regular performances. A _$path_ config must be specified, else the system temporary directory will be used. -* Firestore **(Added in v9)** - * A GCP cloud NoSQL driver using a key-value pair system. Collections are created automatically on-the-fly. - * :new: Is now a composer extension separated from the Phpfastcache core as of v9.2: `phpfastcache/firestore-extension` -* Leveldb - * A NoSQL driver using a key-value pair system. A _$path_ config must be specified, else the system temporary directory will be used. -* Memcache - * The Memcache driver. A memory cache for regular performances. Do not cross this driver with Memcached driver. -* Memcached - * The Memcached driver. A memory cache for regular performances. Do not cross this driver with Memcache driver. -* Memstatic - * The Memstatic driver is a memory static driver that expires when the script execution ends. -* Mongodb - * A very high-performance NoSQL driver using a key-value pair system. - * :new: Is now a composer extension separated from the Phpfastcache core as of v9.2: `phpfastcache/mongodb-extension` -* Predis - * A high-performance memory driver using a in-memory data structure storage. Less efficient than Redis driver as it is an embedded library. -* Ravendb **(Added in v9.2)** - * A Ravendb driver that use the `ravendb/ravendb-php-client` client for good performances. - * :new: It is a composer extension separated from the Phpfastcache core as of v9.2: `phpfastcache/ravendb-extension` -* Redis/Rediscluster - * A very high-performance memory driver using a in-memory data structure storage. More efficient than Predis driver as it is an compiled library. - * RedisCluster use the RedisCluster class with a different driver name but behave slightly differently than Redis driver. -* Relay **(Planned for v9.3.0)** - * A very high-performance memory driver based on a Redis backend - * Relay.so aims to be faster than Redis/Predis using a new php extension. Will be available by the end of 2024. -* Riak **(REMOVED in v8.0.6)** - * A very high-performance NoSQL driver using a key-value pair system. -* Solr **(Added in v9.1)** - * A Solr driver that use Solarium as PHP client for good performances. - * :new: It is now a composer extension separated from the Phpfastcache core as of v9.2: `phpfastcache/solr-extension` -* Sqlite - * A Sqlite driver that use serialization for storing data for regular performances. A _$path_ config must be specified, else the system temporary directory will be used. -* Ssdb - * A very high-performance NoSQL driver using a key-value pair system. -* Wincache - * The Wincache driver. A memory cache for regular performances on Windows platforms. - * **Will be removed in v10** due to the lack of updates to PHP8 [as officially stated by PHP](https://www.php.net/manual/en/install.windows.recommended.php). -* Xcache **(REMOVED in v8)** - * The Xcache driver. A memory cache for regular performances. -* Zend Disk Cache ( * Requires ZendServer Version 4 or higher * ) - * The Zend Data Cache is a by ZendServer supported file cache. The cache is for regular performance. -* Zend Memory Cache ( * Requires ZendServer Version 4 or higher * ) - * The Zend Memory Cache is a by ZendServer supported memory cache. The cache is for high-performance applications. diff --git a/docs/EVENTS.md b/docs/EVENTS.md deleted file mode 100644 index 88477accb..000000000 --- a/docs/EVENTS.md +++ /dev/null @@ -1,323 +0,0 @@ -:mega: As of the V6, Phpfastcache provides an event mechanism. -You can subscribe to an event by passing a Closure to an active event: - -```php -use Phpfastcache\EventManager; - -/** -* Bind the event callback -*/ -EventManager::getInstance()->onCacheGetItem(function(ExtendedCacheItemPoolInterface $itemPool, ExtendedCacheItemInterface $item){ - $item->set('[HACKED BY EVENT] ' . $item->get()); -}); - -``` - -An event callback can get unbind but you MUST provide a name to the callback previously: - - -```php -use Phpfastcache\EventManager; - -/** -* Bind the event callback -*/ -EventManager::getInstance()->onCacheGetItem(function(ExtendedCacheItemPoolInterface $itemPool, ExtendedCacheItemInterface $item){ - $item->set('[HACKED BY EVENT] ' . $item->get()); -}, 'myCallbackName'); - - -/** -* Unbind the event callback -*/ -EventManager::getInstance()->unbindEventCallback('onCacheGetItem', 'myCallbackName'); - -``` - -:new: in V8 - -You can simply subscribe to **every** events at once of Phpfastcache. -```php -onEveryEvents(static function (string $eventName, ...$args) { - echo sprintf("Triggered event '{$eventName}' with %d arguments provided", count($args)); -}, 'debugCallback'); -``` - -This is an exhaustive list, and it will be updated as soon as new events will be added to the Core. - - -:new: In V9 - -- Some callback parameter, that are __NOT__ objects, are passed by reference via the new `\Phpfastcache\Event\EventReferenceParameter` class.\ - This class is instantiated and passed to the callback with the original value passed **by reference** allowing you to either read or re-write its value.\ - If it's allowed by the event dispatcher the type can be changed or not.\ - If you try to while it's not allowed, you will get a `PhpfastcacheInvalidArgumentException` when trying to call `\Phpfastcache\Event\EventReferenceParameter::setParameterValue()`\ - Finally the class `\Phpfastcache\Event\EventReferenceParameter` is `invokable` and trying to do so will return you the parameter value.\ -- A method named `unbindAllEventCallbacks(): bool` has been added to `EventManagerInterface` to allow you to unbind/clear all event from an event instance. -- Event callbacks will now receive the `eventName` as an extra _last_ callback parameter (except for `onEveryEvents` callbacks) -- Added `EventManagerInterface::on(array $eventNames, $callback)` method, to subscribe to multiple events in once with the same callback - -:warning: Changed in V9.2 - -As of the V9.2 there is a slight change with the EventManager: -EventManager is now scoped to its own poll if retrieved through `ExtendedCacheItemPoolTrait::->getEventManager()`. -This means, that the behavior is not more consistent:\ -An EventManager retrieved through `ExtendedCacheItemPoolTrait::->getEventManager()` will now **ONLY** fire events related to this pool instance.\ -However, the global EventManager `EventManager::getInstance()` remains unchanged and will fire any events no matter what pool emitted it. -The order of execution of the events is always the following: - -1. Scoped named Event through `ExtendedCacheItemPoolTrait::->getEventManager()->onXxxxxXxxxx(...)` -2. Scoped `onEveryEvent` Event through `ExtendedCacheItemPoolTrait::->getEventManager()->onEveryEvent(...)` -3. Unscoped named event through `EventManager::getInstance()->onXxxxxXxxxx(...)` -4. Unscoped `onEveryEvent` event through `EventManager::getInstance()->onEveryEvent(...)` - -## List of active events: -### ItemPool Events -- onCacheGetItem(*Callable* **$callback**) - - **Callback arguments** - - *ExtendedCacheItemPoolInterface* **$itemPool** - - *ExtendedCacheItemInterface* **$item** - - **Scope** - - ItemPool - - **Description** - - Allow you to manipulate an item just before it gets returned by the getItem() method. - - **Risky Circular Methods** - - *ExtendedCacheItemPoolInterface::getItem()* - - *ExtendedCacheItemPoolInterface::getItems()* - - *ExtendedCacheItemPoolInterface::getItemsByTag()* - - *ExtendedCacheItemPoolInterface::getItemsAsJsonString()* - -- onCacheGetItems(*Callable* **$callback**) - - **Callback arguments** - - *ExtendedCacheItemPoolInterface* **$itemPool** - - *ExtendedCacheItemInterface[]* **$items** - - **Scope** - - ItemPool - - **Description** - - Allow you to manipulate a set of items just before it gets returned by the getItems() method. - - **Risky Circular Methods** - - *ExtendedCacheItemPoolInterface::getItem()* - - *ExtendedCacheItemPoolInterface::getItems()* - - *ExtendedCacheItemPoolInterface::getItemsByTag()* - - *ExtendedCacheItemPoolInterface::getItemsAsJsonString()* - -- onCacheDeleteItem(*Callable* **$callback**) - - **Callback arguments** - - *ExtendedCacheItemPoolInterface* **$itemPool** - - *ExtendedCacheItemInterface* **$item** - - **Scope** - - ItemPool - - **Description** - - Allow you to manipulate an item after being deleted (this event is not fired if `deleteItems()` is called). :exclamation: **Caution** The provided item is in pool detached-state. - - **Risky Circular Methods** - - *ExtendedCacheItemPoolInterface::deleteItem()* - - *ExtendedCacheItemPoolInterface::deleteItems()* - - *ExtendedCacheItemPoolInterface::getItem()* - - *ExtendedCacheItemPoolInterface::getItems()* - - *ExtendedCacheItemPoolInterface::getItemsByTag()* - - *ExtendedCacheItemPoolInterface::getItemsAsJsonString()* - -- onCacheDeleteItems(*Callable* **$callback**) - - **Callback arguments** - - *ExtendedCacheItemPoolInterface* **$itemPool** - - *ExtendedCacheItemInterface[]* **$items** - - **Scope** - - ItemPool - - **Description** - - Allow you to manipulate multiple items after being deleted. :exclamation: **Caution** The provided item is in pool detached-state. - - **Risky Circular Methods** - - *ExtendedCacheItemPoolInterface::deleteItem()* - - *ExtendedCacheItemPoolInterface::deleteItems()* - - *ExtendedCacheItemPoolInterface::getItem()* - - *ExtendedCacheItemPoolInterface::getItems()* - - *ExtendedCacheItemPoolInterface::getItemsByTag()* - - *ExtendedCacheItemPoolInterface::getItemsAsJsonString()* - -- onCacheSaveItem(*Callable* **$callback**) - - **Callback arguments** - - *ExtendedCacheItemPoolInterface* **$itemPool** - - *ExtendedCacheItemInterface* **$item** - - **Scope** - - ItemPool - - **Description** - - Allow you to manipulate an item just before it gets saved by the driver. - - **Risky Circular Methods** - - *ExtendedCacheItemPoolInterface::commit()* - - *ExtendedCacheItemPoolInterface::save()* - -- onCacheSaveMultipleItems(*Callable* **$callback**) - - **Callback arguments** - - *ExtendedCacheItemPoolInterface* **$itemPool** - - *EventReferenceParameter($items)* **$items** _via EventReferenceParameter object_ **(type modification forbidden)** - - **Scope** - - ItemPool - - **Description** - - Allow you to manipulate an array of items before they get saved by the driver. - - **Risky Circular Methods** - - *ExtendedCacheItemPoolInterface::commit()* - - *ExtendedCacheItemPoolInterface::save()* - - *ExtendedCacheItemPoolInterface::saveMultiple()* - -- onCacheSaveDeferredItem(*Callable* **$callback**) - - **Callback arguments** - - *ExtendedCacheItemPoolInterface* **$itemPool** - - *ExtendedCacheItemInterface* **$item** - - **Scope** - - ItemPool - - **Description** - - Allow you to manipulate an item just before it gets pre-saved by the driver. - - **Risky Circular Methods** - - *ExtendedCacheItemPoolInterface::saveDeferred()* - -- onCacheCommitItem(*Callable* **$callback**) - - **Callback arguments** - - *ExtendedCacheItemPoolInterface* **$itemPool** - - *EventReferenceParameter($items)* **$items** _via EventReferenceParameter object_ **(type modification forbidden)** - - **Scope** - - ItemPool - - **Description** - - Allow you to manipulate and/or alter a set of items just before they gets pre-saved by the driver. - - **Risky Circular Methods** - - *ExtendedCacheItemPoolInterface::commit()* - -- onCacheClearItem(*Callable* **$callback**) - - **Callback arguments** - - *ExtendedCacheItemPoolInterface* **$itemPool** - - *ExtendedCacheItemInterface[]* **$items** - - **Scope** - - ItemPool - - **Description** - - Allow you to manipulate a set of item just before they gets cleared by the driver. - - **Risky Circular Methods** - - *ExtendedCacheItemPoolInterface::clear()* - - *ExtendedCacheItemPoolInterface::clean()* - - - onCacheWriteFileOnDisk(*Callable* **$callback**) - - **Callback arguments** - - *ExtendedCacheItemPoolInterface* **$itemPool** - - *string* **$file** - - *bool* **$secureFileManipulation** - - **Scope** - - ItemPool - - **Description** - - Allow you to get notified when a file is written on disk. - - **Risky Circular Methods** - - *ExtendedCacheItemPoolInterface::writefile()* - -- onCacheGetItemInSlamBatch(*Callable* **$callback**) - - **Callback arguments** - - *ExtendedCacheItemPoolInterface* **$itemPool** - - *ItemBatch* **$driverData** - - *int* **$cacheSlamsSpendSeconds** - - **Scope** - - ItemPool - - **Description** - - Allow you to get notified each time a batch loop is looping - - **Risky Circular Methods** - - *ExtendedCacheItemPoolInterface::deleteItem()* - - *ExtendedCacheItemPoolInterface::getItem()* - - *ExtendedCacheItemPoolInterface::getItems()* - - *ExtendedCacheItemPoolInterface::getItemsByTag()* - - *ExtendedCacheItemPoolInterface::getItemsAsJsonString()* - -- onCacheDriverChecked(*Callable* **$callback**) - - **Callback arguments** - - *ExtendedCacheItemPoolInterface* **$itemPool** - - **Scope** - - ItemPool - - **Description** - - Allow you to bind an event when the driver prerequisites has passed but before it the `driverConnect()` is called. - - **Risky Circular Methods** - - *(none)* -- onCacheDriverConnected(*Callable* **$callback**) - - **Callback arguments** - - *ExtendedCacheItemPoolInterface* **$itemPool** - - *object* **$instance** Internal instance of the backend connect - - **Scope** - - ItemPool - - **Description** - - Allow you to bind an event when the driver backend has been successfully instantiated and connected/authenticated (where applicable). - - **Risky Circular Methods** - - *(none)* -### ItemPool Events (Cluster) -- onCacheReplicationSlaveFallback(*Callable* **$callback**) - - **Callback arguments** - - *ClusterPoolInterface* **$self** - - *string* **$caller** - - **Scope** - - Cluster pool - - **Description** - - Allow you to get notified when a Master/Slave cluster switches on slave - - **Risky Circular Methods** - - N/A - -- onCacheReplicationRandomPoolChosen(*Callable* **$callback**) - - **Callback arguments** - - *ClusterPoolInterface* **$self** - - *ExtendedCacheItemPoolInterface* **$randomPool** - - **Scope** - - Cluster pool - - **Description** - - Allow you to get notified when a Random Replication cluster choose a cluster - - **Risky Circular Methods** - - N/A - -- onCacheClusterBuilt(*Callable* **$callback**) - - **Callback arguments** - - *AggregatorInterface* **$clusterAggregator** - - *ClusterPoolInterface* **$cluster** - - **Scope** - - Cluster aggregator - - **Description** - - Allow you to get notified when a cluster is being built - - **Risky Circular Methods** - - *$clusterAggregator::getCluster()* -### Item Events -- onCacheItemSet(*Callable* **$callback**) - - **Callback arguments** - - *ExtendedCacheItemInterface* **$item** - - *EventReferenceParameter($value)* **$value** _via EventReferenceParameter object_ **(type modification allowed)** - - **Scope** - - Item - - **Description** - - Allow you to read (and rewrite) the value set to an item. - - **Risky Circular Methods** - - *ExtendedCacheItemInterface::get()* - -- onCacheItemExpireAt(*Callable* **$callback**) - - **Callback arguments** - - *ExtendedCacheItemInterface* **$item** - - *\DateTimeInterface* **$expiration** - - **Scope** - - Item - - **Description** - - Allow you to get/set the expiration date of an item. - - **Risky Circular Methods** - - *ExtendedCacheItemInterface::expiresAt()* - -- onCacheItemExpireAfter(*Callable* **$callback**) - - **Callback arguments** - - *ExtendedCacheItemInterface* **$item** - - *int | \DateInterval* **$time** - - **Scope** - - Item - - **Description** - - Allow you to get the "expire after" time of an item. If `$time` is a DateInterval you also set it. - - **Risky Circular Methods** - - *ExtendedCacheItemInterface::expiresAt()* - -### Driver-specific Events (as of V9) -#### Arangodb -See [Arangodb extension event documentation](https://github.com/PHPSocialNetwork/arangodb-extension#events). - -#### Couchdb (v9.2) -See [Couchdb extension event documentation](https://github.com/PHPSocialNetwork/couchdb-extension#events). - -#### Dynamodb -See [Dynamodb extension event documentation](https://github.com/PHPSocialNetwork/dynamodb-extension#events). - -#### Solr -See [Solr extension event documentation](https://github.com/PHPSocialNetwork/solr-extension#events). diff --git a/docs/OPTIONS.md b/docs/OPTIONS.md deleted file mode 100644 index 6660596bf..000000000 --- a/docs/OPTIONS.md +++ /dev/null @@ -1,8 +0,0 @@ -Phpfastcache has some options that you may want to know before using them. - -### Global options -The global options are defined in `\Phpfastcache\Config\ConfigurationOption` ([ConfigurationOption.php](../lib/Phpfastcache/Config/ConfigurationOption.php)) - -### Driver-specific options * -The driver-specific options are defined in `Config.php` file located in each driver [directory](../lib/Phpfastcache/Drivers). -Each driver-specific `Config` class file extends `\Phpfastcache\Config\ConfigurationOption` diff --git a/docs/examples/README.md b/docs/examples/README.md deleted file mode 100644 index eb18c7a2d..000000000 --- a/docs/examples/README.md +++ /dev/null @@ -1,6 +0,0 @@ -### Important notice - -Example files were removed due to maintainability problem.\ -Instead you can take a look at the `/tests` directory which contains a lot of code example your can inspire yourself to. - -[Bring me to `/tests` directory](../../tests) diff --git a/docs/migration/MigratingFromV4ToV5.md b/docs/migration/MigratingFromV4ToV5.md deleted file mode 100644 index 4dcf221db..000000000 --- a/docs/migration/MigratingFromV4ToV5.md +++ /dev/null @@ -1,137 +0,0 @@ -Because the V5 is not backward compatible with the V4 we will help you to migrate your code: - - -### Extending phpFastCache: - -#### :clock1: Then: -```php -namespace My\Custom\Project; -use phpFastCache\Core\phpFastCache; - -/** - * Class Cache - */ -class Cache extends phpFastCache -{ - -} -``` - -#### :alarm_clock: Now: - -```php -namespace My\Custom\Project; -use phpFastCache\Proxy\phpFastCacheAbstractProxy; - -/** - * Class Cache - */ -class Cache extends phpFastCacheAbstractProxy -{ - -} -``` - -See examples/extendedPhpFastCache.php for more information - - - -### Get/Set uses: - -#### :clock1: Then: -```php -namespace My\Custom\Project; -use phpFastCache\Core\phpFastCache; - -$cache = phpFastCache(); -// or -$cache = __c(); - -$myCacheItem = $cache->get("myKey"); - -if($myCacheItem === null){ - $myCacheItem = database_operation(); - $cache->set("myKey", $myCacheItem, 600); -} - - -$template['myCacheItemData'] = $myCacheItem; -``` - -#### :alarm_clock: Now: - -```php -namespace My\Custom\Project; - -$config = [ - 'path' => 'An\absolute\path', -]; -$cache = CacheManager::getInstance('Files', $config); -// or -$cache = CacheManager::Files($config); - -$myCacheItem = $cache->getItem("myKey"); - -if(!$myCacheItem->isHit()){ - $myCacheItem->set(database_operation()); - $cache->save($myCacheItem); -} - -$template['myCacheItemData'] = $myCacheItem->get(); -``` - - - - - - - - - - - -### Cache clearing: - -#### :clock1: Then: -```php -namespace My\Custom\Project; -use phpFastCache\Core\phpFastCache; - -$cache = phpFastCache(); -// or -$cache = __c(); - -$cache->clean(); -``` - -#### :alarm_clock: Now: - -```php -namespace My\Custom\Project; - -$config = [ - 'path' => 'An\absolute\path', -]; -$cache = CacheManager::getInstance('Files', $config); -// or -$cache = CacheManager::Files($config); - -$myCacheItem = $cache->clear(); - -``` - - - - - - - - - - - - -### Search system: -The search system has been removed in favor of Tags features. Remember that the cache must NOT be considered as a search engine like Solr, Sphynx etc. - -See examples/tagsMethods.php for more information \ No newline at end of file diff --git a/docs/migration/MigratingFromV5ToV6.md b/docs/migration/MigratingFromV5ToV6.md deleted file mode 100644 index 3913ebefa..000000000 --- a/docs/migration/MigratingFromV5ToV6.md +++ /dev/null @@ -1,244 +0,0 @@ -Because the V6 is not backward compatible with the V5, here's a guide to help you to migrate your code: - -### Existing data in cache during migration -:anger: :exclamation: If you update PhpFastCache from v5 to v6 you need to clear up the whole cache otherwise you may get this kind of error: -``` -Notice: Undefined index: e in /phpfastcache/src/phpFastCache/Core/Pool/DriverBaseTrait.php on line ... - -Fatal error: Uncaught phpFastCache\Exceptions\phpFastCacheInvalidArgumentException: $expiration must be an object implementing the DateTimeInterface in ... -``` - -### Setting up a default config - -#### :clock1: Then: -PhpFastCache used to set a default global config using the `CacheManager::setup()` method - -```php -namespace My\Custom\Project; - - -$instance = CacheManager::setup([ - 'path' => 'somewhere' -]); -$instance = CacheManager::getInstance('Files'); - -``` - -#### :alarm_clock: Now: -This method has been changed is now replaced by the `CacheManager::setDefaultConfig()` method. -Using the old `CacheManager::setup()` method will trigger a `phpFastCacheInvalidConfigurationException` - -```php -namespace My\Custom\Project; - - -$instance = CacheManager::setDefaultConfig([ - 'path' => 'somewhere' -]); -$instance = CacheManager::getInstance('Files'); - -``` - -### Type hint of Driver instances - -#### :clock1: Then: -Driver instances used to implements a `phpFastCache\Cache\ExtendedCacheItemPoolInterface` interface. - -```php -namespace My\Custom\Project; - - -$instance = CacheManager::getInstance('Files'); - -if($instance instanceof \phpFastCache\Cache\ExtendedCacheItemPoolInterface) -{ - // Some code -} - -``` - -#### :alarm_clock: Now: -This has been changed and they now implements a `phpFastCache\Core\Pool\ExtendedCacheItemPoolInterface` interface - -```php -namespace My\Custom\Project; - - -$instance = CacheManager::getInstance('Files'); - -if($instance instanceof \phpFastCache\Core\Pool\ExtendedCacheItemPoolInterface) -{ - // Some code -} - -``` - -### Type hint of Item instances - -#### :clock1: Then: -Item instances used to implements a ``phpFastCache\Cache\ExtendedCacheItemInterface`` interface. - -```php -namespace My\Custom\Project; - - -$instance = CacheManager::getInstance('Files'); -$item = $instance->getItem('key'); - - -if($item instanceof \phpFastCache\Cache\ExtendedCacheItemInterface) -{ - // Some code -} - -``` - -#### :alarm_clock: Now: -This has been changed and it now returns a `phpFastCache\Core\Item\ExtendedCacheItemInterface` interface - -```php -namespace My\Custom\Project; - - -$instance = CacheManager::getInstance('Files'); -$item = $instance->getItem('key'); - - -if($item instanceof \phpFastCache\Core\Item\ExtendedCacheItemInterface) -{ - // Some code -} - -``` - -### Catching \InvalidArgumentException - -#### :clock1: Then: -Code used to catch a `\InvalidArgumentException` interface. - -```php -namespace My\Custom\Project; - -$instance = CacheManager::getInstance('Files'); - -try{ - $item = $instance->getItem(array()); -}catch(\InvalidArgumentException $e){ - //Caught exception code -} - -``` - -#### :alarm_clock: Now: -This has been changed you now MUST catch `\phpFastCache\Exceptions\phpFastCacheInvalidArgumentException` class - -```php -namespace My\Custom\Project; - -$instance = CacheManager::getInstance('Files'); - -try{ - $item = $instance->getItem(array()); -}catch(\phpFastCache\Exceptions\phpFastCacheInvalidArgumentException $e){ - //Caught exception code -} - -``` -:warning: Please note that `\phpFastCache\Exceptions\phpFastCacheInvalidArgumentException` implements `\Psr\Cache\InvalidArgumentException` as per PSR-6. - -### Catching \LogicException - -#### :clock1: Then: -Code used to catch a `\LogicException`. - -```php -namespace My\Custom\Project; - -$instance = CacheManager::getInstance('Files'); - -try{ - $item = $instance->getItem(array()); -}catch(\LogicException $e){ - //Caught exception code -} - -``` - -#### :alarm_clock: Now: -This has been changed you now MUST catch `\phpFastCache\Exceptions\phpFastCacheLogicException` interface - -```php -namespace My\Custom\Project; - -$instance = CacheManager::getInstance('Files'); - -try{ - $item = $instance->getItem(array()); -}catch(\phpFastCache\Exceptions\phpFastCacheLogicException $e){ - //Caught exception code -} - -``` - -### Allowed characters in key identifier -:warning: As of the V6, the following characters can not longer being a part of the key identifier: `{}()/\@:` - -If you try to do so, an `\phpFastCache\Exceptions\phpFastCacheInvalidArgumentException` will be raised. - -You must replace them with a safe delimiter such as `.|-_` - -### Cache clear method -The deprecated method `phpFastCache\Cache\ExtendedCacheItemPoolInterface::clear()` is now definitely removed. - - -#### :clock1: Then: -In the V5 the method `phpFastCache\Cache\ExtendedCacheItemPoolInterface::clear()` was deprecated. - -```php -namespace My\Custom\Project; - - -$instance = CacheManager::getInstance('Files'); - -if($instance instanceof \phpFastCache\Cache\ExtendedCacheItemPoolInterface) -{ - $instance->clear(); -} - -``` - -#### :alarm_clock: Now: -In the V6 we removed it. Use `phpFastCache\Cache\ExtendedCacheItemPoolInterface::clean()` instead. - -```php -namespace My\Custom\Project; - - -$instance = CacheManager::getInstance('Files'); - -if($instance instanceof \phpFastCache\Core\Pool\ExtendedCacheItemPoolInterface) -{ - $instance->clean(); -} - -``` - -### Mongodb driver has changed -:warning: As of the V6, the Mongodb driver has been updated - -#### :clock1: Then: -In the V5 the driver was making use of of the [deprecated class Mongo](http://php.net/manual/fr/class.mongo.php). - -#### :alarm_clock: Now: -In the V6 we made an important change: We now make use of [Mongodb Driver](http://php.net/manual/fr/set.mongodb.php) -Only your code configuration will have to be updated, PhpFastCache manages all the abstract part by itself. - -### DriverStatistic class name has changed -:warning: As of the V6, DriverStatistic class name has changed for a better classes name normalization - -#### :clock1: Then: -In the V5 the class was named `phpFastCache\Entities\driverStatistic` - -#### :alarm_clock: Now: -In the V6 it has changed and is now `phpFastCache\Entities\DriverStatistic` (with a **D** uppercase), you may need to re-fetch your -git repository completely on some operating systems (especially Windows, meh). \ No newline at end of file diff --git a/docs/migration/MigratingFromV6ToV7.md b/docs/migration/MigratingFromV6ToV7.md deleted file mode 100644 index 333d3ac69..000000000 --- a/docs/migration/MigratingFromV6ToV7.md +++ /dev/null @@ -1,169 +0,0 @@ -Because the V7 is **absolutely** not backward compatible with the V6, here's a guide to help you to migrate your code: - -### :warning: Phpfastcache global namespace :warning: -As of the V7 and to comply with modern standards the Phpfastcache namespace has changed :warning: - -#### :clock1: Then: -We used to declare this namespace: `namespace phpFastCache;` or `use phpFastCache\...;` - -#### :alarm_clock: Now: -The time has changed, you now have to use: `namespace Phpfastcache;` or `use Phpfastcache\...;` -For any useful purpose, the `src/` directory has been moved along to `lib/`. - -### :warning: Phpfastcache "phpFastCache*" classes :warning: -As of the V7 and to comply with modern standards the "phpFastCache*" classes have been **C**apitalized :warning: - -#### :clock1: Then: -We used to declare this kind of class: `class phpFastCacheAbstractProxy` - -#### :alarm_clock: Now: -The time has changed, you now have to use: `class PhpfastcacheAbstractProxy` -For any useful purpose, all the PhpFastCache exceptions has been **C**apitalized. -Class `Phpfastcache\Exceptions\phpFastCache[...]Exception` have been renamed to `Phpfastcache\Exceptions\Phpfastcache[...]Exception` - -### Deprecations -- `Phpfastcache\CacheManager::getStaticAllDrivers()` replaced by `Phpfastcache\CacheManager::getDriverList()` -- `Phpfastcache\CacheManager::getStaticSystemDrivers()` replaced by `Phpfastcache\CacheManager::getDriverList()` -- Configuration option `ignoreSymfonyNotice` will not be replaced since that the related Symfony notice in `Phpfastcache\CacheManager::getInstance()` has been removed - -### Configuration -- Added configuration option `fallbackConfig` for a better fallback configuration - -### Return type & Scalar type declarations -:anger: :exclamation: The V7 will make use of new php's return type & scalars type declarations features. -This means that you will now have to be very careful about the data types that you are sending to the phpFastCache API. -Also PhpFastCache will make use of **strict types** provided by php7 by declaring `declare(strict_types=1);` in the top of each source file. -This ensure you a full compatibility and respect of php types. - -### ActOnAll Helper - -#### :clock1: Then: -The ActOnAll helper used to return an array of returns only for getters and a strict boolean of CRUD operations: -( - Files::DeleteItem(): false + - Memcache::DeleteItem(): true + - Redis::DeleteItem(): true -) => Returning a strict FALSE - -#### :alarm_clock: Now: -Whatever you call will now result in an array of returns giving you the possibility to know which driver is returning an unexpected response via the ActOnAll helper. -Also the ActOnAll helper does no longer implements `ExtendedCacheItemPoolInterface` due to the type hint implementation. - -### Cache Manager: Instance ID -:new: As of the V7 you can now (optionally) specify an instance ID using the CacheManager: - -```php -CacheManager::getInstance($defaultDriver, $options, $instanceId); -``` -Please note that `$instanceId` must be a valid __STRING__. - -There's also a variant that throw a `phpFastCacheInstanceNotFoundException` if the instance is not found. -```php -CacheManager::getInstanceById($instanceId); -``` - -### Configuration option names - -#### :clock1: Then: -Some configuration names were still using "snake case" format: -- default_chmod -- compress_data -- sasl_user -- ... - -#### :alarm_clock: Now: -These configuration names are now "Camelized": -- defaultChmod -- compressData -- saslUser -- ... - -As of the V7 there's no "snake case" names left. - -### Configuration option type - -#### :clock1: Then: -The configuration data used to be a primitive array passed through a `CacheManager` method. - -#### :alarm_clock: Now: -The will now accept only a `\Phpfastcache\Config\ConfigurationOption` object. -There's a short alias available for less verbose configuration: `\Phpfastcache\Config\Config` -This object will contain fluent setters allowing you to make use of chained setters. -Despite the fact that this is a bad practice, this object which implements ArrayAccess interface -will allow you to treat the object as an array for primitive variable accesses: -```php -use Phpfastcache\Config\Config; - -$configArray = []; -$config = new Config(); -$config['path'] = '/an/absolute/path'; -// The line above is doing exact same job as the line below: -$config->setPath('/an/absolute/path'); -$cacheInstace = CacheManager::getInstance('Files', $config); -// This also works well: -$cacheInstace = CacheManager::getInstance('Files', new Config([ - 'path' => '/an/absolute/path'] -)); -``` -#### For non-global option you MUST use the specific Config object provided for each drivers -```php -// The recommended way is to use an alias to not confuse yourself -use Phpfastcache\Drivers\Files\Config as FilesConfig; - -$config = new FilesConfig(); -$config->setPath('/an/absolute/path'); -$config->setSecureFileManipulation(true); -$cacheInstace = CacheManager::getInstance('Files', $config); - -// This also works well: -$cacheInstace = CacheManager::getInstance('Files', new FilesConfig([ - 'path' => '/an/absolute/path'] -)); -``` - -However the ArrayAccess interface has been implemented to make the migration easier, -so we might reconsider it's usefulness in the future. -Then, we recommend you to use the standard object syntax to ensure you a better compatibility. -Please note that the `CacheManager` will still accepts a primitive array but will raise a -E_USER_DEPRECATED error if you do so. - -### Cache manager default configuration - -#### :clock1: Then: -The previous deprecated `CacheManager::setup()` method was kept until V6. -It has been definitely removed as of the V7. - -#### :alarm_clock: Now: -Use the recommended `CacheManager::setDefaultConfig()` method instead - -### Invalid configuration keys/values - -#### :clock1: Then: -PhpFastCache ignored invalid configuration Key/value. - -#### :alarm_clock: Now: -PhpFastCache will now throws a `phpFastCacheInvalidConfigurationException` if you -attempt to make use of an invalid configuration Key/value. - -### API changelog - -#### :clock1: Then: -The API changelog used to be hardcoded as a HEREDOC in the `Api::getChangelog()` method. - -#### :alarm_clock: Now: -The API changelog format has been moved to a MarDown file (.md) -If you were using `Api::getChangelog()` you may need to check that your code is still working as expected. -The method still returns a valid string but its format has changed slightly. - -### Couchbase PHP SDK -The Couchbase driver has been updated to works with PHP SDK 2.4+ (Couchbase Server 5+). -Therefore it way requires a Couchbase Server updated combined with an SDK update. - -### Constants autoload-related -As of the V7, all the constant starting by _PFC\_*_ were moved in to the `Phpfastcache\Autoload` namespace\ -to not pollute php's root namespace. - -### Autoload mechanism -Although we highly recommend you to make use of composer benefits, it's however still possible\ -to use our own standalone autoloader. It is now located in `lib/autoload` - diff --git a/docs/migration/MigratingFromV7ToV8.md b/docs/migration/MigratingFromV7ToV8.md deleted file mode 100644 index b6a606072..000000000 --- a/docs/migration/MigratingFromV7ToV8.md +++ /dev/null @@ -1,88 +0,0 @@ -Because the V8 is **relatively** not backward compatible with the V7, here's a guide to help you to migrate your code: - -### :warning: Minimum php version increased to 7.3+ -As of the V8 the mandatory minimum php version has been increased to 7.3+. -Once released, the php version 8.0 will be unit-tested - -### :warning: "Auto" driver removed -As of the V8 the "Auto" driver in `CacheManager::getInstance()` has been removed.\ -You will now be mandatory to specify the driver to use. - -#### :clock1: Then: -`CacheManager::getInstance('Auto')` or `CacheManager::getInstance()` expecting automatic driver chosen - -#### :alarm_clock: Now: -Use `CacheManager::getInstance('Files')` or `CacheManager::getInstance('Redis')` or something else. - -### Removal of "APC" driver -As of the V8 the "APC" has been removed. Use "APCu" instead. - -#### :clock1: Then: -`CacheManager::getInstance('Apc')` - -#### :alarm_clock: Now: -`CacheManager::getInstance('Apcu')` - -### Removal of "Xcache" driver -As of the V8 the "Xcache" has been removed, no replacement have been made.\ -It is [completely abandoned](https://xcache.lighttpd.net/) (latest update: 2014) -Use alternative memory cache such as Redis, Memcache, Ssdb, etc. - -#### :clock1: Then: -`CacheManager::getInstance('Xcache')` - -#### :alarm_clock: Now: -Find an alternative :) - -### Phpfastcache API has been upgraded to 3.0.0 -Check the [CHANGELOG_API.md](./../../CHANGELOG_API.md) to see the changes. - -### Removal of static counters -As of the V8 the static I/O counter have been removed - -#### :clock1: Then: -Calling `CacheManager::$ReadHits`, `CacheManager::$WriteHits` - -#### :alarm_clock: Now: -Replaced by`\Phpfastcache\Entities\DriverIO` callable in`\Phpfastcache\Core\Pool\ExtendedCacheItemPoolInterface::getIO` - -### Removal of deprecated method `CacheManager::setNamespacePath()` -As of the V8 the deprecated method `CacheManager::setNamespacePath()` have been removed. - -#### :clock1: Then: -Calling `CacheManager::setNamespacePath('some\custom\path')` - -#### :alarm_clock: Now: -Replaced by cache manager "override" or "custom driver" features introduced in V7 - -### Removal of deprecated method `CacheManager::getStaticSystemDrivers()` -As of the V8 the deprecated method `CacheManager::getStaticSystemDrivers()` have been removed. - -#### :clock1: Then: -Calling `CacheManager::getStaticSystemDrivers()` - -#### :alarm_clock: Now: -Replaced by `CacheManager::getDriverList()` - -### Removal of `ActOnAll` helper - -#### :clock1: Then: -The helper `ActOnAll` used to be useful to act on all instance - -#### :alarm_clock: Now: -The "ActOnAll Helper" have been removed in profit of aggregated cluster support - -### Removal of `fallback` feature - -#### :clock1: Then: -The `fallback` features used to be useful when a backend failed to initialize - -#### :alarm_clock: Now: -Use aggregated cluster Master/Slave instead - ------- -More infos in our comprehensive [changelog](./../../CHANGELOG.md). - - - - diff --git a/docs/migration/MigratingFromV8ToV9.md b/docs/migration/MigratingFromV8ToV9.md deleted file mode 100644 index cdc9f72ae..000000000 --- a/docs/migration/MigratingFromV8ToV9.md +++ /dev/null @@ -1,61 +0,0 @@ -Because the V9 is **relatively** not backward compatible with the V8, here's a guide to help you to migrate your code: - -### :warning: Minimum php version increased to 8.0+ -As of the V9 the mandatory php version has been increased to 8.0+. -Once released, the php versions 8.1, 8.2 will be unit-tested - -### Embedded autoload has been removed (and therefore, embedded dependencies too) -Use [Composer](https://getcomposer.org/doc/03-cli.md#require) to include Phpfastcache in your project - -### Removed magics methods from CacheManager `CacheManager::DriverName()` -Use `CacheManager::getInstance('DriverName')` instead.\ -This decision was made to make the cache manager more consistent by removing the "old legacy code". - -### Updated `ConfigurationOption` which is no longer an `ArrayObject` class -You can no longer use the following array-compatible syntax: `$config['yourKey'] = 'value'`\ -Use the object-notation syntax instead: `$config->setYourKey('value')` - -However, this syntax is STILL valid through the configuration constructor\ -For the default config object: `new ConfigurationOption(['yourKey' => 'yourValue'])`\ -Or for specific config objects: `new \Phpfastcache\Drivers\Files\Config(['yourKey' => 'yourValue'])`\ -Finally, the config name you try to set MUST be recognized or an exception will be thrown. - -### Deprecated `\Phpfastcache\Helper\CacheConditionalHelper` -Use `\Phpfastcache\CacheContract` instead. See [Wiki](https://github.com/PHPSocialNetwork/phpfastcache/wiki/%5BV9%CB%96%5D-Cache-contract). - -### Removed `Couchbase` driver (SDK 2 support dropped) -It is now replaced by `Couchbasev3` driver (SDK 3), the configuration options remains the same plus `scopeName` and `collectionName` that are now configurable. - -### Updated EventManager callback parameters -- Updated argument type #2 (`$items`) of `onCacheSaveMultipleItems()` event from `ExtendedCacheItemInterface[]` to `EventReferenceParameter($items)` -- Updated argument type #2 (`$items`) of `onCacheCommitItem()` event from `ExtendedCacheItemInterface[]` to `EventReferenceParameter($items)` -- Updated argument type #2 (`$value`) of `onCacheItemSet()` event from `mixed` to `EventReferenceParameter(mixed $value)` - -See [EVENTS.md](./../EVENTS.md) file for more information -### Upgraded Phpfastcache API -- The Phpfastcache API has been upgraded to `4.0.0` introducing BC breaks. [See full changes](./../../CHANGELOG_API.md) -- Renamed `Api::getPhpFastCacheVersion()` to `Api::getPhpfastcacheVersion()` -- Renamed `Api::getPhpFastCacheChangelog()` to `Api::getPhpfastcacheChangelog()` -- Renamed `Api::getPhpFastCacheGitHeadHash()` to `Api::getPhpfastcacheGitHeadHash()` - -### Removed `Devtrue` and `Devfalse` drivers -They have not been replaced. -However, the `Devrandom` driver with configurable factor chance and data length has been added - -### Removed configuration entry `htaccess` for files-based drivers. -- We consider that it's no longer the task of Phpfastcache to handle server configuration -- Removed `IOConfigurationOptionTrait::getHtaccess()` -- Removed `IOConfigurationOptionTrait::setHtaccess()` - -### Configuration object will now be locked once the cache pool instance is running -If you try to set a configuration value after the cache pool instance is being built, an exception will be thrown. - -### Removed `Cookie` driver because of its potential dangerousness -However, you can always implement it by yourself if you want to by putting it back from previous versions using `\Phpfastcache\CacheManager::addCustomDriver()` method - ------- -More information in our comprehensive [changelog](./../../CHANGELOG.md). - - - - diff --git a/docs/migration/MigratingFromV9.1ToV9.2.md b/docs/migration/MigratingFromV9.1ToV9.2.md deleted file mode 100644 index b215336d8..000000000 --- a/docs/migration/MigratingFromV9.1ToV9.2.md +++ /dev/null @@ -1,31 +0,0 @@ -Because the V9.2 is **completely** backward compatible with the V9.1, there's a small guide to help you to migrate your code: - -### :warning: Phpfastcache core drivers has been moved to their own extensions -If you were using one of those drivers: - -`Arangodb` -`Couchdb` -`Dynamodb` -`Firestore` -`Mongodb` -`Solr` - -Your **CODE IS SAFE AND FINE**, you just need to add a new composer dependency, ex: -```bash -composer install phpfastcache/arangodb-extension -``` - -### :new: Couchbasev4 has been as an extension: -```bash -composer install phpfastcache/couchbasev4-extension -``` -However `Couchbasev3` **will stay in the core** for compatibility reasons but will be deprecated. - - -That's it :) ------- -More information in our comprehensive [changelog](./../../CHANGELOG.md). - - - - diff --git a/images/apple-touch-icon.png b/images/apple-touch-icon.png new file mode 100644 index 000000000..0b9d3d5e8 Binary files /dev/null and b/images/apple-touch-icon.png differ diff --git a/images/authors/georges.jpg b/images/authors/georges.jpg new file mode 100644 index 000000000..cb32e0533 Binary files /dev/null and b/images/authors/georges.jpg differ diff --git a/images/authors/khoa.jpg b/images/authors/khoa.jpg new file mode 100644 index 000000000..fa24e7ca7 Binary files /dev/null and b/images/authors/khoa.jpg differ diff --git a/images/favicon.ico b/images/favicon.ico new file mode 100644 index 000000000..dc1f7a56f Binary files /dev/null and b/images/favicon.ico differ diff --git a/images/favicon_16.png b/images/favicon_16.png new file mode 100644 index 000000000..a4d367d82 Binary files /dev/null and b/images/favicon_16.png differ diff --git a/images/favicon_32.png b/images/favicon_32.png new file mode 100644 index 000000000..4b1d623b0 Binary files /dev/null and b/images/favicon_32.png differ diff --git a/images/favicon_48.png b/images/favicon_48.png new file mode 100644 index 000000000..55319a996 Binary files /dev/null and b/images/favicon_48.png differ diff --git a/images/icon.svg b/images/icon.svg new file mode 100644 index 000000000..44c8ff1c9 --- /dev/null +++ b/images/icon.svg @@ -0,0 +1,14 @@ + + + + background + + + + Layer 1 + + + + + + \ No newline at end of file diff --git a/images/og_512.png b/images/og_512.png new file mode 100644 index 000000000..c92517c0e Binary files /dev/null and b/images/og_512.png differ diff --git a/index.html b/index.html new file mode 100644 index 000000000..244cf7fdd --- /dev/null +++ b/index.html @@ -0,0 +1,269 @@ + + + + + Phpfastcache - A PHP cache library made for building reactive applications + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + +
+
+
+ +
+
+
+
+ +
+
+
+
+ +
+
+
+
+ +
+
+
+
+ +
+
+
+
+ +
+
+
+
+ +
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + diff --git a/js/app.js b/js/app.js new file mode 100644 index 000000000..0ef1963bd --- /dev/null +++ b/js/app.js @@ -0,0 +1,162 @@ +$(document).ready(function () { + var ShowdownOptions = { + headerLevelStart: 2, + emoji: true, + tables: true, + ghMentions: true, + disableForced4SpacesIndentedSublists: true, + simplifiedAutoLink: true + }; + var ShowdownConverter = new showdown.Converter(ShowdownOptions); + var MutationObserver = window.MutationObserver || window.WebKitMutationObserver; + + + var hydrateElementAsynchronously = function (source, target, format) { + var baseMarkupRelativeUrls = 'https://github.com/PHPSocialNetwork/phpfastcache/blob/master/' + if (!target.hasClass('hydrated')) + { + target.addClass('hydrated', true); + $.ajax({ + async: true, + url: source, + beforeSend: function () { + $(target).html('
'); + } + }).done(function (data) { + switch (format) + { + case 'markdown': + $(target).html(ShowdownConverter.makeHtml(data.replace(/\](\(\.\/)(.*)\)/, "](" + baseMarkupRelativeUrls + "$2)"))); + break; + + case 'html': + $(target).html(data); + break; + + case 'text': + default: + $(target).empty().append('
').find('pre').text(data);
+            break;
+        }
+      }).fail(function (jqXHR, textStatus, errorThrown) {
+        $(target).html('
\n' + + ' [' + jqXHR.status + '] Ajax Error
' + + jqXHR.responseText + + '
'); + }).always(function () { + $('pre code').each(function (i, block) { + hljs.highlightBlock(block); + }); + $('.panel-collapse').addClass('fpad2'); + }); + } + }; + + var observer = new MutationObserver(function (mutations, observer) { + for (var key in mutations) + { + $($(mutations[key].target)).find('[data-content-source="remote"][data-src]').each(function () { + hydrateElementAsynchronously( + $(this).data('src'), + $(this), + $(this).attr('data-format') + ); + }); + } + }); + /** + * Define what element should be observed by the observer + * and what types of mutations trigger the callback + */ + observer.observe(document, { + childList: true, + subtree: true, + }); + + /** + * Ajax Tabs + */ + $(document).on('shown.bs.tab shown.bs.collapse', '.panel-collapse, a[data-toggle="tab"]', function (e) { + var $this = ($(this).prop('tagName') === 'A' ? $(this) : $(this).siblings('.panel-heading').find('a[data-toggle="collapse"]')); + + hydrateElementAsynchronously( + $this.data('href'), + $($this.attr('href') + ', ' + $this.attr('href') + '-collapse'), + $this.attr('data-format') + ); + }); + + /** + * Get the latest version + */ + $.ajax({ + async: true, + url: $('[data-object="pfc-version"]').data('object-src'), + beforeSend: function () { + $('[data-object="pfc-version"]').html(''); + } + }).done(function (data) { + var lines = data.split("\n"); + for(var key in lines){ + if(lines[key].indexOf('## ') > -1){ + $('[data-object="pfc-version"]').text(lines[key].replace('## ', '')); + break; + } + } + }).fail(function () { + $(target).text('Ajax error'); + }); + + + /** + * Improving user navigation + * for very long pages + */ + $(window).scroll(function () { + if ($(this).scrollTop() >= 400) + { + $('#return-to-top').addClass('visible'); + } else + { + $('#return-to-top').removeClass('visible'); + } + }); + + $('#return-to-top').click(function () { + $('body,html').animate({ + scrollTop: 0 + }, 500); + }); + + /** + * Bind tooltips + */ + $('[data-toggle="tooltip"]').tooltip(); + + /** + * Reusable component + */ + var triggerTabsLoading = function(anchor){ + if(anchor && $('#main-tabs li[data-anchor="' + anchor + '"]').length){ + $('#main-tabs li[data-anchor="' + anchor + '"] a').click(); + history.replaceState({}, document.title, "."); + } + $('#main-tabs').tabCollapse(); + $('#main-tabs li.active a').trigger('shown.bs.tab'); + $('.panel-collapse.collapse.in').trigger('shown.bs.collapse'); + }; + + /** + * Prevent resizing from mobile to desktop + * viewport to display empty tabs + */ + $(window).resize(function() { + clearTimeout(window.resizedFinished); + window.resizedFinished = setTimeout(function(){ + $('.hydrated:empty').removeClass('hydrated'); + triggerTabsLoading(); + }, 250); + }); + + triggerTabsLoading(window.location.hash); +}); diff --git a/lib/Phpfastcache/Api.php b/lib/Phpfastcache/Api.php deleted file mode 100644 index b34834eed..000000000 --- a/lib/Phpfastcache/Api.php +++ /dev/null @@ -1,162 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -declare(strict_types=1); - -namespace Phpfastcache; - -use Phpfastcache\Exceptions\PhpfastcacheIOException; -use Phpfastcache\Exceptions\PhpfastcacheLogicException; -use Phpfastcache\Helper\UninstanciableObjectTrait; - -/** - * Class Api - * @package Phpfastcache - */ -class Api -{ - use UninstanciableObjectTrait; - - protected static string $version = '4.3.0'; - - /** - * This method will return the current - * API version, the API version will be - * updated by following the semantic versioning - * based on changes of: - * - ExtendedCacheItemPoolInterface - * - ExtendedCacheItemInterface - * - AggregatablePoolInterface - * - AggregatorInterface - * - ClusterPoolInterface - * - EventManagerInterface - * - * @see https://semver.org/ - * @return string - */ - public static function getVersion(): string - { - return self::$version; - } - - /** - * @param bool $fallbackOnChangelog - * @param bool $cacheable - * @return string - * @throws PhpfastcacheLogicException - * @throws PhpfastcacheIOException - */ - public static function getPhpfastcacheVersion(bool $fallbackOnChangelog = true, bool $cacheable = true): string - { - /** - * Cache the version statically to improve - * performances on multiple calls - */ - static $version; - - if ($version && $cacheable) { - return $version; - } - - if (\function_exists('shell_exec')) { - $command = 'git -C "' . __DIR__ . '" describe --abbrev=0 --tags ' . (DIRECTORY_SEPARATOR === '\\' ? '2>nul' : '2>/dev/null'); - $stdout = \shell_exec($command); - if (\is_string($stdout)) { - return trim($stdout); - } - if (!$fallbackOnChangelog) { - throw new PhpfastcacheLogicException('The git command used to retrieve the Phpfastcache version has failed.'); - } - } - - if (!$fallbackOnChangelog) { - throw new PhpfastcacheLogicException('shell_exec is disabled therefore the Phpfastcache version cannot be retrieved.'); - } - - $changelogFilename = __DIR__ . '/../../CHANGELOG.md'; - if (\file_exists($changelogFilename)) { - $semverRegexp = '/^([\d]+)\.([\d]+)\.([\d]+)(?:-([\dA-Za-z-]+(?:\.[\dA-Za-z-]+)*))?(?:\+[\dA-Za-z-]+)?$/'; - $changelog = \explode("\n", self::getPhpfastcacheChangelog()); - foreach ($changelog as $line) { - $trimmedLine = \trim($line, " \t\n\r\0\x0B#"); - if (\str_starts_with($line, '#') && \preg_match($semverRegexp, $trimmedLine)) { - return $trimmedLine; - } - } - throw new PhpfastcacheLogicException('Unable to retrieve the Phpfastcache version through the CHANGELOG.md as no valid string were found in it.'); - } - throw new PhpfastcacheLogicException( - 'shell_exec being disabled we attempted to retrieve the Phpfastcache version through the CHANGELOG.md file but it is not readable or has been removed.' - ); - } - - /** - * Return the Phpfastcache changelog, as a string. - * @return string - * @throws PhpfastcacheLogicException - * @throws PhpfastcacheIOException - */ - public static function getPhpfastcacheChangelog(): string - { - $changelogFilename = __DIR__ . '/../../CHANGELOG.md'; - if (\file_exists($changelogFilename)) { - $string = \str_replace(["\r\n", "\r"], "\n", \trim(\file_get_contents($changelogFilename))); - if ($string) { - return $string; - } - throw new PhpfastcacheLogicException('Unable to retrieve the Phpfastcache changelog as it seems to be empty.'); - } - throw new PhpfastcacheIOException('The CHANGELOG.md file is not readable or has been removed.'); - } - - /** - * @param bool $cacheable - * @return string - */ - public static function getPhpfastcacheGitHeadHash(bool $cacheable = true): string - { - static $hash; - - if ($hash && $cacheable) { - return $hash; - } - - if (\function_exists('shell_exec')) { - $stdout = \shell_exec('git rev-parse --short HEAD ' . (DIRECTORY_SEPARATOR === '\\' ? '2>nul' : '2>/dev/null')); - if (\is_string($stdout)) { - return '#' . \trim($stdout); - } - } - return ''; - } - - /** - * Return the API changelog, as a string. - * @return string - * @throws PhpfastcacheLogicException - * @throws PhpfastcacheIOException - */ - public static function getChangelog(): string - { - $changelogFilename = __DIR__ . '/../../CHANGELOG_API.md'; - if (\file_exists($changelogFilename)) { - $string = \str_replace(["\r\n", "\r"], "\n", \trim(\file_get_contents($changelogFilename))); - if ($string) { - return $string; - } - throw new PhpfastcacheLogicException('Unable to retrieve the Phpfastcache API changelog as it seems to be empty.'); - } - throw new PhpfastcacheIOException('The CHANGELOG_API.md file is not readable or has been removed.'); - } -} diff --git a/lib/Phpfastcache/CacheContract.php b/lib/Phpfastcache/CacheContract.php deleted file mode 100644 index 0d0d80c3b..000000000 --- a/lib/Phpfastcache/CacheContract.php +++ /dev/null @@ -1,61 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -declare(strict_types=1); - -namespace Phpfastcache; - -use DateInterval; -use Psr\Cache\CacheItemPoolInterface; -use Psr\Cache\InvalidArgumentException; - -class CacheContract -{ - protected CacheItemPoolInterface $cacheInstance; - - public function __construct(CacheItemPoolInterface $cacheInstance) - { - $this->cacheInstance = $cacheInstance; - } - - /** - * @throws InvalidArgumentException - */ - public function get(string|\Stringable $cacheKey, callable $callback, DateInterval|int|null $expiresAfter = null): mixed - { - $cacheItem = $this->cacheInstance->getItem((string) $cacheKey); - - if (!$cacheItem->isHit()) { - /* - * Parameter $cacheItem will be available as of 8.0.6 - */ - $cacheItem->set($callback($cacheItem)); - if ($expiresAfter) { - $cacheItem->expiresAfter($expiresAfter); - } - - $this->cacheInstance->save($cacheItem); - } - - return $cacheItem->get(); - } - - /** - * @throws InvalidArgumentException - */ - public function __invoke(string $cacheKey, callable $callback, DateInterval|int|null $expiresAfter = null): mixed - { - return $this->get($cacheKey, $callback, $expiresAfter); - } -} diff --git a/lib/Phpfastcache/CacheManager.php b/lib/Phpfastcache/CacheManager.php deleted file mode 100644 index 842fa5abc..000000000 --- a/lib/Phpfastcache/CacheManager.php +++ /dev/null @@ -1,445 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -declare(strict_types=1); - -namespace Phpfastcache; - -use Phpfastcache\Config\ConfigurationOption; -use Phpfastcache\Config\ConfigurationOptionInterface; -use Phpfastcache\Core\Pool\ExtendedCacheItemPoolInterface; -use Phpfastcache\Exceptions\PhpfastcacheDriverCheckException; -use Phpfastcache\Exceptions\PhpfastcacheDriverException; -use Phpfastcache\Exceptions\PhpfastcacheDriverNotFoundException; -use Phpfastcache\Exceptions\PhpfastcacheExtensionNotFoundException; -use Phpfastcache\Exceptions\PhpfastcacheExtensionNotInstalledException; -use Phpfastcache\Exceptions\PhpfastcacheInstanceNotFoundException; -use Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException; -use Phpfastcache\Exceptions\PhpfastcacheLogicException; -use Phpfastcache\Exceptions\PhpfastcacheUnsupportedOperationException; -use Phpfastcache\Helper\UninstanciableObjectTrait; -use Phpfastcache\Util\ClassNamespaceResolverTrait; - -/** - * @SuppressWarnings(PHPMD.ExcessiveClassComplexity) - */ -class CacheManager -{ - use ClassNamespaceResolverTrait; - use UninstanciableObjectTrait; - - public const CORE_DRIVER_NAMESPACE = 'Phpfastcache\Drivers\\'; - - protected static ConfigurationOptionInterface $config; - - protected static string $namespacePath; - - /** - * @var ExtendedCacheItemPoolInterface[] - */ - protected static array $instances = []; - - /** - * @var string[] - */ - protected static array $driverOverrides = []; - - /** - * @var string[] - */ - protected static array $driverCustoms = []; - - /** - * @var string[] - */ - protected static array $driverExtensions = []; - - /** - * @param string $instanceId - * @return ExtendedCacheItemPoolInterface - * @throws PhpfastcacheInstanceNotFoundException - */ - public static function getInstanceById(string $instanceId): ExtendedCacheItemPoolInterface - { - if (isset(self::$instances[$instanceId])) { - return self::$instances[$instanceId]; - } - - throw new PhpfastcacheInstanceNotFoundException(sprintf('Instance ID %s not found', $instanceId)); - } - - /** - * Return the list of instances - * - * @return ExtendedCacheItemPoolInterface[] - */ - public static function getInstances(): array - { - return self::$instances; - } - - /** - * @param string $driver - * @param ConfigurationOptionInterface|null $config - * @param string|null $instanceId - * @return ExtendedCacheItemPoolInterface - * @throws PhpfastcacheDriverCheckException - * @throws PhpfastcacheDriverException - * @throws PhpfastcacheDriverNotFoundException - * @throws PhpfastcacheExtensionNotInstalledException - * @throws PhpfastcacheLogicException - */ - public static function getInstance(string $driver, ?ConfigurationOptionInterface $config = null, ?string $instanceId = null): ExtendedCacheItemPoolInterface - { - if (\class_exists($driver) && \str_starts_with($driver, 'Phpfastcache')) { - $driverClass = $driver; - } else { - $driver = self::normalizeDriverName($driver); - $driverClass = self::getDriverClass($driver); - } - $config = self::validateConfig($config); - $instanceId = $instanceId ?: self::getInstanceHash($driverClass, $config); - - if (!isset(self::$instances[$instanceId])) { - if (\is_a($driverClass, ExtendedCacheItemPoolInterface::class, true)) { - if (($configClass = $driverClass::getConfigClass()) !== $config::class) { - $config = new $configClass($config->toArray()); - } - self::$instances[$instanceId] = new $driverClass( - $config, - $instanceId, - EventManager::getInstance() - ); - } else { - try { - self::$driverExtensions[$driver] = ExtensionManager::getExtension($driver); - return CacheManager::getInstance($driver, $config, $instanceId); - } catch (PhpfastcacheExtensionNotFoundException) { - if (in_array($driver, ExtensionManager::KNOWN_EXTENSION_NAMES, true)) { - throw new PhpfastcacheExtensionNotInstalledException(sprintf( - 'You requested a driver which is now an extension. Run the following command to solve this issue: %s', - sprintf('composer install phpfastcache/%s-extension', strtolower($driver)) - )); - } - throw new PhpfastcacheDriverNotFoundException(sprintf( - 'The driver "%s" does not exist or does not implement %s.', - $driver, - ExtendedCacheItemPoolInterface::class, - )); - } - } - } - - return self::$instances[$instanceId]; - } - - /** - * @param string $driverClass - * @param ConfigurationOptionInterface $config - * @return string - */ - protected static function getInstanceHash(string $driverClass, ConfigurationOptionInterface $config): string - { - return \md5($driverClass . \serialize( - \array_filter( - $config->toArray(), - static fn ($val) => $config->isValueSerializable($val) - ) - )); - } - - /** - * @param ConfigurationOptionInterface|null $config - * @return ConfigurationOptionInterface - * @throws PhpfastcacheLogicException - */ - protected static function validateConfig(?ConfigurationOptionInterface $config): ConfigurationOptionInterface - { - if ($config instanceof ConfigurationOptionInterface && $config->isLocked()) { - throw new PhpfastcacheLogicException('You provided an already locked configuration, cannot continue.'); - } - return $config ?? self::getDefaultConfig(); - } - - /** - * @return ConfigurationOptionInterface - */ - public static function getDefaultConfig(): ConfigurationOptionInterface - { - return self::$config ?? self::$config = new ConfigurationOption(); - } - - /** - * @param string $driverName - * @return string - */ - public static function normalizeDriverName(string $driverName): string - { - return \ucfirst(\strtolower(\trim($driverName))); - } - - /** - * @param string $driverName - * @return string - */ - public static function getDriverClass(string $driverName): string - { - if (!empty(self::$driverExtensions[$driverName])) { - $driverClass = self::$driverExtensions[$driverName]; - } elseif (!empty(self::$driverCustoms[$driverName])) { - $driverClass = self::$driverCustoms[$driverName]; - } elseif (!empty(self::$driverOverrides[$driverName])) { - $driverClass = self::$driverOverrides[$driverName]; - } else { - $driverClass = self::getNamespacePath() . $driverName . '\Driver'; - } - - return $driverClass; - } - - /** - * @return string - */ - public static function getNamespacePath(): string - { - return self::$namespacePath ?? self::getDefaultNamespacePath(); - } - - /** - * @return string - */ - public static function getDefaultNamespacePath(): string - { - return self::CORE_DRIVER_NAMESPACE; - } - - /** - * @return bool - */ - public static function clearInstances(): bool - { - self::$instances = []; - - \gc_collect_cycles(); - - return true; - } - - /** - * @param ExtendedCacheItemPoolInterface $cachePoolInstance - * @return bool - * @since 7.0.4 - */ - public static function clearInstance(ExtendedCacheItemPoolInterface $cachePoolInstance): bool - { - $found = false; - self::$instances = \array_filter( - \array_map( - static function (ExtendedCacheItemPoolInterface $cachePool) use ($cachePoolInstance, &$found) { - if (\spl_object_hash($cachePool) === \spl_object_hash($cachePoolInstance)) { - $found = true; - return null; - } - return $cachePool; - }, - self::$instances - ) - ); - - return $found; - } - - /** - * @param ConfigurationOptionInterface $config - * @throws PhpfastcacheInvalidArgumentException - */ - public static function setDefaultConfig(ConfigurationOptionInterface $config): void - { - if (\is_subclass_of($config, ConfigurationOption::class)) { - throw new PhpfastcacheInvalidArgumentException('Default configuration cannot be a child class of ConfigurationOption::class'); - } - self::$config = $config; - } - - /** - * @param string $driverName - * @param string $className - * @return void - * @throws PhpfastcacheLogicException - * @throws PhpfastcacheUnsupportedOperationException - * @throws PhpfastcacheInvalidArgumentException - */ - public static function addCustomDriver(string $driverName, string $className): void - { - $driverName = self::normalizeDriverName($driverName); - - if (empty($driverName)) { - throw new PhpfastcacheInvalidArgumentException("Can't add a custom driver because its name is empty"); - } - - if (!\class_exists($className)) { - throw new PhpfastcacheInvalidArgumentException( - \sprintf("Can't add '%s' because the class '%s' does not exist", $driverName, $className) - ); - } - - if (!empty(self::$driverCustoms[$driverName])) { - throw new PhpfastcacheLogicException(\sprintf("Driver '%s' has been already added", $driverName)); - } - - if (\in_array($driverName, self::getDriverList(), true)) { - throw new PhpfastcacheLogicException(\sprintf("Driver '%s' is already a part of the Phpfastcache core", $driverName)); - } - - self::$driverCustoms[$driverName] = $className; - } - - /** - * @param string $driverName - * @return bool - */ - public static function customDriverExists(string $driverName): bool - { - return isset(self::$driverCustoms[$driverName]); - } - - /** - * Return the list of available drivers Capitalized - * with optional FQCN as key - * - * @param bool $fqcnAsKey Describe keys with Full Qualified Class Name - * @return string[] - * @throws PhpfastcacheUnsupportedOperationException - */ - public static function getDriverList(bool $fqcnAsKey = false): array - { - static $driverList; - - if (self::getDefaultNamespacePath() === self::getNamespacePath()) { - if ($driverList === null) { - $prefix = self::CORE_DRIVER_NAMESPACE; - $classMap = self::createClassMap(__DIR__ . '/Drivers'); - $driverList = []; - - foreach (\array_keys($classMap) as $class) { - $driverList[] = \str_replace($prefix, '', \substr($class, 0, \strrpos($class, '\\'))); - } - - $driverList = \array_values(\array_unique($driverList)); - } - - $driverList = \array_merge($driverList, \array_keys(self::$driverCustoms)); - - if ($fqcnAsKey) { - $realDriverList = []; - foreach ($driverList as $driverName) { - $realDriverList[self::getDriverClass($driverName)] = $driverName; - } - $driverList = $realDriverList; - } - - \asort($driverList); - - return $driverList; - } - - throw new PhpfastcacheUnsupportedOperationException('Cannot get the driver list if the default namespace path has changed.'); - } - - /** - * @param string $driverName - * @return void - * @throws PhpfastcacheLogicException - * @throws PhpfastcacheInvalidArgumentException - */ - public static function removeCustomDriver(string $driverName): void - { - $driverName = self::normalizeDriverName($driverName); - - if (empty($driverName)) { - throw new PhpfastcacheInvalidArgumentException("Can't remove a custom driver because its name is empty"); - } - - if (!isset(self::$driverCustoms[$driverName])) { - throw new PhpfastcacheLogicException(\sprintf("Driver '%s' does not exist", $driverName)); - } - - unset(self::$driverCustoms[$driverName]); - } - - /** - * @param string $driverName - * @param string $className - * @return void - * @throws PhpfastcacheLogicException - * @throws PhpfastcacheUnsupportedOperationException - * @throws PhpfastcacheInvalidArgumentException - */ - public static function addCoreDriverOverride(string $driverName, string $className): void - { - $driverName = self::normalizeDriverName($driverName); - - if (empty($driverName)) { - throw new PhpfastcacheInvalidArgumentException("Can't add a core driver override because its name is empty"); - } - - if (!\class_exists($className)) { - throw new PhpfastcacheInvalidArgumentException( - \sprintf("Can't override '%s' because the class '%s' does not exist", $driverName, $className) - ); - } - - if (!empty(self::$driverOverrides[$driverName])) { - throw new PhpfastcacheLogicException(\sprintf("Driver '%s' has been already overridden", $driverName)); - } - - if (!\in_array($driverName, self::getDriverList(), true)) { - throw new PhpfastcacheLogicException(\sprintf("Driver '%s' can't be overridden since its not a part of the Phpfastcache core", $driverName)); - } - - if (!\is_subclass_of($className, self::CORE_DRIVER_NAMESPACE . $driverName . '\\Driver', true)) { - throw new PhpfastcacheLogicException( - \sprintf( - "Can't override '%s' because the class '%s' MUST extend '%s'", - $driverName, - $className, - self::CORE_DRIVER_NAMESPACE . $driverName . '\\Driver' - ) - ); - } - - self::$driverOverrides[$driverName] = $className; - } - - /** - * @param string $driverName - * @return void - * @throws PhpfastcacheLogicException - * @throws PhpfastcacheInvalidArgumentException - */ - public static function removeCoreDriverOverride(string $driverName): void - { - $driverName = self::normalizeDriverName($driverName); - - if (empty($driverName)) { - throw new PhpfastcacheInvalidArgumentException("Can't remove a core driver override because its name is empty"); - } - - if (!isset(self::$driverOverrides[$driverName])) { - throw new PhpfastcacheLogicException(\sprintf("Driver '%s' were not overridden", $driverName)); - } - - unset(self::$driverOverrides[$driverName]); - } -} diff --git a/lib/Phpfastcache/Cluster/AggregatablePoolInterface.php b/lib/Phpfastcache/Cluster/AggregatablePoolInterface.php deleted file mode 100644 index f4b10e657..000000000 --- a/lib/Phpfastcache/Cluster/AggregatablePoolInterface.php +++ /dev/null @@ -1,26 +0,0 @@ - - * - */ - -declare(strict_types=1); - -namespace Phpfastcache\Cluster; - -use Phpfastcache\Core\Pool\ExtendedCacheItemPoolInterface; - -interface AggregatablePoolInterface extends ExtendedCacheItemPoolInterface -{ - public function isAggregatedBy(): ?ClusterPoolInterface; - - public function setAggregatedBy(ClusterPoolInterface $clusterPool): static; -} diff --git a/lib/Phpfastcache/Cluster/AggregatorInterface.php b/lib/Phpfastcache/Cluster/AggregatorInterface.php deleted file mode 100644 index 5364ee6d9..000000000 --- a/lib/Phpfastcache/Cluster/AggregatorInterface.php +++ /dev/null @@ -1,100 +0,0 @@ - - * - */ - -declare(strict_types=1); - -namespace Phpfastcache\Cluster; - -use Phpfastcache\Config\ConfigurationOption; - -interface AggregatorInterface -{ - /** - * Full replication mechanism - * - * Read on first working (and synchronize if needed, no failure allowed), - * Write on all (no failure allowed), - * Delete on all (no failure allowed) - * - * Conflict on multiple reads: Keep first found item (but sync the others) - * Cluster size: 2 minimum, unlimited - */ - public const STRATEGY_FULL_REPLICATION = 1; - - /** - * Semi replication mechanism - * - * Read first working (but do not synchronize, with partial failure allowed), - * Write on all (with partial failure allowed) - * Delete on all (with partial failure allowed) - * - * Conflict on multiple reads: Keep first found item - * Cluster size: 2 minimum, unlimited - */ - public const STRATEGY_SEMI_REPLICATION = 2; - - /** - * First pool is master, second is slave - * - * Read from master (but do not synchronize, with master failure only allowed) - * Write on all (with master failure only allowed) - * Delete on all (with master failure only allowed) - * - * Conflict on multiple reads: No, master is exclusive source except if it fails - * Cluster size: 2 exactly: Master & Slave (Exception if more or less) - */ - public const STRATEGY_MASTER_SLAVE = 4; - - /** - * Mostly used for development testing - * - * CRUD operations are made on a random-chosen backend from a given cluster. - * This means you have 1 chance out of (n count of pools) to find an existing cache item - * but also to write/delete a non-existing item. - */ - public const STRATEGY_RANDOM_REPLICATION = 8; - - /** - * AggregatorInterface constructor. - * - * @param string $clusterAggregatorName - * @param AggregatablePoolInterface ...$driverPools - */ - public function __construct(string $clusterAggregatorName, AggregatablePoolInterface ...$driverPools); - - /** - * @param int $strategy - * - * @return ClusterPoolInterface - */ - public function getCluster(int $strategy): ClusterPoolInterface; - - /** - * @param string $driverName - * @param ConfigurationOption|NULL $driverConfig - * - * @return void - */ - public function aggregateDriverByName(string $driverName, ?ConfigurationOption $driverConfig = null): void; - - /** - * @param AggregatablePoolInterface $driverPool - */ - public function aggregateDriver(AggregatablePoolInterface $driverPool): void; - - /** - * @param AggregatablePoolInterface $driverPool - */ - public function disaggregateDriver(AggregatablePoolInterface $driverPool): void; -} diff --git a/lib/Phpfastcache/Cluster/ClusterAggregator.php b/lib/Phpfastcache/Cluster/ClusterAggregator.php deleted file mode 100644 index 69df214f6..000000000 --- a/lib/Phpfastcache/Cluster/ClusterAggregator.php +++ /dev/null @@ -1,170 +0,0 @@ - - * - */ - -declare(strict_types=1); - -namespace Phpfastcache\Cluster; - -use Exception; -use Phpfastcache\CacheManager; -use Phpfastcache\Config\ConfigurationOption; -use Phpfastcache\Event\Event; -use Phpfastcache\EventManager; -use Phpfastcache\Exceptions\PhpfastcacheDriverCheckException; -use Phpfastcache\Exceptions\PhpfastcacheDriverException; -use Phpfastcache\Exceptions\PhpfastcacheDriverNotFoundException; -use Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException; -use Phpfastcache\Exceptions\PhpfastcacheLogicException; -use stdClass; - -class ClusterAggregator implements AggregatorInterface -{ - /** - * @var array - */ - protected array $driverPools; - - protected ClusterPoolInterface $cluster; - - protected string $clusterAggregatorName; - - /** - * ClusterAggregator constructor. - * @param string $clusterAggregatorName - * @param array $driverPools - * @throws PhpfastcacheLogicException - */ - public function __construct(string $clusterAggregatorName = '', AggregatablePoolInterface ...$driverPools) - { - $clusterAggregatorName = trim($clusterAggregatorName); - if (empty($clusterAggregatorName)) { - try { - $clusterAggregatorName = 'cluster_' . \bin2hex(\random_bytes(15)); - } catch (Exception) { - $clusterAggregatorName = 'cluster_' . \str_shuffle(\spl_object_hash(new stdClass())); - } - } - - $this->clusterAggregatorName = $clusterAggregatorName; - - foreach ($driverPools as $driverPool) { - $this->aggregateDriver($driverPool); - } - } - - /** - * @param AggregatablePoolInterface $driverPool - * - * @throws PhpfastcacheLogicException - */ - public function aggregateDriver(AggregatablePoolInterface $driverPool): void - { - if (isset($this->cluster)) { - throw new PhpfastcacheLogicException('The cluster has been already build, cannot aggregate more pools.'); - } - - $splHash = \spl_object_hash($driverPool); - if (!isset($this->driverPools[$splHash])) { - if ($driverPool instanceof ClusterPoolInterface) { - throw new PhpfastcacheLogicException('Recursive cluster aggregation is not allowed !'); - } - - $this->driverPools[$splHash] = $driverPool; - } else { - throw new PhpfastcacheLogicException('This pool has been already aggregated !'); - } - } - - /** - * @param string $driverName - * @param ConfigurationOption|null $driverConfig - * @throws PhpfastcacheDriverCheckException - * @throws PhpfastcacheDriverException - * @throws PhpfastcacheDriverNotFoundException - * @throws PhpfastcacheLogicException - */ - public function aggregateDriverByName(string $driverName, ?ConfigurationOption $driverConfig = null): void - { - if (isset($this->cluster)) { - throw new PhpfastcacheLogicException('The cluster has been already build, cannot aggregate more pools.'); - } - - $driverInstance = CacheManager::getInstance($driverName, $driverConfig); - - if ($driverInstance instanceof AggregatablePoolInterface) { - $this->aggregateDriver($driverInstance); - } - - throw new PhpfastcacheDriverException( - \sprintf( - 'Driver "%s" does not implements "%s"', - $driverInstance::class, - AggregatablePoolInterface::class - ) - ); - } - - /** - * @param AggregatablePoolInterface $driverPool - * - * @throws PhpfastcacheLogicException - */ - public function disaggregateDriver(AggregatablePoolInterface $driverPool): void - { - if (isset($this->cluster)) { - throw new PhpfastcacheLogicException('The cluster has been already build, cannot disaggregate pools.'); - } - - $splHash = \spl_object_hash($driverPool); - if (isset($this->driverPools[$splHash])) { - unset($this->driverPools[$splHash]); - } else { - throw new PhpfastcacheLogicException('This pool was not aggregated !'); - } - } - - /** - * @param int $strategy - * - * @return ClusterPoolInterface - * @throws PhpfastcacheInvalidArgumentException - */ - public function getCluster(int $strategy = AggregatorInterface::STRATEGY_FULL_REPLICATION): ClusterPoolInterface - { - if (isset(ClusterPoolAbstract::STRATEGY[$strategy])) { - if (!isset($this->cluster)) { - $clusterClass = ClusterPoolAbstract::STRATEGY[$strategy]; - $this->cluster = new $clusterClass( - $this->getClusterAggregatorName(), - EventManager::getInstance(), - ...\array_values($this->driverPools) - ); - - $this->cluster->getEventManager()->dispatch(Event::CACHE_CLUSTER_BUILT, $this, $this->cluster); - } - } else { - throw new PhpfastcacheInvalidArgumentException('Unknown cluster strategy'); - } - - return $this->cluster; - } - - /** - * @return string - */ - public function getClusterAggregatorName(): string - { - return $this->clusterAggregatorName; - } -} diff --git a/lib/Phpfastcache/Cluster/ClusterPoolAbstract.php b/lib/Phpfastcache/Cluster/ClusterPoolAbstract.php deleted file mode 100644 index 029d1cba5..000000000 --- a/lib/Phpfastcache/Cluster/ClusterPoolAbstract.php +++ /dev/null @@ -1,250 +0,0 @@ - - * - */ - -declare(strict_types=1); - -namespace Phpfastcache\Cluster; - -use Phpfastcache\Cluster\Drivers\FullReplication\Driver as FullReplicationCluster; -use Phpfastcache\Cluster\Drivers\MasterSlaveReplication\Driver as MasterSlaveReplicationCluster; -use Phpfastcache\Cluster\Drivers\RandomReplication\Driver as RandomReplicationCluster; -use Phpfastcache\Cluster\Drivers\SemiReplication\Driver as SemiReplicationCluster; -use Phpfastcache\Config\ConfigurationOption; -use Phpfastcache\Core\Item\ExtendedCacheItemInterface; -use Phpfastcache\Core\Pool\ExtendedCacheItemPoolInterface; -use Phpfastcache\Core\Pool\TaggableCacheItemPoolTrait; -use Phpfastcache\Entities\DriverIO; -use Phpfastcache\Entities\DriverStatistic; -use Phpfastcache\Event\EventManagerInterface; -use Phpfastcache\EventManager; -use Phpfastcache\Exceptions\PhpfastcacheCoreException; -use Phpfastcache\Exceptions\PhpfastcacheDriverCheckException; -use Phpfastcache\Exceptions\PhpfastcacheDriverConnectException; -use Phpfastcache\Exceptions\PhpfastcacheDriverException; -use Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException; -use Phpfastcache\Exceptions\PhpfastcacheIOException; -use Phpfastcache\Exceptions\PhpfastcacheLogicException; -use Psr\Cache\CacheItemInterface; -use Psr\Cache\InvalidArgumentException; - -abstract class ClusterPoolAbstract implements ClusterPoolInterface -{ - use TaggableCacheItemPoolTrait; - use ClusterPoolTrait { - TaggableCacheItemPoolTrait::__construct as private __parentConstruct; - } - - public const STRATEGY = [ - AggregatorInterface::STRATEGY_FULL_REPLICATION => FullReplicationCluster::class, - AggregatorInterface::STRATEGY_SEMI_REPLICATION => SemiReplicationCluster::class, - AggregatorInterface::STRATEGY_MASTER_SLAVE => MasterSlaveReplicationCluster::class, - AggregatorInterface::STRATEGY_RANDOM_REPLICATION => RandomReplicationCluster::class, - ]; - - /** - * @var AggregatablePoolInterface[] - */ - protected array $clusterPools; - - /** - * ClusterPoolAbstract constructor. - * @param string $clusterName - * @param EventManagerInterface $em - * @param ExtendedCacheItemPoolInterface ...$driverPools - * @throws PhpfastcacheDriverCheckException - * @throws PhpfastcacheDriverConnectException - * @throws PhpfastcacheInvalidArgumentException - * @throws PhpfastcacheCoreException - * @throws PhpfastcacheDriverException - * @throws PhpfastcacheIOException - */ - public function __construct(string $clusterName, EventManagerInterface $em, AggregatablePoolInterface ...$driverPools) - { - if (count($driverPools) < 2) { - throw new PhpfastcacheInvalidArgumentException('A cluster requires at least two pools to be working.'); - } - $this->clusterPools = $driverPools; - $this->__parentConstruct(new ConfigurationOption(), $clusterName, $em); - $this->setEventManager(EventManager::getInstance()); - $this->setClusterPoolsAggregator(); - } - - protected function setClusterPoolsAggregator(): void - { - foreach ($this->clusterPools as $clusterPool) { - $clusterPool->setAggregatedBy($this); - } - } - - /** - * @inheritDoc - */ - public function getIO(): DriverIO - { - $io = new DriverIO(); - foreach ($this->clusterPools as $clusterPool) { - $io->setReadHit($io->getReadHit() + $clusterPool->getIO()->getReadHit()) - ->setReadMiss($io->getReadMiss() + $clusterPool->getIO()->getReadMiss()) - ->setWriteHit($io->getWriteHit() + $clusterPool->getIO()->getWriteHit()); - } - return $io; - } - - /** - * @inheritDoc - */ - public function getClusterPools(): array - { - return $this->clusterPools; - } - - /** - * @inheritDoc - */ - public function getConfigs(): array - { - $configs = []; - - foreach ($this->getClusterPools() as $clusterPool) { - $configs[$clusterPool->getDriverName()] = $clusterPool->getConfig(); - } - - return $configs; - } - - /** - * @inheritDoc - */ - public function getItems(array $keys = []): iterable - { - $items = []; - - foreach ($keys as $key) { - $items[$key] = $this->getItem($key); - } - - return $items; - } - /** - * Shared method used by All Clusters - */ - - /** - * @inheritDoc - */ - public function deleteItems(array $keys): bool - { - $hasDeletedOnce = false; - foreach ($this->clusterPools as $driverPool) { - if ($result = $driverPool->deleteItems($keys)) { - $hasDeletedOnce = $result; - } - } - // Return true only if at least one backend confirmed the "clear" operation - return $hasDeletedOnce; - } - - /** - * @param CacheItemInterface $item - * @return bool - * @throws InvalidArgumentException - * @throws PhpfastcacheLogicException - */ - public function saveDeferred(CacheItemInterface $item): bool - { - /** @var ExtendedCacheItemInterface $item */ - $hasSavedOnce = false; - foreach ($this->clusterPools as $driverPool) { - $poolItem = $this->getStandardizedItem($item, $driverPool); - if ($result = $driverPool->saveDeferred($poolItem)) { - $hasSavedOnce = $result; - } - } - // Return true only if at least one backend confirmed the "commit" operation - return $hasSavedOnce; - } - - /** - * @param ExtendedCacheItemInterface $item - * @param ExtendedCacheItemPoolInterface $driverPool - * @return ExtendedCacheItemInterface - * @throws InvalidArgumentException - * @throws PhpfastcacheLogicException - */ - protected function getStandardizedItem(ExtendedCacheItemInterface $item, ExtendedCacheItemPoolInterface $driverPool): ExtendedCacheItemInterface - { - if (!$item->doesItemBelongToThatDriverBackend($driverPool)) { - /** - * Avoid infinite loop - */ - if ($driverPool === $this) { - /** @var ExtendedCacheItemInterface $itemPool */ - $itemClass = $driverPool::getItemClass(); - $itemPool = new $itemClass($this, $item->getKey(), $this->getEventManager()); - $item->cloneInto($itemPool, $driverPool); - - return $itemPool; - } - - $itemPool = $driverPool->getItem($item->getKey()); - $item->cloneInto($itemPool, $driverPool); - - return $itemPool; - } - - return $item->setEventManager($this->getEventManager()); - } - - /** - * @return DriverStatistic - */ - public function getStats(): DriverStatistic - { - $stats = new DriverStatistic(); - $stats->setInfo( - sprintf( - 'Using %d pool(s): %s', - \count($this->clusterPools), - \implode( - ', ', - \array_map( - static fn (ExtendedCacheItemPoolInterface $pool) => \get_class($pool), - $this->clusterPools - ) - ) - ) - ); - - $stats->setSize( - (int)\array_sum( - \array_map( - static fn (ExtendedCacheItemPoolInterface $pool) => $pool->getStats()->getSize(), - $this->clusterPools - ) - ) - ); - - $stats->setData( - \implode( - ', ', - \array_map( - static fn (ExtendedCacheItemPoolInterface $pool) => $pool->getStats()->getData(), - $this->clusterPools - ) - ) - ); - - return $stats; - } -} diff --git a/lib/Phpfastcache/Cluster/ClusterPoolInterface.php b/lib/Phpfastcache/Cluster/ClusterPoolInterface.php deleted file mode 100644 index 509c82e4f..000000000 --- a/lib/Phpfastcache/Cluster/ClusterPoolInterface.php +++ /dev/null @@ -1,33 +0,0 @@ - - * - */ - -declare(strict_types=1); - -namespace Phpfastcache\Cluster; - -use Phpfastcache\Config\ConfigurationOptionInterface; -use Phpfastcache\Core\Pool\ExtendedCacheItemPoolInterface; - -interface ClusterPoolInterface extends ExtendedCacheItemPoolInterface -{ - /** - * @return AggregatablePoolInterface[] - */ - public function getClusterPools(): array; - - /** - * @return ConfigurationOptionInterface[] - */ - public function getConfigs(): array; -} diff --git a/lib/Phpfastcache/Cluster/ClusterPoolTrait.php b/lib/Phpfastcache/Cluster/ClusterPoolTrait.php deleted file mode 100644 index 0bec0bb03..000000000 --- a/lib/Phpfastcache/Cluster/ClusterPoolTrait.php +++ /dev/null @@ -1,69 +0,0 @@ - - * - */ - -declare(strict_types=1); - -namespace Phpfastcache\Cluster; - -use Phpfastcache\Core\Item\ExtendedCacheItemInterface; -use Psr\Cache\CacheItemInterface; - -trait ClusterPoolTrait -{ - protected function driverCheck(): bool - { - return true; - } - - protected function driverConnect(): bool - { - return true; - } - - /** - * @param ExtendedCacheItemInterface $item - * @return ?array - */ - protected function driverRead(ExtendedCacheItemInterface $item): ?array - { - return null; - } - - /** - * @param ExtendedCacheItemInterface $item - * @return bool - */ - protected function driverWrite(ExtendedCacheItemInterface $item): bool - { - return true; - } - - /** - * @param string $key - * @param string $encodedKey - * @return bool - */ - protected function driverDelete(string $key, string $encodedKey): bool - { - return true; - } - - /** - * @return bool - */ - protected function driverClear(): bool - { - return true; - } -} diff --git a/lib/Phpfastcache/Cluster/Drivers/FullReplication/Driver.php b/lib/Phpfastcache/Cluster/Drivers/FullReplication/Driver.php deleted file mode 100644 index 2f3d27596..000000000 --- a/lib/Phpfastcache/Cluster/Drivers/FullReplication/Driver.php +++ /dev/null @@ -1,188 +0,0 @@ - - * - */ - -declare(strict_types=1); - -namespace Phpfastcache\Cluster\Drivers\FullReplication; - -use Phpfastcache\Cluster\ClusterPoolAbstract; -use Phpfastcache\Config\ConfigurationOption; -use Phpfastcache\Core\Item\ExtendedCacheItemInterface; -use Phpfastcache\Core\Pool\ExtendedCacheItemPoolInterface; -use Psr\Cache\CacheItemInterface; - -class Driver extends ClusterPoolAbstract -{ - /** - * @inheritDoc - */ - public function getItem(string $key): ExtendedCacheItemInterface - { - /** @var ExtendedCacheItemPoolInterface[] $poolsToResync */ - $poolsToResync = []; - /** @var ?ExtendedCacheItemInterface $item */ - $item = null; - - foreach ($this->clusterPools as $driverPool) { - $poolItem = $driverPool->getItem($key); - if ($poolItem->isHit()) { - if (!$item) { - $item = $poolItem; - continue; - } - - $itemData = $item->get(); - $poolItemData = $poolItem->get(); - - if (\is_object($itemData)) { - if ($item->get() != $poolItemData) { - $poolsToResync[] = $driverPool; - } - } else { - if ($item->get() !== $poolItemData) { - $poolsToResync[] = $driverPool; - } - } - } else { - $poolsToResync[] = $driverPool; - } - } - - $this->resynchronizePool($poolsToResync, $key, $item); - - if ($item === null) { - $item = new Item($this, $key, $this->getEventManager()); - $item->expiresAfter((int) abs($this->getConfig()->getDefaultTtl())); - } - - return $this->getStandardizedItem($item, $this); - } - - /** - * @inheritDoc - */ - public function hasItem(string $key): bool - { - foreach ($this->clusterPools as $driverPool) { - $poolItem = $driverPool->getItem($key); - if ($poolItem->isHit()) { - return true; - } - } - - return false; - } - - /** - * @inheritDoc - */ - public function clear(): bool - { - $hasClearedOnce = false; - foreach ($this->clusterPools as $driverPool) { - if ($result = $driverPool->clear()) { - $hasClearedOnce = $result; - } - } - // Return true only if at least one backend confirmed the "clear" operation - return $hasClearedOnce; - } - - /** - * @inheritDoc - */ - public function deleteItem(string $key): bool - { - $hasDeletedOnce = false; - foreach ($this->clusterPools as $driverPool) { - if ($result = $driverPool->deleteItem($key)) { - $hasDeletedOnce = $result; - } - } - // Return true only if at least one backend confirmed the "clear" operation - return $hasDeletedOnce; - } - - /** - * @inheritDoc - */ - public function save(CacheItemInterface $item): bool - { - /** @var ExtendedCacheItemInterface $item */ - $hasSavedOnce = false; - foreach ($this->clusterPools as $driverPool) { - $poolItem = $this->getStandardizedItem($item, $driverPool); - if ($result = $driverPool->save($poolItem)) { - $hasSavedOnce = $result; - } - } - // Return true only if at least one backend confirmed the "commit" operation - return $hasSavedOnce; - } - - /** - * @inheritDoc - */ - public function saveDeferred(CacheItemInterface $item): bool - { - /** @var ExtendedCacheItemInterface $item */ - $hasSavedOnce = false; - foreach ($this->clusterPools as $driverPool) { - $poolItem = $this->getStandardizedItem($item, $driverPool); - if ($result = $driverPool->saveDeferred($poolItem)) { - $hasSavedOnce = $result; - } - } - // Return true only if at least one backend confirmed the "commit" operation - return $hasSavedOnce; - } - - /** - * @inheritDoc - */ - public function commit(): bool - { - $hasCommitOnce = false; - foreach ($this->clusterPools as $driverPool) { - if ($result = $driverPool->commit()) { - $hasCommitOnce = $result; - } - } - // Return true only if at least one backend confirmed the "commit" operation - return $hasCommitOnce; - } - - /** - * @param ExtendedCacheItemPoolInterface[] $poolsToResynchronize - * @param string $key - * @param ?ExtendedCacheItemInterface $item - * @return void - * @throws \Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException - */ - protected function resynchronizePool(array $poolsToResynchronize, string $key, ?ExtendedCacheItemInterface $item): void - { - if ($item && $item->isHit() && \count($poolsToResynchronize) < \count($this->clusterPools)) { - foreach ($poolsToResynchronize as $poolToResynchronize) { - $poolItem = $poolToResynchronize->getItem($key); - $poolItem->setEventManager($this->getEventManager()) - ->set($item->get()) - ->setHit($item->isHit()) - ->setTags($item->getTags()) - ->expiresAt($item->getExpirationDate()) - ->setDriver($poolToResynchronize); - $poolToResynchronize->save($poolItem); - } - } - } -} diff --git a/lib/Phpfastcache/Cluster/Drivers/FullReplication/Item.php b/lib/Phpfastcache/Cluster/Drivers/FullReplication/Item.php deleted file mode 100644 index 1a5c3498e..000000000 --- a/lib/Phpfastcache/Cluster/Drivers/FullReplication/Item.php +++ /dev/null @@ -1,27 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -declare(strict_types=1); - -namespace Phpfastcache\Cluster\Drivers\FullReplication; - -use Phpfastcache\Cluster\ItemAbstract; - -class Item extends ItemAbstract -{ - protected function getDriverClass(): string - { - return Driver::class; - } -} diff --git a/lib/Phpfastcache/Cluster/Drivers/MasterSlaveReplication/Driver.php b/lib/Phpfastcache/Cluster/Drivers/MasterSlaveReplication/Driver.php deleted file mode 100644 index 62be327de..000000000 --- a/lib/Phpfastcache/Cluster/Drivers/MasterSlaveReplication/Driver.php +++ /dev/null @@ -1,164 +0,0 @@ - - * - */ - -declare(strict_types=1); - -namespace Phpfastcache\Cluster\Drivers\MasterSlaveReplication; - -use Phpfastcache\Cluster\AggregatablePoolInterface; -use Phpfastcache\Cluster\ClusterPoolAbstract; -use Phpfastcache\Core\Item\ExtendedCacheItemInterface; -use Phpfastcache\Core\Pool\ExtendedCacheItemPoolInterface; -use Phpfastcache\Event\Event; -use Phpfastcache\Event\EventManagerInterface; -use Phpfastcache\Exceptions\PhpfastcacheCoreException; -use Phpfastcache\Exceptions\PhpfastcacheDriverCheckException; -use Phpfastcache\Exceptions\PhpfastcacheDriverConnectException; -use Phpfastcache\Exceptions\PhpfastcacheDriverException; -use Phpfastcache\Exceptions\PhpfastcacheExceptionInterface; -use Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException; -use Phpfastcache\Exceptions\PhpfastcacheIOException; -use Phpfastcache\Exceptions\PhpfastcacheReplicationException; -use Psr\Cache\CacheItemInterface; - -class Driver extends ClusterPoolAbstract -{ - /** - * MasterSlaveReplicationCluster constructor. - * @param string $clusterName - * @param EventManagerInterface $em - * @param AggregatablePoolInterface ...$driverPools - * @throws PhpfastcacheDriverCheckException - * @throws PhpfastcacheDriverConnectException - * @throws PhpfastcacheInvalidArgumentException - * @throws PhpfastcacheCoreException - * @throws PhpfastcacheDriverException - * @throws PhpfastcacheIOException - */ - public function __construct(string $clusterName, EventManagerInterface $em, AggregatablePoolInterface ...$driverPools) - { - if (\count($driverPools) !== 2) { - throw new PhpfastcacheInvalidArgumentException('A "master/slave" cluster requires exactly two pools to be working.'); - } - - parent::__construct($clusterName, $em, ...$driverPools); - } - - /** - * @inheritDoc - */ - public function getItem(string $key): ExtendedCacheItemInterface - { - return $this->getStandardizedItem( - $this->makeOperation(static function (ExtendedCacheItemPoolInterface $pool) use ($key) { - return $pool->getItem($key); - }) ?? (new Item($this, $key, $this->getEventManager()))->expiresAfter((int) abs($this->getConfig()->getDefaultTtl())), - $this - ); - } - - /** - * @param callable $operation - * @return mixed - * @throws PhpfastcacheReplicationException - */ - protected function makeOperation(callable $operation) - { - try { - return $operation($this->getMasterPool()); - } catch (PhpfastcacheExceptionInterface $e) { - try { - $this->eventManager->dispatch( - Event::CACHE_REPLICATION_SLAVE_FALLBACK, - $this, - \debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2)[1]['function'] - ); - return $operation($this->getSlavePool()); - } catch (PhpfastcacheExceptionInterface $e) { - throw new PhpfastcacheReplicationException('Master and Slave thrown an exception !'); - } - } - } - - /** - * @return AggregatablePoolInterface - */ - protected function getMasterPool(): AggregatablePoolInterface - { - return $this->clusterPools[0]; - } - - /** - * @return AggregatablePoolInterface - */ - protected function getSlavePool(): AggregatablePoolInterface - { - return $this->clusterPools[1]; - } - - /** - * @inheritDoc - */ - public function hasItem(string $key): bool - { - return $this->makeOperation( - static fn (ExtendedCacheItemPoolInterface $pool) => $pool->hasItem($key) - ); - } - - /** - * @inheritDoc - */ - public function clear(): bool - { - return $this->makeOperation( - static fn (ExtendedCacheItemPoolInterface $pool) => $pool->clear() - ); - } - - /** - * @inheritDoc - */ - public function deleteItem(string $key): bool - { - return $this->makeOperation( - static fn (ExtendedCacheItemPoolInterface $pool) => $pool->deleteItem($key) - ); - } - - /** - * @inheritDoc - */ - public function save(CacheItemInterface $item): bool - { - return $this->makeOperation( - function (ExtendedCacheItemPoolInterface $pool) use ($item) { - /** @var ExtendedCacheItemInterface $item */ - $item->setHit(true); - return $pool->save($this->getStandardizedItem($item, $pool)); - } - ); - } - - - /** - * @inheritDoc - */ - public function commit(): bool - { - return $this->makeOperation( - static fn (ExtendedCacheItemPoolInterface $pool) => $pool->commit() - ); - } -} diff --git a/lib/Phpfastcache/Cluster/Drivers/MasterSlaveReplication/Item.php b/lib/Phpfastcache/Cluster/Drivers/MasterSlaveReplication/Item.php deleted file mode 100644 index 1c4174a61..000000000 --- a/lib/Phpfastcache/Cluster/Drivers/MasterSlaveReplication/Item.php +++ /dev/null @@ -1,27 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -declare(strict_types=1); - -namespace Phpfastcache\Cluster\Drivers\MasterSlaveReplication; - -use Phpfastcache\Cluster\ItemAbstract; - -class Item extends ItemAbstract -{ - protected function getDriverClass(): string - { - return Driver::class; - } -} diff --git a/lib/Phpfastcache/Cluster/Drivers/RandomReplication/Driver.php b/lib/Phpfastcache/Cluster/Drivers/RandomReplication/Driver.php deleted file mode 100644 index 5f688b165..000000000 --- a/lib/Phpfastcache/Cluster/Drivers/RandomReplication/Driver.php +++ /dev/null @@ -1,65 +0,0 @@ - - * - */ - -declare(strict_types=1); - -namespace Phpfastcache\Cluster\Drivers\RandomReplication; - -use Phpfastcache\Cluster\AggregatablePoolInterface; -use Phpfastcache\Cluster\Drivers\MasterSlaveReplication\Driver as MasterSlaveReplicationDriver; -use Phpfastcache\Event\Event; -use Phpfastcache\Event\EventManagerInterface; -use ReflectionException; -use ReflectionMethod; - -class Driver extends MasterSlaveReplicationDriver -{ - /** - * RandomReplicationCluster constructor. - * @param string $clusterName - * @param EventManagerInterface $em - * @param AggregatablePoolInterface ...$driverPools - * @throws ReflectionException - */ - public function __construct( - string $clusterName, - EventManagerInterface $em, - AggregatablePoolInterface ...$driverPools - ) { - /** Straight call to ClusterPoolAbstract constructor */ - (new ReflectionMethod( - \get_parent_class(\get_parent_class($this)), - __FUNCTION__ - ))->invoke($this, $clusterName, $em, ...$driverPools); - - $randomPool = $driverPools[\random_int(0, \count($driverPools) - 1)]; - - $this->eventManager->dispatch( - Event::CACHE_REPLICATION_RANDOM_POOL_CHOSEN, - $this, - $randomPool - ); - - $this->clusterPools = [$randomPool]; - } - - /** - * @param callable $operation - * @return mixed - */ - protected function makeOperation(callable $operation) - { - return $operation($this->getMasterPool()); - } -} diff --git a/lib/Phpfastcache/Cluster/Drivers/RandomReplication/Item.php b/lib/Phpfastcache/Cluster/Drivers/RandomReplication/Item.php deleted file mode 100644 index bcc17a829..000000000 --- a/lib/Phpfastcache/Cluster/Drivers/RandomReplication/Item.php +++ /dev/null @@ -1,27 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -declare(strict_types=1); - -namespace Phpfastcache\Cluster\Drivers\RandomReplication; - -use Phpfastcache\Cluster\ItemAbstract; - -class Item extends ItemAbstract -{ - protected function getDriverClass(): string - { - return Driver::class; - } -} diff --git a/lib/Phpfastcache/Cluster/Drivers/SemiReplication/Driver.php b/lib/Phpfastcache/Cluster/Drivers/SemiReplication/Driver.php deleted file mode 100644 index cd6e0b050..000000000 --- a/lib/Phpfastcache/Cluster/Drivers/SemiReplication/Driver.php +++ /dev/null @@ -1,197 +0,0 @@ - - * - */ - -declare(strict_types=1); - -namespace Phpfastcache\Cluster\Drivers\SemiReplication; - -use Phpfastcache\Cluster\ClusterPoolAbstract; -use Phpfastcache\Core\Item\ExtendedCacheItemInterface; -use Phpfastcache\Exceptions\PhpfastcacheExceptionInterface; -use Phpfastcache\Exceptions\PhpfastcacheReplicationException; -use Psr\Cache\CacheItemInterface; -use Psr\Cache\InvalidArgumentException; - -class Driver extends ClusterPoolAbstract -{ - /** - * @inheritDoc - * @throws InvalidArgumentException - * @throws PhpfastcacheReplicationException - */ - public function getItem(string $key): ExtendedCacheItemInterface - { - /** @var ?ExtendedCacheItemInterface $item */ - $item = null; - $eCount = 0; - - foreach ($this->clusterPools as $driverPool) { - try { - $poolItem = $driverPool->getItem($key); - if (!$item && $poolItem->isHit()) { - $item = $poolItem; - break; - } - } catch (PhpfastcacheExceptionInterface) { - $eCount++; - } - } - - if (\count($this->clusterPools) <= $eCount) { - throw new PhpfastcacheReplicationException('Every pools thrown an exception'); - } - - if ($item === null) { - $item = new Item($this, $key, $this->getEventManager()); - $item->expiresAfter((int) abs($this->getConfig()->getDefaultTtl())); - } - - return $this->getStandardizedItem($item, $this); - } - - /** - * @inheritDoc - * @throws PhpfastcacheReplicationException - */ - public function hasItem(string $key): bool - { - $eCount = 0; - foreach ($this->clusterPools as $driverPool) { - try { - $poolItem = $driverPool->getItem($key); - if ($poolItem->isHit()) { - return true; - } - } catch (PhpfastcacheExceptionInterface) { - $eCount++; - } - } - - if (\count($this->clusterPools) <= $eCount) { - throw new PhpfastcacheReplicationException('Every pools thrown an exception'); - } - - return false; - } - - /** - * @inheritDoc - * @throws PhpfastcacheReplicationException - */ - public function clear(): bool - { - $hasClearedOnce = false; - $eCount = 0; - - foreach ($this->clusterPools as $driverPool) { - try { - if ($result = $driverPool->clear()) { - $hasClearedOnce = $result; - } - } catch (PhpfastcacheExceptionInterface) { - $eCount++; - } - } - - if (\count($this->clusterPools) <= $eCount) { - throw new PhpfastcacheReplicationException('Every pools thrown an exception'); - } - - // Return true only if at least one backend confirmed the "clear" operation - return $hasClearedOnce; - } - - /** - * @inheritDoc - * @throws PhpfastcacheReplicationException - * @throws InvalidArgumentException - */ - public function deleteItem(string $key): bool - { - $hasDeletedOnce = false; - $eCount = 0; - - foreach ($this->clusterPools as $driverPool) { - try { - if ($result = $driverPool->deleteItem($key)) { - $hasDeletedOnce = $result; - } - } catch (PhpfastcacheExceptionInterface) { - $eCount++; - } - } - - if (\count($this->clusterPools) <= $eCount) { - throw new PhpfastcacheReplicationException('Every pools thrown an exception'); - } - // Return true only if at least one backend confirmed the "clear" operation - return $hasDeletedOnce; - } - - /** - * @param CacheItemInterface $item - * @return bool - * @throws InvalidArgumentException - * @throws PhpfastcacheReplicationException - */ - public function save(CacheItemInterface $item): bool - { - /** @var ExtendedCacheItemInterface $item */ - $hasSavedOnce = false; - $eCount = 0; - - foreach ($this->clusterPools as $driverPool) { - try { - $poolItem = $this->getStandardizedItem($item, $driverPool); - if ($result = $driverPool->save($poolItem)) { - $hasSavedOnce = $result; - } - } catch (PhpfastcacheExceptionInterface) { - $eCount++; - } - } - - if (\count($this->clusterPools) <= $eCount) { - throw new PhpfastcacheReplicationException('Every pools thrown an exception'); - } - // Return true only if at least one backend confirmed the "commit" operation - return $hasSavedOnce; - } - - /** - * @inheritDoc - * @throws PhpfastcacheReplicationException - */ - public function commit(): bool - { - $hasCommitOnce = false; - $eCount = 0; - - foreach ($this->clusterPools as $driverPool) { - try { - if ($result = $driverPool->commit()) { - $hasCommitOnce = $result; - } - } catch (PhpfastcacheExceptionInterface) { - $eCount++; - } - } - - if (\count($this->clusterPools) <= $eCount) { - throw new PhpfastcacheReplicationException('Every pools thrown an exception'); - } - // Return true only if at least one backend confirmed the "commit" operation - return $hasCommitOnce; - } -} diff --git a/lib/Phpfastcache/Cluster/Drivers/SemiReplication/Item.php b/lib/Phpfastcache/Cluster/Drivers/SemiReplication/Item.php deleted file mode 100644 index 3720d530d..000000000 --- a/lib/Phpfastcache/Cluster/Drivers/SemiReplication/Item.php +++ /dev/null @@ -1,27 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -declare(strict_types=1); - -namespace Phpfastcache\Cluster\Drivers\SemiReplication; - -use Phpfastcache\Cluster\ItemAbstract; - -class Item extends ItemAbstract -{ - protected function getDriverClass(): string - { - return Driver::class; - } -} diff --git a/lib/Phpfastcache/Cluster/ItemAbstract.php b/lib/Phpfastcache/Cluster/ItemAbstract.php deleted file mode 100644 index ba2706ef9..000000000 --- a/lib/Phpfastcache/Cluster/ItemAbstract.php +++ /dev/null @@ -1,25 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -declare(strict_types=1); - -namespace Phpfastcache\Cluster; - -use Phpfastcache\Core\Item\ExtendedCacheItemInterface; -use Phpfastcache\Core\Item\TaggableCacheItemTrait; - -abstract class ItemAbstract implements ExtendedCacheItemInterface -{ - use TaggableCacheItemTrait; -} diff --git a/lib/Phpfastcache/Config/AbstractConfigurationOption.php b/lib/Phpfastcache/Config/AbstractConfigurationOption.php deleted file mode 100644 index df8ae3ae6..000000000 --- a/lib/Phpfastcache/Config/AbstractConfigurationOption.php +++ /dev/null @@ -1,83 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -declare(strict_types=1); - -namespace Phpfastcache\Config; - -use Phpfastcache\Core\Pool\ExtendedCacheItemPoolInterface; -use Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException; -use Phpfastcache\Exceptions\PhpfastcacheLogicException; - -abstract class AbstractConfigurationOption implements LockableConfigurationInterface -{ - private bool $lockedObject = false; - private ExtendedCacheItemPoolInterface $locker; - - protected function getClassName(): string - { - return $this::class; - } - - public function lock(ExtendedCacheItemPoolInterface $poolInstance): static - { - $this->lockedObject = true; - $this->locker = $poolInstance; - return $this; - } - - public function lockedBy(): ExtendedCacheItemPoolInterface - { - return $this->locker; - } - - public function isLocked(): bool - { - return $this->lockedObject; - } - - /** - * @throws PhpfastcacheLogicException - * @throws PhpfastcacheInvalidArgumentException - */ - protected function setProperty(string $propertyName, mixed $propertyValue): static - { - $this->enforceLockedProperty($propertyName); - if (property_exists($this, $propertyName)) { - $this->$propertyName = $propertyValue; - return $this; - } - throw new PhpfastcacheInvalidArgumentException("Unknown property $propertyName in {$this->getClassName()} context."); - } - - /** - * @throws PhpfastcacheLogicException - */ - protected function enforceLockedProperty(string $propertyName): void - { - if ($this->lockedObject === true) { - $dbt = \debug_backtrace(\DEBUG_BACKTRACE_IGNORE_ARGS, 3); - $cause = $dbt[\array_key_last($dbt)] ?? null; - if ($cause) { - $moreInfo = \sprintf('Caused line %d in %s', $cause['line'], $cause['file']); - } - - throw new PhpfastcacheLogicException(\sprintf( - 'You can no longer change the configuration "%s" as the cache pool instance is now running. %s', - $propertyName, - $moreInfo ?? '' - )); - } - } -} diff --git a/lib/Phpfastcache/Config/Config.php b/lib/Phpfastcache/Config/Config.php deleted file mode 100644 index ee18de6b8..000000000 --- a/lib/Phpfastcache/Config/Config.php +++ /dev/null @@ -1,36 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -declare(strict_types=1); - -namespace Phpfastcache\Config; - -/** - * @deprecated This class is deprecated and will be removed in v10, use ConfigurationOption instead - */ -class Config extends ConfigurationOption -{ - public function __construct(array $parameters = []) - { - \trigger_error( - \sprintf( - '%s class is deprecated and will be removed in v10, use %s instead.', - self::class, - ConfigurationOption::class - ), - \E_USER_DEPRECATED - ); - parent::__construct($parameters); - } -} diff --git a/lib/Phpfastcache/Config/ConfigurationOption.php b/lib/Phpfastcache/Config/ConfigurationOption.php deleted file mode 100644 index d3981f83a..000000000 --- a/lib/Phpfastcache/Config/ConfigurationOption.php +++ /dev/null @@ -1,369 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -declare(strict_types=1); - -namespace Phpfastcache\Config; - -use Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException; -use Phpfastcache\Exceptions\PhpfastcacheInvalidConfigurationException; -use Phpfastcache\Exceptions\PhpfastcacheInvalidTypeException; -use Phpfastcache\Exceptions\PhpfastcacheLogicException; - -class ConfigurationOption extends AbstractConfigurationOption implements ConfigurationOptionInterface -{ - protected bool $itemDetailedDate = false; - - protected bool $autoTmpFallback = false; - - protected int $defaultTtl = 900; - - /** - * @var string|callable - */ - protected mixed $defaultKeyHashFunction = 'md5'; - - /** - * @var string|callable - */ - protected mixed $defaultFileNameHashFunction = 'md5'; - - protected string $path = ''; - - protected bool $preventCacheSlams = false; - - protected int $cacheSlamsTimeout = 15; - - protected bool $useStaticItemCaching = true; - - protected ?object $superGlobalAccessor = null; - - /** - * @inheritDoc - * @throws PhpfastcacheInvalidConfigurationException - * @throws PhpfastcacheInvalidTypeException - */ - public function __construct(array $parameters = []) - { - foreach ($parameters as $configKey => $configVal) { - try { - if (\property_exists($this, $configKey)) { - $this->{'set' . \ucfirst($configKey)}($configVal); - } else { - throw new PhpfastcacheInvalidConfigurationException( - sprintf( - 'Unknown configuration option name "%s" for the config class "%s". Allowed configurations options are "%s"', - $configKey, - $this::class, - \implode('", "', \array_keys($this->toArray())), - ) - ); - } - } catch (\TypeError $e) { - throw new PhpfastcacheInvalidTypeException( - \sprintf( - 'TypeError exception thrown while trying to set your configuration: %s', - $e->getMessage() - ) - ); - } - } - } - - public function toArray(): array - { - return \get_object_vars($this); - } - - /** - * @throws \ReflectionException - */ - public function isValueSerializable(mixed $val): bool - { - return !\is_callable($val) && !(is_object($val) && (new \ReflectionClass($val))->isAnonymous()); - } - - /** - * @param string $optionName - * @return bool - */ - public function isValidOption(string $optionName): bool - { - return \property_exists($this, $optionName); - } - - /** - * @return bool - */ - public function isItemDetailedDate(): bool - { - return $this->itemDetailedDate; - } - - /** - * @param bool $itemDetailedDate - * @return ConfigurationOption - * @throws PhpfastcacheLogicException - */ - public function setItemDetailedDate(bool $itemDetailedDate): static - { - $this->enforceLockedProperty(__FUNCTION__); - $this->itemDetailedDate = $itemDetailedDate; - return $this; - } - - /** - * @return bool - */ - public function isAutoTmpFallback(): bool - { - return $this->autoTmpFallback; - } - - /** - * @param bool $autoTmpFallback - * @return ConfigurationOption - * @throws PhpfastcacheLogicException - */ - public function setAutoTmpFallback(bool $autoTmpFallback): static - { - $this->enforceLockedProperty(__FUNCTION__); - $this->autoTmpFallback = $autoTmpFallback; - return $this; - } - - /** - * @return int - */ - public function getDefaultTtl(): int - { - return $this->defaultTtl; - } - - /** - * @param int $defaultTtl - * @return ConfigurationOption - * @throws PhpfastcacheLogicException - */ - public function setDefaultTtl(int $defaultTtl): static - { - $this->enforceLockedProperty(__FUNCTION__); - $this->defaultTtl = $defaultTtl; - return $this; - } - - /** - * @return callable|string - */ - public function getDefaultKeyHashFunction(): callable|string - { - return $this->defaultKeyHashFunction; - } - - /** - * @param callable|string $defaultKeyHashFunction - * @return ConfigurationOption - * @throws PhpfastcacheInvalidConfigurationException - * @throws PhpfastcacheLogicException - */ - public function setDefaultKeyHashFunction(callable|string $defaultKeyHashFunction): static - { - $this->enforceLockedProperty(__FUNCTION__); - if ($defaultKeyHashFunction && !\is_callable($defaultKeyHashFunction) && (\is_string($defaultKeyHashFunction) && !\function_exists($defaultKeyHashFunction))) { - throw new PhpfastcacheInvalidConfigurationException('defaultKeyHashFunction must be a valid function name string'); - } - $this->defaultKeyHashFunction = $defaultKeyHashFunction; - return $this; - } - - /** - * @return callable|string - */ - public function getDefaultFileNameHashFunction(): callable|string - { - return $this->defaultFileNameHashFunction; - } - - /** - * @param callable|string $defaultFileNameHashFunction - * @return ConfigurationOption - * @throws PhpfastcacheInvalidConfigurationException - * @throws PhpfastcacheLogicException - */ - public function setDefaultFileNameHashFunction(callable|string $defaultFileNameHashFunction): static - { - $this->enforceLockedProperty(__FUNCTION__); - if (!\is_callable($defaultFileNameHashFunction) && (\is_string($defaultFileNameHashFunction) && !\function_exists($defaultFileNameHashFunction))) { - throw new PhpfastcacheInvalidConfigurationException('defaultFileNameHashFunction must be a valid function name string'); - } - $this->defaultFileNameHashFunction = $defaultFileNameHashFunction; - return $this; - } - - /** - * @return string - */ - public function getPath(): string - { - return $this->path; - } - - /** - * @param string $path - * @return ConfigurationOption - * @throws PhpfastcacheLogicException - */ - public function setPath(string $path): static - { - $this->enforceLockedProperty(__FUNCTION__); - $this->path = $path; - return $this; - } - - /** - * @deprecated This method is deprecated and will be soon moved to IOConfigurationOption class, which means they will only be available for `IO` drivers. - * @return bool - */ - public function isPreventCacheSlams(): bool - { - return $this->preventCacheSlams; - } - - /** - * @deprecated This method is deprecated and will be soon moved to IOConfigurationOption class, which means they will only be available for `IO` drivers. - * @param bool $preventCacheSlams - * @return ConfigurationOption - * @throws PhpfastcacheLogicException - */ - public function setPreventCacheSlams(bool $preventCacheSlams): static - { - if ($preventCacheSlams !== $this->preventCacheSlams) { - trigger_error( - 'This method is deprecated and will be soon moved to IOConfigurationOption class, which means they will only be available for `IO` drivers.', - E_USER_DEPRECATED - ); - } - - $this->enforceLockedProperty(__FUNCTION__); - $this->preventCacheSlams = $preventCacheSlams; - return $this; - } - - /** - * @deprecated This method is deprecated and will be soon moved to IOConfigurationOption class, which means they will only be available for `IO` drivers. - * @return int - */ - public function getCacheSlamsTimeout(): int - { - return $this->cacheSlamsTimeout; - } - - /** - * @deprecated This method is deprecated and will be soon moved to IOConfigurationOption class, which means they will only be available for `IO` drivers. - * @param int $cacheSlamsTimeout - * @return ConfigurationOption - * @throws PhpfastcacheLogicException - */ - public function setCacheSlamsTimeout(int $cacheSlamsTimeout): static - { - if ($cacheSlamsTimeout !== $this->cacheSlamsTimeout) { - trigger_error( - 'This method is deprecated and will be soon moved to IOConfigurationOption class, which means they will only be available for `IO` drivers.', - E_USER_DEPRECATED - ); - } - $this->enforceLockedProperty(__FUNCTION__); - $this->cacheSlamsTimeout = $cacheSlamsTimeout; - return $this; - } - - /** - * @return bool - */ - public function isUseStaticItemCaching(): bool - { - return $this->useStaticItemCaching; - } - - /** - * @param bool $useStaticItemCaching - * @return ConfigurationOption - * @throws PhpfastcacheLogicException - */ - public function setUseStaticItemCaching(bool $useStaticItemCaching): static - { - $this->enforceLockedProperty(__FUNCTION__); - $this->useStaticItemCaching = $useStaticItemCaching; - return $this; - } - - /** - * @return object - */ - public function getSuperGlobalAccessor(): object - { - if (!isset($this->superGlobalAccessor)) { - $this->superGlobalAccessor = $this->getDefaultSuperGlobalAccessor(); - } - - return $this->superGlobalAccessor; - } - - /** - * @param ?object $superGlobalAccessor - * @return static - * @throws PhpfastcacheInvalidArgumentException - * @throws PhpfastcacheLogicException - */ - public function setSuperGlobalAccessor(?object $superGlobalAccessor): static - { - $this->enforceLockedProperty(__FUNCTION__); - /** - * Symfony's implementation for users that want a good control of their code: - * - * $config['superGlobalAccessor'] = \Closure::fromCallable(static function(string $superGlobalName, string $keyName) use ($request) { - * return match ($superGlobalName) { - * 'SERVER' => $request->server->get($keyName), - * 'REQUEST' => $request->request->get($keyName), - * }; - * }); - */ - - if ($superGlobalAccessor === null) { - $this->superGlobalAccessor = $this->getDefaultSuperGlobalAccessor(); - } elseif (!\is_callable($superGlobalAccessor)) { - throw new PhpfastcacheInvalidArgumentException('The "superGlobalAccessor" callback must be callable using "__invoke" or \Closure implementation'); - } else { - $this->superGlobalAccessor = $superGlobalAccessor; - } - - return $this; - } - - /** - * @return \Closure - * @SuppressWarnings(PHPMD.Superglobals) - */ - protected function getDefaultSuperGlobalAccessor(): \Closure - { - return \Closure::fromCallable(static function (string $superGlobalName, ?string $keyName = null): string|int|float|array|bool|null { - return match ($superGlobalName) { - 'SERVER' => $keyName !== null ? $_SERVER[$keyName] ?? null : $_SERVER, - 'REQUEST' => $keyName !== null ? $_REQUEST[$keyName] ?? null : $_REQUEST, - 'COOKIE' => $keyName !== null ? $_COOKIE[$keyName] ?? null : $_COOKIE, - default => null, - }; - }); - } -} diff --git a/lib/Phpfastcache/Config/ConfigurationOptionInterface.php b/lib/Phpfastcache/Config/ConfigurationOptionInterface.php deleted file mode 100644 index c38db1054..000000000 --- a/lib/Phpfastcache/Config/ConfigurationOptionInterface.php +++ /dev/null @@ -1,134 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -declare(strict_types=1); - -namespace Phpfastcache\Config; - -use Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException; -use Phpfastcache\Exceptions\PhpfastcacheInvalidConfigurationException; -use Phpfastcache\Exceptions\PhpfastcacheLogicException; - -interface ConfigurationOptionInterface extends LockableConfigurationInterface -{ - /** - * @param array $parameters - * ConfigurationOptionInterface constructor. - */ - public function __construct(array $parameters = []); - - /** - * @return array - */ - public function toArray(): array; - - /** - * @param mixed $val - * @return bool - */ - public function isValueSerializable(mixed $val): bool; - - /** - * @param string $optionName - * @return bool - */ - public function isValidOption(string $optionName): bool; - - /** - * @return bool - */ - public function isItemDetailedDate(): bool; - - /** - * @param bool $itemDetailedDate - * @return ConfigurationOption - */ - public function setItemDetailedDate(bool $itemDetailedDate): static; - - /** - * @return bool - */ - public function isAutoTmpFallback(): bool; - /** - * @param bool $autoTmpFallback - * @return ConfigurationOption - */ - public function setAutoTmpFallback(bool $autoTmpFallback): static; - /** - * @return int - */ - public function getDefaultTtl(): int; - /** - * @param int $defaultTtl - * @return ConfigurationOption - */ - public function setDefaultTtl(int $defaultTtl): static; - /** - * @return callable|string - */ - public function getDefaultKeyHashFunction(): callable|string; - /** - * @param callable|string $defaultKeyHashFunction - * @return ConfigurationOption - * @throws PhpfastcacheInvalidConfigurationException - */ - public function setDefaultKeyHashFunction(callable|string $defaultKeyHashFunction): static; - /** - * @return callable|string - */ - public function getDefaultFileNameHashFunction(): callable|string; - /** - * @param callable|string $defaultFileNameHashFunction - * @return ConfigurationOption - * @throws PhpfastcacheInvalidConfigurationException - */ - public function setDefaultFileNameHashFunction(callable|string $defaultFileNameHashFunction): static; - - /** - * @return string - */ - public function getPath(): string; - - /** - * @param string $path - * @return ConfigurationOption - */ - public function setPath(string $path): static; - - /** - * @return bool - */ - public function isUseStaticItemCaching(): bool; - - /** - * @param bool $useStaticItemCaching - * @return ConfigurationOption - */ - public function setUseStaticItemCaching(bool $useStaticItemCaching): static; - - /** - * @return object - * @throws PhpfastcacheInvalidArgumentException - * @throws PhpfastcacheLogicException - */ - public function getSuperGlobalAccessor(): object; - - /** - * @param ?object $superGlobalAccessor - * @return static - * @throws PhpfastcacheInvalidArgumentException - * @throws PhpfastcacheLogicException - */ - public function setSuperGlobalAccessor(?object $superGlobalAccessor): static; -} diff --git a/lib/Phpfastcache/Config/IOConfigurationOption.php b/lib/Phpfastcache/Config/IOConfigurationOption.php deleted file mode 100644 index f72e3939a..000000000 --- a/lib/Phpfastcache/Config/IOConfigurationOption.php +++ /dev/null @@ -1,156 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -declare(strict_types=1); - -namespace Phpfastcache\Config; - -use Phpfastcache\Exceptions\PhpfastcacheInvalidConfigurationException; -use Phpfastcache\Exceptions\PhpfastcacheLogicException; - -/** - * @todo: As of V10, imports cache slams properties. - */ -class IOConfigurationOption extends ConfigurationOption -{ - protected bool $secureFileManipulation = false; - - protected string $securityKey = ''; - - protected string $cacheFileExtension = 'txt'; - - protected int $defaultChmod = 0777; - - /** - * @return string - */ - public function getSecurityKey(): string - { - return $this->securityKey; - } - - /** - * @param string $securityKey - * @return static - * @throws PhpfastcacheLogicException - */ - public function setSecurityKey(string $securityKey): static - { - return $this->setProperty('securityKey', $securityKey); - } - - /** - * @return bool - */ - public function isSecureFileManipulation(): bool - { - return $this->secureFileManipulation; - } - - /** - * @param bool $secureFileManipulation - * @return static - * @throws PhpfastcacheLogicException - */ - public function setSecureFileManipulation(bool $secureFileManipulation): static - { - return $this->setProperty('secureFileManipulation', $secureFileManipulation); - } - - - /** - * @return string - */ - public function getCacheFileExtension(): string - { - return $this->cacheFileExtension; - } - - /** - * @param string $cacheFileExtension - * @return static - * @throws PhpfastcacheInvalidConfigurationException - * @throws PhpfastcacheLogicException - */ - public function setCacheFileExtension(string $cacheFileExtension): static - { - $safeFileExtensions = \explode('|', IOConfigurationOptionInterface::SAFE_FILE_EXTENSIONS); - - if (\str_contains($cacheFileExtension, '.')) { - throw new PhpfastcacheInvalidConfigurationException('cacheFileExtension cannot contain a dot "."'); - } - if (!\in_array($cacheFileExtension, $safeFileExtensions, true)) { - throw new PhpfastcacheInvalidConfigurationException( - "Extension \"$cacheFileExtension\" is unsafe, currently allowed extension names: " . \implode(', ', $safeFileExtensions) - ); - } - - return $this->setProperty('cacheFileExtension', $cacheFileExtension); - } - - /** - * @return int - */ - public function getDefaultChmod(): int - { - return $this->defaultChmod; - } - - /** - * @param int $defaultChmod - * @return static - * @throws PhpfastcacheLogicException - */ - public function setDefaultChmod(int $defaultChmod): static - { - return $this->setProperty('defaultChmod', $defaultChmod); - } - - - /** - * @return bool - */ - public function isPreventCacheSlams(): bool - { - return $this->preventCacheSlams; - } - - /** - * @param bool $preventCacheSlams - * @return static - * @throws PhpfastcacheLogicException - */ - public function setPreventCacheSlams(bool $preventCacheSlams): static - { - return $this->setProperty('preventCacheSlams', $preventCacheSlams); - } - - /** - * @return int - */ - public function getCacheSlamsTimeout(): int - { - return $this->cacheSlamsTimeout; - } - - /** - * @param int $cacheSlamsTimeout - * @return static - * @throws PhpfastcacheLogicException - */ - public function setCacheSlamsTimeout(int $cacheSlamsTimeout): static - { - return $this->setProperty('cacheSlamsTimeout', $cacheSlamsTimeout); - } -} diff --git a/lib/Phpfastcache/Config/IOConfigurationOptionInterface.php b/lib/Phpfastcache/Config/IOConfigurationOptionInterface.php deleted file mode 100644 index b07c667f5..000000000 --- a/lib/Phpfastcache/Config/IOConfigurationOptionInterface.php +++ /dev/null @@ -1,50 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -declare(strict_types=1); - -namespace Phpfastcache\Config; - -interface IOConfigurationOptionInterface extends ConfigurationOptionInterface -{ - /** - * Feel free to propose your own one - * by opening a pull request :) - */ - public const SAFE_FILE_EXTENSIONS = 'txt|cache|db|pfc'; - - public function getSecurityKey(): string; - - public function setSecurityKey(string $securityKey): static; - - public function isSecureFileManipulation(): bool; - - public function setSecureFileManipulation(bool $secureFileManipulation): static; - - public function getCacheFileExtension(): string; - - public function setCacheFileExtension(string $cacheFileExtension): static; - - public function getDefaultChmod(): int; - - public function setDefaultChmod(int $defaultChmod): static; - - public function isPreventCacheSlams(): bool; - - public function setPreventCacheSlams(bool $preventCacheSlams): static; - - public function getCacheSlamsTimeout(): int; - - public function setCacheSlamsTimeout(int $cacheSlamsTimeout): static; -} diff --git a/lib/Phpfastcache/Config/LockableConfigurationInterface.php b/lib/Phpfastcache/Config/LockableConfigurationInterface.php deleted file mode 100644 index 428451bc0..000000000 --- a/lib/Phpfastcache/Config/LockableConfigurationInterface.php +++ /dev/null @@ -1,31 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -declare(strict_types=1); - -namespace Phpfastcache\Config; - -use Phpfastcache\Core\Pool\ExtendedCacheItemPoolInterface; - -interface LockableConfigurationInterface -{ - /** - * @internal - */ - public function lock(ExtendedCacheItemPoolInterface $poolInstance): static; - - public function lockedBy(): ExtendedCacheItemPoolInterface; - - public function isLocked(): bool; -} diff --git a/lib/Phpfastcache/Core/Item/CacheItemTrait.php b/lib/Phpfastcache/Core/Item/CacheItemTrait.php deleted file mode 100644 index 2d2d24b6d..000000000 --- a/lib/Phpfastcache/Core/Item/CacheItemTrait.php +++ /dev/null @@ -1,149 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -declare(strict_types=1); - -namespace Phpfastcache\Core\Item; - -use DateInterval; -use DateTime; -use DateTimeInterface; -use Phpfastcache\Event\Event; -use Phpfastcache\Event\EventManagerDispatcherTrait; -use Phpfastcache\Event\EventReferenceParameter; -use Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException; -use Phpfastcache\Util\ClassNamespaceResolverTrait; - -trait CacheItemTrait -{ - use EventManagerDispatcherTrait; - use ClassNamespaceResolverTrait; - - protected string $key; - - protected mixed $data; - - protected DateTimeInterface $expirationDate; - - protected DateTimeInterface $creationDate; - - protected DateTimeInterface $modificationDate; - - protected bool $isHit = false; - - public function getKey(): string - { - return $this->key; - } - - public function get(): mixed - { - if (!$this->isHit()) { - return null; - } - - return $this->data; - } - - /** - * @throws PhpfastcacheInvalidArgumentException - */ - public function set(mixed $value): static - { - if ($value instanceof \Closure) { - throw new PhpfastcacheInvalidArgumentException('The value set cannot be an instance of \\Closure.'); - } - - if (\is_resource($value)) { - throw new PhpfastcacheInvalidArgumentException('The value set cannot be a resource'); - } - - $this->eventManager->dispatch(Event::CACHE_ITEM_SET, $this, new EventReferenceParameter($value, true)); - - $this->data = $value; - - return $this; - } - - /** - * @return bool - */ - public function isHit(): bool - { - return $this->isHit; - } - - /** - * @param bool $isHit - * @return ExtendedCacheItemInterface - */ - public function setHit(bool $isHit): ExtendedCacheItemInterface - { - $this->isHit = $isHit; - - return $this; - } - - /** - * @throws PhpfastcacheInvalidArgumentException - */ - public function expiresAt(?\DateTimeInterface $expiration): static - { - if ($expiration instanceof DateTimeInterface) { - $this->eventManager->dispatch(Event::CACHE_ITEM_EXPIRE_AT, $this, $expiration); - $this->expirationDate = $this->demutateDatetime($expiration); - } else { - throw new PhpfastcacheInvalidArgumentException('$expiration must be an object implementing the DateTimeInterface got: ' . \gettype($expiration)); - } - - return $this; - } - - /** - * @return $this - * @throws PhpfastcacheInvalidArgumentException - * @throws \Exception - */ - public function expiresAfter(int|\DateInterval|null $time): static - { - if (\is_numeric($time)) { - if ($time <= 0) { - /** - * 5 months, however memcached or memory cached will be gone when u restart it - * just recommended for sqlite. files - */ - $time = 30 * 24 * 3600 * 5; - } - - $this->eventManager->dispatch(Event::CACHE_ITEM_EXPIRE_AFTER, $this, $time); - - $this->expirationDate = (new DateTime())->add(new DateInterval(\sprintf('PT%dS', $time))); - } elseif ($time instanceof DateInterval) { - $this->eventManager->dispatch(Event::CACHE_ITEM_EXPIRE_AFTER, $this, $time); - - $this->expirationDate = (new DateTime())->add($time); - } else { - throw new PhpfastcacheInvalidArgumentException(\sprintf('Invalid date format, got "%s"', \gettype($time))); - } - - return $this; - } - - protected function demutateDatetime(\DateTimeInterface $dateTime): \DateTimeInterface - { - return $dateTime instanceof \DateTimeImmutable - ? \DateTime::createFromImmutable($dateTime) - : $dateTime; - } -} diff --git a/lib/Phpfastcache/Core/Item/ExtendedCacheItemInterface.php b/lib/Phpfastcache/Core/Item/ExtendedCacheItemInterface.php deleted file mode 100644 index ae546a9c0..000000000 --- a/lib/Phpfastcache/Core/Item/ExtendedCacheItemInterface.php +++ /dev/null @@ -1,207 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -declare(strict_types=1); - -namespace Phpfastcache\Core\Item; - -use DateTimeInterface; -use JsonSerializable; -use Phpfastcache\Core\Pool\ExtendedCacheItemPoolInterface; -use Phpfastcache\Event\EventManagerDispatcherInterface; -use Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException; -use Phpfastcache\Exceptions\PhpfastcacheInvalidTypeException; -use Phpfastcache\Exceptions\PhpfastcacheLogicException; -use Phpfastcache\Util\ClassNamespaceResolverInterface; -use Psr\Cache\CacheItemInterface; - -interface ExtendedCacheItemInterface extends - CacheItemInterface, - EventManagerDispatcherInterface, - ClassNamespaceResolverInterface, - JsonSerializable, - TaggableCacheItemInterface -{ - /** - * Returns the encoded key for the current cache item. - * Is a MD5 (default),SHA1,SHA256 hash if "defaultKeyHashFunction" config option is configured - * Else return the plain cache item key "defaultKeyHashFunction" config option is emptied - * - * @return string - * The encoded key string for this cache item. - */ - public function getEncodedKey(): string; - - /** - * Returns the cache item value, regardless of hit status. - * This method can be called if the cache item is NOT YET - * persisted, and you need to access to its set value. - * - * Although not part of the CacheItemInterface, this method is used by - * the pool for extracting information for saving. - * - * @return mixed - * - * @internal This method is used internally by phpfastcache, so you should not use it in your application. - * @SuppressWarnings(PHPMD.CamelCaseMethodName) - */ - public function _getData(): mixed; // @phpcs:ignore - - /** - * @return DateTimeInterface - */ - public function getExpirationDate(): DateTimeInterface; - - /** - * Alias of expireAt() with forced $expiration param - * - * @param DateTimeInterface $expiration - * The point in time after which the item MUST be considered expired. - * If null is passed explicitly, a default value MAY be used. If none is set, - * the value should be stored permanently or for as long as the - * implementation allows. - * - * @return ExtendedCacheItemInterface - * The called object. - */ - public function setExpirationDate(DateTimeInterface $expiration): ExtendedCacheItemInterface; - - /** - * @return DateTimeInterface - * @throws PhpfastcacheLogicException - */ - public function getCreationDate(): DateTimeInterface; - - /** - * @return DateTimeInterface - * @throws PhpfastcacheLogicException - */ - public function getModificationDate(): DateTimeInterface; - - /** - * @param $date DateTimeInterface - * - * @return ExtendedCacheItemInterface - * @throws PhpfastcacheLogicException - */ - public function setCreationDate(DateTimeInterface $date): ExtendedCacheItemInterface; - - /** - * @param $date DateTimeInterface - * - * @return ExtendedCacheItemInterface - * @throws PhpfastcacheLogicException - */ - public function setModificationDate(DateTimeInterface $date): ExtendedCacheItemInterface; - - /** - * @return int - */ - public function getTtl(): int; - - /** - * @return bool - */ - public function isExpired(): bool; - - /** - * @return bool - */ - public function isNull(): bool; - - /** - * @return bool - */ - public function isEmpty(): bool; - - /** - * Return the data length: - * - Either the number of char if it's a string (binary mode) - * - or the number of element if it's an array - * - or the number returned by count() if it's an object implementing \Countable interface - * - or -1 for anything else - * - * @return int - */ - public function getLength(): int; - - /** - * @param ExtendedCacheItemPoolInterface $driver - * - * @return ExtendedCacheItemInterface - */ - public function setDriver(ExtendedCacheItemPoolInterface $driver): ExtendedCacheItemInterface; - - /** - * @param bool $isHit - * - * @return ExtendedCacheItemInterface - */ - public function setHit(bool $isHit): ExtendedCacheItemInterface; - - /** - * @param int $step - * - * @return ExtendedCacheItemInterface - * @throws PhpfastcacheInvalidTypeException - */ - public function increment(int $step = 1): ExtendedCacheItemInterface; - - /** - * @param int $step - * - * @return ExtendedCacheItemInterface - * @throws PhpfastcacheInvalidTypeException - */ - public function decrement(int $step = 1): ExtendedCacheItemInterface; - - /** - * @param mixed[]|string $data - * - * @return ExtendedCacheItemInterface - * @throws PhpfastcacheInvalidTypeException - */ - public function append(array|string $data): ExtendedCacheItemInterface; - - /** - * @param mixed[]|string $data - * - * @return ExtendedCacheItemInterface - * @throws PhpfastcacheInvalidTypeException - */ - public function prepend(array|string $data): ExtendedCacheItemInterface; - - /** - * Return the data as a well-formatted string. - * Any scalar value will be casted to an array - * - * @param int $options \json_encode() options - * @param int $depth \json_encode() depth - * - * @return string - */ - public function getDataAsJsonString(int $options = JSON_THROW_ON_ERROR, int $depth = 512): string; - - /** - * @param ExtendedCacheItemPoolInterface $driverPool - * @return bool - */ - public function doesItemBelongToThatDriverBackend(ExtendedCacheItemPoolInterface $driverPool): bool; - - /** - * @param ExtendedCacheItemInterface $itemTarget - * @param ExtendedCacheItemPoolInterface|null $itemPoolTarget - */ - public function cloneInto(ExtendedCacheItemInterface $itemTarget, ?ExtendedCacheItemPoolInterface $itemPoolTarget = null): void; -} diff --git a/lib/Phpfastcache/Core/Item/ExtendedCacheItemTrait.php b/lib/Phpfastcache/Core/Item/ExtendedCacheItemTrait.php deleted file mode 100644 index 1ed2888b7..000000000 --- a/lib/Phpfastcache/Core/Item/ExtendedCacheItemTrait.php +++ /dev/null @@ -1,307 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -declare(strict_types=1); - -namespace Phpfastcache\Core\Item; - -use DateTime; -use DateTimeInterface; -use Phpfastcache\Core\Pool\ExtendedCacheItemPoolInterface; -use Phpfastcache\Event\EventManagerInterface; -use Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException; -use Phpfastcache\Exceptions\PhpfastcacheInvalidTypeException; -use Phpfastcache\Exceptions\PhpfastcacheLogicException; - -trait ExtendedCacheItemTrait -{ - use CacheItemTrait; - - protected ExtendedCacheItemPoolInterface $driver; - - protected string $encodedKey; - - /** - * Item constructor. - * @param ExtendedCacheItemPoolInterface $driver - * @param string $key - * @param EventManagerInterface $em - * @throws PhpfastcacheInvalidArgumentException - */ - public function __construct(ExtendedCacheItemPoolInterface $driver, string $key, EventManagerInterface $em) - { - $this->data = null; - $this->key = $key; - $this->setEventManager($em); - $this->setDriver($driver); - if ($driver->getConfig()->isUseStaticItemCaching()) { - $this->driver->setItem($this); - } - $this->expirationDate = new DateTime(); - if ($this->driver->getConfig()->isItemDetailedDate()) { - $this->creationDate = new DateTime(); - $this->modificationDate = new DateTime(); - } - } - - /** - * @param ExtendedCacheItemPoolInterface $driver - * @return ExtendedCacheItemInterface - * @throws PhpfastcacheInvalidArgumentException - */ - public function setDriver(ExtendedCacheItemPoolInterface $driver): ExtendedCacheItemInterface - { - $driverClass = $this->getDriverClass(); - if ($driver instanceof $driverClass) { - $this->driver = $driver; - - return $this; - } - - throw new PhpfastcacheInvalidArgumentException(\sprintf('Invalid driver instance "%s" for cache item "%s"', $driver::class, static::class)); - } - - /** - * @inheritDoc - */ - public function getEncodedKey(): string - { - if (!isset($this->encodedKey)) { - $this->encodedKey = $this->driver->getEncodedKey($this->getKey()); - } - - return $this->encodedKey; - } - - /** - * @inheritDoc - * @SuppressWarnings(PHPMD.CamelCaseMethodName) - */ - public function _getData(): mixed // @phpcs:ignore - { - return $this->data; - } - - /** - * @inheritDoc - */ - public function getExpirationDate(): DateTimeInterface - { - return $this->expirationDate; - } - - /** - * @inheritDoc - * @throws PhpfastcacheInvalidArgumentException - */ - public function setExpirationDate(DateTimeInterface $expiration): ExtendedCacheItemInterface - { - return $this->expiresAt($expiration); - } - - /** - * @inheritDoc - * @throws PhpfastcacheLogicException - */ - public function getCreationDate(): DateTimeInterface - { - if ($this->driver->getConfig()->isItemDetailedDate()) { - return $this->creationDate; - } - - throw new PhpfastcacheLogicException('Cannot access to the creation date when the "itemDetailedDate" configuration is disabled.'); - } - - /** - * @inheritDoc - * @throws PhpfastcacheLogicException - */ - public function setCreationDate(DateTimeInterface $date): ExtendedCacheItemInterface - { - if ($this->driver->getConfig()->isItemDetailedDate()) { - $this->creationDate = $this->demutateDatetime($date); - return $this; - } - - throw new PhpfastcacheLogicException('Cannot access to the creation date when the "itemDetailedDate" configuration is disabled.'); - } - - /** - * @inheritDoc - * @throws PhpfastcacheLogicException - */ - public function getModificationDate(): DateTimeInterface - { - if ($this->driver->getConfig()->isItemDetailedDate()) { - return $this->modificationDate; - } - - throw new PhpfastcacheLogicException('Cannot access to the modification date when the "itemDetailedDate" configuration is disabled.'); - } - - /** - * @inheritDoc - * @throws PhpfastcacheLogicException - */ - public function setModificationDate(DateTimeInterface $date): ExtendedCacheItemInterface - { - if ($this->driver->getConfig()->isItemDetailedDate()) { - $this->modificationDate = $this->demutateDatetime($date); - return $this; - } - - throw new PhpfastcacheLogicException('Cannot access to the modification date when the "itemDetailedDate" configuration is disabled.'); - } - - public function getTtl(): int - { - return \max(0, $this->expirationDate->getTimestamp() - \time()); - } - - public function isExpired(): bool - { - return $this->getTtl() <= 0; - } - - public function isNull(): bool - { - return $this->get() === null; - } - - public function isEmpty(): bool - { - return empty($this->get()); - } - - /** - * Return the data length: - * Either the string length if it's a string (binary mode) - * # or the number of element (count) if it's an array - * # or the number returned by count() if it's an object implementing \Countable interface - * # -1 for anything else - * @return int - */ - public function getLength(): int - { - switch (\gettype($this->data)) { - case 'array': - case 'object': - if (\is_countable($this->data)) { - return \count($this->data); - } - break; - - case 'string': - return \strlen($this->data); - } - - return -1; - } - - /** - * @throws PhpfastcacheInvalidTypeException - */ - public function increment(int $step = 1): ExtendedCacheItemInterface - { - if ($this->data !== null && !\is_numeric($this->data)) { - throw new PhpfastcacheInvalidTypeException(\sprintf('Cannot increment on a "%s" type.', \gettype($this->data))); - } - - $this->data += $step; - - return $this; - } - - /** - * @throws PhpfastcacheInvalidTypeException - */ - public function decrement(int $step = 1): ExtendedCacheItemInterface - { - if ($this->data !== null && !\is_numeric($this->data)) { - throw new PhpfastcacheInvalidTypeException(\sprintf('Cannot decrement on a "%s" type.', \gettype($this->data))); - } - - $this->data -= $step; - - return $this; - } - - /** - * @throws PhpfastcacheInvalidTypeException - */ - public function append(array|string $data): ExtendedCacheItemInterface - { - if ($this->data !== null && !\is_string($this->data) && !\is_array($this->data)) { - throw new PhpfastcacheInvalidTypeException(\sprintf('Cannot append on a "%s" type.', \gettype($this->data))); - } - - if (\is_array($this->data)) { - $this->data[] = $data; - } else { - $this->data .= $data; - } - - return $this; - } - - /** - * @throws PhpfastcacheInvalidTypeException - */ - public function prepend(array|string $data): ExtendedCacheItemInterface - { - if ($this->data !== null && !\is_string($this->data) && !\is_array($this->data)) { - throw new PhpfastcacheInvalidTypeException(\sprintf('Cannot prepend on a "%s" type.', \gettype($this->data))); - } - - if (\is_array($this->data)) { - \array_unshift($this->data, $data); - } else { - $this->data = $data . $this->data; - } - - return $this; - } - - /** - * Return the data as a well-formatted string. - * Any scalar value will be cast to an array - * @param int $options \json_encode() options - * @param int $depth \json_encode() depth - * @return string - */ - public function getDataAsJsonString(int $options = JSON_THROW_ON_ERROR, int $depth = 512): string - { - $data = $this->get(); - - if (\is_object($data) || \is_array($data)) { - $data = \json_encode($data, $options, $depth); - } else { - $data = \json_encode([$data], $options, $depth); - } - - return \json_encode($data, $options, $depth); - } - - public function jsonSerialize(): mixed - { - return $this->get(); - } - - public function doesItemBelongToThatDriverBackend(ExtendedCacheItemPoolInterface $driverPool): bool - { - return $driverPool::getClassNamespace() === self::getClassNamespace(); - } - - abstract protected function getDriverClass(): string; -} diff --git a/lib/Phpfastcache/Core/Item/TaggableCacheItemInterface.php b/lib/Phpfastcache/Core/Item/TaggableCacheItemInterface.php deleted file mode 100644 index 5e8c5ec31..000000000 --- a/lib/Phpfastcache/Core/Item/TaggableCacheItemInterface.php +++ /dev/null @@ -1,122 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -declare(strict_types=1); - -namespace Phpfastcache\Core\Item; - -use Phpfastcache\Core\Pool\TaggableCacheItemPoolInterface; -use Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException; - -interface TaggableCacheItemInterface -{ - /** - * Allows you to get cache item(s) by at least **ONE** of the specified matching tag(s). - * Default behavior - */ - public const TAG_STRATEGY_ONE = TaggableCacheItemPoolInterface::TAG_STRATEGY_ONE; - - /** - * Allows you to get cache item(s) by **ALL** of the specified matching tag(s) - * The cache item *CAN* have additional tag(s) - */ - public const TAG_STRATEGY_ALL = TaggableCacheItemPoolInterface::TAG_STRATEGY_ALL; - - /** - * Allows you to get cache item(s) by **ONLY** the specified matching tag(s) - * The cache item *CANNOT* have additional tag(s) - */ - public const TAG_STRATEGY_ONLY = TaggableCacheItemPoolInterface::TAG_STRATEGY_ONLY; - - /** - * @param string $tagName - * - * @return ExtendedCacheItemInterface - * @throws PhpfastcacheInvalidArgumentException - */ - public function addTag(string $tagName): ExtendedCacheItemInterface; - - /** - * @param string[] $tagNames - * - * @return ExtendedCacheItemInterface - * @throws PhpfastcacheInvalidArgumentException - */ - public function addTags(array $tagNames): ExtendedCacheItemInterface; - - /** - * @param string $tagName - * - * @return bool - */ - public function hasTag(string $tagName): bool; - - /** - * @return bool - */ - public function isTagged(): bool; - - /** - * @param string[] $tagNames - * @param int $strategy - * @return bool - * @throws PhpfastcacheInvalidArgumentException - */ - public function hasTags(array $tagNames, int $strategy = self::TAG_STRATEGY_ONE): bool; - - /** - * @param string[] $tags - * - * @return ExtendedCacheItemInterface - * @throws PhpfastcacheInvalidArgumentException - */ - public function setTags(array $tags): ExtendedCacheItemInterface; - - /** - * @return string[] - */ - public function getTags(): array; - - /** - * @param string $separator - * - * @return string - */ - public function getTagsAsString(string $separator = ', '): string; - - /** - * @param string $tagName - * - * @return ExtendedCacheItemInterface - * @throws PhpfastcacheInvalidArgumentException - */ - public function removeTag(string $tagName): ExtendedCacheItemInterface; - - /** - * @param string[] $tagNames - * - * @return ExtendedCacheItemInterface - */ - public function removeTags(array $tagNames): ExtendedCacheItemInterface; - - /** - * @return string[] - */ - public function getRemovedTags(): array; - - /** - * @return ExtendedCacheItemInterface - */ - public function clearRemovedTags(): ExtendedCacheItemInterface; -} diff --git a/lib/Phpfastcache/Core/Item/TaggableCacheItemTrait.php b/lib/Phpfastcache/Core/Item/TaggableCacheItemTrait.php deleted file mode 100644 index abceafbef..000000000 --- a/lib/Phpfastcache/Core/Item/TaggableCacheItemTrait.php +++ /dev/null @@ -1,192 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -declare(strict_types=1); - -namespace Phpfastcache\Core\Item; - -use Phpfastcache\Core\Pool\ExtendedCacheItemPoolInterface; -use Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException; -use Phpfastcache\Exceptions\PhpfastcacheLogicException; - -trait TaggableCacheItemTrait -{ - use ExtendedCacheItemTrait; - - /** - * @var string[] - */ - protected array $tags = []; - - /** - * @var string[] - */ - protected array $removedTags = []; - - /** - * @param string[] $tagNames - * @return ExtendedCacheItemInterface - */ - public function addTags(array $tagNames): ExtendedCacheItemInterface - { - foreach ($tagNames as $tagName) { - $this->addTag($tagName); - } - - return $this; - } - - /** - * @param string $tagName - * @return ExtendedCacheItemInterface - */ - public function addTag(string $tagName): ExtendedCacheItemInterface - { - $this->tags = \array_unique(\array_merge($this->tags, [$tagName])); - - return $this; - } - - /** - * @param string $tagName - * - * @return bool - */ - public function hasTag(string $tagName): bool - { - return \in_array($tagName, $this->tags, true); - } - - /** - * @return bool - */ - public function isTagged(): bool - { - return !empty($this->tags); - } - - /** - * @param string[] $tagNames - * @param int $strategy - * @return bool - * @throws PhpfastcacheInvalidArgumentException - */ - public function hasTags(array $tagNames, int $strategy = TaggableCacheItemInterface::TAG_STRATEGY_ONE): bool - { - return match ($strategy) { - TaggableCacheItemInterface::TAG_STRATEGY_ONE => !empty(array_intersect($tagNames, $this->tags)), - TaggableCacheItemInterface::TAG_STRATEGY_ALL => empty(\array_diff($tagNames, $this->tags)), - TaggableCacheItemInterface::TAG_STRATEGY_ONLY => empty(\array_diff($tagNames, $this->tags)) && empty(\array_diff($this->tags, $tagNames)), - default => throw new PhpfastcacheInvalidArgumentException('Invalid strategy constant provided.'), - }; - } - - - /** - * @param string[] $tags - * @return ExtendedCacheItemInterface - * @throws PhpfastcacheInvalidArgumentException - */ - public function setTags(array $tags): ExtendedCacheItemInterface - { - if ($tags === [] || \array_filter($tags, 'is_string')) { - $this->tags = $tags; - } else { - throw new PhpfastcacheInvalidArgumentException('$tagName must be an array of string'); - } - - return $this; - } - - /** - * @return string[] - */ - public function getTags(): array - { - return $this->tags; - } - - /** - * @param string $separator - * @return string - */ - public function getTagsAsString(string $separator = ', '): string - { - return \implode($separator, $this->tags); - } - - /** - * @param string[] $tagNames - * @return ExtendedCacheItemInterface - */ - public function removeTags(array $tagNames): ExtendedCacheItemInterface - { - foreach ($tagNames as $tagName) { - $this->removeTag($tagName); - } - - return $this; - } - - /** - * @param string $tagName - * @return ExtendedCacheItemInterface - */ - public function removeTag(string $tagName): ExtendedCacheItemInterface - { - if (($key = \array_search($tagName, $this->tags, true)) !== false) { - unset($this->tags[$key]); - $this->removedTags[] = $tagName; - } - - return $this; - } - - /** - * @return string[] - */ - public function getRemovedTags(): array - { - return \array_diff($this->removedTags, $this->tags); - } - - /** - * @return ExtendedCacheItemInterface - */ - public function clearRemovedTags(): ExtendedCacheItemInterface - { - $this->removedTags = []; - - return $this; - } - - /** - * @throws PhpfastcacheLogicException - * @throws PhpfastcacheInvalidArgumentException - */ - public function cloneInto(ExtendedCacheItemInterface $itemTarget, ?ExtendedCacheItemPoolInterface $itemPoolTarget = null): void - { - $itemTarget->setEventManager($this->getEventManager()) - ->set($this->_getData()) - ->setHit($this->isHit()) - ->setTags($this->getTags()) - ->expiresAt(clone $this->getExpirationDate()) - ->setDriver($itemPoolTarget ?? $this->driver); - - if ($this->driver->getConfig()->isItemDetailedDate()) { - $itemTarget->setCreationDate(clone $this->getCreationDate()) - ->setModificationDate(clone $this->getModificationDate()); - } - } -} diff --git a/lib/Phpfastcache/Core/Pool/AggregatablePoolTrait.php b/lib/Phpfastcache/Core/Pool/AggregatablePoolTrait.php deleted file mode 100644 index 6a1c9425d..000000000 --- a/lib/Phpfastcache/Core/Pool/AggregatablePoolTrait.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -namespace Phpfastcache\Core\Pool; - -use Phpfastcache\Cluster\ClusterPoolInterface; - -trait AggregatablePoolTrait -{ - protected ?ClusterPoolInterface $clusterPool = null; - - public function isAggregatedBy(): ?ClusterPoolInterface - { - return $this->clusterPool; - } - - public function setAggregatedBy(ClusterPoolInterface $clusterPool): static - { - $this->clusterPool = $clusterPool; - - return $this; - } -} diff --git a/lib/Phpfastcache/Core/Pool/CacheItemPoolTrait.php b/lib/Phpfastcache/Core/Pool/CacheItemPoolTrait.php deleted file mode 100644 index a66e99c1b..000000000 --- a/lib/Phpfastcache/Core/Pool/CacheItemPoolTrait.php +++ /dev/null @@ -1,630 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -declare(strict_types=1); - -namespace Phpfastcache\Core\Pool; - -use DateTime; -use Phpfastcache\Config\ConfigurationOptionInterface; -use Phpfastcache\Config\IOConfigurationOptionInterface; -use Phpfastcache\Core\Item\ExtendedCacheItemInterface; -use Phpfastcache\Entities\DriverIO; -use Phpfastcache\Entities\ItemBatch; -use Phpfastcache\Event\Event; -use Phpfastcache\Event\EventManagerInterface; -use Phpfastcache\Event\EventReferenceParameter; -use Phpfastcache\Exceptions\PhpfastcacheCoreException; -use Phpfastcache\Exceptions\PhpfastcacheDriverException; -use Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException; -use Phpfastcache\Exceptions\PhpfastcacheInvalidTypeException; -use Phpfastcache\Exceptions\PhpfastcacheIOException; -use Phpfastcache\Exceptions\PhpfastcacheLogicException; -use Phpfastcache\Exceptions\PhpfastcacheUnsupportedMethodException; -use Psr\Cache\CacheItemInterface; -use RuntimeException; - -/** - * @method string[] driverUnwrapTags(array $wrapper) - * @method void cleanItemTags(ExtendedCacheItemInterface $item) - */ -trait CacheItemPoolTrait -{ - use DriverBaseTrait { - DriverBaseTrait::__construct as __driverBaseConstruct; - } - - /** - * @var string - */ - protected static string $unsupportedKeyChars = '{}()/\@:'; - - /** - * @var ExtendedCacheItemInterface[]|CacheItemInterface[] - */ - protected array $deferredList = []; - - /** - * @var ExtendedCacheItemInterface[]|CacheItemInterface[] - */ - protected array $itemInstances = []; - - protected DriverIO $IO; - - public function __construct(#[\SensitiveParameter] ConfigurationOptionInterface $config, string $instanceId, EventManagerInterface $em) - { - $this->IO = new DriverIO(); - $this->__driverBaseConstruct($config, $instanceId, $em); - } - - /** - * @throws PhpfastcacheLogicException - * @throws PhpfastcacheInvalidArgumentException - */ - public function setItem(CacheItemInterface $item): static - { - if (self::getItemClass() === $item::class) { - if (!$this->getConfig()->isUseStaticItemCaching()) { - throw new PhpfastcacheLogicException( - 'The static item caching option (useStaticItemCaching) is disabled so you cannot attach an item.' - ); - } - - $this->itemInstances[$item->getKey()] = $item; - - return $this; - } - throw new PhpfastcacheInvalidArgumentException( - \sprintf( - 'Invalid cache item class "%s" for driver "%s".', - get_class($item), - get_class($this) - ) - ); - } - - /** - * @inheritDoc - * @throws PhpfastcacheCoreException - * @throws PhpfastcacheDriverException - * @throws PhpfastcacheInvalidArgumentException - * @throws PhpfastcacheLogicException - */ - public function getItems(array $keys = []): iterable - { - $items = []; - - /** - * Usually, drivers that are able to enable cache slams - * does not benefit of driverReadMultiple() call. - */ - if (!$this->getConfig()->isPreventCacheSlams()) { - $this->validateCacheKeys(...$keys); - - /** - * Check for local item instances first. - */ - foreach ($keys as $index => $key) { - if (isset($this->itemInstances[$key]) && $this->getConfig()->isUseStaticItemCaching()) { - $items[$key] = $this->itemInstances[$key]; - // Key already exists in local item instances, no need to fetch it again. - unset($keys[$index]); - } - } - $keys = array_values($keys); - - /** - * If there's still keys to fetch, let's choose the right method (if supported). - */ - if (count($keys) > 1) { - $items = array_merge( - array_combine($keys, array_map(fn($key) => new (self::getItemClass())($this, $key, $this->eventManager), $keys)), - $items - ); - - try { - $driverArrays = $this->driverReadMultiple(...$items); - } catch (PhpfastcacheUnsupportedMethodException) { - /** - * Fallback for drivers that does not yet implement driverReadMultiple() method. - */ - $driverArrays = array_combine( - array_map(fn($item) => $item->getKey(), $items), - array_map(fn($item) => $this->driverRead($item), $items) - ); - } finally { - foreach ($items as $item) { - $driverArray = $driverArrays[$item->getKey()] ?? null; - if ($driverArray !== null) { - $item->set($this->driverUnwrapData($driverArray)); - $item->expiresAt($this->driverUnwrapEdate($driverArray)); - if ($this->getConfig()->isItemDetailedDate()) { - /** - * If the itemDetailedDate has been - * set after caching, we MUST inject - * a new DateTime object on the fly - */ - $item->setCreationDate($this->driverUnwrapCdate($driverArray) ?: new DateTime()); - $item->setModificationDate($this->driverUnwrapMdate($driverArray) ?: new DateTime()); - } - $item->setTags($this->driverUnwrapTags($driverArray)); - $this->handleExpiredCacheItem($item); - } else { - $item->expiresAfter((int) abs($this->getConfig()->getDefaultTtl())); - } - $item->isHit() ? $this->getIO()->incReadHit() : $this->getIO()->incReadMiss(); - } - } - } else { - $index = array_key_first($keys); - if ($index !== null) { - $items[$keys[$index]] = $this->getItem($keys[$index]); - } - } - } else { - $collection = []; - - foreach ($keys as $key) { - $collection[$key] = $this->getItem($key); - } - - return $collection; - } - - $this->eventManager->dispatch(Event::CACHE_GET_ITEMS, $this, $items); - - return $items; - } - - /** - * @param string $key - * @return ExtendedCacheItemInterface - * @throws PhpfastcacheCoreException - * @throws PhpfastcacheInvalidArgumentException - * @throws PhpfastcacheLogicException - * @throws PhpfastcacheDriverException - * - * @SuppressWarnings(PHPMD.NPathComplexity) - * @SuppressWarnings(PHPMD.GotoStatement) - */ - public function getItem(string $key): ExtendedCacheItemInterface - { - /** - * Replace array_key_exists by isset - * due to performance issue on huge - * loop dispatching operations - */ - if (!isset($this->itemInstances[$key]) || !$this->getConfig()->isUseStaticItemCaching()) { - $this->validateCacheKeys($key); - - /** @var $item ExtendedCacheItemInterface */ - $item = new (self::getItemClass())($this, $key, $this->eventManager); - - $getItemDriverRead = function (float $cacheSlamsSpendSeconds = 0) use (&$getItemDriverRead, $item): void { - $config = $this->getConfig(); - - $driverArray = $this->driverRead($item); - - if ($driverArray) { - $driverData = $this->driverUnwrapData($driverArray); - - if ($config instanceof IOConfigurationOptionInterface && $config->isPreventCacheSlams()) { - while ($driverData instanceof ItemBatch) { - if ($driverData->getItemDate()->getTimestamp() + $config->getCacheSlamsTimeout() < \time()) { - /** - * The timeout has been reached - * Consider that the batch has - * failed and serve an empty item - * to avoid get stuck with a - * batch item stored in driver - */ - $this->handleExpiredCacheItem($item); - return; - } - - $this->eventManager->dispatch(Event::CACHE_GET_ITEM_IN_SLAM_BATCH, $this, $driverData, $cacheSlamsSpendSeconds); - - /** - * Wait for a second before - * attempting to get exit - * the current batch process - */ - \usleep(100000); - - $getItemDriverRead($cacheSlamsSpendSeconds + 0.1); - } - } - - $item->set($driverData); - $item->expiresAt($this->driverUnwrapEdate($driverArray)); - - if ($this->getConfig()->isItemDetailedDate()) { - /** - * If the itemDetailedDate has been - * set after caching, we MUST inject - * a new DateTime object on the fly - */ - $item->setCreationDate($this->driverUnwrapCdate($driverArray) ?: new DateTime()); - $item->setModificationDate($this->driverUnwrapMdate($driverArray) ?: new DateTime()); - } - - $item->setTags($this->driverUnwrapTags($driverArray)); - $this->handleExpiredCacheItem($item); - } else { - $item->expiresAfter((int) abs($this->getConfig()->getDefaultTtl())); - } - }; - $getItemDriverRead(); - } else { - $item = $this->itemInstances[$key]; - } - - $this->eventManager->dispatch(Event::CACHE_GET_ITEM, $this, $item); - - $item->isHit() ? $this->getIO()->incReadHit() : $this->getIO()->incReadMiss(); - - return $item; - } - - /** - * @param string $key - * @return bool - * @throws PhpfastcacheCoreException - * @throws PhpfastcacheDriverException - * @throws PhpfastcacheInvalidArgumentException - * @throws PhpfastcacheLogicException - */ - public function hasItem(string $key): bool - { - return $this->getItem($key)->isHit(); - } - - /** - * @return bool - * @throws PhpfastcacheCoreException - * @throws PhpfastcacheDriverException - * @throws PhpfastcacheLogicException - * @throws PhpfastcacheIOException - */ - public function clear(): bool - { - $this->eventManager->dispatch(Event::CACHE_CLEAR_ITEM, $this, $this->itemInstances); - - $this->getIO()->incWriteHit(); - // Faster than detachAllItems() - $this->itemInstances = []; - - return $this->driverClear(); - } - - /** - * @inheritDoc - * @throws PhpfastcacheCoreException - * @throws PhpfastcacheDriverException - * @throws PhpfastcacheInvalidArgumentException - * @throws PhpfastcacheLogicException - */ - public function deleteItems(array $keys): bool - { - if (count($keys) > 1) { - $return = true; - try { - $items = $this->getItems($keys); - $return = $this->driverDeleteMultiple($keys); - foreach ($items as $item) { - $item->setHit(false); - - if (!\str_starts_with($item->getKey(), TaggableCacheItemPoolInterface::DRIVER_TAGS_KEY_PREFIX)) { - $this->cleanItemTags($item); - } - } - $this->getIO()->incWriteHit(); - $this->eventManager->dispatch(Event::CACHE_DELETE_ITEMS, $this, $items); - $this->deregisterItems($keys); - } catch (PhpfastcacheUnsupportedMethodException) { - foreach ($keys as $key) { - $result = $this->deleteItem($key); - if ($result !== true) { - $return = false; - } - } - } - - return $return; - } - - $index = array_key_first($keys); - if ($index !== null) { - return $this->deleteItem($keys[$index]); - } - - return false; - } - - /** - * @param string $key - * @return bool - * @throws PhpfastcacheCoreException - * @throws PhpfastcacheDriverException - * @throws PhpfastcacheInvalidArgumentException - * @throws PhpfastcacheLogicException - */ - public function deleteItem(string $key): bool - { - $item = $this->getItem($key); - if ($item->isHit()) { - $result = $this->driverDelete($item->getKey(), $item->getEncodedKey()); - $item->setHit(false); - $this->getIO()->incWriteHit(); - - $this->eventManager->dispatch(Event::CACHE_DELETE_ITEM, $this, $item); - - /** - * De-register the item instance - * then collect gc cycles - */ - $this->deregisterItem($key); - - /** - * Perform a tag cleanup to avoid memory leaks - */ - if (!\str_starts_with($key, TaggableCacheItemPoolInterface::DRIVER_TAGS_KEY_PREFIX)) { - $this->cleanItemTags($item); - } - - return $result; - } - - return false; - } - - /** - * @param CacheItemInterface $item - * @return bool - */ - public function saveDeferred(CacheItemInterface $item): bool - { - $this->assertCacheItemType($item, self::getItemClass()); - if (!\array_key_exists($item->getKey(), $this->itemInstances)) { - $this->itemInstances[$item->getKey()] = $item; - } elseif (\spl_object_hash($item) !== \spl_object_hash($this->itemInstances[$item->getKey()])) { - throw new RuntimeException('Spl object hash mismatches ! You probably tried to save a detached item which has been already retrieved from cache.'); - } - - $this->eventManager->dispatch(Event::CACHE_SAVE_DEFERRED_ITEM, $this, $item); - $this->deferredList[$item->getKey()] = $item; - - return true; - } - - /** - * @return bool - * @throws PhpfastcacheCoreException - * @throws PhpfastcacheDriverException - * @throws PhpfastcacheInvalidArgumentException - * @throws PhpfastcacheLogicException - */ - public function commit(): bool - { - $this->eventManager->dispatch(Event::CACHE_COMMIT_ITEM, $this, new EventReferenceParameter($this->deferredList)); - - if (\count($this->deferredList)) { - $return = true; - foreach ($this->deferredList as $key => $item) { - $result = $this->save($item); - unset($this->deferredList[$key]); - if ($result !== true) { - $return = $result; - } - } - - return $return; - } - return false; - } - - /** - * @param CacheItemInterface $item - * @return bool - * @throws PhpfastcacheCoreException - * @throws PhpfastcacheDriverException - * @throws PhpfastcacheIOException - * @throws PhpfastcacheInvalidArgumentException - * @throws PhpfastcacheLogicException - */ - public function save(CacheItemInterface $item): bool - { - $this->assertCacheItemType($item, self::getItemClass()); - /** - * @var ExtendedCacheItemInterface $item - * - * Replace array_key_exists by isset - * due to performance issue on huge - * loop dispatching operations - */ - if (!isset($this->itemInstances[$item->getKey()])) { - if ($this->getConfig()->isUseStaticItemCaching()) { - $this->itemInstances[$item->getKey()] = $item; - } - } elseif (\spl_object_hash($item) !== \spl_object_hash($this->itemInstances[$item->getKey()])) { - throw new RuntimeException('Spl object hash mismatches ! You probably tried to save a detached item which has been already retrieved from cache.'); - } - - $this->assertCacheItemType($item, self::getItemClass()); - $this->eventManager->dispatch(Event::CACHE_SAVE_ITEM, $this, $item); - - if ($this->getConfig() instanceof IOConfigurationOptionInterface && $this->getConfig()->isPreventCacheSlams()) { - /** - * @var $itemBatch ExtendedCacheItemInterface - */ - $itemClassName = self::getItemClass(); - $itemBatch = new $itemClassName($this, $item->getKey(), $this->eventManager); - $itemBatch->set(new ItemBatch($item->getKey(), new DateTime())) - ->expiresAfter($this->getConfig()->getCacheSlamsTimeout()); - - /** - * To avoid SPL mismatches - * we have to re-attach the - * original item to the pool - */ - $this->driverWrite($itemBatch); - $this->detachItem($itemBatch); - $this->attachItem($item); - } - - - if ($this->driverWrite($item) && $this->driverWriteTags($item)) { - $item->setHit(true) - ->clearRemovedTags(); - - if ($this->getConfig()->isItemDetailedDate()) { - $item->setModificationDate(new \DateTime()); - } - - $this->getIO()->incWriteHit(); - - return true; - } - - return false; - } - - /** - * @return DriverIO - */ - public function getIO(): DriverIO - { - return $this->IO; - } - - /** - * @internal This method de-register an item from $this->itemInstances - */ - protected function deregisterItem(string $itemKey): static - { - unset($this->itemInstances[$itemKey]); - - if (\gc_enabled()) { - \gc_collect_cycles(); - } - - return $this; - } - - /** - * @param string[] $itemKeys - * @internal This method de-register multiple items from $this->itemInstances - */ - protected function deregisterItems(array $itemKeys): static - { - $this->itemInstances = array_diff_key($this->itemInstances, array_flip($itemKeys)); - - if (\gc_enabled()) { - \gc_collect_cycles(); - } - - return $this; - } - - /** - * @throws PhpfastcacheLogicException - */ - public function attachItem(CacheItemInterface $item): static - { - if (isset($this->itemInstances[$item->getKey()]) && \spl_object_hash($item) !== \spl_object_hash($this->itemInstances[$item->getKey()])) { - throw new PhpfastcacheLogicException( - 'The item already exists and cannot be overwritten because the Spl object hash mismatches ! - You probably tried to re-attach a detached item which has been already retrieved from cache.' - ); - } - - if (!$this->getConfig()->isUseStaticItemCaching()) { - throw new PhpfastcacheLogicException( - 'The static item caching option (useStaticItemCaching) is disabled so you cannot attach an item.' - ); - } - - $this->itemInstances[$item->getKey()] = $item; - - return $this; - } - - public function isAttached(CacheItemInterface $item): bool - { - if (isset($this->itemInstances[$item->getKey()])) { - return \spl_object_hash($item) === \spl_object_hash($this->itemInstances[$item->getKey()]); - } - return false; - } - - protected function validateCacheKeys(string ...$keys): void - { - foreach ($keys as $key) { - if (\preg_match('~([' . \preg_quote(self::$unsupportedKeyChars, '~') . ']+)~', $key, $matches)) { - throw new PhpfastcacheInvalidArgumentException( - 'Unsupported key character detected: "' . $matches[1] . '". - Please check: https://github.com/PHPSocialNetwork/phpfastcache/wiki/%5BV6%5D-Unsupported-characters-in-key-identifiers' - ); - } - } - } - - protected function handleExpiredCacheItem(ExtendedCacheItemInterface $item): void - { - if ($item->isExpired()) { - /** - * Using driverDelete() instead of delete() - * to avoid infinite loop caused by - * getItem() call in delete() method - * As we MUST return an item in any - * way, we do not de-register here - */ - $this->driverDelete($item->getKey(), $item->getEncodedKey()); - - /** - * Reset the Item - */ - $item->set(null) - ->expiresAfter((int) abs($this->getConfig()->getDefaultTtl())) - ->setHit(false) - ->setTags([]); - - if ($this->getConfig()->isItemDetailedDate()) { - /** - * If the itemDetailedDate has been - * set after caching, we MUST inject - * a new DateTime object on the fly - */ - $item->setCreationDate(new DateTime()); - $item->setModificationDate(new DateTime()); - } - } else { - $item->setHit(true); - } - } - - /** - * @param ExtendedCacheItemInterface[] $items - * @param bool $encoded - * @param string $keyPrefix - * @return string[] - */ - protected function getKeys(array $items, bool $encoded = false, string $keyPrefix = ''): array - { - return array_map( - static fn(ExtendedCacheItemInterface $item) => $keyPrefix . ($encoded ? $item->getEncodedKey() : $item->getKey()), - $items - ); - } -} diff --git a/lib/Phpfastcache/Core/Pool/DriverBaseTrait.php b/lib/Phpfastcache/Core/Pool/DriverBaseTrait.php deleted file mode 100644 index 1f3d85e27..000000000 --- a/lib/Phpfastcache/Core/Pool/DriverBaseTrait.php +++ /dev/null @@ -1,324 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -declare(strict_types=1); - -namespace Phpfastcache\Core\Pool; - -use DateTime; -use DateTimeInterface; -use Phpfastcache\Config\ConfigurationOptionInterface; -use Phpfastcache\Event\Event; -use Phpfastcache\Event\EventManagerDispatcherTrait; -use Phpfastcache\Event\EventManagerInterface; -use Phpfastcache\Exceptions\PhpfastcacheCorruptedDataException; -use Phpfastcache\Exceptions\PhpfastcacheDriverException; -use Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException; -use Phpfastcache\Util\ClassNamespaceResolverTrait; -use Throwable; -use Phpfastcache\Config\ConfigurationOption; -use Phpfastcache\Core\Item\ExtendedCacheItemInterface; -use Phpfastcache\Entities\DriverIO; -use Phpfastcache\Exceptions\PhpfastcacheCoreException; -use Phpfastcache\Exceptions\PhpfastcacheDriverCheckException; -use Phpfastcache\Exceptions\PhpfastcacheDriverConnectException; -use Phpfastcache\Exceptions\PhpfastcacheIOException; -use Phpfastcache\Exceptions\PhpfastcacheLogicException; -use ReflectionObject; - -trait DriverBaseTrait -{ - use DriverPoolAbstractTrait; - use ClassNamespaceResolverTrait; - use EventManagerDispatcherTrait; - - /** - * @var string[] - */ - protected static array $cacheItemClasses = []; - - protected ConfigurationOptionInterface $config; - - /** - * @var object|null - */ - protected ?object $instance; - - protected string $driverName; - - protected string $instanceId; - - /** - * Driver constructor. - * @param ConfigurationOptionInterface $config - * @param string $instanceId - * @param EventManagerInterface $em - * @throws PhpfastcacheCoreException - * @throws PhpfastcacheDriverCheckException - * @throws PhpfastcacheDriverConnectException - * @throws PhpfastcacheIOException - * @throws PhpfastcacheInvalidArgumentException - */ - public function __construct(#[\SensitiveParameter] ConfigurationOptionInterface $config, string $instanceId, EventManagerInterface $em) - { - $this->setEventManager($em->getScopedEventManager($this)); - $this->setConfig($config); - $this->instanceId = $instanceId; - - if (!$this->driverCheck()) { - throw new PhpfastcacheDriverCheckException( - \sprintf( - ExtendedCacheItemPoolInterface::DRIVER_CHECK_FAILURE, - $this->getDriverName(), - $this->getHelp() ? " Additionally, {$this->getHelp()}" : '' - ) - ); - } - $this->eventManager->dispatch(Event::CACHE_DRIVER_CHECKED, $this); - - try { - $this->driverConnect(); - $config->lock($this); // Lock the config only after a successful driver connection. - $this->eventManager->dispatch(Event::CACHE_DRIVER_CONNECTED, $this, $this->instance ?? null); - } catch (Throwable $e) { - throw new PhpfastcacheDriverConnectException( - sprintf( - ExtendedCacheItemPoolInterface::DRIVER_CONNECT_FAILURE, - $this->getDriverName(), - $e->getMessage(), - $e->getLine() ?: 'unknown line', - $e->getFile() ?: 'unknown file', - ), - 0, - $e - ); - } - } - - /** - * @return string - */ - public function getDriverName(): string - { - if (!isset($this->driverName)) { - $this->driverName = \ucfirst(\substr(\strrchr((new ReflectionObject($this))->getNamespaceName(), '\\'), 1)); - } - return $this->driverName; - } - - /** - * @return ConfigurationOptionInterface - */ - public function getDefaultConfig(): ConfigurationOptionInterface - { - $className = $this::getConfigClass(); - - return new $className(); - } - - /** - * @return string - */ - public static function getConfigClass(): string - { - $localConfigClass = \substr(static::class, 0, \strrpos(static::class, '\\')) . '\Config'; - if (\class_exists($localConfigClass) && \is_a($localConfigClass, ConfigurationOption::class, true)) { - return $localConfigClass; - } - return ConfigurationOption::class; - } - - public static function getItemClass(): string - { - if (!isset(self::$cacheItemClasses[static::class])) { - self::$cacheItemClasses[static::class] = self::getClassNamespace() . '\\' . 'Item'; - } - - return self::$cacheItemClasses[static::class]; - } - - /** - * @inheritDoc - */ - public function getEncodedKey(string $key): string - { - $keyHashFunction = $this->getConfig()->getDefaultKeyHashFunction(); - - if ($keyHashFunction) { - if (\is_callable($keyHashFunction)) { - return $keyHashFunction($key); - } - throw new PhpfastcacheLogicException('Unable to build the encoded key (defaultKeyHashFunction is not callable)'); - } - - return $key; - } - - - - /** - * @param ExtendedCacheItemInterface $item - * @param bool $stringifyDate - * @return array - * @throws PhpfastcacheLogicException - */ - public function driverPreWrap(ExtendedCacheItemInterface $item, bool $stringifyDate = false): array - { - $wrap = [ - ExtendedCacheItemPoolInterface::DRIVER_KEY_WRAPPER_INDEX => $item->getKey(), // Stored but not really used, allow you to quickly identify the cache key - ExtendedCacheItemPoolInterface::DRIVER_DATA_WRAPPER_INDEX => $item->_getData(), - ExtendedCacheItemPoolInterface::DRIVER_EDATE_WRAPPER_INDEX => $item->getExpirationDate(), - TaggableCacheItemPoolInterface::DRIVER_TAGS_WRAPPER_INDEX => $item->getTags(), - ]; - - if ($this->getConfig()->isItemDetailedDate()) { - $wrap[ExtendedCacheItemPoolInterface::DRIVER_MDATE_WRAPPER_INDEX] = new DateTime();// Always on the latest date - /** - * If the creation date exists - * reuse it else set a new Date - */ - $wrap[ExtendedCacheItemPoolInterface::DRIVER_CDATE_WRAPPER_INDEX] = $item->getCreationDate(); - } else { - $wrap[ExtendedCacheItemPoolInterface::DRIVER_MDATE_WRAPPER_INDEX] = null; - $wrap[ExtendedCacheItemPoolInterface::DRIVER_CDATE_WRAPPER_INDEX] = null; - } - - if ($stringifyDate) { - \array_walk($wrap, static function (mixed &$value, string $key): void { - if ($value instanceof DateTimeInterface && $key !== ExtendedCacheItemPoolInterface::DRIVER_DATA_WRAPPER_INDEX) { - $value = $value->format(DateTimeInterface::W3C); - } - }); - } - - return $wrap; - } - - /** - * @return ConfigurationOptionInterface - */ - public function getConfig(): ConfigurationOptionInterface - { - return $this->config; - } - - /** - * @param ConfigurationOptionInterface $config - * @return static - */ - public function setConfig(ConfigurationOptionInterface $config): static - { - $this->config = $config; - - return $this; - } - - /** - * @param array $wrapper - * @return mixed - * @throws \Exception - */ - public function driverUnwrapData(array $wrapper): mixed - { - return $wrapper[ExtendedCacheItemPoolInterface::DRIVER_DATA_WRAPPER_INDEX]; - } - - /** - * @param array $wrapper - * @return DateTimeInterface - */ - public function driverUnwrapEdate(array $wrapper): \DateTimeInterface - { - if ($wrapper[ExtendedCacheItemPoolInterface::DRIVER_EDATE_WRAPPER_INDEX] instanceof \DateTimeInterface) { - return $wrapper[ExtendedCacheItemPoolInterface::DRIVER_EDATE_WRAPPER_INDEX]; - } - - return DateTime::createFromFormat(\DateTimeInterface::W3C, $wrapper[ExtendedCacheItemPoolInterface::DRIVER_EDATE_WRAPPER_INDEX]); - } - - /** - * @param array $wrapper - * @return DateTimeInterface|null - */ - public function driverUnwrapCdate(array $wrapper): ?\DateTimeInterface - { - if ($wrapper[ExtendedCacheItemPoolInterface::DRIVER_CDATE_WRAPPER_INDEX] instanceof \DateTimeInterface) { - return $wrapper[ExtendedCacheItemPoolInterface::DRIVER_CDATE_WRAPPER_INDEX]; - } - - return DateTime::createFromFormat(\DateTimeInterface::W3C, $wrapper[ExtendedCacheItemPoolInterface::DRIVER_CDATE_WRAPPER_INDEX]); - } - - /** - * @param array $wrapper - * @return DateTimeInterface|null - */ - public function driverUnwrapMdate(array $wrapper): ?\DateTimeInterface - { - if ($wrapper[ExtendedCacheItemPoolInterface::DRIVER_MDATE_WRAPPER_INDEX] instanceof \DateTimeInterface) { - return $wrapper[ExtendedCacheItemPoolInterface::DRIVER_MDATE_WRAPPER_INDEX]; - } - - return DateTime::createFromFormat(\DateTimeInterface::W3C, $wrapper[ExtendedCacheItemPoolInterface::DRIVER_MDATE_WRAPPER_INDEX]); - } - - /** - * @return string - */ - public function getInstanceId(): string - { - return $this->instanceId; - } - - /** - * Encode data types such as object/array - * for driver that does not support - * non-scalar value - * @param mixed $data - * @return string - */ - protected function encode(mixed $data): string - { - return \serialize($data); - } - - /** - * Decode data stored in the cache - * for driver that does not support - * non-scalar value storage. - * @param string|null $value - * @return array|null - * @throws PhpfastcacheDriverException - */ - protected function decode(?string $value): ?array - { - $decoded = $this->unserialize($value); - - if ($decoded === null || is_array($decoded)) { - return $decoded; - } - throw new PhpfastcacheCorruptedDataException( - sprintf( - 'Failed to unserialize data from the cache, expected array or null but got "%s". Stored data may be corrupted.', - gettype($decoded) - ), - $value - ); - } - - protected function unserialize(?string $value): mixed - { - return $value ? \unserialize($value, ['allowed_classes' => true]) : null; - } -} diff --git a/lib/Phpfastcache/Core/Pool/DriverPoolAbstractTrait.php b/lib/Phpfastcache/Core/Pool/DriverPoolAbstractTrait.php deleted file mode 100644 index ea2dd7f76..000000000 --- a/lib/Phpfastcache/Core/Pool/DriverPoolAbstractTrait.php +++ /dev/null @@ -1,124 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -declare(strict_types=1); - -namespace Phpfastcache\Core\Pool; - -use Phpfastcache\Core\Item\ExtendedCacheItemInterface; -use Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException; -use Phpfastcache\Exceptions\PhpfastcacheUnsupportedMethodException; -use Phpfastcache\Wiki; -use Psr\Cache\CacheItemInterface; - -trait DriverPoolAbstractTrait -{ - /** - * @return bool - */ - abstract protected function driverCheck(): bool; - - /** - * @return bool - */ - abstract protected function driverConnect(): bool; - - /** - * @param ExtendedCacheItemInterface $item - * @return ?array - */ - abstract protected function driverRead(ExtendedCacheItemInterface $item): ?array; - - /** - * @param ExtendedCacheItemInterface ...$items - * @return array> - * @throws PhpfastcacheUnsupportedMethodException - */ - protected function driverReadMultiple(ExtendedCacheItemInterface ...$items): array - { - throw new PhpfastcacheUnsupportedMethodException(); - } - - /** - * @return \Traversable - * @throws PhpfastcacheUnsupportedMethodException - */ - protected function driverReadAllKeys(string $pattern = ''): iterable - { - throw new PhpfastcacheUnsupportedMethodException( - sprintf( - 'The "readAll" operation is unsupported by the the "%s" driver. See the Wiki for more information at %s', - $this->getDriverName(), - Wiki::FETCH_ALL_KEY_URL, - ) - ); - } - - /** - * @param ExtendedCacheItemInterface $item - * @return bool - */ - abstract protected function driverWrite(ExtendedCacheItemInterface $item): bool; - - /** - * @param ExtendedCacheItemInterface ...$item - * @return bool - * @throws PhpfastcacheUnsupportedMethodException - */ - protected function driverWriteMultiple(ExtendedCacheItemInterface ...$item): bool - { - /** - * @todo Implement bulk writes to be for v10: - * For methods commit() and saveMultiple() - */ - throw new PhpfastcacheUnsupportedMethodException(); - } - - - /** - * @param string $key - * @param string $encodedKey - * @return bool - */ - abstract protected function driverDelete(string $key, string $encodedKey): bool; - - /** - * @param string[] $keys - * @return bool - * @throws PhpfastcacheUnsupportedMethodException - */ - protected function driverDeleteMultiple(array $keys): bool - { - throw new PhpfastcacheUnsupportedMethodException(); - } - - /** - * @return bool - */ - abstract protected function driverClear(): bool; - - /** - * @param CacheItemInterface $item - * @param string $expectedClassType - * @throws PhpfastcacheInvalidArgumentException - */ - protected function assertCacheItemType(CacheItemInterface $item, string $expectedClassType): void - { - if (!($item instanceof $expectedClassType)) { - throw new PhpfastcacheInvalidArgumentException( - \sprintf('Cross-driver type confusion detected: Expected "%s" object, got "%s"', $expectedClassType, $item::class) - ); - } - } -} diff --git a/lib/Phpfastcache/Core/Pool/ExtendedCacheItemPoolInterface.php b/lib/Phpfastcache/Core/Pool/ExtendedCacheItemPoolInterface.php deleted file mode 100644 index 9f28129bd..000000000 --- a/lib/Phpfastcache/Core/Pool/ExtendedCacheItemPoolInterface.php +++ /dev/null @@ -1,231 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -declare(strict_types=1); - -namespace Phpfastcache\Core\Pool; - -use InvalidArgumentException; -use Phpfastcache\Config\ConfigurationOptionInterface; -use Phpfastcache\Core\Item\ExtendedCacheItemInterface; -use Phpfastcache\Entities\DriverIO; -use Phpfastcache\Entities\DriverStatistic; -use Phpfastcache\Event\EventManagerDispatcherInterface; -use Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException; -use Phpfastcache\Exceptions\PhpfastcacheLogicException; -use Phpfastcache\Exceptions\PhpfastcacheUnsupportedMethodException; -use Phpfastcache\Util\ClassNamespaceResolverInterface; -use Psr\Cache\CacheItemInterface; -use Psr\Cache\CacheItemPoolInterface; - -/** - * Extended cache item pool interface that - * contains all the phpfastcache-related - * methods that does not belong to PSR-6. - */ -interface ExtendedCacheItemPoolInterface extends CacheItemPoolInterface, EventManagerDispatcherInterface, ClassNamespaceResolverInterface, TaggableCacheItemPoolInterface -{ - public const DRIVER_CHECK_FAILURE = '%s is not installed or is misconfigured, cannot continue. - Also, please verify the suggested dependencies in composer because as of the V6, 3rd party libraries are no longer required.%s'; - - public const DRIVER_CONNECT_FAILURE = '%s failed to connect with the following error message: "%s" line %d in %s.'; - - public const DRIVER_KEY_WRAPPER_INDEX = 'k'; - - public const DRIVER_DATA_WRAPPER_INDEX = 'd'; - - /** - * Expiration date Index - */ - public const DRIVER_EDATE_WRAPPER_INDEX = 'e'; - - /** - * Creation date Index - */ - public const DRIVER_CDATE_WRAPPER_INDEX = 'c'; - - /** - * Modification date Index - */ - public const DRIVER_MDATE_WRAPPER_INDEX = 'm'; - - /** - * Hard-limit count of items returns by getAllItems() - */ - public const MAX_ALL_KEYS_COUNT = 9999; - - /** - * Return the config class name - * @return string - */ - public static function getConfigClass(): string; - - /** - * Return the item class name - * @return string - */ - public static function getItemClass(): string; - - /** - * @param string $key - * @return string - */ - public function getEncodedKey(string $key): string; - - /** - * @return ConfigurationOptionInterface - */ - public function getConfig(): ConfigurationOptionInterface; - - /** - * @return ConfigurationOptionInterface - */ - public function getDefaultConfig(): ConfigurationOptionInterface; - - /** - * @return string - */ - public function getDriverName(): string; - - /** - * @return mixed - */ - public function getInstanceId(): string; - - /** - * [Phpfastcache phpDoc Override] - * Returns a Cache Item representing the specified key. - * - * This method must always return a CacheItemInterface object, even in case of - * a cache miss. It MUST NOT return null. - * - * @param string $key - * The key for which to return the corresponding Cache Item. - * - * @return ExtendedCacheItemInterface - * The corresponding Cache Item. - * @throws PhpfastcacheInvalidArgumentException - * If the $key string is not a legal value a phpfastcacheInvalidArgumentException - * MUST be thrown. - * - */ - public function getItem(string $key): ExtendedCacheItemInterface; - - /** - * [Phpfastcache phpDoc Override] - * Returns a traversable set of cache items. - * - * @param string[] $keys - * An indexed array of keys of items to retrieve. - * - * @return iterable - * A traversable collection of Cache Items keyed by the cache keys of - * each item. A Cache item will be returned for each key, even if that - * key is not found. However, if no keys are specified then an empty - * traversable MUST be returned instead. - * @throws InvalidArgumentException - * If any of the keys in $keys are not a legal value a phpfastcacheInvalidArgumentException - * MUST be thrown. - * - */ - public function getItems(array $keys = []): iterable; - - /** - * Returns the WHOLE cache as a traversable set of cache items. - * A hard-limit of 9999 items is defined internally to prevent - * serious performances issues of your application. - * @see ExtendedCacheItemPoolInterface::MAX_ALL_KEYS_COUNT - * - * @param string $pattern - * An optional pattern supported by a limited range of drivers. - * If this parameter is unsupported by the driver, a PhpfastcacheInvalidArgumentException will be thrown. - * - * @return iterable - * A traversable collection of Cache Items keyed by the cache keys of - * each item. However, if no keys are returned by the backend then an empty - * traversable WILL be returned instead. - * - * @throws PhpfastcacheInvalidArgumentException If the driver does not support the $pattern argument - * @throws PhpfastcacheUnsupportedMethodException If the driver does not permit to list all the keys through this implementation. - */ - public function getAllItems(string $pattern = ''): iterable; - - /** - * Returns A json string that represents an array of items. - * - * @param array $keys An indexed array of keys of items to retrieve. - * @param int $options \json_encode() options - * @param int $depth \json_encode() depth - * - * @return string - * @throws InvalidArgumentException - * If any of the keys in $keys are not a legal value a phpfastcacheInvalidArgumentException - * MUST be thrown. - * - */ - public function getItemsAsJsonString(array $keys = [], int $options = \JSON_THROW_ON_ERROR, int $depth = 512): string; - - public function setItem(CacheItemInterface $item): static; - - public function getStats(): DriverStatistic; - - /** - * Get a quick help guide - * about the current driver - */ - public function getHelp(): string; - - public function detachItem(CacheItemInterface $item): static; - - public function detachAllItems(): static; - - public function attachItem(CacheItemInterface $item): static; - - /** - * Returns true if the item exists, is attached and the Spl Hash matches - * Returns false if the item exists, is attached and the Spl Hash mismatches - * Returns null if the item does not exist - * - * @param CacheItemInterface $item - * @return bool - * @throws PhpfastcacheLogicException - */ - public function isAttached(CacheItemInterface $item): bool; - - /** - * Persists a cache item immediately. - * - * @param ExtendedCacheItemInterface|CacheItemInterface $item - * The cache item to save. - * - * @return bool - * True if the item was successfully persisted. False if there was an error. - */ - public function save(ExtendedCacheItemInterface|CacheItemInterface $item): bool; - - /** - * Save multiple items, possible uses: - * saveMultiple([$item1, $item2, $item3]); - * saveMultiple($item1, $item2, $item3); - * - * @param ExtendedCacheItemInterface[] $items - * @return bool - */ - public function saveMultiple(ExtendedCacheItemInterface ...$items): bool; - - /** - * @return DriverIO - */ - public function getIO(): DriverIO; -} diff --git a/lib/Phpfastcache/Core/Pool/ExtendedCacheItemPoolTrait.php b/lib/Phpfastcache/Core/Pool/ExtendedCacheItemPoolTrait.php deleted file mode 100644 index 6ecec6573..000000000 --- a/lib/Phpfastcache/Core/Pool/ExtendedCacheItemPoolTrait.php +++ /dev/null @@ -1,135 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -declare(strict_types=1); - -namespace Phpfastcache\Core\Pool; - -use Phpfastcache\Core\Item\ExtendedCacheItemInterface; -use Phpfastcache\Event\Event; -use Phpfastcache\Event\EventReferenceParameter; -use Phpfastcache\Exceptions\PhpfastcacheCoreException; -use Phpfastcache\Exceptions\PhpfastcacheDriverException; -use Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException; -use Phpfastcache\Exceptions\PhpfastcacheLogicException; -use Psr\Cache\CacheItemInterface; - -trait ExtendedCacheItemPoolTrait -{ - use CacheItemPoolTrait; - use AggregatablePoolTrait; - - /** - * @inheritDoc - * @param string $pattern - * @return array - */ - public function getAllItems(string $pattern = ''): iterable - { - $driverReadAllKeysCallback = fn (string $pattern): iterable => $this->driverReadAllKeys($pattern); - - /** - * This event allow you to customize the callback and wrap it to an invoker - * like SebastianBergmann\Invoke\Invoke, so you can set up custom timeouts. - */ - $this->eventManager->dispatch(Event::CACHE_GET_ALL_ITEMS, $this, new EventReferenceParameter($driverReadAllKeysCallback)); - $keys = $driverReadAllKeysCallback($pattern); - - if (count($keys) > 0) { - return $this->getItems($keys instanceof \Traversable ? iterator_to_array($keys) : $keys); - } - - return []; - } - - /** - * @inheritDoc - * @throws PhpfastcacheCoreException - * @throws PhpfastcacheDriverException - * @throws PhpfastcacheInvalidArgumentException - * @throws PhpfastcacheLogicException - */ - public function getItemsAsJsonString(array $keys = [], int $options = \JSON_THROW_ON_ERROR, int $depth = 512): string - { - return \json_encode( - \array_map( - static fn(CacheItemInterface $item) => $item->get(), - \array_values($this->getItems($keys)) - ), - $options, - $depth - ); - } - - public function detachAllItems(): static - { - foreach ($this->itemInstances as $item) { - $this->detachItem($item); - } - - return $this; - } - - public function detachItem(CacheItemInterface $item): static - { - if (isset($this->itemInstances[$item->getKey()])) { - $this->deregisterItem($item->getKey()); - } - - return $this; - } - - /** - * @param ExtendedCacheItemInterface ...$items - * @return bool - * @throws PhpfastcacheCoreException - * @throws PhpfastcacheDriverException - * @throws PhpfastcacheInvalidArgumentException - * @throws PhpfastcacheLogicException - */ - public function saveMultiple(ExtendedCacheItemInterface ...$items): bool - { - $this->eventManager->dispatch(Event::CACHE_SAVE_MULTIPLE_ITEMS, $this, new EventReferenceParameter($items)); - - if (\count($items)) { - foreach ($items as $item) { - $this->save($item); - } - return true; - } - return false; - } - - /** - * @return string - */ - public function getHelp(): string - { - return ''; - } - - /** - * @throws PhpfastcacheInvalidArgumentException - */ - public function throwUnsupportedDriverReadAllPattern(string $linkReference = ''): void - { - throw new PhpfastcacheInvalidArgumentException( - sprintf( - '%s does not support a pattern argument.%s', - $this->getDriverName(), - $linkReference ? " See $linkReference" : '' - ) - ); - } -} diff --git a/lib/Phpfastcache/Core/Pool/IO/IOHelperTrait.php b/lib/Phpfastcache/Core/Pool/IO/IOHelperTrait.php deleted file mode 100644 index 296f4d6e7..000000000 --- a/lib/Phpfastcache/Core/Pool/IO/IOHelperTrait.php +++ /dev/null @@ -1,314 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -declare(strict_types=1); - -namespace Phpfastcache\Core\Pool\IO; - -use Phpfastcache\Config\IOConfigurationOptionInterface; -use Phpfastcache\Core\Pool\TaggableCacheItemPoolTrait; -use Phpfastcache\Entities\DriverStatistic; -use Phpfastcache\Event\Event; -use Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException; -use Phpfastcache\Exceptions\PhpfastcacheIOException; -use Phpfastcache\Util\Directory; -use Phpfastcache\Util\SapiDetector; - -/** - * @method IOConfigurationOptionInterface getConfig() - */ -trait IOHelperTrait -{ - use TaggableCacheItemPoolTrait; - - /** - * @var array - */ - public array $tmp = []; - - /** - * Provide a generic getStats() method - * for files-based drivers - * @return DriverStatistic - * @throws PhpfastcacheIOException - * @throws PhpfastcacheInvalidArgumentException - */ - public function getStats(): DriverStatistic - { - $stat = new DriverStatistic(); - $path = $this->getFilePath(false); - - if (!is_dir($path)) { - throw new PhpfastcacheIOException("Can't read PATH:" . $path); - } - $stat->setSize(Directory::dirSize($path)) - ->setInfo('Number of files used to build the cache: ' . Directory::getFileCount($path)) - ->setRawData( - [ - 'tmp' => $this->tmp, - ] - ); - - if ($this->getConfig()->isUseStaticItemCaching()) { - $stat->setData(implode(', ', \array_keys($this->itemInstances))); - } else { - $stat->setData('No data available since static item caching option (useStaticItemCaching) is disabled.'); - } - - return $stat; - } - - /** - * @param string|bool $keyword - * @param bool $skip - * @return string - * @throws PhpfastcacheIOException - * @throws PhpfastcacheInvalidArgumentException - */ - protected function getFilePath(string|bool $keyword, bool $skip = false): string - { - $path = $this->getPath(); - - if ($keyword === false) { - return $path; - } - - $filename = $this->encodeFilename($keyword); - $folder = \substr($filename, 0, 2) . DIRECTORY_SEPARATOR . \substr($filename, 2, 2); - $path = \rtrim($path, '/\\') . DIRECTORY_SEPARATOR . $folder; - - /** - * Skip Create Sub Folders; - */ - if (!$skip && !\is_dir($path) && @!\mkdir($path, $this->getDefaultChmod(), true) && !\is_dir($path)) { - throw new PhpfastcacheIOException( - 'Path "' . $path . '" is not writable, please set a chmod 0777 or any writable permission and make sure to make use of an absolute path !' - ); - } - - return $path . \DIRECTORY_SEPARATOR . $filename . '.' . $this->getConfig()->getCacheFileExtension(); - } - - /** - * @param bool $readonly - * @return string - * @throws PhpfastcacheIOException - * @throws PhpfastcacheInvalidArgumentException - */ - public function getPath(bool $readonly = false): string - { - $tmpDir = \rtrim(\ini_get('upload_tmp_dir') ?: \sys_get_temp_dir(), '\\/') . DIRECTORY_SEPARATOR . 'phpfastcache'; - $httpHost = $this->getConfig()->getSuperGlobalAccessor()('SERVER', 'HTTP_HOST'); - $securityKey = $this->buildSecurityKey($httpHost); - - /** - * Extends the temporary directory - * with the security key and the driver name - */ - $tmpDir = \rtrim($tmpDir, '/') . DIRECTORY_SEPARATOR; - - if (empty($this->getConfig()->getPath())) { - $path = $tmpDir; - } else { - $path = \rtrim($this->getConfig()->getPath(), '/') . DIRECTORY_SEPARATOR; - } - - $pathSuffix = $securityKey . DIRECTORY_SEPARATOR . $this->getDriverName(); - $fullPath = Directory::getAbsolutePath($path . $pathSuffix); - $fullPathTmp = Directory::getAbsolutePath($tmpDir . $pathSuffix); - - $this->mkdir($fullPath, $fullPathTmp); - - /** - * In readonly mode we only attempt - * to verify if the directory exists - * or not, if it does not then we - * return the temp dir - */ - if ($readonly) { - if ($this->getConfig()->isAutoTmpFallback() && (!@\file_exists($fullPath) || !@\is_writable($fullPath))) { - return $fullPathTmp; - } - return $fullPath; - } - - return realpath($fullPath); - } - - protected function buildSecurityKey(?string $httpHost): string - { - $securityKey = $this->getConfig()->getSecurityKey(); - if (!$securityKey || \mb_strtolower($securityKey) === 'auto') { - if (isset($httpHost)) { - $securityKey = \preg_replace('/^www./', '', \strtolower(\str_replace(':', '_', $httpHost))); - } else { - $securityKey = (SapiDetector::isWebScript() ? 'web' : 'cli'); - } - } - - if (!empty($securityKey)) { - $securityKey .= '/'; - } - - return static::cleanFileName($securityKey); - } - - /** - * @throws PhpfastcacheIOException - */ - protected function mkdir(string $fullPath, string $fullPathTmp): void - { - $fullPathHash = $this->getConfig()->getDefaultFileNameHashFunction()($fullPath); - - if (!isset($this->tmp[$fullPathHash]) || (!@\file_exists($fullPath) || !@\is_writable($fullPath))) { - if (!@\file_exists($fullPath)) { - if (@mkdir($fullPath, $this->getDefaultChmod(), true) === false && !\is_dir($fullPath)) { - throw new PhpfastcacheIOException('The directory ' . $fullPath . ' could not be created.'); - } - } elseif (!@\is_writable($fullPath) && !@\chmod($fullPath, $this->getDefaultChmod()) && $this->getConfig()->isAutoTmpFallback()) { - /** - * Switch back to tmp dir - * again if the path is not writable - */ - $fullPath = $fullPathTmp; - if (!@\file_exists($fullPath) && @\mkdir($fullPath, $this->getDefaultChmod(), true) && !\is_dir($fullPath)) { - throw new PhpfastcacheIOException('The directory ' . $fullPath . ' could not be created.'); - } - } - - /** - * In case there is no directory - * writable including the temporary - * one, we must throw an exception - */ - if (!@\file_exists($fullPath) || !@\is_writable($fullPath)) { - throw new PhpfastcacheIOException( - 'Path "' . $fullPath . '" is not writable, please set a chmod 0777 or any writable permission and make sure to make use of an absolute path !' - ); - } - - $this->tmp[$fullPathHash] = $fullPath; - } - } - - /** - * @param string $filename - * @return string - */ - protected static function cleanFileName(string $filename): string - { - $regex = [ - '/[\?\[\]\/\\\=\<\>\:\;\,\'\"\&\$\#\*\(\)\|\~\`\!\{\}]/', - '/\.$/', - '/^\./', - ]; - $replace = ['-', '', '']; - - return \trim(\preg_replace($regex, $replace, \trim($filename)), '-'); - } - - /** - * @return int - */ - protected function getDefaultChmod(): int - { - if (!$this->getConfig()->getDefaultChmod()) { - return 0777; - } - - return $this->getConfig()->getDefaultChmod(); - } - - /** - * @param string $keyword - * @return string - */ - protected function encodeFilename(string $keyword): string - { - return $this->getConfig()->getDefaultFileNameHashFunction()($keyword); - } - - /** - * @param string $file - * @return string - * @throws PhpfastcacheIOException - */ - protected function readFile(string $file): string - { - if (!\is_readable($file)) { - throw new PhpfastcacheIOException("Cannot read file located at: $file"); - } - if (\function_exists('file_get_contents')) { - return (string)\file_get_contents($file); - } - - $string = ''; - - $fileHandle = @\fopen($file, 'rb'); - while (!\feof($fileHandle)) { - $line = \fgets($fileHandle); - $string .= $line; - } - \fclose($fileHandle); - - return $string; - } - - /******************** - * - * PSR-6 Extended Methods - * - *******************/ - - /** - * @param string $file - * @param string $data - * @param bool $secureFileManipulation - * @return bool - * @throws PhpfastcacheIOException - * @throws \Exception - */ - protected function writeFile(string $file, string $data, bool $secureFileManipulation = false): bool - { - $this->eventManager->dispatch(Event::CACHE_WRITE_FILE_ON_DISK, $this, $file, $secureFileManipulation); - - if ($secureFileManipulation) { - $tmpFilename = Directory::getAbsolutePath( - dirname($file) . \DIRECTORY_SEPARATOR . 'tmp_' . $this->getConfig()->getDefaultFileNameHashFunction()( - \bin2hex(\random_bytes(16)) - ) - ) . '.' . $this->getConfig()->getCacheFileExtension() . \random_int(1000, 9999); - - $handle = \fopen($tmpFilename, 'w+b'); - if (\is_resource($handle)) { - \flock($handle, \LOCK_EX); - $octetWritten = fwrite($handle, $data); - \flock($handle, \LOCK_UN); - \fclose($handle); - } - - if (!\rename($tmpFilename, $file)) { - throw new PhpfastcacheIOException(\sprintf('Failed to rename %s to %s', $tmpFilename, $file)); - } - } else { - $handle = \fopen($file, 'w+b'); - if (\is_resource($handle)) { - $octetWritten = \fwrite($handle, $data); - \fclose($handle); - } - } - - return (bool)($octetWritten ?? false); - } -} diff --git a/lib/Phpfastcache/Core/Pool/TaggableCacheItemPoolInterface.php b/lib/Phpfastcache/Core/Pool/TaggableCacheItemPoolInterface.php deleted file mode 100644 index 4d73c14b5..000000000 --- a/lib/Phpfastcache/Core/Pool/TaggableCacheItemPoolInterface.php +++ /dev/null @@ -1,288 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -declare(strict_types=1); - -namespace Phpfastcache\Core\Pool; - -use InvalidArgumentException; -use Phpfastcache\Core\Item\ExtendedCacheItemInterface; - -interface TaggableCacheItemPoolInterface -{ - public const DRIVER_TAGS_KEY_PREFIX = '_TAG_'; - - public const DRIVER_TAGS_WRAPPER_INDEX = 'g'; - - /** - * Allows you to get cache item(s) by at least **ONE** of the specified matching tag(s). - * Default behavior - */ - public const TAG_STRATEGY_ONE = 1; - - /** - * Allows you to get cache item(s) by **ALL** of the specified matching tag(s) - * The cache item *CAN* have additional tag(s) - */ - public const TAG_STRATEGY_ALL = 2; - - /** - * Allows you to get cache item(s) by **ONLY** the specified matching tag(s) - * The cache item *CANNOT* have additional tag(s) - */ - public const TAG_STRATEGY_ONLY = 4; - - /** - * Returns a traversable set of cache items by a tag name. - * - * @param string $tagName - * An indexed array of keys of items to retrieve. - * - * @param int $strategy - * - * @return ExtendedCacheItemInterface[] - * A traversable collection of Cache Items keyed by the cache keys of - * each item. A Cache item will be returned for each key, even if that - * key is not found. However, if no keys are specified then an empty - * traversable MUST be returned instead. - * @throws InvalidArgumentException - * If any of the keys in $keys are not a legal value a phpfastcacheInvalidArgumentException - * MUST be thrown. - * - */ - public function getItemsByTag(string $tagName, int $strategy = self::TAG_STRATEGY_ONE): array; - - /** - * Returns a traversable set of cache items by one of multiple tag names. - * - * @param string[] $tagNames - * An indexed array of keys of items to retrieve. - * - * @param int $strategy - * - * @return ExtendedCacheItemInterface[] - * A traversable collection of Cache Items keyed by the cache keys of - * each item. A Cache item will be returned for each key, even if that - * key is not found. However, if no keys are specified then an empty - * traversable MUST be returned instead. - * @throws InvalidArgumentException - * If any of the keys in $keys are not a legal value a phpfastcacheInvalidArgumentException - * MUST be thrown. - * - */ - public function getItemsByTags(array $tagNames, int $strategy = self::TAG_STRATEGY_ONE): array; - - /** - * Returns A json string that represents an array of items by tags-based. - * - * @param string[] $tagNames - * An indexed array of keys of items to retrieve. - * @param int $option \json_encode() options - * @param int $depth \json_encode() depth - * @param int $strategy - * - * @return string - * @throws InvalidArgumentException - * If any of the keys in $keys are not a legal value a phpfastcacheInvalidArgumentException - * MUST be thrown. - * - */ - public function getItemsByTagsAsJsonString(array $tagNames, int $option = \JSON_THROW_ON_ERROR, int $depth = 512, int $strategy = self::TAG_STRATEGY_ONE): string; - - /** - * Removes the item from the pool by tag. - * - * @param string $tagName - * The tag for which to delete - * - * @param int $strategy - * - * @return bool - * True if the item was successfully removed. False if there was an error. - * @throws InvalidArgumentException - * If the $key string is not a legal value a phpfastcacheInvalidArgumentException - * MUST be thrown. - * - */ - public function deleteItemsByTag(string $tagName, int $strategy = self::TAG_STRATEGY_ONE): bool; - - /** - * Removes the item from the pool by one of multiple tag names. - * - * @param string[] $tagNames - * The tag for which to delete - * - * @param int $strategy - * - * @return bool - * True if the items were successfully removed. False if there was an error. - * @throws InvalidArgumentException - * If the $key string is not a legal value a phpfastcacheInvalidArgumentException - * MUST be thrown. - * - */ - public function deleteItemsByTags(array $tagNames, int $strategy = self::TAG_STRATEGY_ONE): bool; - - /** - * Increment the items from the pool by tag. - * - * @param string $tagName - * The tag for which to increment - * - * @param int $step - * - * @param int $strategy - * - * @return bool - * True if the item was successfully incremented. False if there was an error. - * @throws InvalidArgumentException - * If the $key string is not a legal value a phpfastcacheInvalidArgumentException - * MUST be thrown. - * - */ - public function incrementItemsByTag(string $tagName, int $step = 1, int $strategy = self::TAG_STRATEGY_ONE): bool; - - /** - * Increment the items from the pool by one of multiple tag names. - * - * @param string[] $tagNames - * The tag for which to increment - * - * @param int $step - * - * @param int $strategy - * - * @return bool - * True if the items were successfully incremented. False if there was an error. - * @throws InvalidArgumentException - * If the $key string is not a legal value a phpfastcacheInvalidArgumentException - * MUST be thrown. - * - */ - public function incrementItemsByTags(array $tagNames, int $step = 1, int $strategy = self::TAG_STRATEGY_ONE): bool; - - /** - * Decrement the items from the pool by tag. - * - * @param string $tagName - * The tag for which to decrement - * - * @param int $step - * - * @param int $strategy - * - * @return bool - * True if the item was successfully decremented. False if there was an error. - * @throws InvalidArgumentException - * If the $key string is not a legal value a phpfastcacheInvalidArgumentException - * MUST be thrown. - * - */ - public function decrementItemsByTag(string $tagName, int $step = 1, int $strategy = self::TAG_STRATEGY_ONE): bool; - - /** - * Decrement the items from the pool by one of multiple tag names. - * - * @param string[] $tagNames - * The tag for which to decrement - * - * @param int $step - * - * @param int $strategy - * - * @return bool - * True if the item was successfully decremented. False if there was an error. - * @throws InvalidArgumentException - * If the $key string is not a legal value a phpfastcacheInvalidArgumentException - * MUST be thrown. - * - */ - public function decrementItemsByTags(array $tagNames, int $step = 1, int $strategy = self::TAG_STRATEGY_ONE): bool; - - /** - * Decrement the items from the pool by tag. - * - * @param string $tagName - * The tag for which to append - * - * @param array|string $data - * - * @param int $strategy - * - * @return bool - * True if the item was successfully appended. False if there was an error. - * @throws InvalidArgumentException - * If the $key string is not a legal value a phpfastcacheInvalidArgumentException - * MUST be thrown. - * - */ - public function appendItemsByTag(string $tagName, array|string $data, int $strategy = self::TAG_STRATEGY_ONE): bool; - - /** - * Append the items from the pool by one of multiple tag names. - * - * @param string[] $tagNames - * The tag for which to append - * - * @param array|string $data - * - * @param int $strategy - * - * @return bool - * True if the items were successfully appended. False if there was an error. - * @throws InvalidArgumentException - * If the $key string is not a legal value a phpfastcacheInvalidArgumentException - * MUST be thrown. - * - */ - public function appendItemsByTags(array $tagNames, array|string $data, int $strategy = self::TAG_STRATEGY_ONE): bool; - - /** - * Prepend the items from the pool by tag. - * - * @param string $tagName - * The tag for which to prepend - * - * @param array|string $data - * - * @param int $strategy - * - * @return bool - * True if the item was successfully prepended. False if there was an error. - * @throws InvalidArgumentException - * If the $key string is not a legal value a phpfastcacheInvalidArgumentException - * MUST be thrown. - * - */ - public function prependItemsByTag(string $tagName, array|string $data, int $strategy = self::TAG_STRATEGY_ONE): bool; - - /** - * Prepend the items from the pool by one of multiple tag names. - * - * @param string[] $tagNames - * The tag for which to prepend - * - * @param array|string $data - * - * @param int $strategy - * - * @return bool - * True if the item was successfully prepended. False if there was an error. - * @throws InvalidArgumentException - * If the $key string is not a legal value a phpfastcacheInvalidArgumentException - * MUST be thrown. - * - */ - public function prependItemsByTags(array $tagNames, array|string $data, int $strategy = self::TAG_STRATEGY_ONE): bool; -} diff --git a/lib/Phpfastcache/Core/Pool/TaggableCacheItemPoolTrait.php b/lib/Phpfastcache/Core/Pool/TaggableCacheItemPoolTrait.php deleted file mode 100644 index 5ae1eb282..000000000 --- a/lib/Phpfastcache/Core/Pool/TaggableCacheItemPoolTrait.php +++ /dev/null @@ -1,471 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -declare(strict_types=1); - -namespace Phpfastcache\Core\Pool; - -use DateTime; -use Phpfastcache\Core\Item\ExtendedCacheItemInterface; -use Phpfastcache\Exceptions\PhpfastcacheCoreException; -use Phpfastcache\Exceptions\PhpfastcacheDriverException; -use Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException; -use Phpfastcache\Exceptions\PhpfastcacheLogicException; -use Psr\Cache\CacheItemInterface; - -/** - * Trait TaggableCacheItemPoolTrait - * @package Phpfastcache\Core\Pool - */ -trait TaggableCacheItemPoolTrait -{ - use ExtendedCacheItemPoolTrait; - - /** - * @inheritDoc - * @throws PhpfastcacheCoreException - * @throws PhpfastcacheDriverException - * @throws PhpfastcacheInvalidArgumentException - * @throws PhpfastcacheLogicException - */ - public function getItemsByTagsAsJsonString( - array $tagNames, - int $option = \JSON_THROW_ON_ERROR, - int $depth = 512, - int $strategy = TaggableCacheItemPoolInterface::TAG_STRATEGY_ONE - ): string { - return \json_encode( - \array_map( - static fn(CacheItemInterface $item) => $item->get(), - \array_values($this->getItemsByTags($tagNames, $strategy)) - ), - $option, - $depth, - ); - } - - /** - * @inheritDoc - * @throws PhpfastcacheCoreException - * @throws PhpfastcacheDriverException - * @throws PhpfastcacheInvalidArgumentException - * @throws PhpfastcacheLogicException - */ - public function getItemsByTags(array $tagNames, int $strategy = TaggableCacheItemPoolInterface::TAG_STRATEGY_ONE): array - { - $items = []; - foreach (\array_unique($tagNames) as $tagName) { - $items[] = $this->fetchItemsByTagFromBackend($tagName); - } - - $items = \array_merge([], ...$items); - - switch ($strategy) { - case TaggableCacheItemPoolInterface::TAG_STRATEGY_ALL: - foreach ($items as $key => $item) { - if (\array_diff($tagNames, $item->getTags())) { - unset($items[$key]); - } - } - break; - - case TaggableCacheItemPoolInterface::TAG_STRATEGY_ONLY: - foreach ($items as $key => $item) { - if (\array_diff($tagNames, $item->getTags()) || \array_diff($item->getTags(), $tagNames)) { - unset($items[$key]); - } - } - break; - } - return $items; - } - - /** - * @param string $tagName - * @return ExtendedCacheItemInterface[] - * @throws PhpfastcacheCoreException - * @throws PhpfastcacheDriverException - * @throws PhpfastcacheInvalidArgumentException - * @throws PhpfastcacheLogicException - */ - protected function fetchItemsByTagFromBackend(string $tagName): array - { - $driverResponse = $this->getItem($this->getTagKey($tagName)); - - if ($driverResponse->isHit()) { - $tagsItems = (array)$driverResponse->get(); - /** - * getItems() may provide expired item(s) - * themselves provided by a cache of item - * keys based stored the tag item. - * Therefore, we pass a filter callback - * to remove the expired Item(s) provided by - * the item keys passed through getItems() - * - * #headache - */ - return \array_filter( - $this->getItems(\array_unique(\array_keys($tagsItems))), - static fn (ExtendedCacheItemInterface $item) => $item->isHit(), - ); - } - return []; - } - - /** - * @param string $key - * @return string - */ - protected function getTagKey(string $key): string - { - return TaggableCacheItemPoolInterface::DRIVER_TAGS_KEY_PREFIX . $key; - } - - /** - * @inheritDoc - * @throws PhpfastcacheCoreException - * @throws PhpfastcacheInvalidArgumentException - * @throws PhpfastcacheLogicException - * @throws PhpfastcacheDriverException - */ - public function deleteItemsByTags(array $tagNames, int $strategy = TaggableCacheItemPoolInterface::TAG_STRATEGY_ONE): bool - { - $return = true; - - foreach ($this->getItemsByTags($tagNames, $strategy) as $item) { - $result = $this->deleteItem($item->getKey()); - if ($result !== true) { - $return = $result; - } - } - - return $return; - } - - /** - * @inheritDoc - * @throws PhpfastcacheCoreException - * @throws PhpfastcacheInvalidArgumentException - * @throws PhpfastcacheLogicException - * @throws PhpfastcacheDriverException - */ - public function deleteItemsByTag(string $tagName, int $strategy = TaggableCacheItemPoolInterface::TAG_STRATEGY_ONE): bool - { - $return = true; - foreach ($this->getItemsByTag($tagName, $strategy) as $item) { - $result = $this->deleteItem($item->getKey()); - if ($result !== true) { - $return = $result; - } - } - - return $return; - } - - /** - * @inheritDoc - * @throws PhpfastcacheCoreException - * @throws PhpfastcacheDriverException - * @throws PhpfastcacheInvalidArgumentException - * @throws PhpfastcacheLogicException - */ - public function getItemsByTag(string $tagName, int $strategy = TaggableCacheItemPoolInterface::TAG_STRATEGY_ONE): array - { - $items = $this->fetchItemsByTagFromBackend($tagName); - - if ($strategy === TaggableCacheItemPoolInterface::TAG_STRATEGY_ONLY) { - foreach ($items as $key => $item) { - if (\array_diff($item->getTags(), [$tagName])) { - unset($items[$key]); - } - } - } - return $items; - } - - /** - * @inheritDoc - * @throws PhpfastcacheCoreException - * @throws PhpfastcacheDriverException - * @throws PhpfastcacheInvalidArgumentException - * @throws PhpfastcacheLogicException - * @throws \ReflectionException - */ - public function incrementItemsByTags(array $tagNames, int $step = 1, int $strategy = TaggableCacheItemPoolInterface::TAG_STRATEGY_ONE): bool - { - $return = true; - foreach ($tagNames as $tagName) { - $result = $this->incrementItemsByTag($tagName, $step, $strategy); - if ($result !== true) { - $return = $result; - } - } - - return $return; - } - - /** - * @inheritDoc - * @throws PhpfastcacheCoreException - * @throws PhpfastcacheDriverException - * @throws PhpfastcacheInvalidArgumentException - * @throws PhpfastcacheLogicException - * @throws \ReflectionException - */ - public function incrementItemsByTag(string $tagName, int $step = 1, int $strategy = TaggableCacheItemPoolInterface::TAG_STRATEGY_ONE): bool - { - foreach ($this->getItemsByTag($tagName, $strategy) as $item) { - $item->increment($step); - $this->saveDeferred($item); - } - - return $this->commit(); - } - - /** - * @inheritDoc - * @throws PhpfastcacheCoreException - * @throws PhpfastcacheDriverException - * @throws PhpfastcacheInvalidArgumentException - * @throws PhpfastcacheLogicException - * @throws \ReflectionException - */ - public function decrementItemsByTags(array $tagNames, int $step = 1, int $strategy = TaggableCacheItemPoolInterface::TAG_STRATEGY_ONE): bool - { - $return = true; - foreach ($tagNames as $tagName) { - $result = $this->decrementItemsByTag($tagName, $step, $strategy); - if ($result !== true) { - $return = $result; - } - } - - return $return; - } - - /** - * @inheritDoc - * @throws PhpfastcacheCoreException - * @throws PhpfastcacheDriverException - * @throws PhpfastcacheInvalidArgumentException - * @throws PhpfastcacheLogicException - * @throws \ReflectionException - */ - public function decrementItemsByTag(string $tagName, int $step = 1, int $strategy = TaggableCacheItemPoolInterface::TAG_STRATEGY_ONE): bool - { - foreach ($this->getItemsByTag($tagName, $strategy) as $item) { - $item->decrement($step); - $this->saveDeferred($item); - } - - return $this->commit(); - } - - /** - * @inheritDoc - * @throws PhpfastcacheCoreException - * @throws PhpfastcacheDriverException - * @throws PhpfastcacheInvalidArgumentException - * @throws PhpfastcacheLogicException - * @throws \ReflectionException - */ - public function appendItemsByTags(array $tagNames, array|string $data, int $strategy = TaggableCacheItemPoolInterface::TAG_STRATEGY_ONE): bool - { - $return = true; - foreach ($tagNames as $tagName) { - $result = $this->appendItemsByTag($tagName, $data, $strategy); - if ($result !== true) { - $return = $result; - } - } - - return $return; - } - - /** - * @inheritDoc - * @throws PhpfastcacheCoreException - * @throws PhpfastcacheDriverException - * @throws PhpfastcacheInvalidArgumentException - * @throws PhpfastcacheLogicException - * @throws \ReflectionException - */ - public function appendItemsByTag(string $tagName, array|string $data, int $strategy = TaggableCacheItemPoolInterface::TAG_STRATEGY_ONE): bool - { - foreach ($this->getItemsByTag($tagName, $strategy) as $item) { - $item->append($data); - $this->saveDeferred($item); - } - - return $this->commit(); - } - - /** - * @inheritDoc - * @throws PhpfastcacheCoreException - * @throws PhpfastcacheDriverException - * @throws PhpfastcacheInvalidArgumentException - * @throws PhpfastcacheLogicException - * @throws \ReflectionException - */ - public function prependItemsByTags(array $tagNames, array|string $data, int $strategy = TaggableCacheItemPoolInterface::TAG_STRATEGY_ONE): bool - { - $return = true; - foreach ($tagNames as $tagName) { - $result = $this->prependItemsByTag($tagName, $data, $strategy); - if ($result !== true) { - $return = $result; - } - } - - return $return; - } - - /** - * @inheritDoc - * @throws PhpfastcacheCoreException - * @throws PhpfastcacheDriverException - * @throws PhpfastcacheInvalidArgumentException - * @throws PhpfastcacheLogicException - * @throws \ReflectionException - */ - public function prependItemsByTag(string $tagName, array|string $data, int $strategy = TaggableCacheItemPoolInterface::TAG_STRATEGY_ONE): bool - { - foreach ($this->getItemsByTag($tagName, $strategy) as $item) { - $item->prepend($data); - $this->saveDeferred($item); - } - - return $this->commit(); - } - - /** - * @param array $wrapper - * @return string[] - */ - protected function driverUnwrapTags(array $wrapper): array - { - return $wrapper[TaggableCacheItemPoolInterface::DRIVER_TAGS_WRAPPER_INDEX]; - } - - /** - * @param ExtendedCacheItemInterface $item - * @throws PhpfastcacheCoreException - * @throws PhpfastcacheDriverException - * @throws PhpfastcacheInvalidArgumentException - * @throws PhpfastcacheLogicException - */ - protected function cleanItemTags(ExtendedCacheItemInterface $item): void - { - if (!empty($item->getTags()) || !empty($item->getRemovedTags())) { - $this->driverWriteTags($item->removeTags($item->getTags())); - } - } - - /** - * @param ExtendedCacheItemInterface $item - * @return bool - * @throws PhpfastcacheCoreException - * @throws PhpfastcacheInvalidArgumentException - * @throws PhpfastcacheLogicException - * @throws PhpfastcacheDriverException - */ - protected function driverWriteTags(ExtendedCacheItemInterface $item): bool - { - /** - * Do not attempt to write tags - * on tags item, it can lead - * to an infinite recursive calls - */ - if (str_starts_with($item->getKey(), TaggableCacheItemPoolInterface::DRIVER_TAGS_KEY_PREFIX)) { - throw new PhpfastcacheLogicException('Trying to set tag(s) to an Tag item index: ' . $item->getKey()); - } - - if (!$item->getTags() && !$item->getRemovedTags()) { - return true; - } - - /** - * @var $tagsItems ExtendedCacheItemInterface[] - */ - $tagsItems = $this->getItems($this->getTagKeys($item->getTags())); - - foreach ($tagsItems as $tagsItem) { - $data = $tagsItem->get(); - $expTimestamp = $item->getExpirationDate()->getTimestamp(); - - /** - * Using the key will - * avoid to use array_unique - * that has slow performances - */ - $data = \array_merge((array)$data, [$item->getKey() => $expTimestamp]); - $tagsItem->set($data); - - /** - * Recalculate the expiration date - * - * If the $tagsItem does not have - * any cache item references left - * then remove it from tagsItems index - */ - $tagsItem->expiresAt((new DateTime())->setTimestamp(max($data))); - - $this->driverWrite($tagsItem); - $tagsItem->setHit(true); - } - - /** - * Also update removed tags to - * keep the index up to date - */ - $tagsItems = $this->getItems($this->getTagKeys($item->getRemovedTags())); - - foreach ($tagsItems as $tagsItem) { - $data = (array)$tagsItem->get(); - - unset($data[$item->getKey()]); - $tagsItem->set($data); - - /** - * Recalculate the expiration date - * - * If the $tagsItem does not have - * any cache item references left - * then remove it from tagsItems index - */ - if (\count($data)) { - $tagsItem->expiresAt((new DateTime())->setTimestamp(max($data))); - $this->driverWrite($tagsItem); - $tagsItem->setHit(true); - } else { - $this->deleteItem($tagsItem->getKey()); - } - } - - return true; - } - - /** - * @param array $keys - * @return array - */ - protected function getTagKeys(array $keys): array - { - return \array_map( - fn (string $key) => $this->getTagKey($key), - $keys - ); - } -} diff --git a/lib/Phpfastcache/Drivers/Apcu/Config.php b/lib/Phpfastcache/Drivers/Apcu/Config.php deleted file mode 100644 index a0d47d9f9..000000000 --- a/lib/Phpfastcache/Drivers/Apcu/Config.php +++ /dev/null @@ -1,23 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -declare(strict_types=1); - -namespace Phpfastcache\Drivers\Apcu; - -use Phpfastcache\Config\ConfigurationOption; - -class Config extends ConfigurationOption -{ -} diff --git a/lib/Phpfastcache/Drivers/Apcu/Driver.php b/lib/Phpfastcache/Drivers/Apcu/Driver.php deleted file mode 100644 index 73d214b84..000000000 --- a/lib/Phpfastcache/Drivers/Apcu/Driver.php +++ /dev/null @@ -1,118 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -declare(strict_types=1); - -namespace Phpfastcache\Drivers\Apcu; - -use DateTime; -use Phpfastcache\Cluster\AggregatablePoolInterface; -use Phpfastcache\Core\Pool\ExtendedCacheItemPoolInterface; -use Phpfastcache\Core\Pool\TaggableCacheItemPoolTrait; -use Phpfastcache\Config\ConfigurationOption; -use Phpfastcache\Config\ConfigurationOptionInterface; -use Phpfastcache\Core\Item\ExtendedCacheItemInterface; -use Phpfastcache\Entities\DriverStatistic; -use Phpfastcache\Util\SapiDetector; -use Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException; - -/** - * Class Driver - * @method Config getConfig() - */ -class Driver implements AggregatablePoolInterface -{ - use TaggableCacheItemPoolTrait; - - /** - * @return bool - */ - public function driverCheck(): bool - { - return extension_loaded('apcu') && ((ini_get('apc.enabled') && SapiDetector::isWebScript()) || (ini_get('apc.enable_cli') && SapiDetector::isCliScript())); - } - - /** - * @return DriverStatistic - */ - public function getStats(): DriverStatistic - { - $stats = (array)apcu_cache_info(); - $date = (new DateTime())->setTimestamp($stats['start_time']); - - return (new DriverStatistic()) - ->setData(implode(', ', array_keys($this->itemInstances))) - ->setInfo( - sprintf( - "The APCU cache is up since %s, and have %d item(s) in cache.\n For more information see RawData.", - $date->format(DATE_RFC2822), - $stats['num_entries'] - ) - ) - ->setRawData($stats) - ->setSize((int)$stats['mem_size']); - } - - /** - * @return bool - */ - protected function driverConnect(): bool - { - return true; - } - - /** - * @param ExtendedCacheItemInterface $item - * @return bool - * @throws PhpfastcacheInvalidArgumentException - */ - protected function driverWrite(ExtendedCacheItemInterface $item): bool - { - - return (bool)apcu_store($item->getKey(), $this->driverPreWrap($item), $item->getTtl()); - } - - /** - * @param ExtendedCacheItemInterface $item - * @return ?array - */ - protected function driverRead(ExtendedCacheItemInterface $item): ?array - { - $data = apcu_fetch($item->getKey(), $success); - - if ($success === false || !\is_array($data)) { - return null; - } - - return $data; - } - - /** - * @param string $key - * @param string $encodedKey - * @return bool - */ - protected function driverDelete(string $key, string $encodedKey): bool - { - return (bool)apcu_delete($key); - } - - /** - * @return bool - */ - protected function driverClear(): bool - { - return @apcu_clear_cache(); - } -} diff --git a/lib/Phpfastcache/Drivers/Apcu/Item.php b/lib/Phpfastcache/Drivers/Apcu/Item.php deleted file mode 100644 index d2c250a2d..000000000 --- a/lib/Phpfastcache/Drivers/Apcu/Item.php +++ /dev/null @@ -1,30 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -declare(strict_types=1); - -namespace Phpfastcache\Drivers\Apcu; - -use Phpfastcache\Core\Item\ExtendedCacheItemInterface; -use Phpfastcache\Core\Item\TaggableCacheItemTrait; - -class Item implements ExtendedCacheItemInterface -{ - use TaggableCacheItemTrait; - - protected function getDriverClass(): string - { - return Driver::class; - } -} diff --git a/lib/Phpfastcache/Drivers/Cassandra/Config.php b/lib/Phpfastcache/Drivers/Cassandra/Config.php deleted file mode 100644 index a6f7a9dbb..000000000 --- a/lib/Phpfastcache/Drivers/Cassandra/Config.php +++ /dev/null @@ -1,172 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -declare(strict_types=1); - -namespace Phpfastcache\Drivers\Cassandra; - -use Phpfastcache\Config\ConfigurationOption; -use Phpfastcache\Exceptions\PhpfastcacheLogicException; - -class Config extends ConfigurationOption -{ - protected string $host = '127.0.0.1'; - - protected int $port = 9042; - - protected int $timeout = 2; - - protected string $username = ''; - - protected string $password = ''; - - protected bool $sslEnabled = false; - - protected bool $sslVerify = false; - - protected bool $useLegacyExecutionOptions = false; - - public function getHost(): string - { - return $this->host; - } - - /** - * @param string $host - * @throws PhpfastcacheLogicException - */ - public function setHost(string $host): static - { - return $this->setProperty('host', $host); - } - - /** - * @return int - */ - public function getPort(): int - { - return $this->port; - } - - /** - * @param int $port - * @throws PhpfastcacheLogicException - */ - public function setPort(int $port): static - { - return $this->setProperty('port', $port); - } - - /** - * @return int - */ - public function getTimeout(): int - { - return $this->timeout; - } - - /** - * @param int $timeout - * @throws PhpfastcacheLogicException - */ - public function setTimeout(int $timeout): static - { - return $this->setProperty('timeout', $timeout); - } - - /** - * @return string - */ - public function getUsername(): string - { - return $this->username; - } - - /** - * @param string $username - * @throws PhpfastcacheLogicException - */ - public function setUsername(string $username): static - { - return $this->setProperty('username', $username); - } - - /** - * @return string - */ - public function getPassword(): string - { - return $this->password; - } - - /** - * @param string $password - * @throws PhpfastcacheLogicException - */ - public function setPassword(string $password): static - { - return $this->setProperty('password', $password); - } - - /** - * @return bool - */ - public function isSslEnabled(): bool - { - return $this->sslEnabled; - } - - /** - * @param bool $sslEnabled - * @throws PhpfastcacheLogicException - */ - public function setSslEnabled(bool $sslEnabled): static - { - return $this->setProperty('sslEnabled', $sslEnabled); - } - - /** - * @return bool - */ - public function isSslVerify(): bool - { - return $this->sslVerify; - } - - /** - * @param bool $sslVerify - * @throws PhpfastcacheLogicException - */ - public function setSslVerify(bool $sslVerify): static - { - return $this->setProperty('sslVerify', $sslVerify); - } - - /** - * @return bool - */ - public function isUseLegacyExecutionOptions(): bool - { - return $this->useLegacyExecutionOptions; - } - - /** - * @param bool $useLegacyExecutionOptions - * @throws PhpfastcacheLogicException - */ - public function setUseLegacyExecutionOptions(bool $useLegacyExecutionOptions): static - { - return $this->setProperty('useLegacyExecutionOptions', $useLegacyExecutionOptions); - } -} diff --git a/lib/Phpfastcache/Drivers/Cassandra/Driver.php b/lib/Phpfastcache/Drivers/Cassandra/Driver.php deleted file mode 100644 index 54c4c5b6d..000000000 --- a/lib/Phpfastcache/Drivers/Cassandra/Driver.php +++ /dev/null @@ -1,318 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -declare(strict_types=1); - -namespace Phpfastcache\Drivers\Cassandra; - -use Cassandra; -use Cassandra\Exception; -use Cassandra\Exception\InvalidArgumentException; -use Cassandra\Session as CassandraSession; -use DateTime; -use Phpfastcache\Cluster\AggregatablePoolInterface; -use Phpfastcache\Core\Item\ExtendedCacheItemInterface; -use Phpfastcache\Core\Pool\ExtendedCacheItemPoolInterface; -use Phpfastcache\Core\Pool\TaggableCacheItemPoolTrait; -use Phpfastcache\Entities\DriverStatistic; -use Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException; -use Phpfastcache\Exceptions\PhpfastcacheLogicException; - -/** - * Class Driver - * @property CassandraSession|null $instance Instance of driver service - * @method Config getConfig() - */ -class Driver implements AggregatablePoolInterface -{ - use TaggableCacheItemPoolTrait; - - protected const CASSANDRA_KEY_SPACE = 'phpfastcache'; - protected const CASSANDRA_TABLE = 'cacheItems'; - - /** - * @return bool - */ - public function driverCheck(): bool - { - return extension_loaded('Cassandra') && class_exists(Cassandra::class); - } - - /** - * @return bool - * @throws PhpfastcacheLogicException - * @throws Exception - */ - protected function driverConnect(): bool - { - $clientConfig = $this->getConfig(); - - $clusterBuilder = Cassandra::cluster() - ->withContactPoints($clientConfig->getHost()) - ->withPort($clientConfig->getPort()); - - if (!empty($clientConfig->isSslEnabled())) { - $sslBuilder = Cassandra::ssl(); - if (!empty($clientConfig->isSslVerify())) { - $sslBuilder->withVerifyFlags(Cassandra::VERIFY_PEER_CERT); - } else { - $sslBuilder->withVerifyFlags(Cassandra::VERIFY_NONE); - } - - $clusterBuilder->withSSL($sslBuilder->build()); - } - - $clusterBuilder->withConnectTimeout($clientConfig->getTimeout()); - - if ($clientConfig->getUsername()) { - $clusterBuilder->withCredentials($clientConfig->getUsername(), $clientConfig->getPassword()); - } - - $this->instance = $clusterBuilder->build()->connect(''); - - /** - * In case of emergency: - * $this->instance->execute( - * new Cassandra\SimpleStatement(\sprintf("DROP KEYSPACE %s;", self::CASSANDRA_KEY_SPACE)) - * ); - */ - - $this->instance->execute( - new Cassandra\SimpleStatement( - sprintf( - "CREATE KEYSPACE IF NOT EXISTS %s WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 };", - self::CASSANDRA_KEY_SPACE - ) - ), - [] - ); - $this->instance->execute(new Cassandra\SimpleStatement(sprintf('USE %s;', self::CASSANDRA_KEY_SPACE)), []); - $this->instance->execute( - new Cassandra\SimpleStatement( - sprintf( - ' - CREATE TABLE IF NOT EXISTS %s ( - cache_uuid uuid, - cache_id varchar, - cache_data text, - cache_creation_date timestamp, - cache_expiration_date timestamp, - cache_length int, - PRIMARY KEY (cache_id) - );', - self::CASSANDRA_TABLE - ) - ), - [] - ); - - return true; - } - - /** - * @param ExtendedCacheItemInterface $item - * @return ?array - */ - protected function driverRead(ExtendedCacheItemInterface $item): ?array - { - try { - $options = $this->getCompatibleExecutionOptionsArgument( - [ - 'arguments' => ['cache_id' => $item->getKey()], - 'page_size' => 1, - ] - ); - $query = sprintf( - 'SELECT cache_data FROM %s.%s WHERE cache_id = :cache_id;', - self::CASSANDRA_KEY_SPACE, - self::CASSANDRA_TABLE - ); - $results = $this->instance->execute(new Cassandra\SimpleStatement($query), $options); - - if ($results instanceof Cassandra\Rows && $results->count() === 1) { - return $this->decode($results->first()['cache_data']) ?: null; - } - - return null; - } catch (Exception $e) { - return null; - } - } - - /** - * @param ExtendedCacheItemInterface $item - * @return bool - * @throws PhpfastcacheInvalidArgumentException - */ - protected function driverWrite(ExtendedCacheItemInterface $item): bool - { - - try { - $cacheData = $this->encode($this->driverPreWrap($item)); - $options = $this->getCompatibleExecutionOptionsArgument( - [ - 'arguments' => [ - 'cache_uuid' => new Cassandra\Uuid(''), - 'cache_id' => $item->getKey(), - 'cache_data' => $cacheData, - 'cache_creation_date' => new Cassandra\Timestamp((new DateTime())->getTimestamp(), 0), - 'cache_expiration_date' => new Cassandra\Timestamp($item->getExpirationDate()->getTimestamp(), 0), - 'cache_length' => strlen($cacheData), - ], - 'consistency' => Cassandra::CONSISTENCY_ALL, - 'serial_consistency' => Cassandra::CONSISTENCY_SERIAL, - ] - ); - - $query = sprintf( - 'INSERT INTO %s.%s - ( - cache_uuid, - cache_id, - cache_data, - cache_creation_date, - cache_expiration_date, - cache_length - ) - VALUES (:cache_uuid, :cache_id, :cache_data, :cache_creation_date, :cache_expiration_date, :cache_length); - ', - self::CASSANDRA_KEY_SPACE, - self::CASSANDRA_TABLE - ); - - $result = $this->instance->execute(new Cassandra\SimpleStatement($query), $options); - /** - * There's no real way atm - * to know if the item has - * been really upserted - */ - return $result instanceof Cassandra\Rows; - } catch (InvalidArgumentException $e) { - throw new PhpfastcacheInvalidArgumentException($e->getMessage(), 0, $e); - } - } - - /** - * @param string $key - * @param string $encodedKey - * @return bool - */ - protected function driverDelete(string $key, string $encodedKey): bool - { - - try { - $options = $this->getCompatibleExecutionOptionsArgument( - [ - 'arguments' => [ - 'cache_id' => $key, - ], - ] - ); - $result = $this->instance->execute( - new Cassandra\SimpleStatement( - sprintf( - 'DELETE FROM %s.%s WHERE cache_id = :cache_id;', - self::CASSANDRA_KEY_SPACE, - self::CASSANDRA_TABLE - ) - ), - $options - ); - - /** - * There's no real way atm - * to know if the item has - * been really deleted - */ - return $result instanceof Cassandra\Rows; - } catch (Exception $e) { - return false; - } - } - - /** - * @return bool - */ - protected function driverClear(): bool - { - try { - $this->instance->execute( - new Cassandra\SimpleStatement( - sprintf( - 'TRUNCATE %s.%s;', - self::CASSANDRA_KEY_SPACE, - self::CASSANDRA_TABLE - ) - ), - null - ); - - return true; - } catch (Exception) { - return false; - } - } - - /** - * @return string - */ - public function getHelp(): string - { - return << -To install the php Cassandra extension via Pecl: -sudo pecl install cassandra -More information on: https://github.com/datastax/php-driver -Please note that this repository only provide php stubs and C/C++ sources, it does NOT provide php client. -

-HELP; - } - - /** - * @return DriverStatistic - * @throws Exception - */ - public function getStats(): DriverStatistic - { - $result = $this->instance->execute( - new Cassandra\SimpleStatement( - sprintf( - 'SELECT SUM(cache_length) as cache_size FROM %s.%s', - self::CASSANDRA_KEY_SPACE, - self::CASSANDRA_TABLE - ) - ), - null - ); - - return (new DriverStatistic()) - ->setSize($result->first()['cache_size']) - ->setRawData([]) - ->setData(implode(', ', array_keys($this->itemInstances))) - ->setInfo('The cache size represents only the cache data itself without counting data structures associated to the cache entries.'); - } - - /** - * @param array $options - * @return array|Cassandra\ExecutionOptions - */ - protected function getCompatibleExecutionOptionsArgument(array $options): mixed - { - if ($this->getConfig()->isUseLegacyExecutionOptions()) { - return new Cassandra\ExecutionOptions($options); - } - - return $options; - } -} diff --git a/lib/Phpfastcache/Drivers/Cassandra/Item.php b/lib/Phpfastcache/Drivers/Cassandra/Item.php deleted file mode 100644 index f902fedb7..000000000 --- a/lib/Phpfastcache/Drivers/Cassandra/Item.php +++ /dev/null @@ -1,30 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -declare(strict_types=1); - -namespace Phpfastcache\Drivers\Cassandra; - -use Phpfastcache\Core\Item\ExtendedCacheItemInterface; -use Phpfastcache\Core\Item\TaggableCacheItemTrait; - -class Item implements ExtendedCacheItemInterface -{ - use TaggableCacheItemTrait; - - protected function getDriverClass(): string - { - return Driver::class; - } -} diff --git a/lib/Phpfastcache/Drivers/Couchbasev3/Config.php b/lib/Phpfastcache/Drivers/Couchbasev3/Config.php deleted file mode 100644 index 3cda982b1..000000000 --- a/lib/Phpfastcache/Drivers/Couchbasev3/Config.php +++ /dev/null @@ -1,157 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -declare(strict_types=1); - -namespace Phpfastcache\Drivers\Couchbasev3; - -use Phpfastcache\Config\ConfigurationOption; -use Phpfastcache\Exceptions\PhpfastcacheLogicException; - -class Config extends ConfigurationOption -{ - protected const DEFAULT_VALUE = '_default'; - protected string $host = '127.0.0.1'; - protected int $port = 8091; -// SSL: 18091 - - protected string $username = ''; - protected string $password = ''; - protected string $bucketName = self::DEFAULT_VALUE; - protected string $scopeName = self::DEFAULT_VALUE; - protected string $collectionName = self::DEFAULT_VALUE; - - - public function getHost(): string - { - return $this->host; - } - - /** - * @param string $host - * @return Config - * @throws PhpfastcacheLogicException - */ - public function setHost(string $host): Config - { - return $this->setProperty('host', $host); - } - - /** - * @return int - */ - public function getPort() - { - return $this->port; - } - - /** - * @param int $port - * @return Config - * @throws PhpfastcacheLogicException - */ - public function setPort(int $port): Config - { - return $this->setProperty('port', $port); - } - - /** - * @return string - */ - public function getUsername(): string - { - return $this->username; - } - - /** - * @param string $username - * @return Config - * @throws PhpfastcacheLogicException - */ - public function setUsername(string $username): Config - { - return $this->setProperty('username', $username); - } - - /** - * @return string - */ - public function getPassword(): string - { - return $this->password; - } - - /** - * @param string $password - * @return Config - * @throws PhpfastcacheLogicException - */ - public function setPassword(string $password): Config - { - return $this->setProperty('password', $password); - } - - /** - * @return string - */ - public function getBucketName(): string - { - return $this->bucketName; - } - - /** - * @param string $bucketName - * @return Config - * @throws PhpfastcacheLogicException - */ - public function setBucketName(string $bucketName): Config - { - return $this->setProperty('bucketName', $bucketName); - } - /** - * @return string - */ - public function getScopeName(): string - { - return $this->scopeName; - } - - /** - * @param string $scopeName - * @return Config - * @throws PhpfastcacheLogicException - */ - public function setScopeName(string $scopeName): Config - { - return $this->setProperty('scopeName', $scopeName); - } - - /** - * @return string - */ - public function getCollectionName(): string - { - return $this->collectionName; - } - - /** - * @param string $collectionName - * @return Config - * @throws PhpfastcacheLogicException - */ - public function setCollectionName(string $collectionName): Config - { - return $this->setProperty('collectionName', $collectionName); - } -} diff --git a/lib/Phpfastcache/Drivers/Couchbasev3/Driver.php b/lib/Phpfastcache/Drivers/Couchbasev3/Driver.php deleted file mode 100644 index 15a19cc6d..000000000 --- a/lib/Phpfastcache/Drivers/Couchbasev3/Driver.php +++ /dev/null @@ -1,324 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -declare(strict_types=1); - -namespace Phpfastcache\Drivers\Couchbasev3; - -use Couchbase\BaseException as CouchbaseException; -use Couchbase\Bucket as CouchbaseBucket; -use Couchbase\Cluster; -use Couchbase\ClusterOptions; -use Couchbase\Collection; -use Couchbase\DocumentNotFoundException; -use Couchbase\GetResult; -use Couchbase\Scope; -use Couchbase\UpsertOptions; -use DateTimeInterface; -use Phpfastcache\Cluster\AggregatablePoolInterface; -use Phpfastcache\Config\ConfigurationOption; -use Phpfastcache\Core\Item\ExtendedCacheItemInterface; -use Phpfastcache\Core\Pool\ExtendedCacheItemPoolInterface; -use Phpfastcache\Core\Pool\TaggableCacheItemPoolTrait; -use Phpfastcache\Entities\DriverStatistic; -use Phpfastcache\Event\EventManagerInterface; -use Phpfastcache\Exceptions\PhpfastcacheDriverCheckException; -use Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException; -use Phpfastcache\Exceptions\PhpfastcacheLogicException; -use Phpfastcache\Exceptions\PhpfastcacheUnsupportedException; -use Phpfastcache\Exceptions\PhpfastcacheUnsupportedMethodException; - -/** - * @property Cluster $instance Instance of driver service - * @method Config getConfig() - * @SuppressWarnings(PHPMD.CouplingBetweenObjects) - */ -class Driver implements AggregatablePoolInterface -{ - use TaggableCacheItemPoolTrait; - - protected Scope $scope; - - protected Collection $collection; - - protected CouchbaseBucket $bucketInstance; - - /** - * @return bool - */ - public function driverCheck(): bool - { - return extension_loaded('couchbase'); - } - - /** - * @return bool - * @throws PhpfastcacheDriverCheckException - */ - protected function driverConnect(): bool - { - if (!\class_exists(ClusterOptions::class)) { - throw new PhpfastcacheDriverCheckException('You are using the Couchbase PHP SDK 2.x which is no longer supported in Phpfastcache v9'); - } - - $connectionString = "couchbase://{$this->getConfig()->getHost()}:{$this->getConfig()->getPort()}"; - - $options = new ClusterOptions(); - $options->credentials($this->getConfig()->getUsername(), $this->getConfig()->getPassword()); - $this->instance = new Cluster($connectionString, $options); - - $this->setBucket($this->instance->bucket($this->getConfig()->getBucketName())); - $this->setScope($this->getBucket()->scope($this->getConfig()->getScopeName())); - $this->setCollection($this->getScope()->collection($this->getConfig()->getCollectionName())); - - return true; - } - - /** - * @param ExtendedCacheItemInterface $item - * @return ?array - */ - protected function driverRead(ExtendedCacheItemInterface $item): ?array - { - try { - /** - * CouchbaseBucket::get() returns a GetResult interface - */ - return $this->decodeDocument((array)$this->getCollection()->get($item->getEncodedKey())->content()); - } catch (DocumentNotFoundException) { - return null; - } - } - - /** - * @param ExtendedCacheItemInterface $item - * @return array> - */ - protected function driverReadMultiple(ExtendedCacheItemInterface ...$items): array - { - try { - $results = []; - /** - * CouchbaseBucket::get() returns a GetResult interface - */ - /** @var GetResult $document */ - foreach ($this->getCollection()->getMulti($this->getKeys($items, true)) as $document) { - $content = $document->content(); - if ($content) { - $decodedDocument = $this->decodeDocument($content); - $results[$decodedDocument[ExtendedCacheItemPoolInterface::DRIVER_KEY_WRAPPER_INDEX]] = $this->decodeDocument($content); - } - } - - return $results; - } catch (DocumentNotFoundException) { - return []; - } - } - - /** - * @param ExtendedCacheItemInterface $item - * @return bool - * @throws PhpfastcacheInvalidArgumentException - * @throws PhpfastcacheLogicException - */ - protected function driverWrite(ExtendedCacheItemInterface $item): bool - { - - try { - $this->getCollection()->upsert( - $item->getEncodedKey(), - $this->encodeDocument($this->driverPreWrap($item)), - (new UpsertOptions())->expiry($item->getTtl()) - ); - return true; - } catch (CouchbaseException) { - return false; - } - } - - /** - * @param string $key - * @param string $encodedKey - * @return bool - */ - protected function driverDelete(string $key, string $encodedKey): bool - { - - try { - return $this->getCollection()->remove($encodedKey)->mutationToken() !== null; - } catch (DocumentNotFoundException) { - return true; - } catch (CouchbaseException) { - return false; - } - } - - - /** - * @param string[] $keys - * @return bool - */ - protected function driverDeleteMultiple(array $keys): bool - { - try { - $this->getCollection()->removeMulti(array_map(fn(string $key) => $this->getEncodedKey($key), $keys)); - return true; - } catch (CouchbaseException) { - return false; - } - } - - - /** - * @return bool - * @throws PhpfastcacheUnsupportedMethodException - */ - protected function driverClear(): bool - { - if (!$this->instance->buckets()->getBucket($this->getConfig()->getBucketName())->flushEnabled()) { - $this->instance->buckets()->getBucket($this->getConfig()->getBucketName())->enableFlush(true); - /** @phpstan-ignore-next-line */ - if (!$this->instance->buckets()->getBucket($this->getConfig()->getBucketName())->flushEnabled()) { - throw new PhpfastcacheUnsupportedMethodException( - 'Flushing operation is not enabled on your Bucket. See https://docs.couchbase.com/server/current/manage/manage-buckets/flush-bucket.html' - ); - } - } - - $this->instance->buckets()->flush($this->getConfig()->getBucketName()); - - return true; - } - - /** - * @return DriverStatistic - * @throws \Exception - */ - public function getStats(): DriverStatistic - { - /** - * Between SDK 2 and 3 we lost a lot of useful information :( - * @see https://docs.couchbase.com/java-sdk/current/project-docs/migrating-sdk-code-to-3.n.html#management-apis - */ - $info = $this->getBucket()->diagnostics(\bin2hex(\random_bytes(16))); - - return (new DriverStatistic()) - ->setSize(0) - ->setRawData($info) - ->setData(implode(', ', array_keys($this->itemInstances))) - ->setInfo($info['sdk'] . "\n For more information see RawData."); - } - - /** - * @return Collection - */ - public function getCollection(): Collection - { - return $this->collection; - } - - /** - * @param Collection $collection - * @return Driver - */ - public function setCollection(Collection $collection): Driver - { - $this->collection = $collection; - return $this; - } - - /** - * @return Scope - */ - public function getScope(): Scope - { - return $this->scope; - } - - /** - * @param Scope $scope - * @return Driver - */ - public function setScope(Scope $scope): Driver - { - $this->scope = $scope; - return $this; - } - - /** - * @return CouchbaseBucket - */ - protected function getBucket(): CouchbaseBucket - { - return $this->bucketInstance; - } - - /** - * @param CouchbaseBucket $couchbaseBucket - */ - protected function setBucket(CouchbaseBucket $couchbaseBucket): void - { - $this->bucketInstance = $couchbaseBucket; - } - - - /** - * @param array $data - * @return array - */ - protected function encodeDocument(array $data): array - { - $data[ExtendedCacheItemPoolInterface::DRIVER_DATA_WRAPPER_INDEX] = $this->encode($data[ExtendedCacheItemPoolInterface::DRIVER_DATA_WRAPPER_INDEX]); - $data[ExtendedCacheItemPoolInterface::DRIVER_EDATE_WRAPPER_INDEX] = $data[ExtendedCacheItemPoolInterface::DRIVER_EDATE_WRAPPER_INDEX] - ->format(DateTimeInterface::ATOM); - - if ($this->getConfig()->isItemDetailedDate()) { - $data[ExtendedCacheItemPoolInterface::DRIVER_CDATE_WRAPPER_INDEX] = $data[ExtendedCacheItemPoolInterface::DRIVER_CDATE_WRAPPER_INDEX] - ->format(\DateTimeInterface::ATOM); - - $data[ExtendedCacheItemPoolInterface::DRIVER_MDATE_WRAPPER_INDEX] = $data[ExtendedCacheItemPoolInterface::DRIVER_MDATE_WRAPPER_INDEX] - ->format(\DateTimeInterface::ATOM); - } - - return $data; - } - - /** - * @param array $data - * @return array - */ - protected function decodeDocument(array $data): array - { - $data[ExtendedCacheItemPoolInterface::DRIVER_DATA_WRAPPER_INDEX] = $this->unserialize($data[ExtendedCacheItemPoolInterface::DRIVER_DATA_WRAPPER_INDEX]); - $data[ExtendedCacheItemPoolInterface::DRIVER_EDATE_WRAPPER_INDEX] = \DateTime::createFromFormat( - \DateTimeInterface::ATOM, - $data[ExtendedCacheItemPoolInterface::DRIVER_EDATE_WRAPPER_INDEX] - ); - - if ($this->getConfig()->isItemDetailedDate()) { - $data[ExtendedCacheItemPoolInterface::DRIVER_CDATE_WRAPPER_INDEX] = \DateTime::createFromFormat( - \DateTimeInterface::ATOM, - $data[ExtendedCacheItemPoolInterface::DRIVER_CDATE_WRAPPER_INDEX] - ); - - $data[ExtendedCacheItemPoolInterface::DRIVER_MDATE_WRAPPER_INDEX] = \DateTime::createFromFormat( - \DateTimeInterface::ATOM, - $data[ExtendedCacheItemPoolInterface::DRIVER_MDATE_WRAPPER_INDEX] - ); - } - - return $data; - } -} diff --git a/lib/Phpfastcache/Drivers/Couchbasev3/Item.php b/lib/Phpfastcache/Drivers/Couchbasev3/Item.php deleted file mode 100644 index 5fd389471..000000000 --- a/lib/Phpfastcache/Drivers/Couchbasev3/Item.php +++ /dev/null @@ -1,30 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -declare(strict_types=1); - -namespace Phpfastcache\Drivers\Couchbasev3; - -use Phpfastcache\Core\Item\ExtendedCacheItemInterface; -use Phpfastcache\Core\Item\TaggableCacheItemTrait; - -class Item implements ExtendedCacheItemInterface -{ - use TaggableCacheItemTrait; - - protected function getDriverClass(): string - { - return Driver::class; - } -} diff --git a/lib/Phpfastcache/Drivers/Devnull/Config.php b/lib/Phpfastcache/Drivers/Devnull/Config.php deleted file mode 100644 index d6dad2bf3..000000000 --- a/lib/Phpfastcache/Drivers/Devnull/Config.php +++ /dev/null @@ -1,23 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -declare(strict_types=1); - -namespace Phpfastcache\Drivers\Devnull; - -use Phpfastcache\Config\ConfigurationOption; - -class Config extends ConfigurationOption -{ -} diff --git a/lib/Phpfastcache/Drivers/Devnull/Driver.php b/lib/Phpfastcache/Drivers/Devnull/Driver.php deleted file mode 100644 index aa47640bd..000000000 --- a/lib/Phpfastcache/Drivers/Devnull/Driver.php +++ /dev/null @@ -1,101 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -declare(strict_types=1); - -namespace Phpfastcache\Drivers\Devnull; - -use Phpfastcache\Core\Item\ExtendedCacheItemInterface; -use Phpfastcache\Core\Pool\ExtendedCacheItemPoolInterface; -use Phpfastcache\Core\Pool\TaggableCacheItemPoolTrait; -use Phpfastcache\Entities\DriverStatistic; -use Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException; -use Psr\Cache\CacheItemInterface; - -/** - * Class Driver - * @method Config getConfig() - */ -class Driver implements ExtendedCacheItemPoolInterface -{ - use TaggableCacheItemPoolTrait; - - /** - * @return bool - */ - public function driverCheck(): bool - { - return true; - } - - /** - * @return DriverStatistic - */ - public function getStats(): DriverStatistic - { - $stat = new DriverStatistic(); - $stat->setInfo('[Devnull] A void info string') - ->setSize(0) - ->setData(implode(', ', array_keys($this->itemInstances))) - ->setRawData(null); - - return $stat; - } - - /** - * @param ExtendedCacheItemInterface $item - * @return mixed - * @throws PhpfastcacheInvalidArgumentException - */ - protected function driverWrite(ExtendedCacheItemInterface $item): bool - { - - return true; - } - - /** - * @param ExtendedCacheItemInterface $item - * @return ?array - */ - protected function driverRead(CacheItemInterface $item): ?array - { - return null; - } - - /** - * @param string $key - * @param string $encodedKey - * @return bool - */ - protected function driverDelete(string $key, string $encodedKey): bool - { - return true; - } - - /** - * @return bool - */ - protected function driverClear(): bool - { - return true; - } - - /** - * @return bool - */ - protected function driverConnect(): bool - { - return true; - } -} diff --git a/lib/Phpfastcache/Drivers/Devnull/Item.php b/lib/Phpfastcache/Drivers/Devnull/Item.php deleted file mode 100644 index 948e73c4f..000000000 --- a/lib/Phpfastcache/Drivers/Devnull/Item.php +++ /dev/null @@ -1,33 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -declare(strict_types=1); - -namespace Phpfastcache\Drivers\Devnull; - -use Phpfastcache\Core\Item\ExtendedCacheItemInterface; -use Phpfastcache\Core\Item\TaggableCacheItemTrait; - -/** - * Class Item - */ -class Item implements ExtendedCacheItemInterface -{ - use TaggableCacheItemTrait; - - protected function getDriverClass(): string - { - return Driver::class; - } -} diff --git a/lib/Phpfastcache/Drivers/Devrandom/Config.php b/lib/Phpfastcache/Drivers/Devrandom/Config.php deleted file mode 100644 index cd4aa9009..000000000 --- a/lib/Phpfastcache/Drivers/Devrandom/Config.php +++ /dev/null @@ -1,66 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -declare(strict_types=1); - -namespace Phpfastcache\Drivers\Devrandom; - -use Phpfastcache\Config\ConfigurationOption; -use Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException; -use Phpfastcache\Exceptions\PhpfastcacheLogicException; - -class Config extends ConfigurationOption -{ - protected int $dataLength = 16; - protected int $chanceOfRetrieval = 50; -/** - * @return int - */ - public function getDataLength(): int - { - return $this->dataLength; - } - - /** - * @param int $dataLength - * @return Config - * @throws PhpfastcacheLogicException - */ - public function setDataLength(int $dataLength): Config - { - return $this->setProperty('dataLength', $dataLength); - } - - /** - * @return int - */ - public function getChanceOfRetrieval(): int - { - return $this->chanceOfRetrieval; - } - - /** - * @param int $chanceOfRetrieval - * @return Config - * @throws PhpfastcacheInvalidArgumentException - * @throws PhpfastcacheLogicException - */ - public function setChanceOfRetrieval(int $chanceOfRetrieval): Config - { - if ($chanceOfRetrieval < 0 || $chanceOfRetrieval > 100) { - throw new PhpfastcacheInvalidArgumentException('Chance of retrieval must be between 0 and 100'); - } - return $this->setProperty('chanceOfRetrieval', $chanceOfRetrieval); - } -} diff --git a/lib/Phpfastcache/Drivers/Devrandom/Driver.php b/lib/Phpfastcache/Drivers/Devrandom/Driver.php deleted file mode 100644 index 24cc73756..000000000 --- a/lib/Phpfastcache/Drivers/Devrandom/Driver.php +++ /dev/null @@ -1,114 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -declare(strict_types=1); - -namespace Phpfastcache\Drivers\Devrandom; - -use DateInterval; -use DateTime; -use Phpfastcache\Core\Item\ExtendedCacheItemInterface; -use Phpfastcache\Core\Pool\ExtendedCacheItemPoolInterface; -use Phpfastcache\Core\Pool\TaggableCacheItemPoolTrait; -use Phpfastcache\Entities\DriverStatistic; -use Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException; -use Psr\Cache\CacheItemInterface; - -/** - * @method Config getConfig() - */ -class Driver implements ExtendedCacheItemPoolInterface -{ - use TaggableCacheItemPoolTrait; - - /** - * @return bool - */ - public function driverCheck(): bool - { - return true; - } - - /** - * @return DriverStatistic - */ - public function getStats(): DriverStatistic - { - $stat = new DriverStatistic(); - $stat->setInfo('[Devrandom] A void info string') - ->setSize(0) - ->setData(implode(', ', array_keys($this->itemInstances))) - ->setRawData(false); - - return $stat; - } - - /** - * @param ExtendedCacheItemInterface $item - * @return bool - * @throws PhpfastcacheInvalidArgumentException - */ - protected function driverWrite(ExtendedCacheItemInterface $item): bool - { - - return true; - } - - /** - * @param ExtendedCacheItemInterface $item - * @return ?array - * @throws \Exception - */ - protected function driverRead(CacheItemInterface $item): ?array - { - $chanceOfRetrieval = $this->getConfig()->getChanceOfRetrieval(); - $ttl = $this->getConfig()->getDefaultTtl(); - - if (\random_int(0, 100) < $chanceOfRetrieval) { - return [ - self::DRIVER_DATA_WRAPPER_INDEX => \bin2hex(\random_bytes($this->getConfig()->getDataLength())), - self::DRIVER_TAGS_WRAPPER_INDEX => [], - self::DRIVER_EDATE_WRAPPER_INDEX => (new DateTime())->add(new DateInterval("PT{$ttl}S")), - ]; - } - - return null; - } - - /** - * @param string $key - * @param string $encodedKey - * @return bool - */ - protected function driverDelete(string $key, string $encodedKey): bool - { - return true; - } - - /** - * @return bool - */ - protected function driverClear(): bool - { - return true; - } - - /** - * @return bool - */ - protected function driverConnect(): bool - { - return true; - } -} diff --git a/lib/Phpfastcache/Drivers/Devrandom/Item.php b/lib/Phpfastcache/Drivers/Devrandom/Item.php deleted file mode 100644 index 75c82f98e..000000000 --- a/lib/Phpfastcache/Drivers/Devrandom/Item.php +++ /dev/null @@ -1,30 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -declare(strict_types=1); - -namespace Phpfastcache\Drivers\Devrandom; - -use Phpfastcache\Core\Item\ExtendedCacheItemInterface; -use Phpfastcache\Core\Item\TaggableCacheItemTrait; - -class Item implements ExtendedCacheItemInterface -{ - use TaggableCacheItemTrait; - - protected function getDriverClass(): string - { - return Driver::class; - } -} diff --git a/lib/Phpfastcache/Drivers/Files/Config.php b/lib/Phpfastcache/Drivers/Files/Config.php deleted file mode 100644 index 612a1015c..000000000 --- a/lib/Phpfastcache/Drivers/Files/Config.php +++ /dev/null @@ -1,24 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -declare(strict_types=1); - -namespace Phpfastcache\Drivers\Files; - -use Phpfastcache\Config\IOConfigurationOptionInterface; -use Phpfastcache\Config\IOConfigurationOption; - -class Config extends IOConfigurationOption implements IOConfigurationOptionInterface -{ -} diff --git a/lib/Phpfastcache/Drivers/Files/Driver.php b/lib/Phpfastcache/Drivers/Files/Driver.php deleted file mode 100644 index 87782ce08..000000000 --- a/lib/Phpfastcache/Drivers/Files/Driver.php +++ /dev/null @@ -1,129 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -declare(strict_types=1); - -namespace Phpfastcache\Drivers\Files; - -use Exception; -use FilesystemIterator; -use Phpfastcache\Cluster\AggregatablePoolInterface; -use Phpfastcache\Core\Pool\ExtendedCacheItemPoolInterface; -use Phpfastcache\Core\Pool\IO\IOHelperTrait; -use Phpfastcache\Core\Item\ExtendedCacheItemInterface; -use Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException; -use Phpfastcache\Exceptions\PhpfastcacheIOException; -use Phpfastcache\Exceptions\PhpfastcacheLogicException; -use Phpfastcache\Util\Directory; - -/** - * @method Config getConfig() - * - * Important NOTE: - * We are using getKey instead of getEncodedKey since this backend create filename that are - * managed by defaultFileNameHashFunction and not defaultKeyHashFunction - */ -class Driver implements AggregatablePoolInterface -{ - use IOHelperTrait; - - /** - * @return bool - * @throws PhpfastcacheIOException - * @throws PhpfastcacheInvalidArgumentException - */ - public function driverCheck(): bool - { - return is_writable($this->getPath()) || mkdir($concurrentDirectory = $this->getPath(), $this->getDefaultChmod(), true) || is_dir($concurrentDirectory); - } - - /** - * @return bool - */ - protected function driverConnect(): bool - { - return true; - } - - /** - * @param ExtendedCacheItemInterface $item - * @return ?array - * @throws PhpfastcacheIOException - */ - protected function driverRead(ExtendedCacheItemInterface $item): ?array - { - $filePath = $this->getFilePath($item->getKey(), true); - - try { - $content = $this->readFile($filePath); - } catch (PhpfastcacheIOException) { - return null; - } - - return $this->decode($content); - } - - /** - * @param ExtendedCacheItemInterface $item - * @return bool - * @throws PhpfastcacheIOException - * @throws PhpfastcacheInvalidArgumentException - * @throws PhpfastcacheLogicException - */ - protected function driverWrite(ExtendedCacheItemInterface $item): bool - { - - $filePath = $this->getFilePath($item->getKey()); - $data = $this->encode($this->driverPreWrap($item)); - - try { - return $this->writeFile($filePath, $data, $this->getConfig()->isSecureFileManipulation()); - } catch (Exception) { - return false; - } - } - - /** - * @param string $key - * @param string $encodedKey - * @return bool - * @throws PhpfastcacheIOException - * @throws PhpfastcacheInvalidArgumentException - */ - protected function driverDelete(string $key, string $encodedKey): bool - { - - $filePath = $this->getFilePath($key, true); - if (\file_exists($filePath) && @\unlink($filePath)) { - \clearstatcache(true, $filePath); - $dir = \dirname($filePath); - if (!(new FilesystemIterator($dir))->valid()) { - \rmdir($dir); - } - return true; - } - - return false; - } - - /** - * @return bool - * @throws \Phpfastcache\Exceptions\PhpfastcacheIOException - * @throws PhpfastcacheInvalidArgumentException - */ - protected function driverClear(): bool - { - return Directory::rrmdir($this->getPath(true)); - } -} diff --git a/lib/Phpfastcache/Drivers/Files/Item.php b/lib/Phpfastcache/Drivers/Files/Item.php deleted file mode 100644 index 409284558..000000000 --- a/lib/Phpfastcache/Drivers/Files/Item.php +++ /dev/null @@ -1,30 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -declare(strict_types=1); - -namespace Phpfastcache\Drivers\Files; - -use Phpfastcache\Core\Item\ExtendedCacheItemInterface; -use Phpfastcache\Core\Item\TaggableCacheItemTrait; - -class Item implements ExtendedCacheItemInterface -{ - use TaggableCacheItemTrait; - - protected function getDriverClass(): string - { - return Driver::class; - } -} diff --git a/lib/Phpfastcache/Drivers/Leveldb/Config.php b/lib/Phpfastcache/Drivers/Leveldb/Config.php deleted file mode 100644 index 3cff179d4..000000000 --- a/lib/Phpfastcache/Drivers/Leveldb/Config.php +++ /dev/null @@ -1,24 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -declare(strict_types=1); - -namespace Phpfastcache\Drivers\Leveldb; - -use Phpfastcache\Config\IOConfigurationOptionInterface; -use Phpfastcache\Config\IOConfigurationOption; - -class Config extends IOConfigurationOption implements IOConfigurationOptionInterface -{ -} diff --git a/lib/Phpfastcache/Drivers/Leveldb/Driver.php b/lib/Phpfastcache/Drivers/Leveldb/Driver.php deleted file mode 100644 index dcbf121a7..000000000 --- a/lib/Phpfastcache/Drivers/Leveldb/Driver.php +++ /dev/null @@ -1,135 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -declare(strict_types=1); - -namespace Phpfastcache\Drivers\Leveldb; - -use LevelDB as LeveldbClient; -use Phpfastcache\Cluster\AggregatablePoolInterface; -use Phpfastcache\Core\Pool\ExtendedCacheItemPoolInterface; -use Phpfastcache\Core\Pool\IO\IOHelperTrait; -use Phpfastcache\Core\Pool\TaggableCacheItemPoolTrait; -use Phpfastcache\Core\Item\ExtendedCacheItemInterface; -use Phpfastcache\Exceptions\PhpfastcacheCoreException; -use Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException; -use Phpfastcache\Exceptions\PhpfastcacheLogicException; - -/** - * @property LeveldbClient|null $instance Instance of driver service - * @method Config getConfig() - */ -class Driver implements AggregatablePoolInterface -{ - use IOHelperTrait; - - protected const LEVELDB_FILENAME = '.database'; - - /** - * @return bool - */ - public function driverCheck(): bool - { - return extension_loaded('Leveldb'); - } - - /** - * Close connection on destruct - */ - public function __destruct() - { - if ($this->instance instanceof LeveldbClient) { - $this->instance->close(); - $this->instance = null; - } - } - - /** - * @param ExtendedCacheItemInterface $item - * @return ?array - */ - protected function driverRead(ExtendedCacheItemInterface $item): ?array - { - $val = $this->instance->get($item->getKey()); - if (!$val) { - return null; - } - - return $this->decode($val); - } - - /** - * @param ExtendedCacheItemInterface $item - * @return bool - * @throws PhpfastcacheInvalidArgumentException - * @throws PhpfastcacheLogicException - */ - protected function driverWrite(ExtendedCacheItemInterface $item): bool - { - - return (bool)$this->instance->set($item->getKey(), $this->encode($this->driverPreWrap($item))); - } - - /** - * @param string $key - * @param string $encodedKey - * @return bool - */ - protected function driverDelete(string $key, string $encodedKey): bool - { - return $this->instance->delete($key); - } - - /** - * @return bool - * @throws PhpfastcacheCoreException - * @throws PhpfastcacheLogicException - */ - protected function driverClear(): bool - { - if ($this->instance instanceof LeveldbClient) { - $this->instance->close(); - $this->instance = null; - } - $result = LeveldbClient::destroy($this->getLeveldbFile()); - $this->driverConnect(); - - return $result; - } - - /** - * @return string - * @throws PhpfastcacheCoreException - */ - public function getLeveldbFile(): string - { - return $this->getPath() . '/' . self::LEVELDB_FILENAME; - } - - /** - * @return bool - * @throws PhpfastcacheCoreException - * @throws PhpfastcacheLogicException - */ - protected function driverConnect(): bool - { - if ($this->instance instanceof LeveldbClient) { - throw new PhpfastcacheLogicException('Already connected to Leveldb database'); - } - - $this->instance = new LeveldbClient($this->getLeveldbFile()); - - return true; - } -} diff --git a/lib/Phpfastcache/Drivers/Leveldb/Item.php b/lib/Phpfastcache/Drivers/Leveldb/Item.php deleted file mode 100644 index 0eea950a2..000000000 --- a/lib/Phpfastcache/Drivers/Leveldb/Item.php +++ /dev/null @@ -1,30 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -declare(strict_types=1); - -namespace Phpfastcache\Drivers\Leveldb; - -use Phpfastcache\Core\Item\ExtendedCacheItemInterface; -use Phpfastcache\Core\Item\TaggableCacheItemTrait; - -class Item implements ExtendedCacheItemInterface -{ - use TaggableCacheItemTrait; - - protected function getDriverClass(): string - { - return Driver::class; - } -} diff --git a/lib/Phpfastcache/Drivers/Memcache/Config.php b/lib/Phpfastcache/Drivers/Memcache/Config.php deleted file mode 100644 index 281b5cb13..000000000 --- a/lib/Phpfastcache/Drivers/Memcache/Config.php +++ /dev/null @@ -1,141 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -declare(strict_types=1); - -namespace Phpfastcache\Drivers\Memcache; - -use Phpfastcache\Config\ConfigurationOption; -use Phpfastcache\Exceptions\PhpfastcacheDriverException; -use Phpfastcache\Exceptions\PhpfastcacheInvalidConfigurationException; -use Phpfastcache\Exceptions\PhpfastcacheLogicException; - -class Config extends ConfigurationOption -{ - /** - * @var array - * - * Multiple server can be added this way: - * $cfg->setServers([ - * [ - * // If you use an UNIX socket set the host and port to null - * 'host' => '127.0.0.1', - * //'path' => 'path/to/unix/socket', - * 'port' => 11211, - * ] - * ]); - */ - - /** @var array> */ - protected array $servers = []; - protected string $host = '127.0.0.1'; - protected int $port = 11211; - - /** - * @return array> - */ - public function getServers(): array - { - if (!count($this->servers)) { - return [ - [ - 'host' => $this->getHost(), - 'path' => $this->getPath(), - 'port' => $this->getPort(), - ], - ]; - } - - return $this->servers; - } - - /** - * @param array> $servers - * @return self - * @throws PhpfastcacheInvalidConfigurationException - * @throws PhpfastcacheLogicException - * - * @SuppressWarnings(PHPMD.CyclomaticComplexity) - * @SuppressWarnings(PHPMD.NPathComplexity) - */ - public function setServers(array $servers): static - { - foreach ($servers as $server) { - if (\array_key_exists('saslUser', $server) || array_key_exists('saslPassword', $server)) { - throw new PhpfastcacheInvalidConfigurationException('Unlike Memcached, Memcache does not support SASL authentication'); - } - - if ($diff = array_diff(array_keys($server), ['host', 'port', 'path'])) { - throw new PhpfastcacheInvalidConfigurationException('Unknown keys for memcached server: ' . implode(', ', $diff)); - } - - if (!empty($server['host']) && !empty($server['path'])) { - throw new PhpfastcacheInvalidConfigurationException('Host and path cannot be simultaneous defined.'); - } - - if ((isset($server['host']) && !is_string($server['host'])) || (empty($server['path']) && empty($server['host']))) { - throw new PhpfastcacheInvalidConfigurationException('Host must be a valid string in "$server" configuration array if path is not defined'); - } - - if ((isset($server['path']) && !is_string($server['path'])) || (empty($server['host']) && empty($server['path']))) { - throw new PhpfastcacheInvalidConfigurationException('Path must be a valid string in "$server" configuration array if host is not defined'); - } - - if (!empty($server['host']) && (empty($server['port']) || !is_int($server['port']) || $server['port'] < 1)) { - throw new PhpfastcacheInvalidConfigurationException('Port must be a valid integer in "$server" configuration array'); - } - - if (!empty($server['port']) && !empty($server['path'])) { - throw new PhpfastcacheInvalidConfigurationException('Port should not be defined along with path'); - } - } - return $this->setProperty('servers', $servers); - } - - /** - * @return string - */ - public function getHost(): string - { - return $this->host; - } - - /** - * @param string $host - * @return self - * @throws PhpfastcacheLogicException - */ - public function setHost(string $host): static - { - return $this->setProperty('host', $host); - } - - /** - * @return int - */ - public function getPort(): int - { - return $this->port; - } - - /** - * @param int $port - * @return self - * @throws PhpfastcacheLogicException - */ - public function setPort(int $port): static - { - return $this->setProperty('port', $port); - } -} diff --git a/lib/Phpfastcache/Drivers/Memcache/Driver.php b/lib/Phpfastcache/Drivers/Memcache/Driver.php deleted file mode 100644 index b44452271..000000000 --- a/lib/Phpfastcache/Drivers/Memcache/Driver.php +++ /dev/null @@ -1,195 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -declare(strict_types=1); - -namespace Phpfastcache\Drivers\Memcache; - -use DateTime; -use Exception; -use Memcache as MemcacheSoftware; -use Phpfastcache\Cluster\AggregatablePoolInterface; -use Phpfastcache\Config\ConfigurationOption; -use Phpfastcache\Core\Pool\ExtendedCacheItemPoolInterface; -use Phpfastcache\Core\Pool\TaggableCacheItemPoolTrait; -use Phpfastcache\Core\Item\ExtendedCacheItemInterface; -use Phpfastcache\Entities\DriverStatistic; -use Phpfastcache\Event\EventManagerInterface; -use Phpfastcache\Exceptions\PhpfastcacheCoreException; -use Phpfastcache\Exceptions\PhpfastcacheDriverCheckException; -use Phpfastcache\Exceptions\PhpfastcacheDriverConnectException; -use Phpfastcache\Exceptions\PhpfastcacheDriverException; -use Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException; -use Phpfastcache\Exceptions\PhpfastcacheIOException; -use Phpfastcache\Exceptions\PhpfastcacheLogicException; -use Phpfastcache\Util\MemcacheDriverCollisionDetectorTrait; - -/** - * @property MemcacheSoftware $instance - * @method Config getConfig() - */ -class Driver implements AggregatablePoolInterface -{ - use TaggableCacheItemPoolTrait { - __construct as protected __parentConstruct; - } - use MemcacheDriverCollisionDetectorTrait; - - protected int $memcacheFlags = 0; - - /** - * Driver constructor. - * @param ConfigurationOption $config - * @param string $instanceId - * @param EventManagerInterface $em - * @throws PhpfastcacheDriverConnectException - * @throws PhpfastcacheInvalidArgumentException - * @throws PhpfastcacheCoreException - * @throws PhpfastcacheDriverCheckException - * @throws PhpfastcacheIOException - */ - public function __construct(ConfigurationOption $config, string $instanceId, EventManagerInterface $em) - { - self::checkCollision('Memcache'); - $this->__parentConstruct($config, $instanceId, $em); - } - - /** - * @return bool - */ - public function driverCheck(): bool - { - return class_exists('Memcache'); - } - - /** - * @return DriverStatistic - */ - public function getStats(): DriverStatistic - { - $stats = (array)$this->instance->getstats(); - $stats['uptime'] = (isset($stats['uptime']) ? $stats['uptime'] : 0); - $stats['version'] = (isset($stats['version']) ? $stats['version'] : 'UnknownVersion'); - $stats['bytes'] = (isset($stats['bytes']) ? $stats['version'] : 0); - - $date = (new DateTime())->setTimestamp(time() - $stats['uptime']); - - return (new DriverStatistic()) - ->setData(implode(', ', array_keys($this->itemInstances))) - ->setInfo(sprintf("The memcache daemon v%s is up since %s.\n For more information see RawData.", $stats['version'], $date->format(DATE_RFC2822))) - ->setRawData($stats) - ->setSize((int)$stats['bytes']); - } - - /** - * @return bool - * @throws PhpfastcacheDriverException - */ - protected function driverConnect(): bool - { - $this->instance = new MemcacheSoftware(); - - foreach ($this->getConfig()->getServers() as $server) { - try { - /** - * If path is provided we consider it as a UNIX Socket - */ - if (!empty($server['path'])) { - $this->instance->addServer($server['path'], 0); - } elseif (!empty($server['host'])) { - $this->instance->addServer($server['host'], $server['port']); - } - - if (!empty($server['saslUser']) && !empty($server['saslPassword'])) { - throw new PhpfastcacheDriverException('Unlike Memcached, Memcache does not support SASL authentication'); - } - } catch (Exception $e) { - throw new PhpfastcacheDriverConnectException( - sprintf( - 'Failed to connect to memcache host/path "%s" with the following error: %s', - $server['host'] ?: $server['path'], - $e->getMessage() - ) - ); - } - - /** - * Since Memcached does not throw - * any error if not connected ... - */ - if ( - !$this->instance->getServerStatus( - !empty($server['path']) ? $server['path'] : $server['host'], - !empty($server['port']) ? $server['port'] : 0 - ) - ) { - throw new PhpfastcacheDriverException('Memcache seems to not be connected'); - } - } - - return true; - } - - /** - * @param ExtendedCacheItemInterface $item - * @return ?array - */ - protected function driverRead(ExtendedCacheItemInterface $item): ?array - { - $val = $this->instance->get($item->getKey()); - - if (empty($val) || !\is_array($val)) { - return null; - } - - return $val; - } - - /** - * @param ExtendedCacheItemInterface $item - * @return mixed - * @throws PhpfastcacheInvalidArgumentException - * @throws PhpfastcacheLogicException - */ - protected function driverWrite(ExtendedCacheItemInterface $item): bool - { - - $ttl = $item->getExpirationDate()->getTimestamp() - time(); - - // Memcache will only allow an expiration timer less than 2592000 seconds, - // otherwise, it will assume you're giving it a UNIX timestamp. - if ($ttl > 2592000) { - $ttl = time() + $ttl; - } - return $this->instance->set($item->getKey(), $this->driverPreWrap($item), $this->memcacheFlags, $ttl); - } - - /** - * @param string $key - * @param string $encodedKey - * @return bool - */ - protected function driverDelete(string $key, string $encodedKey): bool - { - return $this->instance->delete($key); - } - - /** - * @return bool - */ - protected function driverClear(): bool - { - return $this->instance->flush(); - } -} diff --git a/lib/Phpfastcache/Drivers/Memcache/Item.php b/lib/Phpfastcache/Drivers/Memcache/Item.php deleted file mode 100644 index f299088b5..000000000 --- a/lib/Phpfastcache/Drivers/Memcache/Item.php +++ /dev/null @@ -1,30 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -declare(strict_types=1); - -namespace Phpfastcache\Drivers\Memcache; - -use Phpfastcache\Core\Item\ExtendedCacheItemInterface; -use Phpfastcache\Core\Item\TaggableCacheItemTrait; - -class Item implements ExtendedCacheItemInterface -{ - use TaggableCacheItemTrait; - - protected function getDriverClass(): string - { - return Driver::class; - } -} diff --git a/lib/Phpfastcache/Drivers/Memcached/Config.php b/lib/Phpfastcache/Drivers/Memcached/Config.php deleted file mode 100644 index bd3a467f3..000000000 --- a/lib/Phpfastcache/Drivers/Memcached/Config.php +++ /dev/null @@ -1,203 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -declare(strict_types=1); - -namespace Phpfastcache\Drivers\Memcached; - -use Phpfastcache\Config\ConfigurationOption; -use Phpfastcache\Exceptions\PhpfastcacheInvalidConfigurationException; -use Phpfastcache\Exceptions\PhpfastcacheLogicException; - -class Config extends ConfigurationOption -{ - /** - * @var array - * - * Multiple server can be added this way: - * $cfg->setServers([ - * [ - * // If you use a UNIX socket set the host and port to null - * 'host' => '127.0.0.1', - * //'path' => 'path/to/unix/socket', - * 'port' => 11211, - * 'saslUser' => null, - * 'saslPassword' => null, - * ] - * ]); - */ - - /** @var array> */ - protected array $servers = []; - protected string $host = '127.0.0.1'; - protected int $port = 11211; - protected string $saslUser = ''; - protected string $saslPassword = ''; - protected string $optPrefix = ''; -/** - * @return string - */ - public function getSaslUser(): string - { - return $this->saslUser; - } - - /** - * @param string $saslUser - * @return self - * @throws PhpfastcacheLogicException - */ - public function setSaslUser(string $saslUser): static - { - return $this->setProperty('saslUser', $saslUser); - } - - /** - * @return string - */ - public function getSaslPassword(): string - { - return $this->saslPassword; - } - - /** - * @param string $saslPassword - * @return self - * @throws PhpfastcacheLogicException - */ - public function setSaslPassword(string $saslPassword): static - { - return $this->setProperty('saslPassword', $saslPassword); - } - - /** - * @return array> - */ - public function getServers(): array - { - if (!count($this->servers)) { - return [ - [ - 'host' => $this->getHost(), - 'path' => $this->getPath(), - 'port' => $this->getPort(), - 'saslUser' => $this->getSaslUser() ?: null, - 'saslPassword' => $this->getSaslPassword() ?: null, - ], - ]; - } - - return $this->servers; - } - - /** - * @param array> $servers - * @return self - * @throws PhpfastcacheInvalidConfigurationException - * @throws PhpfastcacheLogicException - * - * @SuppressWarnings(PHPMD.CyclomaticComplexity) - * @SuppressWarnings(PHPMD.NPathComplexity) - */ - public function setServers(array $servers): static - { - foreach ($servers as $server) { - if ($diff = array_diff(array_keys($server), ['host', 'port', 'saslUser', 'saslPassword', 'path'])) { - throw new PhpfastcacheInvalidConfigurationException('Unknown keys for memcached server: ' . implode(', ', $diff)); - } - - if (!empty($server['host']) && !empty($server['path'])) { - throw new PhpfastcacheInvalidConfigurationException('Host and path cannot be simultaneous defined.'); - } - - if ((isset($server['host']) && !is_string($server['host'])) || (empty($server['path']) && empty($server['host']))) { - throw new PhpfastcacheInvalidConfigurationException('Host must be a valid string in "$server" configuration array if path is not defined'); - } - - if ((isset($server['path']) && !is_string($server['path'])) || (empty($server['host']) && empty($server['path']))) { - throw new PhpfastcacheInvalidConfigurationException('Path must be a valid string in "$server" configuration array if host is not defined'); - } - - if (!empty($server['host']) && (empty($server['port']) || !is_int($server['port']) || $server['port'] < 1)) { - throw new PhpfastcacheInvalidConfigurationException('Port must be a valid integer in "$server" configuration array'); - } - - if (!empty($server['port']) && !empty($server['path'])) { - throw new PhpfastcacheInvalidConfigurationException('Port should not be defined along with path'); - } - - if (!empty($server['saslUser']) && !empty($server['saslPassword']) && (!is_string($server['saslUser']) || !is_string($server['saslPassword']))) { - throw new PhpfastcacheInvalidConfigurationException('If provided, saslUser and saslPassword must be a string'); - } - } - - return $this->setProperty('servers', $servers); - } - - /** - * @return string - */ - public function getHost(): string - { - return $this->host; - } - - /** - * @param string $host - * @return self - * @throws PhpfastcacheLogicException - */ - public function setHost(string $host): static - { - return $this->setProperty('host', $host); - } - - /** - * @return int - */ - public function getPort(): int - { - return $this->port; - } - - /** - * @param int $port - * @return Config - * @throws PhpfastcacheLogicException - */ - public function setPort(int $port): static - { - return $this->setProperty('port', $port); - } - - /** - * @return string - * @since 8.0.2 - */ - public function getOptPrefix(): string - { - return $this->optPrefix; - } - - /** - * @param string $optPrefix - * @return Config - * @throws PhpfastcacheLogicException - * @since 8.0.2 - */ - public function setOptPrefix(string $optPrefix): Config - { - return $this->setProperty('optPrefix', trim($optPrefix)); - } -} diff --git a/lib/Phpfastcache/Drivers/Memcached/Driver.php b/lib/Phpfastcache/Drivers/Memcached/Driver.php deleted file mode 100644 index 9c70367b9..000000000 --- a/lib/Phpfastcache/Drivers/Memcached/Driver.php +++ /dev/null @@ -1,230 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -declare(strict_types=1); - -namespace Phpfastcache\Drivers\Memcached; - -use DateTime; -use Memcached as MemcachedSoftware; -use Phpfastcache\Cluster\AggregatablePoolInterface; -use Phpfastcache\Config\ConfigurationOption; -use Phpfastcache\Core\Pool\ExtendedCacheItemPoolInterface; -use Phpfastcache\Core\Pool\TaggableCacheItemPoolTrait; -use Phpfastcache\Core\Item\ExtendedCacheItemInterface; -use Phpfastcache\Entities\DriverStatistic; -use Phpfastcache\Event\EventManagerInterface; -use Phpfastcache\Exceptions\PhpfastcacheCoreException; -use Phpfastcache\Exceptions\PhpfastcacheDriverCheckException; -use Phpfastcache\Exceptions\PhpfastcacheDriverConnectException; -use Phpfastcache\Exceptions\PhpfastcacheDriverException; -use Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException; -use Phpfastcache\Exceptions\PhpfastcacheInvalidTypeException; -use Phpfastcache\Exceptions\PhpfastcacheIOException; -use Phpfastcache\Exceptions\PhpfastcacheLogicException; -use Phpfastcache\Util\MemcacheDriverCollisionDetectorTrait; -use Psr\Cache\CacheItemInterface; - -/** - * @property MemcachedSoftware $instance - * @method Config getConfig() - */ -class Driver implements AggregatablePoolInterface -{ - use TaggableCacheItemPoolTrait { - __construct as protected __parentConstruct; - } - use MemcacheDriverCollisionDetectorTrait; - - /** - * Driver constructor. - * @param ConfigurationOption $config - * @param string $instanceId - * @param EventManagerInterface $em - * @throws PhpfastcacheDriverConnectException - * @throws PhpfastcacheInvalidArgumentException - * @throws PhpfastcacheCoreException - * @throws PhpfastcacheDriverCheckException - * @throws PhpfastcacheIOException - */ - public function __construct(ConfigurationOption $config, string $instanceId, EventManagerInterface $em) - { - self::checkCollision('Memcached'); - $this->__parentConstruct($config, $instanceId, $em); - } - - /** - * @return bool - */ - public function driverCheck(): bool - { - return class_exists('Memcached'); - } - - /** - * @return DriverStatistic - */ - public function getStats(): DriverStatistic - { - $stats = current($this->instance->getStats()); - $stats['uptime'] = $stats['uptime'] ?? 0; - $stats['bytes'] = $stats['bytes'] ?? 0; - $stats['version'] = $stats['version'] ?? $this->instance->getVersion(); - - $date = (new DateTime())->setTimestamp(time() - $stats['uptime']); - - return (new DriverStatistic()) - ->setData(implode(', ', array_keys($this->itemInstances))) - ->setInfo(sprintf("The memcache daemon v%s is up since %s.\n For more information see RawData.", $stats['version'], $date->format(DATE_RFC2822))) - ->setRawData($stats) - ->setSize((int)$stats['bytes']); - } - - /** - * @return bool - * @throws PhpfastcacheDriverException - */ - protected function driverConnect(): bool - { - $this->instance = new MemcachedSoftware(); - $optPrefix = $this->getConfig()->getOptPrefix(); - $this->instance->setOption(MemcachedSoftware::OPT_BINARY_PROTOCOL, true); - - if ($optPrefix) { - $this->instance->setOption(MemcachedSoftware::OPT_PREFIX_KEY, $optPrefix); - } - - foreach ($this->getConfig()->getServers() as $server) { - $connected = false; - /** - * If path is provided we consider it as an UNIX Socket - */ - if (!empty($server['path'])) { - $connected = $this->instance->addServer($server['path'], 0); - } elseif (!empty($server['host'])) { - $connected = $this->instance->addServer($server['host'], $server['port']); - } - if (!empty($server['saslUser']) && !empty($server['saslPassword'])) { - $this->instance->setSaslAuthData($server['saslUser'], $server['saslPassword']); - } - if (!$connected) { - throw new PhpfastcacheDriverConnectException( - sprintf( - 'Failed to connect to memcache host/path "%s".', - $server['host'] ?: $server['path'], - ) - ); - } - } - - /** - * Since Memcached does not throw - * any error if not connected ... - */ - $version = $this->instance->getVersion(); - if (!$version || $this->instance->getResultCode() !== MemcachedSoftware::RES_SUCCESS) { - throw new PhpfastcacheDriverException('Memcached seems to not be connected'); - } - return true; - } - - /** - * @param ExtendedCacheItemInterface $item - * @return ?array - */ - protected function driverRead(ExtendedCacheItemInterface $item): ?array - { - $val = $this->instance->get($item->getKey()); - - if (empty($val) || !\is_array($val)) { - return null; - } - - return $val; - } - - /** - * @param ExtendedCacheItemInterface ...$items - * @return array> - */ - protected function driverReadMultiple(ExtendedCacheItemInterface ...$items): array - { - $keys = $this->getKeys($items); - - $val = $this->instance->getMulti($keys); - - if (empty($val) || !\is_array($val)) { - return []; - } - - return $val; - } - - - /** - * @return array - * @throws PhpfastcacheInvalidArgumentException - */ - protected function driverReadAllKeys(string $pattern = ''): iterable - { - if ($pattern !== '') { - $this->throwUnsupportedDriverReadAllPattern('https://www.php.net/manual/en/memcached.getallkeys.php'); - } - $keys = $this->instance->getAllKeys(); - - if (is_iterable($keys)) { - return $keys; - } else { - return []; - } - } - - /** - * @param ExtendedCacheItemInterface $item - * @return bool - * @throws PhpfastcacheInvalidArgumentException - * @throws PhpfastcacheLogicException - */ - protected function driverWrite(ExtendedCacheItemInterface $item): bool - { - - $ttl = $item->getExpirationDate()->getTimestamp() - time(); - - // Memcache will only allow a expiration timer less than 2592000 seconds, - // otherwise, it will assume you're giving it a UNIX timestamp. - if ($ttl > 2592000) { - $ttl = time() + $ttl; - } - - return $this->instance->set($item->getKey(), $this->driverPreWrap($item), $ttl); - } - - /** - * @param string $key - * @param string $encodedKey - * @return bool - */ - protected function driverDelete(string $key, string $encodedKey): bool - { - return $this->instance->delete($key); - } - - /** - * @return bool - */ - protected function driverClear(): bool - { - return $this->instance->flush(); - } -} diff --git a/lib/Phpfastcache/Drivers/Memcached/Item.php b/lib/Phpfastcache/Drivers/Memcached/Item.php deleted file mode 100644 index cb01697d4..000000000 --- a/lib/Phpfastcache/Drivers/Memcached/Item.php +++ /dev/null @@ -1,30 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -declare(strict_types=1); - -namespace Phpfastcache\Drivers\Memcached; - -use Phpfastcache\Core\Item\ExtendedCacheItemInterface; -use Phpfastcache\Core\Item\TaggableCacheItemTrait; - -class Item implements ExtendedCacheItemInterface -{ - use TaggableCacheItemTrait; - - protected function getDriverClass(): string - { - return Driver::class; - } -} diff --git a/lib/Phpfastcache/Drivers/Memory/Config.php b/lib/Phpfastcache/Drivers/Memory/Config.php deleted file mode 100644 index 7e36d8a2b..000000000 --- a/lib/Phpfastcache/Drivers/Memory/Config.php +++ /dev/null @@ -1,23 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -declare(strict_types=1); - -namespace Phpfastcache\Drivers\Memory; - -use Phpfastcache\Config\ConfigurationOption; - -class Config extends ConfigurationOption -{ -} diff --git a/lib/Phpfastcache/Drivers/Memory/Driver.php b/lib/Phpfastcache/Drivers/Memory/Driver.php deleted file mode 100644 index 218f8aa11..000000000 --- a/lib/Phpfastcache/Drivers/Memory/Driver.php +++ /dev/null @@ -1,128 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -declare(strict_types=1); - -namespace Phpfastcache\Drivers\Memory; - -use Phpfastcache\Core\Pool\ExtendedCacheItemPoolInterface; -use Phpfastcache\Core\Pool\TaggableCacheItemPoolTrait; -use Phpfastcache\Core\Item\ExtendedCacheItemInterface; -use Phpfastcache\Entities\DriverStatistic; -use Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException; -use Phpfastcache\Exceptions\PhpfastcacheInvalidTypeException; -use Phpfastcache\Exceptions\PhpfastcacheLogicException; -use Psr\Cache\CacheItemInterface; - -/** - * Class Driver - * @method Config getConfig() - */ -class Driver implements ExtendedCacheItemPoolInterface -{ - use TaggableCacheItemPoolTrait; - - /** - * @var array> - */ - protected array $staticStack = []; - - /** - * @return bool - */ - public function driverCheck(): bool - { - return true; - } - - /** - * @return bool - */ - protected function driverConnect(): bool - { - return true; - } - - /** - * @param ExtendedCacheItemInterface $item - * @return ?array - */ - protected function driverRead(ExtendedCacheItemInterface $item): ?array - { - return $this->staticStack[$item->getKey()] ?? null; - } - - /** - * @return array - */ - protected function driverReadAllKeys(string $pattern = ''): iterable - { - return array_filter(array_keys($this->staticStack), function (string $key) use ($pattern) { - return $pattern - ? preg_match('/' . str_replace('*', '(.*)', $pattern) . '/', $key) - : true; - }); - } - - /** - * @param ExtendedCacheItemInterface $item - * @return bool - * @throws PhpfastcacheInvalidArgumentException - * @throws PhpfastcacheLogicException - */ - protected function driverWrite(ExtendedCacheItemInterface $item): bool - { - - $this->staticStack[$item->getKey()] = $this->driverPreWrap($item); - return true; - } - - /** - * @param string $key - * @param string $encodedKey - * @return bool - */ - protected function driverDelete(string $key, string $encodedKey): bool - { - if (isset($this->staticStack[$key])) { - unset($this->staticStack[$key]); - return true; - } - return false; - } - - /** - * @return bool - */ - protected function driverClear(): bool - { - unset($this->staticStack); - $this->staticStack = []; - return true; - } - - /** - * @return DriverStatistic - */ - public function getStats(): DriverStatistic - { - $stat = new DriverStatistic(); - $stat->setInfo('[Memstatic] A memory static driver') - ->setSize(mb_strlen(serialize($this->staticStack))) - ->setData(implode(', ', array_keys($this->itemInstances))) - ->setRawData($this->staticStack); - - return $stat; - } -} diff --git a/lib/Phpfastcache/Drivers/Memory/Item.php b/lib/Phpfastcache/Drivers/Memory/Item.php deleted file mode 100644 index 895f647e3..000000000 --- a/lib/Phpfastcache/Drivers/Memory/Item.php +++ /dev/null @@ -1,30 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -declare(strict_types=1); - -namespace Phpfastcache\Drivers\Memory; - -use Phpfastcache\Core\Item\ExtendedCacheItemInterface; -use Phpfastcache\Core\Item\TaggableCacheItemTrait; - -class Item implements ExtendedCacheItemInterface -{ - use TaggableCacheItemTrait; - - protected function getDriverClass(): string - { - return Driver::class; - } -} diff --git a/lib/Phpfastcache/Drivers/Memstatic/Config.php b/lib/Phpfastcache/Drivers/Memstatic/Config.php deleted file mode 100644 index 94a88be32..000000000 --- a/lib/Phpfastcache/Drivers/Memstatic/Config.php +++ /dev/null @@ -1,30 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -declare(strict_types=1); - -namespace Phpfastcache\Drivers\Memstatic; - -/** - * @deprecated Memstatic driver has changed its name, it is now called "Memory". - * @see \Phpfastcache\Drivers\Memory\Config - */ -class Config extends \Phpfastcache\Drivers\Memory\Config -{ - public function __construct(array $parameters = []) - { - trigger_error('Memstatic driver has changed its name, it is now called "Memory"', E_USER_DEPRECATED); - parent::__construct($parameters); - } -} diff --git a/lib/Phpfastcache/Drivers/Memstatic/Driver.php b/lib/Phpfastcache/Drivers/Memstatic/Driver.php deleted file mode 100644 index 6f161b530..000000000 --- a/lib/Phpfastcache/Drivers/Memstatic/Driver.php +++ /dev/null @@ -1,33 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -declare(strict_types=1); - -namespace Phpfastcache\Drivers\Memstatic; - -use Phpfastcache\Config\ConfigurationOptionInterface; -use Phpfastcache\Event\EventManagerInterface; - -/** - * @deprecated Memstatic driver has changed its name, it is now called "Memory". - * @see \Phpfastcache\Drivers\Memory\Driver - */ -class Driver extends \Phpfastcache\Drivers\Memory\Driver -{ - public function __construct(#[\SensitiveParameter] ConfigurationOptionInterface $config, string $instanceId, EventManagerInterface $em) - { - trigger_error('Memstatic driver has changed its name, it is now called "Memory"', E_USER_DEPRECATED); - parent::__construct($config, $instanceId, $em); - } -} diff --git a/lib/Phpfastcache/Drivers/Memstatic/Item.php b/lib/Phpfastcache/Drivers/Memstatic/Item.php deleted file mode 100644 index e4f58328c..000000000 --- a/lib/Phpfastcache/Drivers/Memstatic/Item.php +++ /dev/null @@ -1,33 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -declare(strict_types=1); - -namespace Phpfastcache\Drivers\Memstatic; - -use Phpfastcache\Core\Pool\ExtendedCacheItemPoolInterface; -use Phpfastcache\Event\EventManagerInterface; - -/** - * @deprecated Memstatic driver has changed its name, it is now called "Memory". - * @see \Phpfastcache\Drivers\Memory\Item - */ -class Item extends \Phpfastcache\Drivers\Memory\Item -{ - public function __construct(ExtendedCacheItemPoolInterface $driver, string $key, EventManagerInterface $em) - { - trigger_error('Memstatic driver has changed its name, it is now called "Memory"', E_USER_DEPRECATED); - parent::__construct($driver, $key, $em); - } -} diff --git a/lib/Phpfastcache/Drivers/Predis/Config.php b/lib/Phpfastcache/Drivers/Predis/Config.php deleted file mode 100644 index a30c74fcf..000000000 --- a/lib/Phpfastcache/Drivers/Predis/Config.php +++ /dev/null @@ -1,216 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -declare(strict_types=1); - -namespace Phpfastcache\Drivers\Predis; - -use Phpfastcache\Config\ConfigurationOption; -use Phpfastcache\Exceptions\PhpfastcacheInvalidConfigurationException; -use Phpfastcache\Exceptions\PhpfastcacheLogicException; -use Predis\Client; - -class Config extends ConfigurationOption -{ - protected string $host = '127.0.0.1'; - protected int $port = 6379; - protected string $password = ''; - protected int $database = 0; - protected ?Client $predisClient = null; - protected string $optPrefix = ''; - protected int $timeout = 5; - protected bool $persistent = false; - protected string $scheme = 'unix'; -/** - * @return array - */ - public function getPredisConfigArray(): array - { - return [ - 'host' => $this->getHost(), - 'port' => $this->getPort(), - 'password' => $this->getPassword() ?: null, - 'database' => $this->getDatabase(), - 'timeout' => $this->getTimeout(), - ]; - } - - /** - * @return string - */ - public function getHost(): string - { - return $this->host; - } - - /** - * @param string $host - * @return Config - * @throws PhpfastcacheLogicException - */ - public function setHost(string $host): static - { - return $this->setProperty('host', $host); - } - - /** - * @return int - */ - public function getPort(): int - { - return $this->port; - } - - /** - * @param int $port - * @return Config - * @throws PhpfastcacheLogicException - */ - public function setPort(int $port): static - { - return $this->setProperty('port', $port); - } - - /** - * @return string - */ - public function getPassword(): string - { - return $this->password; - } - - /** - * @param string $password - * @return self - * @throws PhpfastcacheLogicException - */ - public function setPassword(string $password): static - { - return $this->setProperty('password', $password); - } - - /** - * @return int - */ - public function getDatabase(): int - { - return $this->database; - } - - /** - * @param int $database - * @return Config - * @throws PhpfastcacheLogicException - */ - public function setDatabase(int $database): static - { - return $this->setProperty('database', $database); - } - - /** - * @return int - */ - public function getTimeout(): int - { - return $this->timeout; - } - - /** - * @param int $timeout - * @return self - * @throws PhpfastcacheLogicException - */ - public function setTimeout(int $timeout): static - { - return $this->setProperty('timeout', $timeout); - } - - /** - * @return Client|null - */ - public function getPredisClient(): ?Client - { - return $this->predisClient; - } - - /** - * @param Client|null $predisClient - * @return Config - * @throws PhpfastcacheLogicException - */ - public function setPredisClient(?Client $predisClient = null): Config - { - return $this->setProperty('predisClient', $predisClient); - } - - /** - * @return string - * @since 7.0.2 - */ - public function getOptPrefix(): string - { - return $this->optPrefix; - } - - /** - * @param string $optPrefix - * @return Config - * @throws PhpfastcacheLogicException - * @since 7.0.2 - */ - public function setOptPrefix(string $optPrefix): Config - { - return $this->setProperty('optPrefix', trim($optPrefix)); - } - - /** - * @return bool - */ - public function isPersistent(): bool - { - return $this->persistent; - } - - /** - * @param bool $persistent - * @return Config - * @throws PhpfastcacheLogicException - */ - public function setPersistent(bool $persistent): Config - { - return $this->setProperty('persistent', $persistent); - } - - /** - * @return string - */ - public function getScheme(): string - { - return $this->scheme; - } - - /** - * @param string $scheme - * @return Config - * @throws PhpfastcacheInvalidConfigurationException - * @throws PhpfastcacheLogicException - */ - public function setScheme(string $scheme): Config - { - if (!in_array($scheme, ['unix', 'tls'], true)) { - throw new PhpfastcacheInvalidConfigurationException('Invalid scheme: ' . $scheme); - } - return $this->setProperty('scheme', $scheme); - } -} diff --git a/lib/Phpfastcache/Drivers/Predis/Driver.php b/lib/Phpfastcache/Drivers/Predis/Driver.php deleted file mode 100644 index c00f47ac2..000000000 --- a/lib/Phpfastcache/Drivers/Predis/Driver.php +++ /dev/null @@ -1,235 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -declare(strict_types=1); - -namespace Phpfastcache\Drivers\Predis; - -use DateTime; -use Phpfastcache\Cluster\AggregatablePoolInterface; -use Phpfastcache\Core\Pool\ExtendedCacheItemPoolInterface; -use Phpfastcache\Core\Pool\TaggableCacheItemPoolTrait; -use Phpfastcache\Core\Item\ExtendedCacheItemInterface; -use Phpfastcache\Entities\DriverStatistic; -use Phpfastcache\Exceptions\PhpfastcacheDriverException; -use Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException; -use Phpfastcache\Exceptions\PhpfastcacheLogicException; -use Predis\Client as PredisClient; -use Predis\Collection\Iterator as PredisIterator; -use Predis\Connection\ConnectionException as PredisConnectionException; - -/** - * @property PredisClient $instance Instance of driver service - * @method Config getConfig() - */ -class Driver implements AggregatablePoolInterface -{ - use TaggableCacheItemPoolTrait; - - /** - * @return bool - */ - public function driverCheck(): bool - { - if (extension_loaded('Redis')) { - trigger_error('The native Redis extension is installed, you should use Redis instead of Predis to increase performances', E_USER_NOTICE); - } - - return class_exists(\Predis\Client::class); - } - - /** - * @return string - */ - public function getHelp(): string - { - return << -To install the Predis library via Composer: -composer require "predis/predis" "~1.1.0" -

-HELP; - } - - /** - * @return DriverStatistic - */ - public function getStats(): DriverStatistic - { - $info = $this->instance->info(); - $size = ($info['Memory']['used_memory'] ?? 0); - $version = ($info['Server']['redis_version'] ?? 0); - $date = (isset($info['Server']['uptime_in_seconds']) ? (new DateTime())->setTimestamp(time() - $info['Server']['uptime_in_seconds']) : 'unknown date'); - - return (new DriverStatistic()) - ->setData(implode(', ', array_keys($this->itemInstances))) - ->setRawData($info) - ->setSize((int)$size) - ->setInfo( - sprintf( - "The Redis daemon v%s (with Predis v%s) is up since %s.\n For more information see RawData. \n Driver size includes the memory allocation size.", - $version, - PredisClient::VERSION, - $date->format(DATE_RFC2822) - ) - ); - } - - /** - * @return bool - * @throws PhpfastcacheDriverException - * @throws PhpfastcacheLogicException - */ - protected function driverConnect(): bool - { - /** - * In case of a user-provided - * Predis client just return here - */ - if ($this->getConfig()->getPredisClient() instanceof PredisClient) { - $this->instance = $this->getConfig()->getPredisClient(); - if (!$this->instance->isConnected()) { - $this->instance->connect(); - } - return true; - } - - $options = []; - - if ($this->getConfig()->getOptPrefix()) { - $options['prefix'] = $this->getConfig()->getOptPrefix(); - } - - if (!empty($this->getConfig()->getPath())) { - $this->instance = new PredisClient( - [ - 'scheme' => $this->getConfig()->getScheme(), - 'persistent' => $this->getConfig()->isPersistent(), - 'timeout' => $this->getConfig()->getTimeout(), - 'path' => $this->getConfig()->getPath(), - ], - $options - ); - } else { - $this->instance = new PredisClient($this->getConfig()->getPredisConfigArray(), $options); - } - - try { - $this->instance->connect(); - } catch (PredisConnectionException $e) { - throw new PhpfastcacheDriverException( - 'Failed to connect to predis server. Check the Predis documentation: https://github.com/nrk/predis/tree/v1.1#how-to-install-and-use-predis', - 0, - $e - ); - } - - return true; - } - - /** - * @param ExtendedCacheItemInterface $item - * @return ?array - */ - protected function driverRead(ExtendedCacheItemInterface $item): ?array - { - $val = $this->instance->get($item->getKey()); - - if ($val === null) { - return null; - } - - return $this->decode($val); - } - - - /** - * @param ExtendedCacheItemInterface ...$items - * @return array> - * @throws \Phpfastcache\Exceptions\PhpfastcacheDriverException - * @throws \RedisException - */ - protected function driverReadMultiple(ExtendedCacheItemInterface ...$items): array - { - $keys = $this->getKeys($items); - - return array_combine($keys, array_map( - fn($val) => $val ? $this->decode($val) : null, - $this->instance->mget($keys) - )); - } - - /** - * @return array - * @throws \RedisException - */ - protected function driverReadAllKeys(string $pattern = '*'): iterable - { - $keys = []; - foreach (new PredisIterator\Keyspace($this->instance, $pattern, ExtendedCacheItemPoolInterface::MAX_ALL_KEYS_COUNT) as $key) { - $keys[] = $key; - } - return $keys; - } - - - /** - * @param ExtendedCacheItemInterface $item - * @return mixed - * @throws PhpfastcacheInvalidArgumentException - * @throws PhpfastcacheLogicException - */ - protected function driverWrite(ExtendedCacheItemInterface $item): bool - { - - $ttl = $item->getExpirationDate()->getTimestamp() - time(); - - /** - * @see https://redis.io/commands/setex - * @see https://redis.io/commands/expire - */ - if ($ttl <= 0) { - return (bool)$this->instance->expire($item->getKey(), 0); - } - - return $this->instance->setex($item->getKey(), $ttl, $this->encode($this->driverPreWrap($item)))->getPayload() === 'OK'; - } - - /** - * @param string $key - * @param string $encodedKey - * @return bool - */ - protected function driverDelete(string $key, string $encodedKey): bool - { - return (bool)$this->instance->del([$key]); - } - - /** - * @param string[] $keys - * @return bool - */ - protected function driverDeleteMultiple(array $keys): bool - { - return (bool) $this->instance->del(...$keys); - } - - /** - * @return bool - */ - protected function driverClear(): bool - { - return $this->instance->flushdb()->getPayload() === 'OK'; - } -} diff --git a/lib/Phpfastcache/Drivers/Predis/Item.php b/lib/Phpfastcache/Drivers/Predis/Item.php deleted file mode 100644 index 91de8173d..000000000 --- a/lib/Phpfastcache/Drivers/Predis/Item.php +++ /dev/null @@ -1,30 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -declare(strict_types=1); - -namespace Phpfastcache\Drivers\Predis; - -use Phpfastcache\Core\Item\ExtendedCacheItemInterface; -use Phpfastcache\Core\Item\TaggableCacheItemTrait; - -class Item implements ExtendedCacheItemInterface -{ - use TaggableCacheItemTrait; - - protected function getDriverClass(): string - { - return Driver::class; - } -} diff --git a/lib/Phpfastcache/Drivers/Redis/Config.php b/lib/Phpfastcache/Drivers/Redis/Config.php deleted file mode 100644 index f87536d3d..000000000 --- a/lib/Phpfastcache/Drivers/Redis/Config.php +++ /dev/null @@ -1,161 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -declare(strict_types=1); - -namespace Phpfastcache\Drivers\Redis; - -use Phpfastcache\Config\ConfigurationOption; -use Phpfastcache\Exceptions\PhpfastcacheLogicException; -use Redis as RedisClient; - -class Config extends ConfigurationOption -{ - protected string $host = '127.0.0.1'; - protected int $port = 6379; - protected string $password = ''; - protected int $database = 0; - protected int $timeout = 5; - protected ?RedisClient $redisClient = null; - protected string $optPrefix = ''; -/** - * @return string - */ - public function getHost(): string - { - return $this->host; - } - - /** - * @param string $host - * @return static - * @throws PhpfastcacheLogicException - */ - public function setHost(string $host): static - { - return $this->setProperty('host', $host); - } - - /** - * @return int - */ - public function getPort(): int - { - return $this->port; - } - - /** - * @param int $port - * @return static - * @throws PhpfastcacheLogicException - */ - public function setPort(int $port): static - { - return $this->setProperty('port', $port); - } - - /** - * @return string - */ - public function getPassword(): string - { - return $this->password; - } - - /** - * @param string $password - * - * @return static - * @throws PhpfastcacheLogicException - */ - public function setPassword(string $password): static - { - return $this->setProperty('password', $password); - } - - /** - * @return null|int - */ - public function getDatabase(): ?int - { - return $this->database; - } - - /** - * @param int|null $database - * - * @return static - * @throws PhpfastcacheLogicException - */ - public function setDatabase(?int $database = null): static - { - return $this->setProperty('database', $database); - } - - /** - * @return int - */ - public function getTimeout(): int - { - return $this->timeout; - } - - /** - * @param int $timeout - * @return static - * @throws PhpfastcacheLogicException - */ - public function setTimeout(int $timeout): static - { - return $this->setProperty('timeout', $timeout); - } - - /** - * @return RedisClient|null - */ - public function getRedisClient(): ?RedisClient - { - return $this->redisClient; - } - - /** - * @param RedisClient|null $redisClient - * @return Config - * @throws PhpfastcacheLogicException - */ - public function setRedisClient(?RedisClient $redisClient): Config - { - return $this->setProperty('redisClient', $redisClient); - } - - /** - * @return string - * @since 7.0.2 - */ - public function getOptPrefix(): string - { - return $this->optPrefix; - } - - /** - * @param string $optPrefix - * @return Config - * @throws PhpfastcacheLogicException - * @since 7.0.2 - */ - public function setOptPrefix(string $optPrefix): Config - { - return $this->setProperty('optPrefix', trim($optPrefix)); - } -} diff --git a/lib/Phpfastcache/Drivers/Redis/Driver.php b/lib/Phpfastcache/Drivers/Redis/Driver.php deleted file mode 100644 index 8a24d311e..000000000 --- a/lib/Phpfastcache/Drivers/Redis/Driver.php +++ /dev/null @@ -1,146 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -declare(strict_types=1); - -namespace Phpfastcache\Drivers\Redis; - -use DateTime; -use Phpfastcache\Cluster\AggregatablePoolInterface; -use Phpfastcache\Core\Pool\ExtendedCacheItemPoolInterface; -use Phpfastcache\Core\Pool\TaggableCacheItemPoolTrait; -use Phpfastcache\Entities\DriverStatistic; -use Phpfastcache\Exceptions\PhpfastcacheLogicException; -use Redis as RedisClient; - -/** - * @property RedisClient $instance - * @method Config getConfig() - */ -class Driver implements AggregatablePoolInterface -{ - use RedisDriverTrait, TaggableCacheItemPoolTrait { - RedisDriverTrait::driverReadMultiple insteadof TaggableCacheItemPoolTrait; - RedisDriverTrait::driverDeleteMultiple insteadof TaggableCacheItemPoolTrait; - } - - - /** - * @return bool - */ - public function driverCheck(): bool - { - return extension_loaded('Redis') && class_exists(RedisClient::class); - } - - /** - * @return DriverStatistic - */ - public function getStats(): DriverStatistic - { - // used_memory - $info = $this->instance->info(); - $date = (new DateTime())->setTimestamp(time() - $info['uptime_in_seconds']); - - return (new DriverStatistic()) - ->setData(implode(', ', array_keys($this->itemInstances))) - ->setRawData($info) - ->setSize((int)$info['used_memory_dataset']) - ->setInfo( - sprintf( - "The Redis daemon v%s, php-ext v%s, is up since %s.\n For more information see RawData.", - $info['redis_version'], - \phpversion("redis"), - $date->format(DATE_RFC2822) - ) - ); - } - - /** - * @return bool - * @throws PhpfastcacheLogicException - */ - protected function driverConnect(): bool - { - if (isset($this->instance) && $this->instance instanceof RedisClient) { - throw new PhpfastcacheLogicException('Already connected to Redis server'); - } - - /** - * In case of an user-provided - * Redis client just return here - */ - if ($this->getConfig()->getRedisClient() instanceof RedisClient) { - /** - * Unlike Predis, we can't test if we're connected - * or not, so let's just assume that we are - */ - $this->instance = $this->getConfig()->getRedisClient(); - return true; - } - - $this->instance = $this->instance ?? new RedisClient(); - - /** - * If path is provided we consider it as a UNIX Socket - */ - if ($this->getConfig()->getPath()) { - $isConnected = $this->instance->connect($this->getConfig()->getPath()); - } else { - $isConnected = $this->instance->connect($this->getConfig()->getHost(), $this->getConfig()->getPort(), $this->getConfig()->getTimeout()); - } - - if (!$isConnected && $this->getConfig()->getPath()) { - return false; - } - - if ($this->getConfig()->getOptPrefix()) { - $this->instance->setOption(RedisClient::OPT_PREFIX, $this->getConfig()->getOptPrefix()); - } - - if ($this->getConfig()->getPassword() && !$this->instance->auth($this->getConfig()->getPassword())) { - return false; - } - - if ($this->getConfig()->getDatabase() !== null) { - $this->instance->select($this->getConfig()->getDatabase()); - } - return true; - } - - /** - * @return array - * @throws \RedisException - */ - protected function driverReadAllKeys(string $pattern = '*'): iterable - { - $i = null; - $pattern = $pattern === '' ? '*' : $pattern; - do { - $keys[] = $this->instance->scan($i, $pattern); - if (\count($keys) > ExtendedCacheItemPoolInterface::MAX_ALL_KEYS_COUNT) { - break; - } - } while ($i > 0); - return \array_merge([], ...$keys); - } - - /** - * @return bool - */ - protected function driverClear(): bool - { - return $this->instance->flushDB(); - } -} diff --git a/lib/Phpfastcache/Drivers/Redis/Item.php b/lib/Phpfastcache/Drivers/Redis/Item.php deleted file mode 100644 index d1c956e88..000000000 --- a/lib/Phpfastcache/Drivers/Redis/Item.php +++ /dev/null @@ -1,30 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -declare(strict_types=1); - -namespace Phpfastcache\Drivers\Redis; - -use Phpfastcache\Core\Item\ExtendedCacheItemInterface; -use Phpfastcache\Core\Item\TaggableCacheItemTrait; - -class Item implements ExtendedCacheItemInterface -{ - use TaggableCacheItemTrait; - - protected function getDriverClass(): string - { - return Driver::class; - } -} diff --git a/lib/Phpfastcache/Drivers/Redis/RedisDriverTrait.php b/lib/Phpfastcache/Drivers/Redis/RedisDriverTrait.php deleted file mode 100644 index 67569650f..000000000 --- a/lib/Phpfastcache/Drivers/Redis/RedisDriverTrait.php +++ /dev/null @@ -1,103 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -declare(strict_types=1); - -namespace Phpfastcache\Drivers\Redis; - -use Phpfastcache\Core\Item\ExtendedCacheItemInterface; -use Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException; -use Phpfastcache\Exceptions\PhpfastcacheLogicException; -use Redis as RedisClient; -use RedisCluster as RedisClusterClient; - -/** - * @property RedisClient|RedisClusterClient $instance - * @method Config getConfig() - */ -trait RedisDriverTrait -{ - /** - * @param ExtendedCacheItemInterface $item - * @return ?array - */ - protected function driverRead(ExtendedCacheItemInterface $item): ?array - { - $val = $this->instance->get($item->getKey()); - if (!$val) { - return null; - } - - return $this->decode($val); - } - - /** - * @param ExtendedCacheItemInterface ...$items - * @return array> - * @throws \Phpfastcache\Exceptions\PhpfastcacheDriverException - * @throws \RedisException - */ - protected function driverReadMultiple(ExtendedCacheItemInterface ...$items): array - { - $keys = $this->getKeys($items); - - return array_combine($keys, array_map( - fn($val) => $val ? $this->decode($val) : null, - $this->instance->mGet($keys) - )); - } - - /** - * @param ExtendedCacheItemInterface $item - * @return mixed - * @throws PhpfastcacheInvalidArgumentException - * @throws PhpfastcacheLogicException - */ - protected function driverWrite(ExtendedCacheItemInterface $item): bool - { - $this->assertCacheItemType($item, self::getItemClass()); - - $ttl = $item->getExpirationDate()->getTimestamp() - time(); - - /** - * @see https://redis.io/commands/setex - * @see https://redis.io/commands/expire - */ - if ($ttl <= 0) { - return $this->instance->expire($item->getKey(), 0); - } - - return $this->instance->setex($item->getKey(), $ttl, $this->encode($this->driverPreWrap($item))); - } - - /** - * @param string $key - * @param string $encodedKey - * @return bool - * @throws \RedisException - */ - protected function driverDelete(string $key, string $encodedKey): bool - { - return (bool) $this->instance->del($key); - } - - /** - * @param string[] $keys - * @return bool - */ - protected function driverDeleteMultiple(array $keys): bool - { - return (bool) $this->instance->del(...$keys); - } -} diff --git a/lib/Phpfastcache/Drivers/Rediscluster/Config.php b/lib/Phpfastcache/Drivers/Rediscluster/Config.php deleted file mode 100644 index 502f6584b..000000000 --- a/lib/Phpfastcache/Drivers/Rediscluster/Config.php +++ /dev/null @@ -1,186 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -declare(strict_types=1); - -namespace Phpfastcache\Drivers\Rediscluster; - -use Phpfastcache\Config\ConfigurationOption; -use Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException; -use Phpfastcache\Exceptions\PhpfastcacheLogicException; -use RedisCluster as RedisClusterClient; - -class Config extends ConfigurationOption -{ - /** - * @var array - */ - protected array $clusters = []; - protected string $password = ''; - protected int $timeout = 5; - protected int $readTimeout = 5; - protected ?RedisClusterClient $redisClusterClient = null; - protected string $optPrefix = ''; - protected ?int $slaveFailover = null; - - /** - * @return array - */ - public function getClusters(): array - { - return $this->clusters; - } - - /** - * @param string $cluster - * @return Config - */ - public function addCluster(string $cluster): static - { - $this->enforceLockedProperty(__FUNCTION__); - $this->clusters[] = $cluster; - return $this; - } - - /** - * @param string $clusters - * @return Config - */ - public function setClusters(...$clusters): static - { - return $this->setProperty('clusters', $clusters); - } - - /** - * @return string - */ - public function getPassword(): string - { - return $this->password; - } - - /** - * @param string $password - * - * @return static - * @throws PhpfastcacheLogicException - */ - public function setPassword(string $password): static - { - return $this->setProperty('password', $password); - } - - /** - * @return int - */ - public function getTimeout(): int - { - return $this->timeout; - } - - /** - * @param int $timeout - * @return static - * @throws PhpfastcacheLogicException - */ - public function setTimeout(int $timeout): static - { - return $this->setProperty('timeout', $timeout); - } - - /** - * @return int - */ - public function getReadTimeout(): int - { - return $this->readTimeout; - } - - /** - * @param int $readTimeout - * @return static - * @throws PhpfastcacheLogicException - */ - public function setReadTimeout(int $readTimeout): static - { - return $this->setProperty('readTimeout', $readTimeout); - } - - - /** - * @return RedisClusterClient|null - */ - public function getRedisClusterClient(): ?RedisClusterClient - { - return $this->redisClusterClient; - } - - /** - * @param RedisClusterClient|null $redisClusterClient - * @return Config - * @throws PhpfastcacheLogicException - */ - public function setRedisClusterClient(?RedisClusterClient $redisClusterClient): static - { - return $this->setProperty('redisClusterClient', $redisClusterClient); - } - - /** - * @return string - * @since 7.0.2 - */ - public function getOptPrefix(): string - { - return $this->optPrefix; - } - - /** - * @param string $optPrefix - * @return Config - * @throws PhpfastcacheLogicException - * @since 7.0.2 - */ - public function setOptPrefix(string $optPrefix): static - { - return $this->setProperty('optPrefix', trim($optPrefix)); - } - - /** - * @return int|null - */ - public function getSlaveFailover(): ?int - { - return $this->slaveFailover; - } - - /** - * @param int|null $slaveFailover - * @return Config - * @throws PhpfastcacheInvalidArgumentException - */ - public function setSlaveFailover(?int $slaveFailover): static - { - if ( - $slaveFailover !== null && !in_array($slaveFailover, [ - RedisClusterClient::FAILOVER_NONE, - RedisClusterClient::FAILOVER_ERROR, - RedisClusterClient::FAILOVER_DISTRIBUTE, - RedisClusterClient::FAILOVER_DISTRIBUTE_SLAVES, - ]) - ) { - throw new PhpfastcacheInvalidArgumentException('Invalid Slave Failover option: ' . $slaveFailover); - } - return $this->setProperty('slaveFailover', $slaveFailover); - } -} diff --git a/lib/Phpfastcache/Drivers/Rediscluster/Driver.php b/lib/Phpfastcache/Drivers/Rediscluster/Driver.php deleted file mode 100644 index d791201c1..000000000 --- a/lib/Phpfastcache/Drivers/Rediscluster/Driver.php +++ /dev/null @@ -1,151 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -declare(strict_types=1); - -namespace Phpfastcache\Drivers\Rediscluster; - -use DateTime; -use Phpfastcache\Cluster\AggregatablePoolInterface; -use Phpfastcache\Core\Pool\ExtendedCacheItemPoolInterface; -use Phpfastcache\Core\Pool\TaggableCacheItemPoolTrait; -use Phpfastcache\Drivers\Redis\RedisDriverTrait; -use Phpfastcache\Entities\DriverStatistic; -use Phpfastcache\Exceptions\PhpfastcacheLogicException; -use RedisCluster; - -/** - * @property RedisCluster $instance - * @method Config getConfig() - */ -class Driver implements AggregatablePoolInterface -{ - use RedisDriverTrait, TaggableCacheItemPoolTrait { - RedisDriverTrait::driverReadMultiple insteadof TaggableCacheItemPoolTrait; - RedisDriverTrait::driverDeleteMultiple insteadof TaggableCacheItemPoolTrait; - } - - /** - * @return bool - */ - public function driverCheck(): bool - { - return extension_loaded('Redis') && class_exists(RedisCluster::class); - } - - /** - * @return DriverStatistic - */ - public function getStats(): DriverStatistic - { - $masters = $this->instance->_masters(); - $infos = array_map(fn($cluster) => $this->instance->info($cluster), $masters); - $date = (new DateTime())->setTimestamp(time() - min(array_column($infos, 'uptime_in_seconds'))); - - return (new DriverStatistic()) - ->setData(implode(', ', array_keys($this->itemInstances))) - ->setRawData($infos) - ->setSize(array_sum(array_column($infos, 'used_memory_dataset'))) - ->setInfo( - sprintf( - trim(<<format(DATE_RFC2822) - ) - ); - } - - /** - * @return bool - * @throws PhpfastcacheLogicException - */ - protected function driverConnect(): bool - { - if (isset($this->instance) && $this->instance instanceof RedisCluster) { - throw new PhpfastcacheLogicException('Already connected to Redis server'); - } - - /** - * In case of a user-provided - * Redis client just return here - */ - if ($this->getConfig()->getRedisClusterClient() instanceof RedisCluster) { - /** - * Unlike Predis, we can't test if we're connected - * or not, so let's just assume that we are - */ - $this->instance = $this->getConfig()->getRedisClusterClient(); - return true; - } - - $this->instance = $this->instance ?? new RedisCluster( - null, - $this->getConfig()->getClusters(), - $this->getConfig()->getTimeout(), - $this->getConfig()->getReadTimeout(), - true, - $this->getConfig()->getPassword() - ); - - $this->instance->setOption(RedisCluster::OPT_SCAN, RedisCluster::SCAN_RETRY); - - if ($this->getConfig()->getOptPrefix()) { - $this->instance->setOption(RedisCluster::OPT_PREFIX, $this->getConfig()->getOptPrefix()); - } - - if ($this->getConfig()->getSlaveFailover()) { - $this->instance->setOption(RedisCluster::OPT_SLAVE_FAILOVER, $this->getConfig()->getSlaveFailover()); - } - - - return true; - } - - /** - * @return array - */ - protected function driverReadAllKeys(string $pattern = '*'): iterable - { - $result = [[]]; - foreach ($this->instance->_masters() as $master) { - $i = 0; - $pattern = $pattern === '' ? '*' : $pattern; - do { - $result[] = $this->instance->scan($i, $master, $pattern); - if (\count($result) > ExtendedCacheItemPoolInterface::MAX_ALL_KEYS_COUNT) { - break; - } - } while ($i > 0); - } - return array_unique(\array_merge(...$result)); - } - - /** - * @return bool - */ - protected function driverClear(): bool - { - foreach ($this->instance->_masters() as $nodeMaster) { - $this->instance->flushDb($nodeMaster); - } - return true; - } -} diff --git a/lib/Phpfastcache/Drivers/Rediscluster/Item.php b/lib/Phpfastcache/Drivers/Rediscluster/Item.php deleted file mode 100644 index fe5136281..000000000 --- a/lib/Phpfastcache/Drivers/Rediscluster/Item.php +++ /dev/null @@ -1,30 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -declare(strict_types=1); - -namespace Phpfastcache\Drivers\Rediscluster; - -use Phpfastcache\Core\Item\ExtendedCacheItemInterface; -use Phpfastcache\Core\Item\TaggableCacheItemTrait; - -class Item implements ExtendedCacheItemInterface -{ - use TaggableCacheItemTrait; - - protected function getDriverClass(): string - { - return Driver::class; - } -} diff --git a/lib/Phpfastcache/Drivers/Sqlite/Config.php b/lib/Phpfastcache/Drivers/Sqlite/Config.php deleted file mode 100644 index 8c92711a6..000000000 --- a/lib/Phpfastcache/Drivers/Sqlite/Config.php +++ /dev/null @@ -1,24 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -declare(strict_types=1); - -namespace Phpfastcache\Drivers\Sqlite; - -use Phpfastcache\Config\IOConfigurationOptionInterface; -use Phpfastcache\Config\IOConfigurationOption; - -class Config extends IOConfigurationOption implements IOConfigurationOptionInterface -{ -} diff --git a/lib/Phpfastcache/Drivers/Sqlite/Driver.php b/lib/Phpfastcache/Drivers/Sqlite/Driver.php deleted file mode 100644 index db86388d6..000000000 --- a/lib/Phpfastcache/Drivers/Sqlite/Driver.php +++ /dev/null @@ -1,341 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -declare(strict_types=1); - -namespace Phpfastcache\Drivers\Sqlite; - -use PDO; -use PDOException; -use Phpfastcache\Cluster\AggregatablePoolInterface; -use Phpfastcache\Core\Pool\DriverBaseTrait; -use Phpfastcache\Core\Pool\ExtendedCacheItemPoolInterface; -use Phpfastcache\Core\Pool\IO\IOHelperTrait; -use Phpfastcache\Core\Pool\TaggableCacheItemPoolTrait; -use Phpfastcache\Core\Item\ExtendedCacheItemInterface; -use Phpfastcache\Exceptions\PhpfastcacheCoreException; -use Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException; -use Phpfastcache\Exceptions\PhpfastcacheIOException; -use Phpfastcache\Exceptions\PhpfastcacheLogicException; -use Psr\Cache\CacheItemInterface; - -/** - * @method Config getConfig() - */ -class Driver implements AggregatablePoolInterface -{ - use IOHelperTrait; - - /** @var array */ - protected array $dbInstances = []; - protected const INDEXING_FILE = 'indexing'; - - protected int $maxSize = 10; - - protected int $currentDB = 1; - - protected string $sqliteDir = ''; - - protected ?PDO $indexing; - - /** - * @return bool - * @throws PhpfastcacheCoreException - */ - public function driverCheck(): bool - { - return extension_loaded('pdo_sqlite') && (is_writable($this->getSqliteDir()) || @mkdir($this->getSqliteDir(), $this->getDefaultChmod(), true)); - } - - /** - * @return string - * @throws PhpfastcacheCoreException - * @throws PhpfastcacheInvalidArgumentException - */ - public function getSqliteDir(): string - { - return $this->sqliteDir ?: $this->getPath(); - } - - /** - * @return array - */ - public function __sleep(): array - { - return array_diff(array_keys(get_object_vars($this)), ['indexing', 'instance']); - } - - /** - * @return bool - * @throws PhpfastcacheIOException - */ - protected function driverConnect(): bool - { - if (!file_exists($this->getSqliteDir()) && !@mkdir($this->getSqliteDir(), $this->getDefaultChmod(), true)) { - throw new PhpfastcacheIOException(sprintf('Sqlite cannot write in "%s", aborting...', $this->getPath())); - } - - $this->sqliteDir = $this->getPath(); - - return true; - } - - /** - * @param ExtendedCacheItemInterface $item - * @return ?array - */ - protected function driverRead(ExtendedCacheItemInterface $item): ?array - { - try { - $stm = $this->getDb($item->getEncodedKey()) - ->prepare("SELECT * FROM `caching` WHERE `keyword`=:keyword LIMIT 1"); - $stm->execute( - [ - ':keyword' => $item->getEncodedKey(), - ] - ); - $row = $stm->fetch(PDO::FETCH_ASSOC); - } catch (PDOException $e) { - try { - $stm = $this->getDb($item->getEncodedKey(), true) - ->prepare("SELECT * FROM `caching` WHERE `keyword`=:keyword LIMIT 1"); - $stm->execute( - [ - ':keyword' => $item->getEncodedKey(), - ] - ); - $row = $stm->fetch(PDO::FETCH_ASSOC); - } catch (PDOException $e) { - return null; - } - } - - if (isset($row['object'])) { - return $this->decode($row['object']); - } - - return null; - } - - /** - * @param string $keyword - * @param bool $reset - * @return PDO - */ - public function getDb(string $keyword, bool $reset = false): PDO - { - /** - * Default is phpfastcache - */ - $instant = $this->getDbIndex($keyword); - - /** - * init instant - */ - if (!isset($this->dbInstances[$instant])) { - // check DB Files ready or not - $tableCreated = false; - if ($reset || !file_exists($this->sqliteDir . '/db' . $instant)) { - $tableCreated = true; - } - $pdo = new PDO('sqlite:' . $this->sqliteDir . '/db' . $instant); - $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); - - if ($tableCreated) { - $this->initDB($pdo); - } - - $this->dbInstances[$instant] = $pdo; - unset($pdo); - } - - return $this->dbInstances[$instant]; - } - - /** - * Return Database of Keyword - * @param string $keyword - * @return int - */ - public function getDbIndex(string $keyword) - { - if (!isset($this->indexing)) { - $tableCreated = false; - if (!file_exists($this->sqliteDir . '/indexing')) { - $tableCreated = true; - } - - $pdo = new PDO("sqlite:" . $this->sqliteDir . '/' . self::INDEXING_FILE); - $pdo->setAttribute( - PDO::ATTR_ERRMODE, - PDO::ERRMODE_EXCEPTION - ); - - if ($tableCreated) { - $this->initIndexing($pdo); - } - $this->indexing = $pdo; - unset($pdo); - - $stm = $this->indexing->prepare("SELECT MAX(`db`) as `db` FROM `balancing`"); - $stm->execute(); - $row = $stm->fetch(PDO::FETCH_ASSOC); - if (!isset($row['db'])) { - $db = 1; - } elseif ($row['db'] <= 1) { - $db = 1; - } else { - $db = $row['db']; - } - - // check file size - - $size = file_exists($this->sqliteDir . '/db' . $db) ? filesize($this->sqliteDir . '/db' . $db) : 1; - $size = round($size / 1024 / 1024, 1); - - - if ($size > $this->maxSize) { - $db++; - } - $this->currentDB = $db; - } - - // look for keyword - $stm = $this->indexing->prepare("SELECT * FROM `balancing` WHERE `keyword`=:keyword LIMIT 1"); - $stm->execute( - [ - ':keyword' => $keyword, - ] - ); - $row = $stm->fetch(PDO::FETCH_ASSOC); - if (isset($row['db']) && $row['db'] != '') { - $db = $row['db']; - } else { - /* - * Insert new to Indexing - */ - $db = $this->currentDB; - $stm = $this->indexing->prepare("INSERT INTO `balancing` (`keyword`,`db`) VALUES(:keyword, :db)"); - $stm->execute( - [ - ':keyword' => $keyword, - ':db' => $db, - ] - ); - } - - return $db; - } - - /** - * INIT Indexing DB - * @param PDO $db - */ - public function initIndexing(PDO $db): void - { - // delete everything before reset indexing - $dir = opendir($this->sqliteDir); - while ($file = readdir($dir)) { - if ($file !== '.' && $file !== '..' && $file !== 'indexing' && $file !== 'dbfastcache') { - unlink($this->sqliteDir . '/' . $file); - } - } - - $db->exec('DROP TABLE if exists "balancing"'); - $db->exec('CREATE TABLE "balancing" ("keyword" VARCHAR PRIMARY KEY NOT NULL UNIQUE, "db" INTEGER)'); - $db->exec('CREATE INDEX "db" ON "balancing" ("db")'); - $db->exec('CREATE UNIQUE INDEX "lookup" ON "balancing" ("keyword")'); - } - - /** - * INIT NEW DB - * @param PDO $db - */ - protected function initDB(PDO $db): void - { - $db->exec('drop table if exists "caching"'); - $db->exec('CREATE TABLE "caching" ("id" INTEGER PRIMARY KEY AUTOINCREMENT, "keyword" VARCHAR UNIQUE, "object" BLOB, "exp" INTEGER)'); - $db->exec('CREATE UNIQUE INDEX "cleanup" ON "caching" ("keyword","exp")'); - $db->exec('CREATE INDEX "exp" ON "caching" ("exp")'); - $db->exec('CREATE UNIQUE INDEX "keyword" ON "caching" ("keyword")'); - } - - /** - * @param ExtendedCacheItemInterface $item - * @return mixed - * @throws PhpfastcacheInvalidArgumentException - * @throws PhpfastcacheLogicException - */ - protected function driverWrite(ExtendedCacheItemInterface $item): bool - { - - try { - $stm = $this->getDb($item->getEncodedKey()) - ->prepare("INSERT OR REPLACE INTO `caching` (`keyword`,`object`,`exp`) values(:keyword,:object,:exp)"); - $stm->execute( - [ - ':keyword' => $item->getEncodedKey(), - ':object' => $this->encode($this->driverPreWrap($item)), - ':exp' => $item->getExpirationDate()->getTimestamp(), - ] - ); - - return true; - } catch (PDOException $e) { - return false; - } - } - - /** - * @param string $key - * @param string $encodedKey - * @return bool - */ - protected function driverDelete(string $key, string $encodedKey): bool - { - try { - $stm = $this->getDb($encodedKey) - ->prepare("DELETE FROM `caching` WHERE (`exp` <= :exp) OR (`keyword`=:keyword) "); - - return $stm->execute( - [ - ':keyword' => $encodedKey, - ':exp' => time(), - ] - ); - } catch (PDOException $e) { - return false; - } - } - - /** - * @return bool - * @throws PhpfastcacheCoreException - */ - protected function driverClear(): bool - { - $this->dbInstances = []; - $this->indexing = null; - - // delete everything before reset indexing - $dir = opendir($this->getSqliteDir()); - while ($file = readdir($dir)) { - if ($file !== '.' && $file !== '..') { - unlink($this->getSqliteDir() . '/' . $file); - } - } - - return true; - } -} diff --git a/lib/Phpfastcache/Drivers/Sqlite/Item.php b/lib/Phpfastcache/Drivers/Sqlite/Item.php deleted file mode 100644 index 01e2ebd98..000000000 --- a/lib/Phpfastcache/Drivers/Sqlite/Item.php +++ /dev/null @@ -1,30 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -declare(strict_types=1); - -namespace Phpfastcache\Drivers\Sqlite; - -use Phpfastcache\Core\Item\ExtendedCacheItemInterface; -use Phpfastcache\Core\Item\TaggableCacheItemTrait; - -class Item implements ExtendedCacheItemInterface -{ - use TaggableCacheItemTrait; - - protected function getDriverClass(): string - { - return Driver::class; - } -} diff --git a/lib/Phpfastcache/Drivers/Ssdb/Config.php b/lib/Phpfastcache/Drivers/Ssdb/Config.php deleted file mode 100644 index 5680f970d..000000000 --- a/lib/Phpfastcache/Drivers/Ssdb/Config.php +++ /dev/null @@ -1,99 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -declare(strict_types=1); - -namespace Phpfastcache\Drivers\Ssdb; - -use Phpfastcache\Config\ConfigurationOption; -use Phpfastcache\Exceptions\PhpfastcacheLogicException; - -class Config extends ConfigurationOption -{ - protected string $host = '127.0.0.1'; - protected int $port = 8888; - protected string $password = ''; - protected int $timeout = 2000; -/** - * @return string - */ - public function getHost(): string - { - return $this->host; - } - - /** - * @param string $host - * @return Config - * @throws PhpfastcacheLogicException - */ - public function setHost(string $host): Config - { - return $this->setProperty('host', $host); - } - - /** - * @return int - */ - public function getPort(): int - { - return $this->port; - } - - /** - * @param int $port - * @return Config - * @throws PhpfastcacheLogicException - */ - public function setPort(int $port): Config - { - return $this->setProperty('port', $port); - } - - /** - * @return string - */ - public function getPassword(): string - { - return $this->password; - } - - /** - * @param string $password - * @return Config - * @throws PhpfastcacheLogicException - */ - public function setPassword(string $password): Config - { - return $this->setProperty('password', $password); - } - - /** - * @return int - */ - public function getTimeout(): int - { - return $this->timeout; - } - - /** - * @param int $timeout - * @return Config - * @throws PhpfastcacheLogicException - */ - public function setTimeout(int $timeout): Config - { - return $this->setProperty('timeout', $timeout); - } -} diff --git a/lib/Phpfastcache/Drivers/Ssdb/Driver.php b/lib/Phpfastcache/Drivers/Ssdb/Driver.php deleted file mode 100644 index 3c7067d52..000000000 --- a/lib/Phpfastcache/Drivers/Ssdb/Driver.php +++ /dev/null @@ -1,138 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -declare(strict_types=1); - -namespace Phpfastcache\Drivers\Ssdb; - -use Phpfastcache\Cluster\AggregatablePoolInterface; -use Phpfastcache\Core\Pool\ExtendedCacheItemPoolInterface; -use Phpfastcache\Core\Pool\TaggableCacheItemPoolTrait; -use Phpfastcache\Core\Item\ExtendedCacheItemInterface; -use Phpfastcache\Entities\DriverStatistic; -use Phpfastcache\Exceptions\PhpfastcacheDriverCheckException; -use Phpfastcache\Exceptions\PhpfastcacheDriverException; -use Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException; -use Phpfastcache\Exceptions\PhpfastcacheLogicException; -use phpssdb\Core\SimpleSSDB; -use phpssdb\Core\SSDBException; -use phpssdb\Core\SSDB; - -/** - * @property SimpleSSDB $instance Instance of driver service - * @method Config getConfig() - */ -class Driver implements AggregatablePoolInterface -{ - use TaggableCacheItemPoolTrait; - - /** - * @return bool - */ - public function driverCheck(): bool - { - static $driverCheck; - - return $driverCheck ?? ($driverCheck = class_exists(SSDB::class)); - } - - /** - * @return DriverStatistic - */ - public function getStats(): DriverStatistic - { - $stat = new DriverStatistic(); - $info = $this->instance->info(); - - /** - * Data returned by Ssdb are very poorly formatted - * using hardcoded offset of pair key-value :-( - */ - $stat->setInfo(sprintf("Ssdb-server v%s with a total of %s call(s).\n For more information see RawData.", $info[2], $info[6])) - ->setRawData($info) - ->setData(implode(', ', array_keys($this->itemInstances))) - ->setSize($this->instance->dbsize()); - - return $stat; - } - - /** - * @return bool - * @throws PhpfastcacheDriverException - */ - protected function driverConnect(): bool - { - try { - $clientConfig = $this->getConfig(); - - $this->instance = new SimpleSSDB($clientConfig->getHost(), $clientConfig->getPort(), $clientConfig->getTimeout()); - if (!empty($clientConfig->getPassword())) { - $this->instance->auth($clientConfig->getPassword()); - } - $this->instance->ping(); - - return true; - } catch (SSDBException $e) { - throw new PhpfastcacheDriverCheckException('Ssdb failed to connect with error: ' . $e->getMessage(), 0, $e); - } - } - - /** - * @param ExtendedCacheItemInterface $item - * @return ?array - */ - protected function driverRead(ExtendedCacheItemInterface $item): ?array - { - $val = $this->instance->get($item->getEncodedKey()); - - if (empty($val)) { - return null; - } - - return $this->decode($val); - } - - /** - * @param ExtendedCacheItemInterface $item - * @return mixed - * @throws PhpfastcacheInvalidArgumentException - * @throws PhpfastcacheLogicException - */ - protected function driverWrite(ExtendedCacheItemInterface $item): bool - { - - return (bool)$this->instance->setx($item->getEncodedKey(), $this->encode($this->driverPreWrap($item)), $item->getTtl()); - } - - /** - * @param string $key - * @param string $encodedKey - * @return bool - */ - protected function driverDelete(string $key, string $encodedKey): bool - { - return (bool)$this->instance->del($encodedKey); - } - - /** - * @return bool - */ - protected function driverClear(): bool - { - $this->instance->flushdb('kv'); - - // Status not returned, then we assume its true - return true; - } -} diff --git a/lib/Phpfastcache/Drivers/Ssdb/Item.php b/lib/Phpfastcache/Drivers/Ssdb/Item.php deleted file mode 100644 index 03d074137..000000000 --- a/lib/Phpfastcache/Drivers/Ssdb/Item.php +++ /dev/null @@ -1,30 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -declare(strict_types=1); - -namespace Phpfastcache\Drivers\Ssdb; - -use Phpfastcache\Core\Item\ExtendedCacheItemInterface; -use Phpfastcache\Core\Item\TaggableCacheItemTrait; - -class Item implements ExtendedCacheItemInterface -{ - use TaggableCacheItemTrait; - - protected function getDriverClass(): string - { - return Driver::class; - } -} diff --git a/lib/Phpfastcache/Drivers/Wincache/Config.php b/lib/Phpfastcache/Drivers/Wincache/Config.php deleted file mode 100644 index 5b33a9f36..000000000 --- a/lib/Phpfastcache/Drivers/Wincache/Config.php +++ /dev/null @@ -1,35 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -declare(strict_types=1); - -namespace Phpfastcache\Drivers\Wincache; - -use Phpfastcache\Config\ConfigurationOption; - -/** - * @deprecated will be removed as of v10 due to the lack of updates to PHP8 as officially stated by PHP: https://www.php.net/manual/en/install.windows.recommended.php - */ -class Config extends ConfigurationOption -{ - public function __construct(array $parameters = []) - { - trigger_error( - 'Wincache is now deprecated and will be removed as of v10 due to the lack of updates to PHP8 as officially stated by PHP: - https://www.php.net/manual/en/install.windows.recommended.php', - E_USER_DEPRECATED - ); - parent::__construct($parameters); - } -} diff --git a/lib/Phpfastcache/Drivers/Wincache/Driver.php b/lib/Phpfastcache/Drivers/Wincache/Driver.php deleted file mode 100644 index 111aae8e9..000000000 --- a/lib/Phpfastcache/Drivers/Wincache/Driver.php +++ /dev/null @@ -1,119 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -declare(strict_types=1); - -namespace Phpfastcache\Drivers\Wincache; - -use DateTime; -use Phpfastcache\Cluster\AggregatablePoolInterface; -use Phpfastcache\Core\Pool\ExtendedCacheItemPoolInterface; -use Phpfastcache\Core\Pool\TaggableCacheItemPoolTrait; -use Phpfastcache\Core\Item\ExtendedCacheItemInterface; -use Phpfastcache\Entities\DriverStatistic; -use Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException; -use Phpfastcache\Exceptions\PhpfastcacheLogicException; - -/** - * @deprecated will be removed as of v10 due to the lack of updates to PHP8 as officially stated by PHP: https://www.php.net/manual/en/install.windows.recommended.php - * @method Config getConfig() - */ -class Driver implements AggregatablePoolInterface -{ - use TaggableCacheItemPoolTrait; - - /** - * @return bool - */ - public function driverCheck(): bool - { - return extension_loaded('wincache') && function_exists('wincache_ucache_set'); - } - - public function getHelp(): string - { - return <<setTimestamp(time() - $info['total_cache_uptime']); - - return (new DriverStatistic()) - ->setInfo(sprintf("The Wincache daemon is up since %s.\n For more information see RawData.", $date->format(DATE_RFC2822))) - ->setSize($memInfo['memory_free'] - $memInfo['memory_total']) - ->setData(implode(', ', array_keys($this->itemInstances))) - ->setRawData($memInfo); - } - - /** - * @return bool - */ - protected function driverConnect(): bool - { - return true; - } - - /** - * @param ExtendedCacheItemInterface $item - * @return ?array - */ - protected function driverRead(ExtendedCacheItemInterface $item): ?array - { - $val = wincache_ucache_get($item->getKey(), $suc); - - if ($suc === false || empty($val)) { - return null; - } - - return $val; - } - - /** - * @param ExtendedCacheItemInterface $item - * @return mixed - * @throws PhpfastcacheInvalidArgumentException - * @throws PhpfastcacheLogicException - */ - protected function driverWrite(ExtendedCacheItemInterface $item): bool - { - - return wincache_ucache_set($item->getKey(), $this->driverPreWrap($item), $item->getTtl()); - } - - /** - * @param string $key - * @param string $encodedKey - * @return bool - */ - protected function driverDelete(string $key, string $encodedKey): bool - { - return wincache_ucache_delete($key); - } - - /** - * @return bool - */ - protected function driverClear(): bool - { - return wincache_ucache_clear(); - } -} diff --git a/lib/Phpfastcache/Drivers/Wincache/Item.php b/lib/Phpfastcache/Drivers/Wincache/Item.php deleted file mode 100644 index f490fbe3e..000000000 --- a/lib/Phpfastcache/Drivers/Wincache/Item.php +++ /dev/null @@ -1,33 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -declare(strict_types=1); - -namespace Phpfastcache\Drivers\Wincache; - -use Phpfastcache\Core\Item\ExtendedCacheItemInterface; -use Phpfastcache\Core\Item\TaggableCacheItemTrait; - -/** - * @deprecated will be removed as of v10 due to the lack of updates to PHP8 as officially stated by PHP: https://www.php.net/manual/en/install.windows.recommended.php - */ -class Item implements ExtendedCacheItemInterface -{ - use TaggableCacheItemTrait; - - protected function getDriverClass(): string - { - return Driver::class; - } -} diff --git a/lib/Phpfastcache/Drivers/Zenddisk/Config.php b/lib/Phpfastcache/Drivers/Zenddisk/Config.php deleted file mode 100644 index 7ae7742cd..000000000 --- a/lib/Phpfastcache/Drivers/Zenddisk/Config.php +++ /dev/null @@ -1,23 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -declare(strict_types=1); - -namespace Phpfastcache\Drivers\Zenddisk; - -use Phpfastcache\Config\ConfigurationOption; - -class Config extends ConfigurationOption -{ -} diff --git a/lib/Phpfastcache/Drivers/Zenddisk/Driver.php b/lib/Phpfastcache/Drivers/Zenddisk/Driver.php deleted file mode 100644 index 93a895cff..000000000 --- a/lib/Phpfastcache/Drivers/Zenddisk/Driver.php +++ /dev/null @@ -1,120 +0,0 @@ - - * - */ - -declare(strict_types=1); - -namespace Phpfastcache\Drivers\Zenddisk; - -use Phpfastcache\Cluster\AggregatablePoolInterface; -use Phpfastcache\Core\Pool\ExtendedCacheItemPoolInterface; -use Phpfastcache\Core\Pool\TaggableCacheItemPoolTrait; -use Phpfastcache\Core\Item\ExtendedCacheItemInterface; -use Phpfastcache\Entities\DriverStatistic; -use Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException; - -/** - * Requires Zend Data Cache Functions from ZendServer - * @method Config getConfig() - */ -class Driver implements AggregatablePoolInterface -{ - use TaggableCacheItemPoolTrait; - - /** - * @return bool - */ - public function driverCheck(): bool - { - return extension_loaded('Zend Data Cache') && function_exists('zend_disk_cache_store'); - } - - /** - * @return string - */ - public function getHelp(): string - { - return << -This driver rely on Zend Server 8.5+, see: https://www.zend.com/products/zend-server -

-HELP; - } - - /** - * @return DriverStatistic - */ - public function getStats(): DriverStatistic - { - $stat = new DriverStatistic(); - $stat->setInfo('[ZendDisk] A void info string') - ->setSize(0) - ->setData(implode(', ', array_keys($this->itemInstances))) - ->setRawData(false); - - return $stat; - } - - /** - * @return bool - */ - protected function driverConnect(): bool - { - return true; - } - - /** - * @param ExtendedCacheItemInterface $item - * @return ?array - */ - protected function driverRead(ExtendedCacheItemInterface $item): ?array - { - $data = zend_disk_cache_fetch($item->getKey()); - - if (empty($data) || !\is_array($data)) { - return null; - } - - return $data; - } - - /** - * @param ExtendedCacheItemInterface $item - * @return mixed - * @throws PhpfastcacheInvalidArgumentException - */ - protected function driverWrite(ExtendedCacheItemInterface $item): bool - { - - $ttl = $item->getExpirationDate()->getTimestamp() - time(); - - return zend_disk_cache_store($item->getKey(), $this->driverPreWrap($item), ($ttl > 0 ? $ttl : 0)); - } - - /** - * @param string $key - * @param string $encodedKey - * @return bool - */ - protected function driverDelete(string $key, string $encodedKey): bool - { - - return (bool)zend_disk_cache_delete($key); - } - - - protected function driverClear(): bool - { - return @zend_disk_cache_clear(); - } -} diff --git a/lib/Phpfastcache/Drivers/Zenddisk/Item.php b/lib/Phpfastcache/Drivers/Zenddisk/Item.php deleted file mode 100644 index f0fba9a9c..000000000 --- a/lib/Phpfastcache/Drivers/Zenddisk/Item.php +++ /dev/null @@ -1,30 +0,0 @@ - - * - */ - -declare(strict_types=1); - -namespace Phpfastcache\Drivers\Zenddisk; - -use Phpfastcache\Core\Item\ExtendedCacheItemInterface; -use Phpfastcache\Core\Item\TaggableCacheItemTrait; - -class Item implements ExtendedCacheItemInterface -{ - use TaggableCacheItemTrait; - - protected function getDriverClass(): string - { - return Driver::class; - } -} diff --git a/lib/Phpfastcache/Drivers/Zendshm/Config.php b/lib/Phpfastcache/Drivers/Zendshm/Config.php deleted file mode 100644 index 73492526a..000000000 --- a/lib/Phpfastcache/Drivers/Zendshm/Config.php +++ /dev/null @@ -1,23 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -declare(strict_types=1); - -namespace Phpfastcache\Drivers\Zendshm; - -use Phpfastcache\Config\ConfigurationOption; - -class Config extends ConfigurationOption -{ -} diff --git a/lib/Phpfastcache/Drivers/Zendshm/Driver.php b/lib/Phpfastcache/Drivers/Zendshm/Driver.php deleted file mode 100644 index 157c744e8..000000000 --- a/lib/Phpfastcache/Drivers/Zendshm/Driver.php +++ /dev/null @@ -1,117 +0,0 @@ - - * - */ - -declare(strict_types=1); - -namespace Phpfastcache\Drivers\Zendshm; - -use Phpfastcache\Cluster\AggregatablePoolInterface; -use Phpfastcache\Core\Pool\ExtendedCacheItemPoolInterface; -use Phpfastcache\Core\Pool\TaggableCacheItemPoolTrait; -use Phpfastcache\Core\Item\ExtendedCacheItemInterface; -use Phpfastcache\Entities\DriverStatistic; -use Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException; - -/** - * Requires Zend Data Cache Functions from ZendServer - * @method Config getConfig() - */ -class Driver implements AggregatablePoolInterface -{ - use TaggableCacheItemPoolTrait; - - /** - * @return bool - */ - public function driverCheck(): bool - { - return extension_loaded('Zend Data Cache') && function_exists('zend_shm_cache_store'); - } - - /** - * @return string - */ - public function getHelp(): string - { - return << -This driver rely on Zend Server 8.5+, see: https://www.zend.com/products/zend-server -

-HELP; - } - - /** - * @return DriverStatistic - */ - public function getStats(): DriverStatistic - { - $stats = (array)zend_shm_cache_info(); - return (new DriverStatistic()) - ->setData(implode(', ', array_keys($this->itemInstances))) - ->setInfo(sprintf("The Zend memory have %d item(s) in cache.\n For more information see RawData.", $stats['items_total'])) - ->setRawData($stats) - ->setSize($stats['memory_total']); - } - - /** - * @return bool - */ - protected function driverConnect(): bool - { - return true; - } - - /** - * @param ExtendedCacheItemInterface $item - * @return ?array - */ - protected function driverRead(ExtendedCacheItemInterface $item): ?array - { - $data = zend_shm_cache_fetch($item->getKey()); - - if (empty($data) || !\is_array($data)) { - return null; - } - - return $data; - } - - /** - * @param ExtendedCacheItemInterface $item - * @return mixed - * @throws PhpfastcacheInvalidArgumentException - */ - protected function driverWrite(ExtendedCacheItemInterface $item): bool - { - - $ttl = $item->getExpirationDate()->getTimestamp() - time(); - - return zend_shm_cache_store($item->getKey(), $this->driverPreWrap($item), ($ttl > 0 ? $ttl : 0)); - } - - /** - * @param string $key - * @param string $encodedKey - * @return bool - */ - protected function driverDelete(string $key, string $encodedKey): bool - { - return (bool)zend_shm_cache_delete($key); - } - - protected function driverClear(): bool - { - return @zend_shm_cache_clear(); - } -} diff --git a/lib/Phpfastcache/Drivers/Zendshm/Item.php b/lib/Phpfastcache/Drivers/Zendshm/Item.php deleted file mode 100644 index 3af071a71..000000000 --- a/lib/Phpfastcache/Drivers/Zendshm/Item.php +++ /dev/null @@ -1,30 +0,0 @@ - - * - */ - -declare(strict_types=1); - -namespace Phpfastcache\Drivers\Zendshm; - -use Phpfastcache\Core\Item\ExtendedCacheItemInterface; -use Phpfastcache\Core\Item\TaggableCacheItemTrait; - -class Item implements ExtendedCacheItemInterface -{ - use TaggableCacheItemTrait; - - protected function getDriverClass(): string - { - return Driver::class; - } -} diff --git a/lib/Phpfastcache/Entities/DriverIO.php b/lib/Phpfastcache/Entities/DriverIO.php deleted file mode 100644 index 1d1361cb1..000000000 --- a/lib/Phpfastcache/Entities/DriverIO.php +++ /dev/null @@ -1,82 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -declare(strict_types=1); - -namespace Phpfastcache\Entities; - -class DriverIO -{ - protected int $writeHit = 0; - - protected int $readHit = 0; - - protected int $readMiss = 0; - - - public function getWriteHit(): int - { - return $this->writeHit; - } - - /** - * @param int $writeHit - * @return DriverIO - */ - public function setWriteHit(int $writeHit): DriverIO - { - $this->writeHit = $writeHit; - return $this; - } - - public function incWriteHit(): DriverIO - { - $this->writeHit++; - return $this; - } - - public function getReadHit(): int - { - return $this->readHit; - } - - public function setReadHit(int $readHit): DriverIO - { - $this->readHit = $readHit; - return $this; - } - - public function incReadHit(): DriverIO - { - $this->readHit++; - return $this; - } - - public function getReadMiss(): int - { - return $this->readMiss; - } - - public function setReadMiss(int $readMiss): DriverIO - { - $this->readMiss = $readMiss; - return $this; - } - - public function incReadMiss(): DriverIO - { - $this->readMiss++; - return $this; - } -} diff --git a/lib/Phpfastcache/Entities/DriverStatistic.php b/lib/Phpfastcache/Entities/DriverStatistic.php deleted file mode 100644 index 26f5b7fec..000000000 --- a/lib/Phpfastcache/Entities/DriverStatistic.php +++ /dev/null @@ -1,130 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -declare(strict_types=1); - -namespace Phpfastcache\Entities; - -/** - * @see https://github.com/PHPSocialNetwork/phpfastcache/wiki/%5BV5%CB%96%5D-The-cache-statistics - */ -class DriverStatistic -{ - protected string $info = ''; - - protected ?int $size = 0; - - protected ?int $count = 0; - - protected string $data = ''; - - protected mixed $rawData; - - /** - * Return quick information about the driver instance - * @return string - */ - public function getInfo(): string - { - return $this->info; - } - - public function setInfo(string $info): static - { - $this->info = $info; - - return $this; - } - - /** - * Return the approximate size taken by the driver instance (in bytes) (null if unsupported by the driver) - * @return int|null - */ - public function getSize(): ?int - { - return $this->size; - } - - public function setSize(?int $size): static - { - $this->size = $size; - - return $this; - } - - /** - * Return the approximate count of elements stored in a driver database (or collection if applicable). Added in v9.2.3 - * @since 9.2.3 - * @return int|null - */ - public function getCount(): ?int - { - return $this->count; - } - - public function setCount(?int $count): static - { - $this->count = $count; - return $this; - } - - /** - * Return an array of item keys used by this driver instance (deprecated as of v9.2.3, will be removed as of v10) - * @deprecated as of phpfastcache 9.2.3, will be removed as of v10 - */ - public function getData(): string - { - return $this->data; - } - - /** - * @deprecated as of phpfastcache 9.2.3, will be removed as of v10 - */ - public function setData(string $data): static - { - $this->data = ($data ?: ''); - - return $this; - } - - /** - * Return a bunch of random data provided by the driver. Any type can be provided, usually an array - * @return mixed - */ - public function getRawData(): mixed - { - return $this->rawData; - } - - public function setRawData(mixed $raw): static - { - $this->rawData = $raw; - - return $this; - } - - /** - * @return array - */ - public function getPublicDesc(): array - { - return [ - 'Info' => 'Cache Information', - 'Size' => 'Cache Size', - 'Count' => 'Cache database/collection count', - 'Data' => 'Cache items keys (Deprecated)', - 'RawData' => 'Cache raw data', - ]; - } -} diff --git a/lib/Phpfastcache/Entities/ItemBatch.php b/lib/Phpfastcache/Entities/ItemBatch.php deleted file mode 100644 index 4bf172466..000000000 --- a/lib/Phpfastcache/Entities/ItemBatch.php +++ /dev/null @@ -1,49 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -declare(strict_types=1); - -namespace Phpfastcache\Entities; - -use DateTimeInterface; - -class ItemBatch -{ - /** - * ItemBatch constructor. - * @param string $itemKey - * @param DateTimeInterface $itemDate - */ - public function __construct( - protected string $itemKey, - protected DateTimeInterface $itemDate - ) { - } - - /** - * @return string - */ - public function getItemKey(): string - { - return $this->itemKey; - } - - /** - * @return DateTimeInterface - */ - public function getItemDate(): DateTimeInterface - { - return $this->itemDate; - } -} diff --git a/lib/Phpfastcache/Event/Event.php b/lib/Phpfastcache/Event/Event.php deleted file mode 100644 index 1225a5b69..000000000 --- a/lib/Phpfastcache/Event/Event.php +++ /dev/null @@ -1,50 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -declare(strict_types=1); - -namespace Phpfastcache\Event; - -use Phpfastcache\Helper\UninstanciableObjectTrait; - -class Event implements EventInterface -{ - use UninstanciableObjectTrait; - - public const CACHE_GET_ITEM = 'CacheGetItem'; - public const CACHE_GET_ITEMS = 'CacheGetItems'; - public const CACHE_DELETE_ITEM = 'CacheDeleteItem'; - public const CACHE_DELETE_ITEMS = 'CacheDeleteItems'; - public const CACHE_SAVE_ITEM = 'CacheSaveItem'; - public const CACHE_SAVE_MULTIPLE_ITEMS = 'CacheSaveMultipleItems'; - public const CACHE_SAVE_DEFERRED_ITEM = 'CacheSaveDeferredItem'; - public const CACHE_COMMIT_ITEM = 'CacheCommitItem'; - public const CACHE_CLEAR_ITEM = 'CacheClearItem'; - public const CACHE_WRITE_FILE_ON_DISK = 'CacheWriteFileOnDisk'; - public const CACHE_GET_ITEM_IN_SLAM_BATCH = 'CacheGetItemInSlamBatch'; - public const CACHE_REPLICATION_SLAVE_FALLBACK = 'CacheReplicationSlaveFallback'; - public const CACHE_REPLICATION_RANDOM_POOL_CHOSEN = 'CacheReplicationRandomPoolChosen'; - public const CACHE_CLUSTER_BUILT = 'CacheClusterBuilt'; - public const CACHE_ITEM_SET = 'CacheItemSet'; - public const CACHE_ITEM_EXPIRE_AT = 'CacheItemExpireAt'; - public const CACHE_ITEM_EXPIRE_AFTER = 'CacheItemExpireAfter'; - public const CACHE_GET_ALL_ITEMS = 'CacheGetAllItems'; - public const CACHE_DRIVER_CHECKED = 'CacheDriverChecked'; - public const CACHE_DRIVER_CONNECTED = 'CacheDriverConnected'; - - public static function getEvents(): array - { - return (new \ReflectionClass(static::class))->getConstants(); - } -} diff --git a/lib/Phpfastcache/Event/EventInterface.php b/lib/Phpfastcache/Event/EventInterface.php deleted file mode 100644 index f951e3e58..000000000 --- a/lib/Phpfastcache/Event/EventInterface.php +++ /dev/null @@ -1,25 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -declare(strict_types=1); - -namespace Phpfastcache\Event; - -interface EventInterface -{ - /** - * @return array - */ - public static function getEvents(): array; -} diff --git a/lib/Phpfastcache/Event/EventManagerDispatcherInterface.php b/lib/Phpfastcache/Event/EventManagerDispatcherInterface.php deleted file mode 100644 index 90975bf4b..000000000 --- a/lib/Phpfastcache/Event/EventManagerDispatcherInterface.php +++ /dev/null @@ -1,37 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -declare(strict_types=1); - -namespace Phpfastcache\Event; - -interface EventManagerDispatcherInterface -{ - /** - * @return EventManagerInterface - */ - public function getEventManager(): EventManagerInterface; - - /** - * @param EventManagerInterface $eventManager - * @return mixed - */ - public function setEventManager(EventManagerInterface $eventManager): static; - - /** - * @return bool - * @deprecated Will be removed in v10 - */ - public function hasEventManager(): bool; -} diff --git a/lib/Phpfastcache/Event/EventManagerDispatcherTrait.php b/lib/Phpfastcache/Event/EventManagerDispatcherTrait.php deleted file mode 100644 index e98c2d716..000000000 --- a/lib/Phpfastcache/Event/EventManagerDispatcherTrait.php +++ /dev/null @@ -1,51 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -declare(strict_types=1); - -namespace Phpfastcache\Event; - -trait EventManagerDispatcherTrait -{ - /** - * @var EventManagerInterface - */ - protected EventManagerInterface $eventManager; -/** - * @return EventManagerInterface - */ - public function getEventManager(): EventManagerInterface - { - return $this->eventManager; - } - - /** - * @param EventManagerInterface $em - * @return static - */ - public function setEventManager(EventManagerInterface $em): static - { - $this->eventManager = $em; - return $this; - } - - /** - * @deprecated Will be removed in v10 - * @return bool - */ - public function hasEventManager(): bool - { - return isset($this->eventManager); - } -} diff --git a/lib/Phpfastcache/Event/EventManagerInterface.php b/lib/Phpfastcache/Event/EventManagerInterface.php deleted file mode 100644 index 7dcfb6aaa..000000000 --- a/lib/Phpfastcache/Event/EventManagerInterface.php +++ /dev/null @@ -1,118 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -declare(strict_types=1); - -namespace Phpfastcache\Event; - -use BadMethodCallException; -use Phpfastcache\Core\Pool\ExtendedCacheItemPoolInterface; -use Phpfastcache\Exceptions\PhpfastcacheEventManagerException; -use Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException; - -/** - * == ItemPool Events == - * @method Void onCacheGetItem(Callable $callable, ?string $callbackName = null) - * @method Void onCacheGetItems(Callable $callable, ?string $callbackName = null) - * @method Void onCacheDeleteItem(Callable $callable, ?string $callbackName = null) - * @method Void onCacheSaveItem(Callable $callable, ?string $callbackName = null) - * @method Void onCacheSaveMultipleItems(Callable $callable, ?string $callbackName = null) - * @method Void onCacheSaveDeferredItem(Callable $callable, ?string $callbackName = null) - * @method Void onCacheCommitItem(Callable $callable, ?string $callbackName = null) - * @method Void onCacheClearItem(Callable $callable, ?string $callbackName = null) - * @method Void onCacheWriteFileOnDisk(Callable $callable, ?string $callbackName = null) - * @method Void onCacheGetItemInSlamBatch(Callable $callable, ?string $callbackName = null) - * - * == ItemPool Events (Cluster) == - * @method Void onCacheReplicationSlaveFallback(Callable $callable, ?string $callbackName = null) - * @method Void onCacheReplicationRandomPoolChosen(Callable $callable, ?string $callbackName = null) - * @method Void onCacheClusterBuilt(Callable $callable, ?string $callbackName = null) - * - * == Item Events == - * @method Void onCacheItemSet(Callable $callable, ?string $callbackName = null) - * @method Void onCacheItemExpireAt(Callable $callable, ?string $callbackName = null) - * @method Void onCacheItemExpireAfter(Callable $callable, ?string $callbackName = null) - * - * == Driver-specific events == - * @method Void onArangodbConnection(Callable $callable, ?string $callbackName = null) - * @method Void onArangodbCollectionParams(Callable $callable, ?string $callbackName = null) - * @method Void onCouchdbCreateOptions(Callable $callable, ?string $callbackName = null) - * @method Void onDynamodbCreateTable(Callable $callable, ?string $callbackName = null) - * @method Void onSolrBuildEndpoint(Callable $callable, ?string $callbackName = null) - * @method Void onFirestoreClientOptions(Callable $callable, ?string $callbackName = null) - */ -interface EventManagerInterface -{ - /** - * @return self - */ - public static function getInstance(): EventManagerInterface; - - /** - * @param EventManagerInterface $eventManagerInstance - * @return void - */ - public static function setInstance(EventManagerInterface $eventManagerInstance): void; - - /** - * @param string $eventName - * @param array $args - */ - public function dispatch(string $eventName, ...$args): void; - - /** - * @param string $name - * @param array $arguments - * @throws PhpfastcacheInvalidArgumentException - * @throws BadMethodCallException - */ - public function __call(string $name, array $arguments): void; - - /** - * @param callable $callback - * @param string $callbackName - */ - public function onEveryEvents(callable $callback, string $callbackName): void; - - /** - * @param string[]|string $events - * @param callable $callback - */ - public function on(array|string $events, callable $callback): void; - - /** - * @param string $eventName - * @param string $callbackName - * @return bool - */ - public function unbindEventCallback(string $eventName, string $callbackName): bool; - - /** - * @return bool - */ - public function unbindAllEventCallbacks(): bool; - - /** - * @param ExtendedCacheItemPoolInterface $pool - * @return EventManagerInterface - */ - public function getScopedEventManager(ExtendedCacheItemPoolInterface $pool): EventManagerInterface; - - /** - * @param ExtendedCacheItemPoolInterface $pool - * @return EventManagerInterface - * @throws PhpfastcacheEventManagerException - */ - public function setItemPoolContext(ExtendedCacheItemPoolInterface $pool): EventManagerInterface; -} diff --git a/lib/Phpfastcache/Event/EventReferenceParameter.php b/lib/Phpfastcache/Event/EventReferenceParameter.php deleted file mode 100644 index 170a044e8..000000000 --- a/lib/Phpfastcache/Event/EventReferenceParameter.php +++ /dev/null @@ -1,56 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -declare(strict_types=1); - -namespace Phpfastcache\Event; - -use Phpfastcache\Exceptions\PhpfastcacheInvalidTypeException; - -class EventReferenceParameter -{ - public function __construct(protected mixed &$parameter, protected bool $allowTypeChange = false) - { - } - - public function getParameterValue(): mixed - { - return $this->parameter; - } - - /** - * @throws PhpfastcacheInvalidTypeException - */ - public function setParameterValue(mixed $newValue): void - { - if (!$this->allowTypeChange) { - $currentType = \gettype($this->parameter); - $newType = \gettype($newValue); - if ($newType !== $currentType) { - throw new PhpfastcacheInvalidTypeException(\sprintf( - 'You tried to change the variable type from "%s" to "%s", which is not allowed.', - $currentType, - $newType - )); - } - } - - $this->parameter = $newValue; - } - - public function __invoke(): mixed - { - return $this->getParameterValue(); - } -} diff --git a/lib/Phpfastcache/EventManager.php b/lib/Phpfastcache/EventManager.php deleted file mode 100644 index 9c6465754..000000000 --- a/lib/Phpfastcache/EventManager.php +++ /dev/null @@ -1,197 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -declare(strict_types=1); - -namespace Phpfastcache; - -use Phpfastcache\Core\Pool\ExtendedCacheItemPoolInterface; -use Phpfastcache\Event\EventManagerInterface; -use Phpfastcache\Exceptions\PhpfastcacheEventManagerException; -use Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException; -use Phpfastcache\Helper\UninstanciableObjectTrait; - -class EventManager implements EventManagerInterface -{ - use UninstanciableObjectTrait; - - public const ON_EVERY_EVENT = '__every'; - - protected static EventManagerInterface $instance; - - protected bool $isScopedEventManager = false; - - protected ?ExtendedCacheItemPoolInterface $itemPoolContext = null; - - /** @var array> */ - protected array $events = [ - self::ON_EVERY_EVENT => [] - ]; - - /** - * @return EventManagerInterface - */ - public static function getInstance(): EventManagerInterface - { - return (self::$instance ?? self::$instance = new static()); - } - - /** - * @param EventManagerInterface $eventManagerInstance - * @return void - */ - public static function setInstance(EventManagerInterface $eventManagerInstance): void - { - self::$instance = $eventManagerInstance; - } - - public function dispatch(string $eventName, ...$args): void - { - /** - * Replace array_key_exists by isset - * due to performance issue on huge - * loop dispatching operations - */ - if (isset($this->events[$eventName]) && $eventName !== self::ON_EVERY_EVENT) { - $loopArgs = array_merge($args, [$eventName]); - foreach ($this->events[$eventName] as $event) { - /** - * @todo V10: BC Break: Put eventName as first parameter (like self::ON_EVERY_EVENT) - */ - $event(...$loopArgs); - } - } - foreach ($this->events[self::ON_EVERY_EVENT] as $event) { - $event($eventName, ...$args); - } - } - - /** - * @inheritDoc - * @throws PhpfastcacheInvalidArgumentException - * @throws PhpfastcacheEventManagerException - */ - public function __call(string $name, array $arguments): void - { - if (\str_starts_with($name, 'on')) { - $name = \substr($name, 2); - if (\is_callable($arguments[0])) { - if (isset($arguments[1]) && \is_string($arguments[0])) { - $this->events[$name][$arguments[1]] = $arguments[0]; - } else { - $this->events[$name][] = $arguments[0]; - } - } else { - throw new PhpfastcacheInvalidArgumentException(\sprintf('Expected Callable, got "%s"', \gettype($arguments[0]))); - } - } else { - throw new PhpfastcacheEventManagerException('An event must start with "on" such as "onCacheGetItem"'); - } - } - - /** - * @param callable $callback - * @param string $callbackName - * @throws PhpfastcacheEventManagerException - */ - public function onEveryEvents(callable $callback, string $callbackName): void - { - if ($callbackName === '') { - throw new PhpfastcacheEventManagerException('Callbackname cannot be empty'); - } - $this->events[self::ON_EVERY_EVENT][$callbackName] = $callback; - } - - - /** - * @throws PhpfastcacheEventManagerException - */ - public function on(array|string $events, callable $callback): void - { - if (is_string($events)) { - $events = [$events]; - } - foreach ($events as $event) { - if (!\preg_match('#^([a-zA-Z])*$#', $event)) { - throw new PhpfastcacheEventManagerException(\sprintf('Invalid event name "%s"', $event)); - } - - $this->{'on' . \ucfirst($event)}($callback); - } - } - - /** - * @param string $eventName - * @param string $callbackName - * @return bool - */ - public function unbindEventCallback(string $eventName, string $callbackName): bool - { - $return = isset($this->events[$eventName][$callbackName]); - unset($this->events[$eventName][$callbackName]); - - return $return; - } - - /** - * @return bool - */ - public function unbindAllEventCallbacks(): bool - { - $this->events = [ - self::ON_EVERY_EVENT => [] - ]; - - return true; - } - - public function __clone(): void - { - $this->isScopedEventManager = true; - $this->unbindAllEventCallbacks(); - } - - /** - * @param ExtendedCacheItemPoolInterface $pool - * @return EventManagerInterface - * @throws PhpfastcacheEventManagerException - */ - public function getScopedEventManager(ExtendedCacheItemPoolInterface $pool): EventManagerInterface - { - return (clone $this)->setItemPoolContext($pool); - } - - /** - * @param ExtendedCacheItemPoolInterface $pool - * @return EventManagerInterface - * @throws PhpfastcacheEventManagerException - */ - public function setItemPoolContext(ExtendedCacheItemPoolInterface $pool): EventManagerInterface - { - if (!$this->isScopedEventManager) { - throw new PhpfastcacheEventManagerException('Cannot set itemPool context on unscoped event manager instance.'); - } - $this->itemPoolContext = $pool; - - $this->onEveryEvents(function (string $eventName, ...$args) { - EventManager::getInstance()->dispatch($eventName, ...$args); - }, 'Scoped' . $pool->getDriverName() . spl_object_hash($this)); - - return $this; - } -} - -// phpcs:disable -\class_alias(EventManager::class, PhpfastcacheEventManager::class); // @phpstan-ignore-line -// phpcs:enable diff --git a/lib/Phpfastcache/Exceptions/PhpfastcacheCoreException.php b/lib/Phpfastcache/Exceptions/PhpfastcacheCoreException.php deleted file mode 100644 index 90f3d4df4..000000000 --- a/lib/Phpfastcache/Exceptions/PhpfastcacheCoreException.php +++ /dev/null @@ -1,21 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -declare(strict_types=1); - -namespace Phpfastcache\Exceptions; - -class PhpfastcacheCoreException extends PhpfastcacheRootException -{ -} diff --git a/lib/Phpfastcache/Exceptions/PhpfastcacheCorruptedDataException.php b/lib/Phpfastcache/Exceptions/PhpfastcacheCorruptedDataException.php deleted file mode 100644 index ffa6b0364..000000000 --- a/lib/Phpfastcache/Exceptions/PhpfastcacheCorruptedDataException.php +++ /dev/null @@ -1,29 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -declare(strict_types=1); - -namespace Phpfastcache\Exceptions; - -class PhpfastcacheCorruptedDataException extends PhpfastcacheDriverException -{ - /** - * @param string $message - * @param mixed|null $corruptedData - */ - public function __construct(protected $message = '', protected mixed $corruptedData = null) - { - parent::__construct($message); - } -} diff --git a/lib/Phpfastcache/Exceptions/PhpfastcacheDeprecatedException.php b/lib/Phpfastcache/Exceptions/PhpfastcacheDeprecatedException.php deleted file mode 100644 index bbf1f891f..000000000 --- a/lib/Phpfastcache/Exceptions/PhpfastcacheDeprecatedException.php +++ /dev/null @@ -1,21 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -declare(strict_types=1); - -namespace Phpfastcache\Exceptions; - -class PhpfastcacheDeprecatedException extends PhpfastcacheRootException -{ -} diff --git a/lib/Phpfastcache/Exceptions/PhpfastcacheDriverCheckException.php b/lib/Phpfastcache/Exceptions/PhpfastcacheDriverCheckException.php deleted file mode 100644 index 4ca92edbd..000000000 --- a/lib/Phpfastcache/Exceptions/PhpfastcacheDriverCheckException.php +++ /dev/null @@ -1,21 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -declare(strict_types=1); - -namespace Phpfastcache\Exceptions; - -class PhpfastcacheDriverCheckException extends PhpfastcacheDriverException -{ -} diff --git a/lib/Phpfastcache/Exceptions/PhpfastcacheDriverConnectException.php b/lib/Phpfastcache/Exceptions/PhpfastcacheDriverConnectException.php deleted file mode 100644 index 3ea062d9e..000000000 --- a/lib/Phpfastcache/Exceptions/PhpfastcacheDriverConnectException.php +++ /dev/null @@ -1,21 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -declare(strict_types=1); - -namespace Phpfastcache\Exceptions; - -class PhpfastcacheDriverConnectException extends PhpfastcacheDriverException -{ -} diff --git a/lib/Phpfastcache/Exceptions/PhpfastcacheDriverException.php b/lib/Phpfastcache/Exceptions/PhpfastcacheDriverException.php deleted file mode 100644 index 32f616390..000000000 --- a/lib/Phpfastcache/Exceptions/PhpfastcacheDriverException.php +++ /dev/null @@ -1,21 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -declare(strict_types=1); - -namespace Phpfastcache\Exceptions; - -class PhpfastcacheDriverException extends PhpfastcacheRootException -{ -} diff --git a/lib/Phpfastcache/Exceptions/PhpfastcacheDriverNotFoundException.php b/lib/Phpfastcache/Exceptions/PhpfastcacheDriverNotFoundException.php deleted file mode 100644 index 53f8893b6..000000000 --- a/lib/Phpfastcache/Exceptions/PhpfastcacheDriverNotFoundException.php +++ /dev/null @@ -1,21 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -declare(strict_types=1); - -namespace Phpfastcache\Exceptions; - -class PhpfastcacheDriverNotFoundException extends PhpfastcacheDriverException -{ -} diff --git a/lib/Phpfastcache/Exceptions/PhpfastcacheEventManagerException.php b/lib/Phpfastcache/Exceptions/PhpfastcacheEventManagerException.php deleted file mode 100644 index 96d2ae6e6..000000000 --- a/lib/Phpfastcache/Exceptions/PhpfastcacheEventManagerException.php +++ /dev/null @@ -1,21 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -declare(strict_types=1); - -namespace Phpfastcache\Exceptions; - -class PhpfastcacheEventManagerException extends PhpfastcacheRootException -{ -} diff --git a/lib/Phpfastcache/Exceptions/PhpfastcacheExceptionInterface.php b/lib/Phpfastcache/Exceptions/PhpfastcacheExceptionInterface.php deleted file mode 100644 index 7848ca051..000000000 --- a/lib/Phpfastcache/Exceptions/PhpfastcacheExceptionInterface.php +++ /dev/null @@ -1,23 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -declare(strict_types=1); - -namespace Phpfastcache\Exceptions; - -use Psr\Cache\CacheException; - -interface PhpfastcacheExceptionInterface extends CacheException -{ -} diff --git a/lib/Phpfastcache/Exceptions/PhpfastcacheExtensionNotFoundException.php b/lib/Phpfastcache/Exceptions/PhpfastcacheExtensionNotFoundException.php deleted file mode 100644 index 605e00e31..000000000 --- a/lib/Phpfastcache/Exceptions/PhpfastcacheExtensionNotFoundException.php +++ /dev/null @@ -1,21 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -declare(strict_types=1); - -namespace Phpfastcache\Exceptions; - -class PhpfastcacheExtensionNotFoundException extends PhpfastcacheDriverNotFoundException -{ -} diff --git a/lib/Phpfastcache/Exceptions/PhpfastcacheExtensionNotInstalledException.php b/lib/Phpfastcache/Exceptions/PhpfastcacheExtensionNotInstalledException.php deleted file mode 100644 index b0f43bc5d..000000000 --- a/lib/Phpfastcache/Exceptions/PhpfastcacheExtensionNotInstalledException.php +++ /dev/null @@ -1,21 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -declare(strict_types=1); - -namespace Phpfastcache\Exceptions; - -class PhpfastcacheExtensionNotInstalledException extends PhpfastcacheDriverNotFoundException -{ -} diff --git a/lib/Phpfastcache/Exceptions/PhpfastcacheIOException.php b/lib/Phpfastcache/Exceptions/PhpfastcacheIOException.php deleted file mode 100644 index 522840096..000000000 --- a/lib/Phpfastcache/Exceptions/PhpfastcacheIOException.php +++ /dev/null @@ -1,37 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -declare(strict_types=1); - -namespace Phpfastcache\Exceptions; - -/** - * @since v6 - */ -class PhpfastcacheIOException extends PhpfastcacheCoreException -{ - /** - * @inheritdoc - */ - public function __construct(string $message = "", int $code = 0, ?\Throwable $previous = null) - { - $lastError = error_get_last(); - if ($lastError) { - $message .= "\n"; - $message .= "Additional information provided by error_get_last():\n"; - $message .= "{$lastError['message']} in {$lastError['file']} line {$lastError['line']}"; - } - parent::__construct($message, $code, $previous); - } -} diff --git a/lib/Phpfastcache/Exceptions/PhpfastcacheInstanceNotFoundException.php b/lib/Phpfastcache/Exceptions/PhpfastcacheInstanceNotFoundException.php deleted file mode 100644 index 1d0a15240..000000000 --- a/lib/Phpfastcache/Exceptions/PhpfastcacheInstanceNotFoundException.php +++ /dev/null @@ -1,21 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -declare(strict_types=1); - -namespace Phpfastcache\Exceptions; - -class PhpfastcacheInstanceNotFoundException extends PhpfastcacheRootException -{ -} diff --git a/lib/Phpfastcache/Exceptions/PhpfastcacheInvalidArgumentException.php b/lib/Phpfastcache/Exceptions/PhpfastcacheInvalidArgumentException.php deleted file mode 100644 index c57f2d3df..000000000 --- a/lib/Phpfastcache/Exceptions/PhpfastcacheInvalidArgumentException.php +++ /dev/null @@ -1,23 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -declare(strict_types=1); - -namespace Phpfastcache\Exceptions; - -use Psr\Cache\InvalidArgumentException; - -class PhpfastcacheInvalidArgumentException extends PhpfastcacheRootException implements InvalidArgumentException -{ -} diff --git a/lib/Phpfastcache/Exceptions/PhpfastcacheInvalidConfigurationException.php b/lib/Phpfastcache/Exceptions/PhpfastcacheInvalidConfigurationException.php deleted file mode 100644 index 6ab816b50..000000000 --- a/lib/Phpfastcache/Exceptions/PhpfastcacheInvalidConfigurationException.php +++ /dev/null @@ -1,21 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -declare(strict_types=1); - -namespace Phpfastcache\Exceptions; - -class PhpfastcacheInvalidConfigurationException extends PhpfastcacheRootException -{ -} diff --git a/lib/Phpfastcache/Exceptions/PhpfastcacheInvalidTypeException.php b/lib/Phpfastcache/Exceptions/PhpfastcacheInvalidTypeException.php deleted file mode 100644 index c7bd1bf06..000000000 --- a/lib/Phpfastcache/Exceptions/PhpfastcacheInvalidTypeException.php +++ /dev/null @@ -1,23 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -declare(strict_types=1); - -namespace Phpfastcache\Exceptions; - -use Psr\Cache\InvalidArgumentException; - -class PhpfastcacheInvalidTypeException extends PhpfastcacheRootException implements InvalidArgumentException -{ -} diff --git a/lib/Phpfastcache/Exceptions/PhpfastcacheLogicException.php b/lib/Phpfastcache/Exceptions/PhpfastcacheLogicException.php deleted file mode 100644 index 7852434a4..000000000 --- a/lib/Phpfastcache/Exceptions/PhpfastcacheLogicException.php +++ /dev/null @@ -1,21 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -declare(strict_types=1); - -namespace Phpfastcache\Exceptions; - -class PhpfastcacheLogicException extends PhpfastcacheRootException -{ -} diff --git a/lib/Phpfastcache/Exceptions/PhpfastcacheReplicationException.php b/lib/Phpfastcache/Exceptions/PhpfastcacheReplicationException.php deleted file mode 100644 index ca4cc9cad..000000000 --- a/lib/Phpfastcache/Exceptions/PhpfastcacheReplicationException.php +++ /dev/null @@ -1,21 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -declare(strict_types=1); - -namespace Phpfastcache\Exceptions; - -class PhpfastcacheReplicationException extends PhpfastcacheRootException -{ -} diff --git a/lib/Phpfastcache/Exceptions/PhpfastcacheRootException.php b/lib/Phpfastcache/Exceptions/PhpfastcacheRootException.php deleted file mode 100644 index 091174633..000000000 --- a/lib/Phpfastcache/Exceptions/PhpfastcacheRootException.php +++ /dev/null @@ -1,23 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -declare(strict_types=1); - -namespace Phpfastcache\Exceptions; - -use Exception; - -abstract class PhpfastcacheRootException extends Exception implements PhpfastcacheExceptionInterface -{ -} diff --git a/lib/Phpfastcache/Exceptions/PhpfastcacheSimpleCacheException.php b/lib/Phpfastcache/Exceptions/PhpfastcacheSimpleCacheException.php deleted file mode 100644 index 0782c6df0..000000000 --- a/lib/Phpfastcache/Exceptions/PhpfastcacheSimpleCacheException.php +++ /dev/null @@ -1,24 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -declare(strict_types=1); - -namespace Phpfastcache\Exceptions; - -use Exception; -use Psr\SimpleCache\CacheException; - -class PhpfastcacheSimpleCacheException extends Exception implements CacheException -{ -} diff --git a/lib/Phpfastcache/Exceptions/PhpfastcacheUnsupportedException.php b/lib/Phpfastcache/Exceptions/PhpfastcacheUnsupportedException.php deleted file mode 100644 index b24b8c7e7..000000000 --- a/lib/Phpfastcache/Exceptions/PhpfastcacheUnsupportedException.php +++ /dev/null @@ -1,21 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -declare(strict_types=1); - -namespace Phpfastcache\Exceptions; - -abstract class PhpfastcacheUnsupportedException extends PhpfastcacheRootException -{ -} diff --git a/lib/Phpfastcache/Exceptions/PhpfastcacheUnsupportedMethodException.php b/lib/Phpfastcache/Exceptions/PhpfastcacheUnsupportedMethodException.php deleted file mode 100644 index 0c3925c5e..000000000 --- a/lib/Phpfastcache/Exceptions/PhpfastcacheUnsupportedMethodException.php +++ /dev/null @@ -1,21 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -declare(strict_types=1); - -namespace Phpfastcache\Exceptions; - -class PhpfastcacheUnsupportedMethodException extends PhpfastcacheUnsupportedException -{ -} diff --git a/lib/Phpfastcache/Exceptions/PhpfastcacheUnsupportedOperationException.php b/lib/Phpfastcache/Exceptions/PhpfastcacheUnsupportedOperationException.php deleted file mode 100644 index 503d95b75..000000000 --- a/lib/Phpfastcache/Exceptions/PhpfastcacheUnsupportedOperationException.php +++ /dev/null @@ -1,21 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -declare(strict_types=1); - -namespace Phpfastcache\Exceptions; - -class PhpfastcacheUnsupportedOperationException extends PhpfastcacheUnsupportedException -{ -} diff --git a/lib/Phpfastcache/ExtensionManager.php b/lib/Phpfastcache/ExtensionManager.php deleted file mode 100644 index 66b5a58f1..000000000 --- a/lib/Phpfastcache/ExtensionManager.php +++ /dev/null @@ -1,81 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -declare(strict_types=1); - -namespace Phpfastcache; - -use Phpfastcache\Exceptions\PhpfastcacheExtensionNotFoundException; -use Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException; -use Phpfastcache\Helper\UninstanciableObjectTrait; - -/** - * @internal This extension manager is meant to manage officials Phpfastcache's extensions. - * @see \Phpfastcache\CacheManager::addCustomDriver() to add you own drivers. - */ -final class ExtensionManager -{ - use UninstanciableObjectTrait; - - public const KNOWN_EXTENSION_NAMES = [ - 'Arangodb', - 'Couchbasev4', - 'Couchdb', - 'Dynamodb', - 'Firestore', - 'Mongodb', - 'Ravendb', - 'Solr' - ]; - - /** - * @var array - */ - protected static array $registeredExtensions = []; - - public static function registerExtension(string $extensionName, string $driverClassName): void - { - if (!str_starts_with($driverClassName, ltrim('Phpfastcache\\Extensions\\', '\\'))) { - throw new PhpfastcacheInvalidArgumentException( - 'Only extensions from "\\Phpfastcache\\Extensions\\" namespace are allowed. Use CacheManager::addCustomDriver() to create your own extensions.' - ); - } - self::$registeredExtensions[$extensionName] = $driverClassName; - } - - public static function extensionExists(string $extensionName): bool - { - return isset(self::$registeredExtensions[$extensionName]); - } - - /** - * @param string $name - * @return string - * @throws PhpfastcacheExtensionNotFoundException - */ - public static function getExtension(string $name): string - { - if (isset(self::$registeredExtensions[$name])) { - return self::$registeredExtensions[$name]; - } else { - throw new PhpfastcacheExtensionNotFoundException( - sprintf( - 'Unable too find the %s extension. Make sure that you you added through composer: `composer require phpfastcache/%s-extension`', - $name, - strtolower($name) - ) - ); - } - } -} diff --git a/lib/Phpfastcache/Helper/CacheConditionalHelper.php b/lib/Phpfastcache/Helper/CacheConditionalHelper.php deleted file mode 100644 index 2199fc4e6..000000000 --- a/lib/Phpfastcache/Helper/CacheConditionalHelper.php +++ /dev/null @@ -1,44 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -declare(strict_types=1); - -namespace Phpfastcache\Helper; - -use Phpfastcache\CacheContract; -use Psr\Cache\CacheItemPoolInterface; - -/** - * @deprecated Use \Phpfastcache\CacheContract instead - */ -class CacheConditionalHelper extends CacheContract -{ - /** - * CacheConditionalHelper constructor. - * @param CacheItemPoolInterface $cacheInstance - */ - public function __construct(CacheItemPoolInterface $cacheInstance) - { - \trigger_error( - \sprintf( - 'Class "%s" is deprecated, use "%s" class instead. See the documentation about this change here: %s', - self::class, - parent::class, - 'https://github.com/PHPSocialNetwork/phpfastcache/wiki/%5BV9%CB%96%5D-Cache-contract' - ), - E_USER_DEPRECATED - ); - parent::__construct($cacheInstance); - } -} diff --git a/lib/Phpfastcache/Helper/Psr16Adapter.php b/lib/Phpfastcache/Helper/Psr16Adapter.php deleted file mode 100644 index fbed034f3..000000000 --- a/lib/Phpfastcache/Helper/Psr16Adapter.php +++ /dev/null @@ -1,216 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -declare(strict_types=1); - -namespace Phpfastcache\Helper; - -use DateInterval; -use DateTime; -use Phpfastcache\CacheManager; -use Phpfastcache\Config\ConfigurationOptionInterface; -use Phpfastcache\Core\Item\ExtendedCacheItemInterface; -use Phpfastcache\Core\Pool\ExtendedCacheItemPoolInterface; -use Phpfastcache\Exceptions\PhpfastcacheDriverCheckException; -use Phpfastcache\Exceptions\PhpfastcacheDriverException; -use Phpfastcache\Exceptions\PhpfastcacheDriverNotFoundException; -use Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException; -use Phpfastcache\Exceptions\PhpfastcacheLogicException; -use Phpfastcache\Exceptions\PhpfastcacheRootException; -use Phpfastcache\Exceptions\PhpfastcacheSimpleCacheException; -use Psr\Cache\InvalidArgumentException; -use Psr\SimpleCache\CacheInterface; -use Traversable; - -class Psr16Adapter implements CacheInterface -{ - /** - * @var ExtendedCacheItemPoolInterface - */ - protected ExtendedCacheItemPoolInterface $internalCacheInstance; - - /** - * Psr16Adapter constructor. - * @param string|ExtendedCacheItemPoolInterface $driver - * @param null|ConfigurationOptionInterface $config - * @throws PhpfastcacheDriverCheckException - * @throws PhpfastcacheLogicException - * @throws PhpfastcacheDriverException - * @throws PhpfastcacheDriverNotFoundException - */ - public function __construct(string|ExtendedCacheItemPoolInterface $driver, ?ConfigurationOptionInterface $config = null) - { - if ($driver instanceof ExtendedCacheItemPoolInterface) { - if ($config !== null) { - throw new PhpfastcacheLogicException("You can't pass a config parameter along with an non-string '\$driver' parameter."); - } - $this->internalCacheInstance = $driver; - } else { - $this->internalCacheInstance = CacheManager::getInstance($driver, $config); - } - } - - /** - * @param string $key - * @param mixed $default - * @return mixed - * @throws PhpfastcacheSimpleCacheException - */ - public function get(string $key, mixed $default = null): mixed - { - try { - $cacheItem = $this->internalCacheInstance->getItem($key); - if (!$cacheItem->isExpired() && $cacheItem->get() !== null) { - return $cacheItem->get(); - } - - return $default; - } catch (PhpfastcacheInvalidArgumentException $e) { - throw new PhpfastcacheSimpleCacheException($e->getMessage(), 0, $e); - } - } - - /** - * @param string $key - * @param mixed $value - * @param null|int|DateInterval $ttl - * @return bool - * @throws PhpfastcacheSimpleCacheException - */ - public function set(string $key, mixed $value, null|int|\DateInterval $ttl = null): bool - { - try { - $cacheItem = $this->internalCacheInstance - ->getItem($key) - ->set($value); - if (\is_int($ttl) && $ttl <= 0) { - $cacheItem->expiresAt((new DateTime('@0'))); - } elseif ($ttl !== null) { - $cacheItem->expiresAfter($ttl); - } - return $this->internalCacheInstance->save($cacheItem); - } catch (PhpfastcacheInvalidArgumentException $e) { - throw new PhpfastcacheSimpleCacheException($e->getMessage(), 0, $e); - } - } - - /** - * @param string $key - * @return bool - * @throws PhpfastcacheSimpleCacheException - * @throws InvalidArgumentException - */ - public function delete(string $key): bool - { - try { - return $this->internalCacheInstance->deleteItem($key); - } catch (PhpfastcacheInvalidArgumentException $e) { - throw new PhpfastcacheSimpleCacheException($e->getMessage(), 0, $e); - } - } - - /** - * @return bool - * @throws PhpfastcacheSimpleCacheException - */ - public function clear(): bool - { - try { - return $this->internalCacheInstance->clear(); - } catch (PhpfastcacheRootException $e) { - throw new PhpfastcacheSimpleCacheException($e->getMessage(), 0, $e); - } - } - - /** - * @param iterable $keys - * @param null $default - * @return ExtendedCacheItemInterface[] - * @throws PhpfastcacheSimpleCacheException - */ - public function getMultiple(iterable $keys, mixed $default = null): iterable - { - if ($keys instanceof Traversable) { - $keys = \iterator_to_array($keys); - } - try { - return \array_map( - static fn (ExtendedCacheItemInterface $item) => $item->isHit() ? $item->get() : $default, - $this->internalCacheInstance->getItems($keys) - ); - } catch (PhpfastcacheInvalidArgumentException $e) { - throw new PhpfastcacheSimpleCacheException($e->getMessage(), 0, $e); - } - } - - /** - * @param iterable $values - * @param null|int|DateInterval $ttl - * @return bool - * @throws PhpfastcacheSimpleCacheException - */ - public function setMultiple(iterable $values, null|int|\DateInterval $ttl = null): bool - { - try { - foreach ($values as $key => $value) { - $cacheItem = $this->internalCacheInstance->getItem($key)->set($value); - - if (\is_int($ttl) && $ttl <= 0) { - $cacheItem->expiresAt((new DateTime('@0'))); - } elseif ($ttl !== null) { - $cacheItem->expiresAfter($ttl); - } - $this->internalCacheInstance->saveDeferred($cacheItem); - unset($cacheItem); - } - return $this->internalCacheInstance->commit(); - } catch (PhpfastcacheInvalidArgumentException $e) { - throw new PhpfastcacheSimpleCacheException($e->getMessage(), 0, $e); - } - } - - /** - * @param iterable $keys - * @return bool - * @throws PhpfastcacheSimpleCacheException - * @throws InvalidArgumentException - */ - public function deleteMultiple(iterable $keys): bool - { - try { - if (\is_array($keys)) { - return $this->internalCacheInstance->deleteItems($keys); - } - - return $this->internalCacheInstance->deleteItems(\iterator_to_array($keys)); - } catch (PhpfastcacheInvalidArgumentException $e) { - throw new PhpfastcacheSimpleCacheException($e->getMessage(), 0, $e); - } - } - - /** - * @param string $key - * @return bool - * @throws PhpfastcacheSimpleCacheException - */ - public function has(string $key): bool - { - try { - $cacheItem = $this->internalCacheInstance->getItem($key); - return $cacheItem->isHit() && !$cacheItem->isExpired(); - } catch (PhpfastcacheInvalidArgumentException $e) { - throw new PhpfastcacheSimpleCacheException($e->getMessage(), 0, $e); - } - } -} diff --git a/lib/Phpfastcache/Helper/UninstanciableObjectTrait.php b/lib/Phpfastcache/Helper/UninstanciableObjectTrait.php deleted file mode 100644 index 43cd7f229..000000000 --- a/lib/Phpfastcache/Helper/UninstanciableObjectTrait.php +++ /dev/null @@ -1,42 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -declare(strict_types=1); - -namespace Phpfastcache\Helper; - -use DateInterval; -use DateTime; -use Phpfastcache\CacheManager; -use Phpfastcache\Config\ConfigurationOptionInterface; -use Phpfastcache\Core\Item\ExtendedCacheItemInterface; -use Phpfastcache\Core\Pool\ExtendedCacheItemPoolInterface; -use Phpfastcache\Exceptions\PhpfastcacheDriverCheckException; -use Phpfastcache\Exceptions\PhpfastcacheDriverException; -use Phpfastcache\Exceptions\PhpfastcacheDriverNotFoundException; -use Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException; -use Phpfastcache\Exceptions\PhpfastcacheLogicException; -use Phpfastcache\Exceptions\PhpfastcacheRootException; -use Phpfastcache\Exceptions\PhpfastcacheSimpleCacheException; -use Psr\Cache\InvalidArgumentException; -use Psr\SimpleCache\CacheInterface; -use Traversable; - -trait UninstanciableObjectTrait -{ - final protected function __construct() - { - // The target class is not meant to be instantiated - } -} diff --git a/lib/Phpfastcache/Proxy/PhpfastcacheAbstractProxy.php b/lib/Phpfastcache/Proxy/PhpfastcacheAbstractProxy.php deleted file mode 100644 index ef5b7a626..000000000 --- a/lib/Phpfastcache/Proxy/PhpfastcacheAbstractProxy.php +++ /dev/null @@ -1,61 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -declare(strict_types=1); - -namespace Phpfastcache\Proxy; - -use Phpfastcache\CacheManager; -use Phpfastcache\Config\ConfigurationOptionInterface; -use Phpfastcache\Core\Pool\ExtendedCacheItemPoolInterface; -use Phpfastcache\Exceptions\PhpfastcacheDriverCheckException; -use Phpfastcache\Exceptions\PhpfastcacheDriverException; -use Phpfastcache\Exceptions\PhpfastcacheDriverNotFoundException; -use Phpfastcache\Exceptions\PhpfastcacheLogicException; - -/** - * Handle methods using annotations for IDE - * because they're handled by __call() - * Check out ExtendedCacheItemInterface to see all - * the drivers methods magically implemented - */ -abstract class PhpfastcacheAbstractProxy implements PhpfastcacheAbstractProxyInterface -{ - /** - * @var ExtendedCacheItemPoolInterface - */ - protected ExtendedCacheItemPoolInterface $instance; - - /** - * PhpfastcacheAbstractProxy constructor. - * @param string $driver - * @param null|ConfigurationOptionInterface $config - * @throws PhpfastcacheDriverCheckException - * @throws PhpfastcacheDriverException - * @throws PhpfastcacheDriverNotFoundException - * @throws PhpfastcacheLogicException - */ - public function __construct(string $driver, ?ConfigurationOptionInterface $config = null) - { - $this->instance = CacheManager::getInstance($driver, $config); - } - - /** - * @inheritDoc - */ - public function __call(string $name, array $args): mixed - { - return $this->instance->$name(...$args); - } -} diff --git a/lib/Phpfastcache/Proxy/PhpfastcacheAbstractProxyInterface.php b/lib/Phpfastcache/Proxy/PhpfastcacheAbstractProxyInterface.php deleted file mode 100644 index 481429de9..000000000 --- a/lib/Phpfastcache/Proxy/PhpfastcacheAbstractProxyInterface.php +++ /dev/null @@ -1,88 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -declare(strict_types=1); - -namespace Phpfastcache\Proxy; - -use Phpfastcache\Config\ConfigurationOption; -use Phpfastcache\Core\Item\ExtendedCacheItemInterface; -use Phpfastcache\Core\Pool\ExtendedCacheItemPoolInterface; -use Phpfastcache\Core\Pool\TaggableCacheItemPoolInterface; -use Phpfastcache\Entities\DriverIO; -use Phpfastcache\Entities\DriverStatistic; -use Psr\Cache\CacheItemInterface; - -/** - * @method ExtendedCacheItemInterface getItem(string $key) Retrieve an item and returns an empty item if not found - * @method ExtendedCacheItemInterface[] getItems(string[] $keys) Retrieve an item and returns an empty item if not found - * @method ExtendedCacheItemInterface[] getAllItems(string $pattern = ''): Retrieve all items int the cache with a hard-limit of 9999 - * @method bool hasItem(string $key) Tests if an item exists - * @method static string getConfigClass() - * @method ConfigurationOption getItemClass() - * @method ConfigurationOption getConfig() - * @method ConfigurationOption getDefaultConfig() - * @method string getDriverName() - * @method string getInstanceId() - * @method bool deleteItem(string $key) Delete an item - * @method bool deleteItems(string[] $keys) Delete some items - * @method bool save(CacheItemInterface $item) Save an item - * @method bool saveMultiple(CacheItemInterface ...$items) Save multiple items - * @method bool saveDeferred(CacheItemInterface $item) Sets a cache item to be persisted later - * @method bool commit() Persists any deferred cache items - * @method bool clear() Allow you to completely empty the cache and restart from the beginning - * @method DriverStatistic getStats() Returns a DriverStatistic object - * @method string getHelp() Returns help about a driver, if available - * @method ExtendedCacheItemInterface getItemsByTag(string $tagName, int $strategy = TaggableCacheItemPoolInterface::TAG_STRATEGY_ONE) Return items by a tag - * @method ExtendedCacheItemInterface[] getItemsByTags(string[] $tagNames, int $strategy = TaggableCacheItemPoolInterface::TAG_STRATEGY_ONE) Return items by some tags - * @method bool deleteItemsByTag(string $tagName, int $strategy = TaggableCacheItemPoolInterface::TAG_STRATEGY_ONE) Delete items by a tag - * @method bool deleteItemsByTags(string[] $tagNames, int $strategy = TaggableCacheItemPoolInterface::TAG_STRATEGY_ONE) // Delete items by some tags - * @method void incrementItemsByTag(string $tagName, int $step = 1, int $strategy = TaggableCacheItemPoolInterface::TAG_STRATEGY_ONE) // Increment items by a tag - * @method void incrementItemsByTags(string[] $tagNames, int $step = 1, int $strategy = TaggableCacheItemPoolInterface::TAG_STRATEGY_ONE) // Increment items by some tags - * @method void decrementItemsByTag(string $tagName, int $step = 1, int $strategy = TaggableCacheItemPoolInterface::TAG_STRATEGY_ONE) // Decrement items by a tag - * @method void decrementItemsByTags(string[] $tagNames, int $step = 1, int $strategy = TaggableCacheItemPoolInterface::TAG_STRATEGY_ONE) // Decrement items by some tags - * @method void appendItemsByTag(string $tagName, mixed $data, int $strategy = TaggableCacheItemPoolInterface::TAG_STRATEGY_ONE) // Append items by a tag - * @method void appendItemsByTags(string[] $tagNames, mixed $data, int $strategy = TaggableCacheItemPoolInterface::TAG_STRATEGY_ONE) // Append items by a tags - * @method void prependItemsByTag(string $tagName, mixed $data, int $strategy = TaggableCacheItemPoolInterface::TAG_STRATEGY_ONE) // Prepend items by a tag - * @method void prependItemsByTags(string[] $tagNames, mixed $data, int $strategy = TaggableCacheItemPoolInterface::TAG_STRATEGY_ONE) // Prepend items by a tags - * @method string getItemsAsJsonString(string[] $tagNames, int $option, int $depth, int $strategy = TaggableCacheItemPoolInterface::TAG_STRATEGY_ONE) - * @method ExtendedCacheItemInterface detachItem(CacheItemInterface $item) - * @method ExtendedCacheItemInterface attachItem(CacheItemInterface $item) - * @method ExtendedCacheItemInterface detachAllItems() - * @method bool isAttached(CacheItemInterface $item) - * @method DriverIO getIO() - */ -interface PhpfastcacheAbstractProxyInterface -{ - public const DRIVER_CHECK_FAILURE = ExtendedCacheItemPoolInterface::DRIVER_CHECK_FAILURE; - public const DRIVER_CONNECT_FAILURE = ExtendedCacheItemPoolInterface::DRIVER_CONNECT_FAILURE; - public const DRIVER_KEY_WRAPPER_INDEX = ExtendedCacheItemPoolInterface::DRIVER_KEY_WRAPPER_INDEX; - public const DRIVER_DATA_WRAPPER_INDEX = ExtendedCacheItemPoolInterface::DRIVER_DATA_WRAPPER_INDEX; - public const DRIVER_EDATE_WRAPPER_INDEX = ExtendedCacheItemPoolInterface::DRIVER_EDATE_WRAPPER_INDEX; - public const DRIVER_CDATE_WRAPPER_INDEX = ExtendedCacheItemPoolInterface::DRIVER_CDATE_WRAPPER_INDEX; - public const DRIVER_MDATE_WRAPPER_INDEX = ExtendedCacheItemPoolInterface::DRIVER_MDATE_WRAPPER_INDEX; - - public const DRIVER_TAGS_KEY_PREFIX = TaggableCacheItemPoolInterface::DRIVER_TAGS_KEY_PREFIX; - public const DRIVER_TAGS_WRAPPER_INDEX = TaggableCacheItemPoolInterface::DRIVER_TAGS_WRAPPER_INDEX; - public const TAG_STRATEGY_ONE = TaggableCacheItemPoolInterface::TAG_STRATEGY_ONE; - public const TAG_STRATEGY_ALL = TaggableCacheItemPoolInterface::TAG_STRATEGY_ALL; - public const TAG_STRATEGY_ONLY = TaggableCacheItemPoolInterface::TAG_STRATEGY_ONLY; - - /** - * @param string $name - * @param array $args - * @return mixed - */ - public function __call(string $name, array $args): mixed; -} diff --git a/lib/Phpfastcache/Util/ClassNamespaceResolverInterface.php b/lib/Phpfastcache/Util/ClassNamespaceResolverInterface.php deleted file mode 100644 index 3b7a1aa47..000000000 --- a/lib/Phpfastcache/Util/ClassNamespaceResolverInterface.php +++ /dev/null @@ -1,30 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -declare(strict_types=1); - -namespace Phpfastcache\Util; - -interface ClassNamespaceResolverInterface -{ - /** - * @return string - */ - public static function getClassNamespace(): string; - - /** - * @return string - */ - public function getClassName(): string; -} diff --git a/lib/Phpfastcache/Util/ClassNamespaceResolverTrait.php b/lib/Phpfastcache/Util/ClassNamespaceResolverTrait.php deleted file mode 100644 index 161f52df6..000000000 --- a/lib/Phpfastcache/Util/ClassNamespaceResolverTrait.php +++ /dev/null @@ -1,193 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -declare(strict_types=1); - -namespace Phpfastcache\Util; - -use RecursiveDirectoryIterator; -use RecursiveIteratorIterator; - -trait ClassNamespaceResolverTrait -{ - /** - * @var array - */ - protected static array $namespaces = []; - - /** - * Iterate over all files in the given directory searching for classes. - * - * NOTICE: This method has been borrowed from Symfony ClassLoader 3.4 since they - * deprecated the whole component as of SF4. Our thanks to them. - * - * @param string $dir The directory to search in or an iterator - * - * @return array A class map array - */ - protected static function createClassMap(string $dir): array - { - $dirIterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dir)); - - $map = []; - - foreach ($dirIterator as $file) { - if (!$file->isFile()) { - continue; - } - $path = $file->getRealPath() ?: $file->getPathname(); - if ('php' !== pathinfo($path, PATHINFO_EXTENSION)) { - continue; - } - $classes = self::findClasses($path); - gc_mem_caches(); - foreach ($classes as $class) { - $map[$class] = $path; - } - } - - return $map; - } - - /** - * Extract the classes in the given file. - * - * NOTICE: This method has been borrowed from Symfony ClassLoader 3.4 since they - * deprecated the whole component as of SF4. Our thanks to them. - * - * @param string $path The file to check - * - * @return string[] The found classes - * - * @SuppressWarnings(PHPMD.CyclomaticComplexity) - */ - protected static function findClasses(string $path): array - { - $contents = file_get_contents($path); - $tokens = token_get_all($contents); - $classes = []; - $namespace = ''; - for ($i = 0; isset($tokens[$i]); ++$i) { - $token = $tokens[$i]; - if (!isset($token[1])) { - continue; - } - $class = ''; - switch ($token[0]) { - case T_NAMESPACE: - $namespace = self::buildTokenNamespace($i, $tokens); - break; - case T_CLASS: - case T_INTERFACE: - case T_TRAIT: - $classes = self::buildTokenClasses($namespace, $class, $classes, $i, $tokens); - break; - default: - break; - } - } - - return $classes; - } - - /** - * @param string $namespace - * @param string $class - * @param string[] $classes - * @param int $index - * @param array|string> $tokens - * @return string[] - */ - protected static function buildTokenClasses(string $namespace, string $class, array $classes, int $index, array $tokens): array - { - // Skip usage of ::class constant - $isClassConstant = false; - for ($j = $index - 1; $j > 0; --$j) { - if (!isset($tokens[$j][1])) { - break; - } - if (T_DOUBLE_COLON === $tokens[$j][0]) { - $isClassConstant = true; - break; - } - - if (!\in_array($tokens[$j][0], [T_WHITESPACE, T_DOC_COMMENT, T_COMMENT], false)) { - break; - } - } - if ($isClassConstant) { - return $classes; - } - - // Find the classname - while (isset($tokens[++$index][1])) { - $t = $tokens[$index]; - if (T_STRING === $t[0]) { - $class .= $t[1]; - } elseif ('' !== $class && T_WHITESPACE === $t[0]) { - break; - } - } - - return \array_merge($classes, [\ltrim($namespace . $class, '\\')]); - } - - /** - * @param int $index - * @param array|string> $tokens - * @return string - */ - protected static function buildTokenNamespace(int $index, array $tokens): string - { - $namespace = ''; - - // If there is a namespace, extract it (PHP 8 test) - if (\defined('T_NAME_QUALIFIED')) { - while (isset($tokens[++$index][1])) { - if ($tokens[$index][0] === T_NAME_QUALIFIED) { - $namespace = $tokens[$index][1]; - break; - } - } - } else { - while (isset($tokens[++$index][1])) { - if (\in_array($tokens[$index][0], [T_STRING, T_NS_SEPARATOR], true)) { - $namespace .= $tokens[$index][1]; - } - } - } - - return $namespace . '\\'; - } - - /** - * @return string - */ - public static function getClassNamespace(): string - { - if (!isset(self::$namespaces[static::class])) { - self::$namespaces[static::class] = substr(static::class, 0, strrpos(static::class, '\\')); - } - - return self::$namespaces[static::class]; - } - - /** - * @return string - */ - public function getClassName(): string - { - return static::class; - } -} diff --git a/lib/Phpfastcache/Util/Directory.php b/lib/Phpfastcache/Util/Directory.php deleted file mode 100644 index 4a133787e..000000000 --- a/lib/Phpfastcache/Util/Directory.php +++ /dev/null @@ -1,148 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -declare(strict_types=1); - -namespace Phpfastcache\Util; - -use FilesystemIterator; -use RecursiveDirectoryIterator; -use RecursiveIteratorIterator; -use SplFileInfo; - -class Directory -{ - /** - * Get the directory size - * @param string $directory - * @param bool $includeDirAllocSize - * @return int - */ - public static function dirSize(string $directory, bool $includeDirAllocSize = false): int - { - $size = 0; - foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($directory)) as $file) { - /** - * @var SplFileInfo $file - */ - if ($file->isFile()) { - $size += filesize($file->getRealPath()); - } elseif ($includeDirAllocSize) { - $size += $file->getSize(); - } - } - - return $size; - } - - /** - * @param string $path - * @return int - */ - public static function getFileCount(string $path): int - { - $count = 0; - $objects = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path), RecursiveIteratorIterator::SELF_FIRST); - foreach ($objects as $object) { - /** - * @var SplFileInfo $object - */ - if ($object->isFile()) { - $count++; - } - } - - return $count; - } - - /** - * Recursively delete a directory and all of its contents - e.g.the equivalent of `rm -r` on the command-line. - * Consistent with `rmdir()` and `unlink()`, an E_WARNING level error will be generated on failure. - * - * @param string $source absolute path to directory or file to delete. - * @param bool $removeOnlyChildren set to true will only remove content inside directory. - * - * @return bool true on success; false on failure - */ - public static function rrmdir(string $source, bool $removeOnlyChildren = false): bool - { - if (empty($source) || file_exists($source) === false) { - return false; - } - - if (is_file($source) || is_link($source)) { - clearstatcache(true, $source); - return unlink($source); - } - - $files = new RecursiveIteratorIterator( - new RecursiveDirectoryIterator($source, FilesystemIterator::SKIP_DOTS), - RecursiveIteratorIterator::CHILD_FIRST - ); - - foreach ($files as $fileInfo) { - /** - * @var SplFileInfo $fileInfo - */ - $realpath = $fileInfo->getRealPath(); - if ($realpath) { - if ($fileInfo->isDir()) { - if (self::rrmdir($fileInfo->getRealPath()) === false) { - return false; - } - } elseif (unlink($realpath) === false) { - return false; - } - } else { - return false; - } - } - - if ($removeOnlyChildren === false) { - return rmdir($source); - } - - return true; - } - - /** - * Alias of realpath() but work - * on non-existing files - * - * @param string $path - * @return string - */ - public static function getAbsolutePath(string $path): string - { - $parts = preg_split('~[/\\\\]+~', $path, 0, PREG_SPLIT_NO_EMPTY); - $absolutes = []; - foreach ($parts as $part) { - if ('.' === $part) { - continue; - } - if ('..' === $part) { - array_pop($absolutes); - } else { - $absolutes[] = $part; - } - } - - /** - * Allows dereferencing char - */ - $file = preg_replace('~^(([a-z0-9\-]+)://)~', '', __FILE__);// remove file protocols such as "phar://" etc. - $prefix = $file[0] === DIRECTORY_SEPARATOR ? DIRECTORY_SEPARATOR : ''; - return $prefix . implode(DIRECTORY_SEPARATOR, $absolutes); - } -} diff --git a/lib/Phpfastcache/Util/MemcacheDriverCollisionDetectorTrait.php b/lib/Phpfastcache/Util/MemcacheDriverCollisionDetectorTrait.php deleted file mode 100644 index aa8f0d9d9..000000000 --- a/lib/Phpfastcache/Util/MemcacheDriverCollisionDetectorTrait.php +++ /dev/null @@ -1,48 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -declare(strict_types=1); - -namespace Phpfastcache\Util; - -trait MemcacheDriverCollisionDetectorTrait -{ - protected static string $driverUsed; - - public static function checkCollision(string $driverName): bool - { - $constantName = __NAMESPACE__ . '\MEMCACHE_DRIVER_USED'; - - if ($driverName) { - if (!defined($constantName)) { - define($constantName, $driverName); - - return true; - } - - if (constant($constantName) !== $driverName) { - trigger_error( - 'Memcache collision detected, you used both Memcache and Memcached driver in your script, this may leads to unexpected behaviours', - E_USER_WARNING - ); - - return false; - } - - return true; - } - - return false; - } -} diff --git a/lib/Phpfastcache/Util/SapiDetector.php b/lib/Phpfastcache/Util/SapiDetector.php deleted file mode 100644 index 894466c44..000000000 --- a/lib/Phpfastcache/Util/SapiDetector.php +++ /dev/null @@ -1,33 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -declare(strict_types=1); - -namespace Phpfastcache\Util; - -class SapiDetector -{ - /** - * @SuppressWarnings(PHPMD.Superglobals) - */ - public static function isWebScript(): bool - { - return \PHP_SAPI === 'apache2handler' || str_contains(\PHP_SAPI, 'handler') || isset($_SERVER['REQUEST_METHOD']); - } - - public static function isCliScript(): bool - { - return (\PHP_SAPI === 'cli') || \defined('STDIN'); - } -} diff --git a/lib/Phpfastcache/Wiki.php b/lib/Phpfastcache/Wiki.php deleted file mode 100644 index 060d15c8d..000000000 --- a/lib/Phpfastcache/Wiki.php +++ /dev/null @@ -1,26 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -declare(strict_types=1); - -namespace Phpfastcache; - -use Phpfastcache\Helper\UninstanciableObjectTrait; - -class Wiki -{ - use UninstanciableObjectTrait; - - public const FETCH_ALL_KEY_URL = 'https://github.com/PHPSocialNetwork/phpfastcache/wiki/%5BV5%CB%96%5D-Fetching-all-keys'; -} diff --git a/lib/highlight/CHANGES.md b/lib/highlight/CHANGES.md new file mode 100644 index 000000000..05473a265 --- /dev/null +++ b/lib/highlight/CHANGES.md @@ -0,0 +1,1646 @@ +## Version 9.12.0 + +New language: + +- *MikroTik* RouterOS Scripting language by [Ivan Dementev][]. + +New style: + +- *VisualStudio 2015 Dark* by [Nicolas LLOBERA][] + +Improvements: + +- *Crystal* updated with new keywords and syntaxes by [Tsuyusato Kitsune][]. +- *Julia* updated to the modern definitions by [Alex Arslan][]. +- *julia-repl* added by [Morten Piibeleht][]. +- [Stanislav Belov][] wrote a new definition for *1C*, replacing the one that + has not been updated for more than 8 years. The new version supports syntax + for versions 7.7 and 8. +- [Nicolas LLOBERA][] improved C# definition fixing edge cases with function + titles detection and added highlighting of `[Attributes]`. +- [nnnik][] provided a few correctness fixes for *Autohotkey*. +- [Martin Clausen][] made annotation collections in *Clojure* to look + consistently with other kinds. +- [Alejandro Alonso][] updated *Swift* keywords. + +[Tsuyusato Kitsune]: https://github.com/MakeNowJust +[Alex Arslan]: https://github.com/ararslan +[Morten Piibeleht]: https://github.com/mortenpi +[Stanislav Belov]: https://github.com/4ppl +[Ivan Dementev]: https://github.com/DiVAN1x +[Nicolas LLOBERA]: https://github.com/Nicolas01 +[nnnik]: https://github.com/nnnik +[Martin Clausen]: https://github.com/maacl +[Alejandro Alonso]: https://github.com/Azoy + + +## Version 9.11.0 + +New languages: + +- *Shell* by [Tsuyusato Kitsune][] +- *jboss-cli* by [Raphaël Parrëe][] + +Improvements: + +- [Joël Porquet] has [greatly improved the definition of *makefile*][5b3e0e6]. +- *C++* class titles are now highlighted as in other languages with classes. +- [Jordi Petit][] added rarely used `or`, `and` and `not` keywords to *C++*. +- [Pieter Vantorre][] fixed highlighting of negative floating point values. + + +[Tsuyusato Kitsune]: https://github.com/MakeNowJust +[Jordi Petit]: https://github.com/jordi-petit +[Raphaël Parrëe]: https://github.com/rparree +[Pieter Vantorre]: https://github.com/NuclearCookie +[5b3e0e6]: https://github.com/isagalaev/highlight.js/commit/5b3e0e68bfaae282faff6697d6a490567fa9d44b + + +## Version 9.10.0 + +Apologies for missing the previous release cycle. Some thing just can't be +automated… Anyway, we're back! + +New languages: + +- *Hy* by [Sergey Sobko][] +- *Leaf* by [Hale Chan][] +- *N1QL* by [Andres Täht][] and [Rene Saarsoo][] + +Improvements: + +- *Rust* got updated with new keywords by [Kasper Andersen][] and then + significantly modernized even more by [Eduard-Mihai Burtescu][] (yes, @eddyb, + Rust core team member!) +- *Python* updated with f-literals by [Philipp A][]. +- *YAML* updated with unquoted strings support. +- *Gauss* updated with new keywords by [Matt Evans][]. +- *Lua* updated with new keywords by [Joe Blow][]. +- *Kotlin* updated with new keywords by [Philipp Hauer][]. +- *TypeScript* got highlighting of function params and updated keywords by + [Ike Ku][]. +- *Scheme* now correctly handles \`-quoted lists thanks to [Guannan Wei]. +- [Sam Wu][] fixed handling of `<<` in *C++* defines. + +[Philipp A]: https://github.com/flying-sheep +[Philipp Hauer]: https://github.com/phauer +[Sergey Sobko]: https://github.com/profitware +[Hale Chan]: https://github.com/halechan +[Matt Evans]: https://github.com/matthewevans +[Joe Blow]: https://github.com/mossarelli +[Kasper Andersen]: https://github.com/kasma1990 +[Eduard-Mihai Burtescu]: https://github.com/eddyb +[Andres Täht]: https://github.com/andrestaht +[Rene Saarsoo]: https://github.com/nene +[Philipp Hauer]: https://github.com/phauer +[Ike Ku]: https://github.com/dempfi +[Guannan Wei]: https://github.com/Kraks +[Sam Wu]: https://github.com/samsam2310 + + +## Version 9.9.0 + +New languages + +- *LLVM* by [Michael Rodler][] + +Improvements: + +- *TypeScript* updated with annotations and param lists inside constructors, by + [Raphael Parree][]. +- *CoffeeScript* updated with new keywords and fixed to recognize JavaScript + in \`\`\`, thanks to thanks to [Geoffrey Booth][]. +- Compiler directives in *Delphi* are now correctly highlighted as "meta". + +[Raphael Parree]: https://github.com/rparree +[Michael Rodler]: https://github.com/f0rki +[Geoffrey Booth]: https://github.com/GeoffreyBooth + + +## Version 9.8.0 "New York" + +This version is the second one that deserved a name. Because I'm in New York, +and the release isn't missing the deadline only because it's still Tuesday on +West Coast. + +New languages: + +- *Clean* by [Camil Staps][] +- *Flix* by [Magnus Madsen][] + +Improvements: + +- [Kenton Hamaluik][] did a comprehensive update for *Haxe*. +- New commands for *PowerShell* from [Nicolas Le Gall][]. +- [Jan T. Sott][] updated *NSIS*. +- *Java* and *Swift* support unicode characters in identifiers thanks to + [Alexander Lichter][]. + +[Camil Staps]: https://github.com/camilstaps +[Magnus Madsen]: https://github.com/magnus-madsen +[Kenton Hamaluik]: https://github.com/FuzzyWuzzie +[Nicolas Le Gall]: https://github.com/darkitty +[Jan T. Sott]: https://github.com/idleberg +[Alexander Lichter]: https://github.com/manniL + + +## Version 9.7.0 + +A comprehensive bugfix release. This is one of the best things about +highlight.js: even boring things keep getting better (even if slow). + +- VHDL updated with PSL keywords and uses more consistent styling. +- Nested C-style comments no longer break highlighting in many languages. +- JavaScript updated with `=>` functions, highlighted object attributes and + parsing within template string substitution blocks (`${...}`). +- Fixed another corner case with self-closing `` in JSX. +- Added `HEALTHCHECK` directive in Docker. +- Delphi updated with new Free Pascal keywords. +- Fixed digit separator parsing in C++. +- C# updated with new keywords and fixed to allow multiple identifiers within + generics `<...>`. +- Fixed another slow regex in Less. + + +## Version 9.6.0 + +New languages: + +- *ABNF* and *EBNF* by [Alex McKibben][] +- *Awk* by [Matthew Daly][] +- *SubUnit* by [Sergey Bronnikov][] + +New styles: + +- *Atom One* in both Dark and Light variants by [Daniel Gamage][] + +Plus, a few smaller updates for *Lasso*, *Elixir*, *C++* and *SQL*. + +[Alex McKibben]: https://github.com/mckibbenta +[Daniel Gamage]: https://github.com/danielgamage +[Matthew Daly]: https://github.com/matthewbdaly +[Sergey Bronnikov]: https://github.com/ligurio + + +## Version 9.5.0 + +New languages: + +- *Excel* by [Victor Zhou][] +- *Linden Scripting Language* by [Builder's Brewery][] +- *TAP* (Test Anything Protocol) by [Sergey Bronnikov][] +- *Pony* by [Joe Eli McIlvain][] +- *Coq* by [Stephan Boyer][] +- *dsconfig* and *LDIF* by [Jacob Childress][] + +New styles: + +- *Ocean Dark* by [Gavin Siu][] + +Notable changes: + +- [Minh Nguyễn][] added more built-ins to Objective C. +- [Jeremy Hull][] fixed corner cases in C++ preprocessor directives and Diff + comments. +- [Victor Zhou][] added support for digit separators in C++ numbers. + +[Gavin Siu]: https://github.com/gavsiu +[Builder's Brewery]: https://github.com/buildersbrewery +[Victor Zhou]: https://github.com/OiCMudkips +[Sergey Bronnikov]: https://github.com/ligurio +[Joe Eli McIlvain]: https://github.com/jemc +[Stephan Boyer]: https://github.com/boyers +[Jacob Childress]: https://github.com/braveulysses +[Minh Nguyễn]: https://github.com/1ec5 +[Jeremy Hull]: https://github.com/sourrust + + +## Version 9.4.0 + +New languages: + +- *PureBASIC* by [Tristano Ajmone][] +- *BNF* by [Oleg Efimov][] +- *Ada* by [Lars Schulna][] + +New styles: + +- *PureBASIC* by [Tristano Ajmone][] + +Improvements to existing languages and styles: + +- We now highlight function declarations in Go. +- [Taisuke Fujimoto][] contributed very convoluted rules for raw and + interpolated strings in C#. +- [Boone Severson][] updated Verilog to comply with IEEE 1800-2012 + SystemVerilog. +- [Victor Zhou][] improved rules for comments and strings in PowerShell files. +- [Janis Voigtländer][] updated the definition of Elm to version 0.17 of the + languages. Elm is now featured on the front page of . +- Special variable `$this` is highlighted as a keyword in PHP. +- `usize` and `isize` are now highlighted in Rust. +- Fixed labels and directives in x86 assembler. + +[Tristano Ajmone]: https://github.com/tajmone +[Taisuke Fujimoto]: https://github.com/temp-impl +[Oleg Efimov]: https://github.com/Sannis +[Boone Severson]: https://github.com/BooneJS +[Victor Zhou]: https://github.com/OiCMudkips +[Lars Schulna]: https://github.com/captain-hanuta +[Janis Voigtländer]: https://github.com/jvoigtlaender + + +## Version 9.3.0 + +New languages: + +- *Tagger Script* by [Philipp Wolfer][] +- *MoonScript* by [Billy Quith][] + +New styles: + +- *xt256* by [Herbert Shin][] + +Improvements to existing languages and styles: + +- More robust handling of unquoted HTML tag attributes +- Relevance tuning for QML which was unnecessary eager at seizing other + languages' code +- Improve GAMS language parsing +- Fixed a bunch of bugs around selectors in Less +- Kotlin's got a new definition for annotations, updated keywords and other + minor improvements +- Added `move` to Rust keywords +- Markdown now recognizes \`\`\`-fenced code blocks +- Improved detection of function declarations in C++ and C# + +[Philipp Wolfer]: https://github.com/phw +[Billy Quith]: https://github.com/billyquith +[Herbert Shin]: https://github.com/initbar + + +## Version 9.2.0 + +New languages: + +- *QML* by [John Foster][] +- *HTMLBars* by [Michael Johnston][] +- *CSP* by [Taras][] +- *Maxima* by [Robert Dodier][] + +New styles: + +- *Gruvbox* by [Qeole][] +- *Dracula* by [Denis Ciccale][] + +Improvements to existing languages and styles: + +- We now correctly handle JSX with arbitrary node tree depth. +- Argument list for `(lambda)` in Scheme is no longer highlighted as a function + call. +- Stylus syntax doesn't break on valid CSS. +- More correct handling of comments and strings and other improvements for + VimScript. +- More subtle work on the default style. +- We now use anonymous modules for AMD. +- `macro_rules!` is now recognized as a built-in in Rust. + +[John Foster]: https://github.com/jf990 +[Qeole]: https://github.com/Qeole +[Denis Ciccale]: https://github.com/dciccale +[Michael Johnston]: https://github.com/lastobelus +[Taras]: https://github.com/oxdef +[Robert Dodier]: https://github.com/robert-dodier + + +## Version 9.1.0 + +New languages: + +- *Stan* by [Brendan Rocks][] +- *BASIC* by [Raphaël Assénat][] +- *GAUSS* by [Matt Evans][] +- *DTS* by [Martin Braun][] +- *Arduino* by [Stefania Mellai][] + +New Styles: + +- *Arduino Light* by [Stefania Mellai][] + +Improvements to existing languages and styles: + +- Handle return type annotations in Python +- Allow shebang headers in Javascript +- Support strings in Rust meta +- Recognize `struct` as a class-level definition in Rust +- Recognize b-prefixed chars and strings in Rust +- Better numbers handling in Verilog + +[Brendan Rocks]: http://brendanrocks.com +[Raphaël Assénat]: https://github.com/raphnet +[Matt Evans]: https://github.com/matthewevans +[Martin Braun]: https://github.com/mbr0wn +[Stefania Mellai]: https://github.com/smellai + + +## Version 9.0.0 + +The new major version brings a reworked styling system. Highlight.js now defines +a limited set of highlightable classes giving a consistent result across all the +styles and languages. You can read a more detailed explanation and background in +the [tracking issue][#348] that started this long process back in May. + +This change is backwards incompatible for those who uses highlight.js with a +custom stylesheet. The [new style guide][sg] explains how to write styles +in this new world. + +Bundled themes have also suffered a significant amount of improvements and may +look different in places, but all the things now consistent and make more sense. +Among others, the Default style has got a refresh and will probably be tweaked +some more in next releases. Please do give your feedback in our +[issue tracker][issues]. + +New languages in this release: + +- *Caché Object Script* by [Nikita Savchenko][] +- *YAML* by [Stefan Wienert][] +- *MIPS Assembler* by [Nebuleon Fumika][] +- *HSP* by [prince][] + +Improvements to existing languages and styles: + +- ECMAScript 6 modules import now do not require closing semicolon. +- ECMAScript 6 classes constructors now highlighted. +- Template string support for Typescript, as for ECMAScript 6. +- Scala case classes params highlight fixed. +- Built-in names introduced in Julia v0.4 added by [Kenta Sato][]. +- Refreshed Default style. + +Other notable changes: + +- [Web workers support][webworkers] added bu [Jan Kühle][]. +- We now have tests for compressed browser builds as well. +- The building tool chain has been switched to node.js 4.x. and is now + shamelessly uses ES6 features all over the place, courtesy of [Jeremy Hull][]. +- License added to non-compressed browser build. + +[Jan Kühle]: https://github.com/frigus02 +[Stefan Wienert]: https://github.com/zealot128 +[Kenta Sato]: https://github.com/bicycle1885 +[Nikita Savchenko]: https://github.com/ZitRos +[webworkers]: https://github.com/isagalaev/highlight.js#web-workers +[Jeremy Hull]: https://github.com/sourrust +[#348]: https://github.com/isagalaev/highlight.js/issues/348 +[sg]: http://highlightjs.readthedocs.org/en/latest/style-guide.html +[issues]: https://github.com/isagalaev/highlight.js/issues +[Nebuleon Fumika]: https://github.com/Nebuleon +[prince]: https://github.com/prince-0203 + + +## Version 8.9.1 + +Some last-minute changes reverted due to strange bug with minified browser build: + +- Scala case classes params highlight fixed +- ECMAScript 6 modules import now do not require closing semicolon +- ECMAScript 6 classes constructors now highlighted +- Template string support for Typescript, as for ECMAScript 6 +- License added to not minified browser build + + +## Version 8.9.0 + +New languages: + +- *crmsh* by [Kristoffer Gronlund][] +- *SQF* by [Soren Enevoldsen][] + +[Kristoffer Gronlund]: https://github.com/krig +[Soren Enevoldsen]: https://github.com/senevoldsen90 + +Notable fixes and improvements to existing languages: + +- Added `abstract` and `namespace` keywords to TypeScript by [Daniel Rosenwasser][] +- Added `label` support to Dockerfile by [Ladislav Prskavec][] +- Crystal highlighting improved by [Tsuyusato Kitsune][] +- Missing Swift keywords added by [Nate Cook][] +- Improve detection of C block comments +- ~~Scala case classes params highlight fixed~~ +- ~~ECMAScript 6 modules import now do not require closing semicolon~~ +- ~~ECMAScript 6 classes constructors now highlighted~~ +- ~~Template string support for Typescript, as for ECMAScript 6~~ + +Other notable changes: + +- ~~License added to not minified browser build~~ + +[Kristoffer Gronlund]: https://github.com/krig +[Søren Enevoldsen]: https://github.com/senevoldsen90 +[Daniel Rosenwasser]: https://github.com/DanielRosenwasser +[Ladislav Prskavec]: https://github.com/abtris +[Tsuyusato Kitsune]: https://github.com/MakeNowJust +[Nate Cook]: https://github.com/natecook1000 + + +## Version 8.8.0 + +New languages: + +- *Golo* by [Philippe Charrière][] +- *GAMS* by [Stefan Bechert][] +- *IRPF90* by [Anthony Scemama][] +- *Access logs* by [Oleg Efimov][] +- *Crystal* by [Tsuyusato Kitsune][] + +Notable fixes and improvements to existing languages: + +- JavaScript highlighting no longer fails with ES6 default parameters +- Added keywords `async` and `await` to Python +- PHP heredoc support improved +- Allow preprocessor directives within C++ functions + +Other notable changes: + +- Change versions to X.Y.Z SemVer-compatible format +- Added ability to build all targets at once + +[Philippe Charrière]: https://github.com/k33g +[Stefan Bechert]: https://github.com/b-pos465 +[Anthony Scemama]: https://github.com/scemama +[Oleg Efimov]: https://github.com/Sannis +[Tsuyusato Kitsune]: https://github.com/MakeNowJust + + +## Version 8.7 + +New languages: + +- *Zephir* by [Oleg Efimov][] +- *Elm* by [Janis Voigtländer][] +- *XQuery* by [Dirk Kirsten][] +- *Mojolicious* by [Dotan Dimet][] +- *AutoIt* by Manh Tuan from [J2TeaM][] +- *Toml* (ini extension) by [Guillaume Gomez][] + +New styles: + +- *Hopscotch* by [Jan T. Sott][] +- *Grayscale* by [MY Sun][] + +Notable fixes and improvements to existing languages: + +- Fix encoding of images when copied over in certain builds +- Fix incorrect highlighting of the word "bug" in comments +- Treat decorators different from matrix multiplication in Python +- Fix traits inheritance highlighting in Rust +- Fix incorrect document +- Oracle keywords added to SQL language definition by [Vadimtro][] +- Postgres keywords added to SQL language definition by [Benjamin Auder][] +- Fix registers in x86asm being highlighted as a hex number +- Fix highlighting for numbers with a leading decimal point +- Correctly highlight numbers and strings inside of C/C++ macros +- C/C++ functions now support pointer, reference, and move returns + +[Oleg Efimov]: https://github.com/Sannis +[Guillaume Gomez]: https://github.com/GuillaumeGomez +[Janis Voigtländer]: https://github.com/jvoigtlaender +[Jan T. Sott]: https://github.com/idleberg +[Dirk Kirsten]: https://github.com/dirkk +[MY Sun]: https://github.com/simonmysun +[Vadimtro]: https://github.com/Vadimtro +[Benjamin Auder]: https://github.com/ghost +[Dotan Dimet]: https://github.com/dotandimet +[J2TeaM]: https://github.com/J2TeaM + + +## Version 8.6 + +New languages: + +- *C/AL* by [Kenneth Fuglsang][] +- *DNS zone file* by [Tim Schumacher][] +- *Ceylon* by [Lucas Werkmeister][] +- *OpenSCAD* by [Dan Panzarella][] +- *Inform7* by [Bruno Dias][] +- *armasm* by [Dan Panzarella][] +- *TP* by [Jay Strybis][] + +New styles: + +- *Atelier Cave*, *Atelier Estuary*, + *Atelier Plateau* and *Atelier Savanna* by [Bram de Haan][] +- *Github Gist* by [Louis Barranqueiro][] + +Notable fixes and improvements to existing languages: + +- Multi-line raw strings from C++11 are now supported +- Fix class names with dashes in HAML +- The `async` keyword from ES6/7 is now supported +- TypeScript functions handle type and parameter complexity better +- We unified phpdoc/javadoc/yardoc etc modes across all languages +- CSS .class selectors relevance was dropped to prevent wrong language detection +- Images is now included to CDN build +- Release process is now automated + +[Bram de Haan]: https://github.com/atelierbram +[Kenneth Fuglsang]: https://github.com/kfuglsang +[Louis Barranqueiro]: https://github.com/LouisBarranqueiro +[Tim Schumacher]: https://github.com/enko +[Lucas Werkmeister]: https://github.com/lucaswerkmeister +[Dan Panzarella]: https://github.com/pzl +[Bruno Dias]: https://github.com/sequitur +[Jay Strybis]: https://github.com/unreal + + +## Version 8.5 + +New languages: + +- *pf.conf* by [Peter Piwowarski][] +- *Julia* by [Kenta Sato][] +- *Prolog* by [Raivo Laanemets][] +- *Docker* by [Alexis Hénaut][] +- *Fortran* by [Anthony Scemama][] and [Thomas Applencourt][] +- *Kotlin* by [Sergey Mashkov][] + +New styles: + +- *Agate* by [Taufik Nurrohman][] +- *Darcula* by [JetBrains][] +- *Atelier Sulphurpool* by [Bram de Haan][] +- *Android Studio* by [Pedro Oliveira][] + +Notable fixes and improvements to existing languages: + +- ES6 features in JavaScript are better supported now by [Gu Yiling][]. +- Swift now recognizes body-less method definitions. +- Single expression functions `def foo, do: ... ` now work in Elixir. +- More uniform detection of built-in classes in Objective C. +- Fixes for number literals and processor directives in Rust. +- HTML ` + ``` + +- `tabReplace` and `useBR` that were used in different places are also unified + into the global options object and are to be set using `configure(options)`. + This function is documented in our [API docs][]. Also note that these + parameters are gone from `highlightBlock` and `fixMarkup` which are now also + rely on `configure`. + +- We removed public-facing (though undocumented) object `hljs.LANGUAGES` which + was used to register languages with the library in favor of two new methods: + `registerLanguage` and `getLanguage`. Both are documented in our [API docs][]. + +- Result returned from `highlight` and `highlightAuto` no longer contains two + separate attributes contributing to relevance score, `relevance` and + `keyword_count`. They are now unified in `relevance`. + +Another technically compatible change that nonetheless might need attention: + +- The structure of the NPM package was refactored, so if you had installed it + locally, you'll have to update your paths. The usual `require('highlight.js')` + works as before. This is contributed by [Dmitry Smolin][]. + +New features: + +- Languages now can be recognized by multiple names like "js" for JavaScript or + "html" for, well, HTML (which earlier insisted on calling it "xml"). These + aliases can be specified in the class attribute of the code container in your + HTML as well as in various API calls. For now there are only a few very common + aliases but we'll expand it in the future. All of them are listed in the + [class reference][cr]. + +- Language detection can now be restricted to a subset of languages relevant in + a given context — a web page or even a single highlighting call. This is + especially useful for node.js build that includes all the known languages. + Another example is a StackOverflow-style site where users specify languages + as tags rather than in the markdown-formatted code snippets. This is + documented in the [API reference][] (see methods `highlightAuto` and + `configure`). + +- Language definition syntax streamlined with [variants][] and + [beginKeywords][]. + +New languages and styles: + +- *Oxygene* by [Carlo Kok][] +- *Mathematica* by [Daniel Kvasnička][] +- *Autohotkey* by [Seongwon Lee][] +- *Atelier* family of styles in 10 variants by [Bram de Haan][] +- *Paraíso* styles by [Jan T. Sott][] + +Miscellaneous improvements: + +- Highlighting `=>` prompts in Clojure. +- [Jeremy Hull][] fixed a lot of styles for consistency. +- Finally, highlighting PHP and HTML [mixed in peculiar ways][php-html]. +- Objective C and C# now properly highlight titles in method definition. +- Big overhaul of relevance counting for a number of languages. Please do report + bugs about mis-detection of non-trivial code snippets! + +[API reference]: http://highlightjs.readthedocs.org/en/latest/api.html + +[cr]: http://highlightjs.readthedocs.org/en/latest/css-classes-reference.html +[api docs]: http://highlightjs.readthedocs.org/en/latest/api.html +[variants]: https://groups.google.com/d/topic/highlightjs/VoGC9-1p5vk/discussion +[beginKeywords]: https://github.com/isagalaev/highlight.js/commit/6c7fdea002eb3949577a85b3f7930137c7c3038d +[php-html]: https://twitter.com/highlightjs/status/408890903017689088 + +[Carlo Kok]: https://github.com/carlokok +[Bram de Haan]: https://github.com/atelierbram +[Daniel Kvasnička]: https://github.com/dkvasnicka +[Dmitry Smolin]: https://github.com/dimsmol +[Jeremy Hull]: https://github.com/sourrust +[Seongwon Lee]: https://github.com/dlimpid +[Jan T. Sott]: https://github.com/idleberg + + +## Version 7.5 + +A catch-up release dealing with some of the accumulated contributions. This one +is probably will be the last before the 8.0 which will be slightly backwards +incompatible regarding some advanced use-cases. + +One outstanding change in this version is the addition of 6 languages to the +[hosted script][d]: Markdown, ObjectiveC, CoffeeScript, Apache, Nginx and +Makefile. It now weighs about 6K more but we're going to keep it under 30K. + +New languages: + +- OCaml by [Mehdi Dogguy][mehdid] and [Nicolas Braud-Santoni][nbraud] +- [LiveCode Server][lcs] by [Ralf Bitter][revig] +- Scilab by [Sylvestre Ledru][sylvestre] +- basic support for Makefile by [Ivan Sagalaev][isagalaev] + +Improvements: + +- Ruby's got support for characters like `?A`, `?1`, `?\012` etc. and `%r{..}` + regexps. +- Clojure now allows a function call in the beginning of s-expressions + `(($filter "myCount") (arr 1 2 3 4 5))`. +- Haskell's got new keywords and now recognizes more things like pragmas, + preprocessors, modules, containers, FFIs etc. Thanks to [Zena Treep][treep] + for the implementation and to [Jeremy Hull][sourrust] for guiding it. +- Miscellaneous fixes in PHP, Brainfuck, SCSS, Asciidoc, CMake, Python and F#. + +[mehdid]: https://github.com/mehdid +[nbraud]: https://github.com/nbraud +[revig]: https://github.com/revig +[lcs]: http://livecode.com/developers/guides/server/ +[sylvestre]: https://github.com/sylvestre +[isagalaev]: https://github.com/isagalaev +[treep]: https://github.com/treep +[sourrust]: https://github.com/sourrust +[d]: http://highlightjs.org/download/ + + +## New core developers + +The latest long period of almost complete inactivity in the project coincided +with growing interest to it led to a decision that now seems completely obvious: +we need more core developers. + +So without further ado let me welcome to the core team two long-time +contributors: [Jeremy Hull][] and [Oleg +Efimov][]. + +Hope now we'll be able to work through stuff faster! + +P.S. The historical commit is [here][1] for the record. + +[Jeremy Hull]: https://github.com/sourrust +[Oleg Efimov]: https://github.com/sannis +[1]: https://github.com/isagalaev/highlight.js/commit/f3056941bda56d2b72276b97bc0dd5f230f2473f + + +## Version 7.4 + +This long overdue version is a snapshot of the current source tree with all the +changes that happened during the past year. Sorry for taking so long! + +Along with the changes in code highlight.js has finally got its new home at +, moving from its cradle on Software Maniacs which it +outgrew a long time ago. Be sure to report any bugs about the site to +. + +On to what's new… + +New languages: + +- Handlebars templates by [Robin Ward][] +- Oracle Rules Language by [Jason Jacobson][] +- F# by [Joans Follesø][] +- AsciiDoc and Haml by [Dan Allen][] +- Lasso by [Eric Knibbe][] +- SCSS by [Kurt Emch][] +- VB.NET by [Poren Chiang][] +- Mizar by [Kelley van Evert][] + +[Robin Ward]: https://github.com/eviltrout +[Jason Jacobson]: https://github.com/jayce7 +[Joans Follesø]: https://github.com/follesoe +[Dan Allen]: https://github.com/mojavelinux +[Eric Knibbe]: https://github.com/EricFromCanada +[Kurt Emch]: https://github.com/kemch +[Poren Chiang]: https://github.com/rschiang +[Kelley van Evert]: https://github.com/kelleyvanevert + +New style themes: + +- Monokai Sublime by [noformnocontent][] +- Railscasts by [Damien White][] +- Obsidian by [Alexander Marenin][] +- Docco by [Simon Madine][] +- Mono Blue by [Ivan Sagalaev][] (uses a single color hue for everything) +- Foundation by [Dan Allen][] + +[noformnocontent]: http://nn.mit-license.org/ +[Damien White]: https://github.com/visoft +[Alexander Marenin]: https://github.com/ioncreature +[Simon Madine]: https://github.com/thingsinjars +[Ivan Sagalaev]: https://github.com/isagalaev + +Other notable changes: + +- Corrected many corner cases in CSS. +- Dropped Python 2 version of the build tool. +- Implemented building for the AMD format. +- Updated Rust keywords (thanks to [Dmitry Medvinsky][]). +- Literal regexes can now be used in language definitions. +- CoffeeScript highlighting is now significantly more robust and rich due to + input from [Cédric Néhémie][]. + +[Dmitry Medvinsky]: https://github.com/dmedvinsky +[Cédric Néhémie]: https://github.com/abe33 + + +## Version 7.3 + +- Since this version highlight.js no longer works in IE version 8 and older. + It's made it possible to reduce the library size and dramatically improve code + readability and made it easier to maintain. Time to go forward! + +- New languages: AppleScript (by [Nathan Grigg][ng] and [Dr. Drang][dd]) and + Brainfuck (by [Evgeny Stepanischev][bolk]). + +- Improvements to existing languages: + + - interpreter prompt in Python (`>>>` and `...`) + - @-properties and classes in CoffeeScript + - E4X in JavaScript (by [Oleg Efimov][oe]) + - new keywords in Perl (by [Kirk Kimmel][kk]) + - big Ruby syntax update (by [Vasily Polovnyov][vast]) + - small fixes in Bash + +- Also Oleg Efimov did a great job of moving all the docs for language and style + developers and contributors from the old wiki under the source code in the + "docs" directory. Now these docs are nicely presented at + . + +[ng]: https://github.com/nathan11g +[dd]: https://github.com/drdrang +[bolk]: https://github.com/bolknote +[oe]: https://github.com/Sannis +[kk]: https://github.com/kimmel +[vast]: https://github.com/vast + + +## Version 7.2 + +A regular bug-fix release without any significant new features. Enjoy! + + +## Version 7.1 + +A Summer crop: + +- [Marc Fornos][mf] made the definition for Clojure along with the matching + style Rainbow (which, of course, works for other languages too). +- CoffeeScript support continues to improve getting support for regular + expressions. +- Yoshihide Jimbo ported to highlight.js [five Tomorrow styles][tm] from the + [project by Chris Kempson][tm0]. +- Thanks to [Casey Duncun][cd] the library can now be built in the popular + [AMD format][amd]. +- And last but not least, we've got a fair number of correctness and consistency + fixes, including a pretty significant refactoring of Ruby. + +[mf]: https://github.com/mfornos +[tm]: http://jmblog.github.com/color-themes-for-highlightjs/ +[tm0]: https://github.com/ChrisKempson/Tomorrow-Theme +[cd]: https://github.com/caseman +[amd]: http://requirejs.org/docs/whyamd.html + + +## Version 7.0 + +The reason for the new major version update is a global change of keyword syntax +which resulted in the library getting smaller once again. For example, the +hosted build is 2K less than at the previous version while supporting two new +languages. + +Notable changes: + +- The library now works not only in a browser but also with [node.js][]. It is + installable with `npm install highlight.js`. [API][] docs are available on our + wiki. + +- The new unique feature (apparently) among syntax highlighters is highlighting + *HTTP* headers and an arbitrary language in the request body. The most useful + languages here are *XML* and *JSON* both of which highlight.js does support. + Here's [the detailed post][p] about the feature. + +- Two new style themes: a dark "south" *[Pojoaque][]* by Jason Tate and an + emulation of*XCode* IDE by [Angel Olloqui][ao]. + +- Three new languages: *D* by [Aleksandar Ružičić][ar], *R* by [Joe Cheng][jc] + and *GLSL* by [Sergey Tikhomirov][st]. + +- *Nginx* syntax has become a million times smaller and more universal thanks to + remaking it in a more generic manner that doesn't require listing all the + directives in the known universe. + +- Function titles are now highlighted in *PHP*. + +- *Haskell* and *VHDL* were significantly reworked to be more rich and correct + by their respective maintainers [Jeremy Hull][sr] and [Igor Kalnitsky][ik]. + +And last but not least, many bugs have been fixed around correctness and +language detection. + +Overall highlight.js currently supports 51 languages and 20 style themes. + +[node.js]: http://nodejs.org/ +[api]: http://softwaremaniacs.org/wiki/doku.php/highlight.js:api +[p]: http://softwaremaniacs.org/blog/2012/05/10/http-and-json-in-highlight-js/en/ +[pojoaque]: http://web-cms-designs.com/ftopict-10-pojoaque-style-for-highlight-js-code-highlighter.html +[ao]: https://github.com/angelolloqui +[ar]: https://github.com/raleksandar +[jc]: https://github.com/jcheng5 +[st]: https://github.com/tikhomirov +[sr]: https://github.com/sourrust +[ik]: https://github.com/ikalnitsky + + +## Version 6.2 + +A lot of things happened in highlight.js since the last version! We've got nine +new contributors, the discussion group came alive, and the main branch on GitHub +now counts more than 350 followers. Here are most significant results coming +from all this activity: + +- 5 (five!) new languages: Rust, ActionScript, CoffeeScript, MatLab and + experimental support for markdown. Thanks go to [Andrey Vlasovskikh][av], + [Alexander Myadzel][am], [Dmytrii Nagirniak][dn], [Oleg Efimov][oe], [Denis + Bardadym][db] and [John Crepezzi][jc]. + +- 2 new style themes: Monokai by [Luigi Maselli][lm] and stylistic imitation of + another well-known highlighter Google Code Prettify by [Aahan Krish][ak]. + +- A vast number of [correctness fixes and code refactorings][log], mostly made + by [Oleg Efimov][oe] and [Evgeny Stepanischev][es]. + +[av]: https://github.com/vlasovskikh +[am]: https://github.com/myadzel +[dn]: https://github.com/dnagir +[oe]: https://github.com/Sannis +[db]: https://github.com/btd +[jc]: https://github.com/seejohnrun +[lm]: http://grigio.org/ +[ak]: https://github.com/geekpanth3r +[es]: https://github.com/bolknote +[log]: https://github.com/isagalaev/highlight.js/commits/ + + +## Version 6.1 — Solarized + +[Jeremy Hull][jh] has implemented my dream feature — a port of [Solarized][] +style theme famous for being based on the intricate color theory to achieve +correct contrast and color perception. It is now available for highlight.js in +both variants — light and dark. + +This version also adds a new original style Arta. Its author pumbur maintains a +[heavily modified fork of highlight.js][pb] on GitHub. + +[jh]: https://github.com/sourrust +[solarized]: http://ethanschoonover.com/solarized +[pb]: https://github.com/pumbur/highlight.js + + +## Version 6.0 + +New major version of the highlighter has been built on a significantly +refactored syntax. Due to this it's even smaller than the previous one while +supporting more languages! + +New languages are: + +- Haskell by [Jeremy Hull][sourrust] +- Erlang in two varieties — module and REPL — made collectively by [Nikolay + Zakharov][desh], [Dmitry Kovega][arhibot] and [Sergey Ignatov][ignatov] +- Objective C by [Valerii Hiora][vhbit] +- Vala by [Antono Vasiljev][antono] +- Go by [Stephan Kountso][steplg] + +[sourrust]: https://github.com/sourrust +[desh]: http://desh.su/ +[arhibot]: https://github.com/arhibot +[ignatov]: https://github.com/ignatov +[vhbit]: https://github.com/vhbit +[antono]: https://github.com/antono +[steplg]: https://github.com/steplg + +Also this version is marginally faster and fixes a number of small long-standing +bugs. + +Developer overview of the new language syntax is available in a [blog post about +recent beta release][beta]. + +[beta]: http://softwaremaniacs.org/blog/2011/04/25/highlight-js-60-beta/en/ + +P.S. New version is not yet available on a Yandex CDN, so for now you have to +download [your own copy][d]. + +[d]: /soft/highlight/en/download/ + + +## Version 5.14 + +Fixed bugs in HTML/XML detection and relevance introduced in previous +refactoring. + +Also test.html now shows the second best result of language detection by +relevance. + + +## Version 5.13 + +Past weekend began with a couple of simple additions for existing languages but +ended up in a big code refactoring bringing along nice improvements for language +developers. + +### For users + +- Description of C++ has got new keywords from the upcoming [C++ 0x][] standard. +- Description of HTML has got new tags from [HTML 5][]. +- CSS-styles have been unified to use consistent padding and also have lost + pop-outs with names of detected languages. +- [Igor Kalnitsky][ik] has sent two new language descriptions: CMake & VHDL. + +This makes total number of languages supported by highlight.js to reach 35. + +Bug fixes: + +- Custom classes on `
` tags are not being overridden anymore
+- More correct highlighting of code blocks inside non-`
` containers:
+  highlighter now doesn't insist on replacing them with its own container and
+  just replaces the contents.
+- Small fixes in browser compatibility and heuristics.
+
+[c++ 0x]: http://ru.wikipedia.org/wiki/C%2B%2B0x
+[html 5]: http://en.wikipedia.org/wiki/HTML5
+[ik]: http://kalnitsky.org.ua/
+
+### For developers
+
+The most significant change is the ability to include language submodes right
+under `contains` instead of defining explicit named submodes in the main array:
+
+    contains: [
+      'string',
+      'number',
+      {begin: '\\n', end: hljs.IMMEDIATE_RE}
+    ]
+
+This is useful for auxiliary modes needed only in one place to define parsing.
+Note that such modes often don't have `className` and hence won't generate a
+separate `` in the resulting markup. This is similar in effect to
+`noMarkup: true`. All existing languages have been refactored accordingly.
+
+Test file test.html has at last become a real test. Now it not only puts the
+detected language name under the code snippet but also tests if it matches the
+expected one. Test summary is displayed right above all language snippets.
+
+
+## CDN
+
+Fine people at [Yandex][] agreed to host highlight.js on their big fast servers.
+[Link up][l]!
+
+[yandex]: http://yandex.com/
+[l]: http://softwaremaniacs.org/soft/highlight/en/download/
+
+
+## Version 5.10 — "Paris".
+
+Though I'm on a vacation in Paris, I decided to release a new version with a
+couple of small fixes:
+
+- Tomas Vitvar discovered that TAB replacement doesn't always work when used
+  with custom markup in code
+- SQL parsing is even more rigid now and doesn't step over SmallTalk in tests
+
+
+## Version 5.9
+
+A long-awaited version is finally released.
+
+New languages:
+
+- Andrew Fedorov made a definition for Lua
+- a long-time highlight.js contributor [Peter Leonov][pl] made a definition for
+  Nginx config
+- [Vladimir Moskva][vm] made a definition for TeX
+
+[pl]: http://kung-fu-tzu.ru/
+[vm]: http://fulc.ru/
+
+Fixes for existing languages:
+
+- [Loren Segal][ls] reworked the Ruby definition and added highlighting for
+  [YARD][] inline documentation
+- the definition of SQL has become more solid and now it shouldn't be overly
+  greedy when it comes to language detection
+
+[ls]: http://gnuu.org/
+[yard]: http://yardoc.org/
+
+The highlighter has become more usable as a library allowing to do highlighting
+from initialization code of JS frameworks and in ajax methods (see.
+readme.eng.txt).
+
+Also this version drops support for the [WordPress][wp] plugin. Everyone is
+welcome to [pick up its maintenance][p] if needed.
+
+[wp]: http://wordpress.org/
+[p]: http://bazaar.launchpad.net/~isagalaev/+junk/highlight/annotate/342/src/wp_highlight.js.php
+
+
+## Version 5.8
+
+- Jan Berkel has contributed a definition for Scala. +1 to hotness!
+- All CSS-styles are rewritten to work only inside `
` tags to avoid
+  conflicts with host site styles.
+
+
+## Version 5.7.
+
+Fixed escaping of quotes in VBScript strings.
+
+
+## Version 5.5
+
+This version brings a small change: now .ini-files allow digits, underscores and
+square brackets in key names.
+
+
+## Version 5.4
+
+Fixed small but upsetting bug in the packer which caused incorrect highlighting
+of explicitly specified languages. Thanks to Andrew Fedorov for precise
+diagnostics!
+
+
+## Version 5.3
+
+The version to fulfil old promises.
+
+The most significant change is that highlight.js now preserves custom user
+markup in code along with its own highlighting markup. This means that now it's
+possible to use, say, links in code. Thanks to [Vladimir Dolzhenko][vd] for the
+[initial proposal][1] and for making a proof-of-concept patch.
+
+Also in this version:
+
+- [Vasily Polovnyov][vp] has sent a GitHub-like style and has implemented
+  support for CSS @-rules and Ruby symbols.
+- Yura Zaripov has sent two styles: Brown Paper and School Book.
+- Oleg Volchkov has sent a definition for [Parser 3][p3].
+
+[1]: http://softwaremaniacs.org/forum/highlightjs/6612/
+[p3]: http://www.parser.ru/
+[vp]: http://vasily.polovnyov.ru/
+[vd]: http://dolzhenko.blogspot.com/
+
+
+## Version 5.2
+
+- at last it's possible to replace indentation TABs with something sensible
+  (e.g. 2 or 4 spaces)
+- new keywords and built-ins for 1C by Sergey Baranov
+- a couple of small fixes to Apache highlighting
+
+
+## Version 5.1
+
+This is one of those nice version consisting entirely of new and shiny
+contributions!
+
+- [Vladimir Ermakov][vooon] created highlighting for AVR Assembler
+- [Ruslan Keba][rukeba] created highlighting for Apache config file. Also his
+  original visual style for it is now available for all highlight.js languages
+  under the name "Magula".
+- [Shuen-Huei Guan][drake] (aka Drake) sent new keywords for RenderMan
+  languages. Also thanks go to [Konstantin Evdokimenko][ke] for his advice on
+  the matter.
+
+[vooon]: http://vehq.ru/about/
+[rukeba]: http://rukeba.com/
+[drake]: http://drakeguan.org/
+[ke]: http://k-evdokimenko.moikrug.ru/
+
+
+## Version 5.0
+
+The main change in the new major version of highlight.js is a mechanism for
+packing several languages along with the library itself into a single compressed
+file. Now sites using several languages will load considerably faster because
+the library won't dynamically include additional files while loading.
+
+Also this version fixes a long-standing bug with Javascript highlighting that
+couldn't distinguish between regular expressions and division operations.
+
+And as usually there were a couple of minor correctness fixes.
+
+Great thanks to all contributors! Keep using highlight.js.
+
+
+## Version 4.3
+
+This version comes with two contributions from [Jason Diamond][jd]:
+
+- language definition for C# (yes! it was a long-missed thing!)
+- Visual Studio-like highlighting style
+
+Plus there are a couple of minor bug fixes for parsing HTML and XML attributes.
+
+[jd]: http://jason.diamond.name/weblog/
+
+
+## Version 4.2
+
+The biggest news is highlighting for Lisp, courtesy of Vasily Polovnyov. It's
+somewhat experimental meaning that for highlighting "keywords" it doesn't use
+any pre-defined set of a Lisp dialect. Instead it tries to highlight first word
+in parentheses wherever it makes sense. I'd like to ask people programming in
+Lisp to confirm if it's a good idea and send feedback to [the forum][f].
+
+Other changes:
+
+- Smalltalk was excluded from DEFAULT_LANGUAGES to save traffic
+- [Vladimir Epifanov][voldmar] has implemented javascript style switcher for
+  test.html
+- comments now allowed inside Ruby function definition
+- [MEL][] language from [Shuen-Huei Guan][drake]
+- whitespace now allowed between `
` and ``
+- better auto-detection of C++ and PHP
+- HTML allows embedded VBScript (`<% .. %>`)
+
+[f]: http://softwaremaniacs.org/forum/highlightjs/
+[voldmar]: http://voldmar.ya.ru/
+[mel]: http://en.wikipedia.org/wiki/Maya_Embedded_Language
+[drake]: http://drakeguan.org/
+
+
+## Version 4.1
+
+Languages:
+
+- Bash from Vah
+- DOS bat-files from Alexander Makarov (Sam)
+- Diff files from Vasily Polovnyov
+- Ini files from myself though initial idea was from Sam
+
+Styles:
+
+- Zenburn from Vladimir Epifanov, this is an imitation of a
+  [well-known theme for Vim][zenburn].
+- Ascetic from myself, as a realization of ideals of non-flashy highlighting:
+  just one color in only three gradations :-)
+
+In other news. [One small bug][bug] was fixed, built-in keywords were added for
+Python and C++ which improved auto-detection for the latter (it was shame that
+[my wife's blog][alenacpp] had issues with it from time to time). And lastly
+thanks go to Sam for getting rid of my stylistic comments in code that were
+getting in the way of [JSMin][].
+
+[zenburn]: http://en.wikipedia.org/wiki/Zenburn
+[alenacpp]: http://alenacpp.blogspot.com/
+[bug]: http://softwaremaniacs.org/forum/viewtopic.php?id=1823
+[jsmin]: http://code.google.com/p/jsmin-php/
+
+
+## Version 4.0
+
+New major version is a result of vast refactoring and of many contributions.
+
+Visible new features:
+
+- Highlighting of embedded languages. Currently is implemented highlighting of
+  Javascript and CSS inside HTML.
+- Bundled 5 ready-made style themes!
+
+Invisible new features:
+
+- Highlight.js no longer pollutes global namespace. Only one object and one
+  function for backward compatibility.
+- Performance is further increased by about 15%.
+
+Changing of a major version number caused by a new format of language definition
+files. If you use some third-party language files they should be updated.
+
+
+## Version 3.5
+
+A very nice version in my opinion fixing a number of small bugs and slightly
+increased speed in a couple of corner cases. Thanks to everybody who reports
+bugs in he [forum][f] and by email!
+
+There is also a new language — XML. A custom XML formerly was detected as HTML
+and didn't highlight custom tags. In this version I tried to make custom XML to
+be detected and highlighted by its own rules. Which by the way include such
+things as CDATA sections and processing instructions (``).
+
+[f]: http://softwaremaniacs.org/forum/viewforum.php?id=6
+
+
+## Version 3.3
+
+[Vladimir Gubarkov][xonix] has provided an interesting and useful addition.
+File export.html contains a little program that shows and allows to copy and
+paste an HTML code generated by the highlighter for any code snippet. This can
+be useful in situations when one can't use the script itself on a site.
+
+
+[xonix]: http://xonixx.blogspot.com/
+
+
+## Version 3.2 consists completely of contributions:
+
+- Vladimir Gubarkov has described SmallTalk
+- Yuri Ivanov has described 1C
+- Peter Leonov has packaged the highlighter as a Firefox extension
+- Vladimir Ermakov has compiled a mod for phpBB
+
+Many thanks to you all!
+
+
+## Version 3.1
+
+Three new languages are available: Django templates, SQL and Axapta. The latter
+two are sent by [Dmitri Roudakov][1]. However I've almost entirely rewrote an
+SQL definition but I'd never started it be it from the ground up :-)
+
+The engine itself has got a long awaited feature of grouping keywords
+("keyword", "built-in function", "literal"). No more hacks!
+
+[1]: http://roudakov.ru/
+
+
+## Version 3.0
+
+It is major mainly because now highlight.js has grown large and has become
+modular. Now when you pass it a list of languages to highlight it will
+dynamically load into a browser only those languages.
+
+Also:
+
+- Konstantin Evdokimenko of [RibKit][] project has created a highlighting for
+  RenderMan Shading Language and RenderMan Interface Bytestream. Yay for more
+  languages!
+- Heuristics for C++ and HTML got better.
+- I've implemented (at last) a correct handling of backslash escapes in C-like
+  languages.
+
+There is also a small backwards incompatible change in the new version. The
+function initHighlighting that was used to initialize highlighting instead of
+initHighlightingOnLoad a long time ago no longer works. If you by chance still
+use it — replace it with the new one.
+
+[RibKit]: http://ribkit.sourceforge.net/
+
+
+## Version 2.9
+
+Highlight.js is a parser, not just a couple of regular expressions. That said
+I'm glad to announce that in the new version 2.9 has support for:
+
+- in-string substitutions for Ruby -- `#{...}`
+- strings from from numeric symbol codes (like #XX) for Delphi
+
+
+## Version 2.8
+
+A maintenance release with more tuned heuristics. Fully backwards compatible.
+
+
+## Version 2.7
+
+- Nikita Ledyaev presents highlighting for VBScript, yay!
+- A couple of bugs with escaping in strings were fixed thanks to Mickle
+- Ongoing tuning of heuristics
+
+Fixed bugs were rather unpleasant so I encourage everyone to upgrade!
+
+
+## Version 2.4
+
+- Peter Leonov provides another improved highlighting for Perl
+- Javascript gets a new kind of keywords — "literals". These are the words
+  "true", "false" and "null"
+
+Also highlight.js homepage now lists sites that use the library. Feel free to
+add your site by [dropping me a message][mail] until I find the time to build a
+submit form.
+
+[mail]: mailto:Maniac@SoftwareManiacs.Org
+
+
+## Version 2.3
+
+This version fixes IE breakage in previous version. My apologies to all who have
+already downloaded that one!
+
+
+## Version 2.2
+
+- added highlighting for Javascript
+- at last fixed parsing of Delphi's escaped apostrophes in strings
+- in Ruby fixed highlighting of keywords 'def' and 'class', same for 'sub' in
+  Perl
+
+
+## Version 2.0
+
+- Ruby support by [Anton Kovalyov][ak]
+- speed increased by orders of magnitude due to new way of parsing
+- this same way allows now correct highlighting of keywords in some tricky
+  places (like keyword "End" at the end of Delphi classes)
+
+[ak]: http://anton.kovalyov.net/
+
+
+## Version 1.0
+
+Version 1.0 of javascript syntax highlighter is released!
+
+It's the first version available with English description. Feel free to post
+your comments and question to [highlight.js forum][forum]. And don't be afraid
+if you find there some fancy Cyrillic letters -- it's for Russian users too :-)
+
+[forum]: http://softwaremaniacs.org/forum/viewforum.php?id=6
diff --git a/lib/highlight/LICENSE b/lib/highlight/LICENSE
new file mode 100644
index 000000000..422deb735
--- /dev/null
+++ b/lib/highlight/LICENSE
@@ -0,0 +1,24 @@
+Copyright (c) 2006, Ivan Sagalaev
+All rights reserved.
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+    * Redistributions of source code must retain the above copyright
+      notice, this list of conditions and the following disclaimer.
+    * Redistributions in binary form must reproduce the above copyright
+      notice, this list of conditions and the following disclaimer in the
+      documentation and/or other materials provided with the distribution.
+    * Neither the name of highlight.js nor the names of its contributors 
+      may be used to endorse or promote products derived from this software 
+      without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/lib/highlight/README.md b/lib/highlight/README.md
new file mode 100644
index 000000000..9f76e6bd5
--- /dev/null
+++ b/lib/highlight/README.md
@@ -0,0 +1,150 @@
+# Highlight.js
+
+[![Build Status](https://travis-ci.org/isagalaev/highlight.js.svg?branch=master)](https://travis-ci.org/isagalaev/highlight.js)
+
+Highlight.js is a syntax highlighter written in JavaScript. It works in
+the browser as well as on the server. It works with pretty much any
+markup, doesn’t depend on any framework and has automatic language
+detection.
+
+## Getting Started
+
+The bare minimum for using highlight.js on a web page is linking to the
+library along with one of the styles and calling
+[`initHighlightingOnLoad`][1]:
+
+```html
+
+
+
+```
+
+This will find and highlight code inside of `
` tags; it tries
+to detect the language automatically. If automatic detection doesn’t
+work for you, you can specify the language in the `class` attribute:
+
+```html
+
...
+``` + +The list of supported language classes is available in the [class +reference][2]. Classes can also be prefixed with either `language-` or +`lang-`. + +To disable highlighting altogether use the `nohighlight` class: + +```html +
...
+``` + +## Custom Initialization + +When you need a bit more control over the initialization of +highlight.js, you can use the [`highlightBlock`][3] and [`configure`][4] +functions. This allows you to control *what* to highlight and *when*. + +Here’s an equivalent way to calling [`initHighlightingOnLoad`][1] using +jQuery: + +```javascript +$(document).ready(function() { + $('pre code').each(function(i, block) { + hljs.highlightBlock(block); + }); +}); +``` + +You can use any tags instead of `
` to mark up your code. If
+you don't use a container that preserve line breaks you will need to
+configure highlight.js to use the `
` tag: + +```javascript +hljs.configure({useBR: true}); + +$('div.code').each(function(i, block) { + hljs.highlightBlock(block); +}); +``` + +For other options refer to the documentation for [`configure`][4]. + + +## Web Workers + +You can run highlighting inside a web worker to avoid freezing the browser +window while dealing with very big chunks of code. + +In your main script: + +```javascript +addEventListener('load', function() { + var code = document.querySelector('#code'); + var worker = new Worker('worker.js'); + worker.onmessage = function(event) { code.innerHTML = event.data; } + worker.postMessage(code.textContent); +}) +``` + +In worker.js: + +```javascript +onmessage = function(event) { + importScripts('/highlight.pack.js'); + var result = self.hljs.highlightAuto(event.data); + postMessage(result.value); +} +``` + + +## Getting the Library + +You can get highlight.js as a hosted, or custom-build, browser script or +as a server module. Right out of the box the browser script supports +both AMD and CommonJS, so if you wish you can use RequireJS or +Browserify without having to build from source. The server module also +works perfectly fine with Browserify, but there is the option to use a +build specific to browsers rather than something meant for a server. +Head over to the [download page][5] for all the options. + +**Don't link to GitHub directly.** The library is not supposed to work straight +from the source, it requires building. If none of the pre-packaged options +work for you refer to the [building documentation][6]. + +**The CDN-hosted package doesn't have all the languages.** Otherwise it'd be +too big. If you don't see the language you need in the ["Common" section][5], +it can be added manually: + +```html + +``` + +**On Almond.** You need to use the optimizer to give the module a name. For +example: + +``` +r.js -o name=hljs paths.hljs=/path/to/highlight out=highlight.js +``` + + +## License + +Highlight.js is released under the BSD License. See [LICENSE][7] file +for details. + +## Links + +The official site for the library is at . + +Further in-depth documentation for the API and other topics is at +. + +Authors and contributors are listed in the [AUTHORS.en.txt][8] file. + +[1]: http://highlightjs.readthedocs.io/en/latest/api.html#inithighlightingonload +[2]: http://highlightjs.readthedocs.io/en/latest/css-classes-reference.html +[3]: http://highlightjs.readthedocs.io/en/latest/api.html#highlightblock-block +[4]: http://highlightjs.readthedocs.io/en/latest/api.html#configure-options +[5]: https://highlightjs.org/download/ +[6]: http://highlightjs.readthedocs.io/en/latest/building-testing.html +[7]: https://github.com/isagalaev/highlight.js/blob/master/LICENSE +[8]: https://github.com/isagalaev/highlight.js/blob/master/AUTHORS.en.txt diff --git a/lib/highlight/README.ru.md b/lib/highlight/README.ru.md new file mode 100644 index 000000000..ac481d071 --- /dev/null +++ b/lib/highlight/README.ru.md @@ -0,0 +1,142 @@ +# Highlight.js + +Highlight.js — это инструмент для подсветки синтаксиса, написанный на JavaScript. Он работает +и в браузере, и на сервере. Он работает с практически любой HTML разметкой, не +зависит от каких-либо фреймворков и умеет автоматически определять язык. + + +## Начало работы + +Минимум, что нужно сделать для использования highlight.js на веб-странице — это +подключить библиотеку, CSS-стили и вызывать [`initHighlightingOnLoad`][1]: + +```html + + + +``` + +Библиотека найдёт и раскрасит код внутри тегов `
`, попытавшись
+автоматически определить язык. Когда автоопределение не срабатывает, можно явно
+указать язык в атрибуте class:
+
+```html
+
...
+``` + +Список поддерживаемых классов языков доступен в [справочнике по классам][2]. +Класс также можно предварить префиксами `language-` или `lang-`. + +Чтобы отключить подсветку для какого-то блока, используйте класс `nohighlight`: + +```html +
...
+``` + +## Инициализация вручную + +Чтобы иметь чуть больше контроля за инициализацией подсветки, вы можете +использовать функции [`highlightBlock`][3] и [`configure`][4]. Таким образом +можно управлять тем, *что* и *когда* подсвечивать. + +Вот пример инициализации, эквивалентной вызову [`initHighlightingOnLoad`][1], но +с использованием jQuery: + +```javascript +$(document).ready(function() { + $('pre code').each(function(i, block) { + hljs.highlightBlock(block); + }); +}); +``` + +Вы можете использовать любые теги разметки вместо `
`. Если
+используете контейнер, не сохраняющий переводы строк, вам нужно сказать
+highlight.js использовать для них тег `
`: + +```javascript +hljs.configure({useBR: true}); + +$('div.code').each(function(i, block) { + hljs.highlightBlock(block); +}); +``` + +Другие опции можно найти в документации функции [`configure`][4]. + + +## Web Workers + +Подсветку можно запустить внутри web worker'а, чтобы окно +браузера не подтормаживало при работе с большими кусками кода. + +В основном скрипте: + +```javascript +addEventListener('load', function() { + var code = document.querySelector('#code'); + var worker = new Worker('worker.js'); + worker.onmessage = function(event) { code.innerHTML = event.data; } + worker.postMessage(code.textContent); +}) +``` + +В worker.js: + +```javascript +onmessage = function(event) { + importScripts('/highlight.pack.js'); + var result = self.hljs.highlightAuto(event.data); + postMessage(result.value); +} +``` + + +## Установка библиотеки + +Highlight.js можно использовать в браузере прямо с CDN хостинга или скачать +индивидуальную сборку, а также установив модуль на сервере. На +[странице загрузки][5] подробно описаны все варианты. + +**Не подключайте GitHub напрямую.** Библиотека не предназначена для +использования в виде исходного кода, а требует отдельной сборки. Если вам не +подходит ни один из готовых вариантов, читайте [документацию по сборке][6]. + +**Файл на CDN содержит не все языки.** Иначе он будет слишком большого размера. +Если нужного вам языка нет в [категории "Common"][5], можно дообавить его +вручную: + +```html + +``` + +**Про Almond.** Нужно задать имя модуля в оптимизаторе, например: + +``` +r.js -o name=hljs paths.hljs=/path/to/highlight out=highlight.js +``` + + +## Лицензия + +Highlight.js распространяется под лицензией BSD. Подробнее читайте файл +[LICENSE][7]. + + +## Ссылки + +Официальный сайт билиотеки расположен по адресу . + +Более подробная документация по API и другим темам расположена на +. + +Авторы и контрибьюторы перечислены в файле [AUTHORS.ru.txt][8] file. + +[1]: http://highlightjs.readthedocs.io/en/latest/api.html#inithighlightingonload +[2]: http://highlightjs.readthedocs.io/en/latest/css-classes-reference.html +[3]: http://highlightjs.readthedocs.io/en/latest/api.html#highlightblock-block +[4]: http://highlightjs.readthedocs.io/en/latest/api.html#configure-options +[5]: https://highlightjs.org/download/ +[6]: http://highlightjs.readthedocs.io/en/latest/building-testing.html +[7]: https://github.com/isagalaev/highlight.js/blob/master/LICENSE +[8]: https://github.com/isagalaev/highlight.js/blob/master/AUTHORS.ru.txt diff --git a/lib/highlight/highlight.pack.js b/lib/highlight/highlight.pack.js new file mode 100644 index 000000000..788c5eb1d --- /dev/null +++ b/lib/highlight/highlight.pack.js @@ -0,0 +1,2 @@ +/*! highlight.js v9.12.0 | BSD3 License | git.io/hljslicense */ +!function(e){var n="object"==typeof window&&window||"object"==typeof self&&self;"undefined"!=typeof exports?e(exports):n&&(n.hljs=e({}),"function"==typeof define&&define.amd&&define([],function(){return n.hljs}))}(function(e){function n(e){return e.replace(/&/g,"&").replace(//g,">")}function t(e){return e.nodeName.toLowerCase()}function r(e,n){var t=e&&e.exec(n);return t&&0===t.index}function a(e){return k.test(e)}function i(e){var n,t,r,i,o=e.className+" ";if(o+=e.parentNode?e.parentNode.className:"",t=B.exec(o))return w(t[1])?t[1]:"no-highlight";for(o=o.split(/\s+/),n=0,r=o.length;r>n;n++)if(i=o[n],a(i)||w(i))return i}function o(e){var n,t={},r=Array.prototype.slice.call(arguments,1);for(n in e)t[n]=e[n];return r.forEach(function(e){for(n in e)t[n]=e[n]}),t}function u(e){var n=[];return function r(e,a){for(var i=e.firstChild;i;i=i.nextSibling)3===i.nodeType?a+=i.nodeValue.length:1===i.nodeType&&(n.push({event:"start",offset:a,node:i}),a=r(i,a),t(i).match(/br|hr|img|input/)||n.push({event:"stop",offset:a,node:i}));return a}(e,0),n}function c(e,r,a){function i(){return e.length&&r.length?e[0].offset!==r[0].offset?e[0].offset"}function u(e){s+=""}function c(e){("start"===e.event?o:u)(e.node)}for(var l=0,s="",f=[];e.length||r.length;){var g=i();if(s+=n(a.substring(l,g[0].offset)),l=g[0].offset,g===e){f.reverse().forEach(u);do c(g.splice(0,1)[0]),g=i();while(g===e&&g.length&&g[0].offset===l);f.reverse().forEach(o)}else"start"===g[0].event?f.push(g[0].node):f.pop(),c(g.splice(0,1)[0])}return s+n(a.substr(l))}function l(e){return e.v&&!e.cached_variants&&(e.cached_variants=e.v.map(function(n){return o(e,{v:null},n)})),e.cached_variants||e.eW&&[o(e)]||[e]}function s(e){function n(e){return e&&e.source||e}function t(t,r){return new RegExp(n(t),"m"+(e.cI?"i":"")+(r?"g":""))}function r(a,i){if(!a.compiled){if(a.compiled=!0,a.k=a.k||a.bK,a.k){var o={},u=function(n,t){e.cI&&(t=t.toLowerCase()),t.split(" ").forEach(function(e){var t=e.split("|");o[t[0]]=[n,t[1]?Number(t[1]):1]})};"string"==typeof a.k?u("keyword",a.k):x(a.k).forEach(function(e){u(e,a.k[e])}),a.k=o}a.lR=t(a.l||/\w+/,!0),i&&(a.bK&&(a.b="\\b("+a.bK.split(" ").join("|")+")\\b"),a.b||(a.b=/\B|\b/),a.bR=t(a.b),a.e||a.eW||(a.e=/\B|\b/),a.e&&(a.eR=t(a.e)),a.tE=n(a.e)||"",a.eW&&i.tE&&(a.tE+=(a.e?"|":"")+i.tE)),a.i&&(a.iR=t(a.i)),null==a.r&&(a.r=1),a.c||(a.c=[]),a.c=Array.prototype.concat.apply([],a.c.map(function(e){return l("self"===e?a:e)})),a.c.forEach(function(e){r(e,a)}),a.starts&&r(a.starts,i);var c=a.c.map(function(e){return e.bK?"\\.?("+e.b+")\\.?":e.b}).concat([a.tE,a.i]).map(n).filter(Boolean);a.t=c.length?t(c.join("|"),!0):{exec:function(){return null}}}}r(e)}function f(e,t,a,i){function o(e,n){var t,a;for(t=0,a=n.c.length;a>t;t++)if(r(n.c[t].bR,e))return n.c[t]}function u(e,n){if(r(e.eR,n)){for(;e.endsParent&&e.parent;)e=e.parent;return e}return e.eW?u(e.parent,n):void 0}function c(e,n){return!a&&r(n.iR,e)}function l(e,n){var t=N.cI?n[0].toLowerCase():n[0];return e.k.hasOwnProperty(t)&&e.k[t]}function p(e,n,t,r){var a=r?"":I.classPrefix,i='',i+n+o}function h(){var e,t,r,a;if(!E.k)return n(k);for(a="",t=0,E.lR.lastIndex=0,r=E.lR.exec(k);r;)a+=n(k.substring(t,r.index)),e=l(E,r),e?(B+=e[1],a+=p(e[0],n(r[0]))):a+=n(r[0]),t=E.lR.lastIndex,r=E.lR.exec(k);return a+n(k.substr(t))}function d(){var e="string"==typeof E.sL;if(e&&!y[E.sL])return n(k);var t=e?f(E.sL,k,!0,x[E.sL]):g(k,E.sL.length?E.sL:void 0);return E.r>0&&(B+=t.r),e&&(x[E.sL]=t.top),p(t.language,t.value,!1,!0)}function b(){L+=null!=E.sL?d():h(),k=""}function v(e){L+=e.cN?p(e.cN,"",!0):"",E=Object.create(e,{parent:{value:E}})}function m(e,n){if(k+=e,null==n)return b(),0;var t=o(n,E);if(t)return t.skip?k+=n:(t.eB&&(k+=n),b(),t.rB||t.eB||(k=n)),v(t,n),t.rB?0:n.length;var r=u(E,n);if(r){var a=E;a.skip?k+=n:(a.rE||a.eE||(k+=n),b(),a.eE&&(k=n));do E.cN&&(L+=C),E.skip||(B+=E.r),E=E.parent;while(E!==r.parent);return r.starts&&v(r.starts,""),a.rE?0:n.length}if(c(n,E))throw new Error('Illegal lexeme "'+n+'" for mode "'+(E.cN||"")+'"');return k+=n,n.length||1}var N=w(e);if(!N)throw new Error('Unknown language: "'+e+'"');s(N);var R,E=i||N,x={},L="";for(R=E;R!==N;R=R.parent)R.cN&&(L=p(R.cN,"",!0)+L);var k="",B=0;try{for(var M,j,O=0;;){if(E.t.lastIndex=O,M=E.t.exec(t),!M)break;j=m(t.substring(O,M.index),M[0]),O=M.index+j}for(m(t.substr(O)),R=E;R.parent;R=R.parent)R.cN&&(L+=C);return{r:B,value:L,language:e,top:E}}catch(T){if(T.message&&-1!==T.message.indexOf("Illegal"))return{r:0,value:n(t)};throw T}}function g(e,t){t=t||I.languages||x(y);var r={r:0,value:n(e)},a=r;return t.filter(w).forEach(function(n){var t=f(n,e,!1);t.language=n,t.r>a.r&&(a=t),t.r>r.r&&(a=r,r=t)}),a.language&&(r.second_best=a),r}function p(e){return I.tabReplace||I.useBR?e.replace(M,function(e,n){return I.useBR&&"\n"===e?"
":I.tabReplace?n.replace(/\t/g,I.tabReplace):""}):e}function h(e,n,t){var r=n?L[n]:t,a=[e.trim()];return e.match(/\bhljs\b/)||a.push("hljs"),-1===e.indexOf(r)&&a.push(r),a.join(" ").trim()}function d(e){var n,t,r,o,l,s=i(e);a(s)||(I.useBR?(n=document.createElementNS("http://www.w3.org/1999/xhtml","div"),n.innerHTML=e.innerHTML.replace(/\n/g,"").replace(//g,"\n")):n=e,l=n.textContent,r=s?f(s,l,!0):g(l),t=u(n),t.length&&(o=document.createElementNS("http://www.w3.org/1999/xhtml","div"),o.innerHTML=r.value,r.value=c(t,u(o),l)),r.value=p(r.value),e.innerHTML=r.value,e.className=h(e.className,s,r.language),e.result={language:r.language,re:r.r},r.second_best&&(e.second_best={language:r.second_best.language,re:r.second_best.r}))}function b(e){I=o(I,e)}function v(){if(!v.called){v.called=!0;var e=document.querySelectorAll("pre code");E.forEach.call(e,d)}}function m(){addEventListener("DOMContentLoaded",v,!1),addEventListener("load",v,!1)}function N(n,t){var r=y[n]=t(e);r.aliases&&r.aliases.forEach(function(e){L[e]=n})}function R(){return x(y)}function w(e){return e=(e||"").toLowerCase(),y[e]||y[L[e]]}var E=[],x=Object.keys,y={},L={},k=/^(no-?highlight|plain|text)$/i,B=/\blang(?:uage)?-([\w-]+)\b/i,M=/((^(<[^>]+>|\t|)+|(?:\n)))/gm,C="
",I={classPrefix:"hljs-",tabReplace:null,useBR:!1,languages:void 0};return e.highlight=f,e.highlightAuto=g,e.fixMarkup=p,e.highlightBlock=d,e.configure=b,e.initHighlighting=v,e.initHighlightingOnLoad=m,e.registerLanguage=N,e.listLanguages=R,e.getLanguage=w,e.inherit=o,e.IR="[a-zA-Z]\\w*",e.UIR="[a-zA-Z_]\\w*",e.NR="\\b\\d+(\\.\\d+)?",e.CNR="(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",e.BNR="\\b(0b[01]+)",e.RSR="!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~",e.BE={b:"\\\\[\\s\\S]",r:0},e.ASM={cN:"string",b:"'",e:"'",i:"\\n",c:[e.BE]},e.QSM={cN:"string",b:'"',e:'"',i:"\\n",c:[e.BE]},e.PWM={b:/\b(a|an|the|are|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such|will|you|your|they|like|more)\b/},e.C=function(n,t,r){var a=e.inherit({cN:"comment",b:n,e:t,c:[]},r||{});return a.c.push(e.PWM),a.c.push({cN:"doctag",b:"(?:TODO|FIXME|NOTE|BUG|XXX):",r:0}),a},e.CLCM=e.C("//","$"),e.CBCM=e.C("/\\*","\\*/"),e.HCM=e.C("#","$"),e.NM={cN:"number",b:e.NR,r:0},e.CNM={cN:"number",b:e.CNR,r:0},e.BNM={cN:"number",b:e.BNR,r:0},e.CSSNM={cN:"number",b:e.NR+"(%|em|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc|px|deg|grad|rad|turn|s|ms|Hz|kHz|dpi|dpcm|dppx)?",r:0},e.RM={cN:"regexp",b:/\//,e:/\/[gimuy]*/,i:/\n/,c:[e.BE,{b:/\[/,e:/\]/,r:0,c:[e.BE]}]},e.TM={cN:"title",b:e.IR,r:0},e.UTM={cN:"title",b:e.UIR,r:0},e.METHOD_GUARD={b:"\\.\\s*"+e.UIR,r:0},e});hljs.registerLanguage("scss",function(e){var t="[a-zA-Z-][a-zA-Z0-9_-]*",i={cN:"variable",b:"(\\$"+t+")\\b"},r={cN:"number",b:"#[0-9A-Fa-f]+"};({cN:"attribute",b:"[A-Z\\_\\.\\-]+",e:":",eE:!0,i:"[^\\s]",starts:{eW:!0,eE:!0,c:[r,e.CSSNM,e.QSM,e.ASM,e.CBCM,{cN:"meta",b:"!important"}]}});return{cI:!0,i:"[=/|']",c:[e.CLCM,e.CBCM,{cN:"selector-id",b:"\\#[A-Za-z0-9_-]+",r:0},{cN:"selector-class",b:"\\.[A-Za-z0-9_-]+",r:0},{cN:"selector-attr",b:"\\[",e:"\\]",i:"$"},{cN:"selector-tag",b:"\\b(a|abbr|acronym|address|area|article|aside|audio|b|base|big|blockquote|body|br|button|canvas|caption|cite|code|col|colgroup|command|datalist|dd|del|details|dfn|div|dl|dt|em|embed|fieldset|figcaption|figure|footer|form|frame|frameset|(h[1-6])|head|header|hgroup|hr|html|i|iframe|img|input|ins|kbd|keygen|label|legend|li|link|map|mark|meta|meter|nav|noframes|noscript|object|ol|optgroup|option|output|p|param|pre|progress|q|rp|rt|ruby|samp|script|section|select|small|span|strike|strong|style|sub|sup|table|tbody|td|textarea|tfoot|th|thead|time|title|tr|tt|ul|var|video)\\b",r:0},{b:":(visited|valid|root|right|required|read-write|read-only|out-range|optional|only-of-type|only-child|nth-of-type|nth-last-of-type|nth-last-child|nth-child|not|link|left|last-of-type|last-child|lang|invalid|indeterminate|in-range|hover|focus|first-of-type|first-line|first-letter|first-child|first|enabled|empty|disabled|default|checked|before|after|active)"},{b:"::(after|before|choices|first-letter|first-line|repeat-index|repeat-item|selection|value)"},i,{cN:"attribute",b:"\\b(z-index|word-wrap|word-spacing|word-break|width|widows|white-space|visibility|vertical-align|unicode-bidi|transition-timing-function|transition-property|transition-duration|transition-delay|transition|transform-style|transform-origin|transform|top|text-underline-position|text-transform|text-shadow|text-rendering|text-overflow|text-indent|text-decoration-style|text-decoration-line|text-decoration-color|text-decoration|text-align-last|text-align|tab-size|table-layout|right|resize|quotes|position|pointer-events|perspective-origin|perspective|page-break-inside|page-break-before|page-break-after|padding-top|padding-right|padding-left|padding-bottom|padding|overflow-y|overflow-x|overflow-wrap|overflow|outline-width|outline-style|outline-offset|outline-color|outline|orphans|order|opacity|object-position|object-fit|normal|none|nav-up|nav-right|nav-left|nav-index|nav-down|min-width|min-height|max-width|max-height|mask|marks|margin-top|margin-right|margin-left|margin-bottom|margin|list-style-type|list-style-position|list-style-image|list-style|line-height|letter-spacing|left|justify-content|initial|inherit|ime-mode|image-orientation|image-resolution|image-rendering|icon|hyphens|height|font-weight|font-variant-ligatures|font-variant|font-style|font-stretch|font-size-adjust|font-size|font-language-override|font-kerning|font-feature-settings|font-family|font|float|flex-wrap|flex-shrink|flex-grow|flex-flow|flex-direction|flex-basis|flex|filter|empty-cells|display|direction|cursor|counter-reset|counter-increment|content|column-width|column-span|column-rule-width|column-rule-style|column-rule-color|column-rule|column-gap|column-fill|column-count|columns|color|clip-path|clip|clear|caption-side|break-inside|break-before|break-after|box-sizing|box-shadow|box-decoration-break|bottom|border-width|border-top-width|border-top-style|border-top-right-radius|border-top-left-radius|border-top-color|border-top|border-style|border-spacing|border-right-width|border-right-style|border-right-color|border-right|border-radius|border-left-width|border-left-style|border-left-color|border-left|border-image-width|border-image-source|border-image-slice|border-image-repeat|border-image-outset|border-image|border-color|border-collapse|border-bottom-width|border-bottom-style|border-bottom-right-radius|border-bottom-left-radius|border-bottom-color|border-bottom|border|background-size|background-repeat|background-position|background-origin|background-image|background-color|background-clip|background-attachment|background-blend-mode|background|backface-visibility|auto|animation-timing-function|animation-play-state|animation-name|animation-iteration-count|animation-fill-mode|animation-duration|animation-direction|animation-delay|animation|align-self|align-items|align-content)\\b",i:"[^\\s]"},{b:"\\b(whitespace|wait|w-resize|visible|vertical-text|vertical-ideographic|uppercase|upper-roman|upper-alpha|underline|transparent|top|thin|thick|text|text-top|text-bottom|tb-rl|table-header-group|table-footer-group|sw-resize|super|strict|static|square|solid|small-caps|separate|se-resize|scroll|s-resize|rtl|row-resize|ridge|right|repeat|repeat-y|repeat-x|relative|progress|pointer|overline|outside|outset|oblique|nowrap|not-allowed|normal|none|nw-resize|no-repeat|no-drop|newspaper|ne-resize|n-resize|move|middle|medium|ltr|lr-tb|lowercase|lower-roman|lower-alpha|loose|list-item|line|line-through|line-edge|lighter|left|keep-all|justify|italic|inter-word|inter-ideograph|inside|inset|inline|inline-block|inherit|inactive|ideograph-space|ideograph-parenthesis|ideograph-numeric|ideograph-alpha|horizontal|hidden|help|hand|groove|fixed|ellipsis|e-resize|double|dotted|distribute|distribute-space|distribute-letter|distribute-all-lines|disc|disabled|default|decimal|dashed|crosshair|collapse|col-resize|circle|char|center|capitalize|break-word|break-all|bottom|both|bolder|bold|block|bidi-override|below|baseline|auto|always|all-scroll|absolute|table|table-cell)\\b"},{b:":",e:";",c:[i,r,e.CSSNM,e.QSM,e.ASM,{cN:"meta",b:"!important"}]},{b:"@",e:"[{;]",k:"mixin include extend for if else each while charset import debug media page content font-face namespace warn",c:[i,e.QSM,e.ASM,r,e.CSSNM,{b:"\\s[A-Za-z0-9_.-]+",r:0}]}]}});hljs.registerLanguage("sql",function(e){var t=e.C("--","$");return{cI:!0,i:/[<>{}*#]/,c:[{bK:"begin end start commit rollback savepoint lock alter create drop rename call delete do handler insert load replace select truncate update set show pragma grant merge describe use explain help declare prepare execute deallocate release unlock purge reset change stop analyze cache flush optimize repair kill install uninstall checksum restore check backup revoke comment",e:/;/,eW:!0,l:/[\w\.]+/,k:{keyword:"abort abs absolute acc acce accep accept access accessed accessible account acos action activate add addtime admin administer advanced advise aes_decrypt aes_encrypt after agent aggregate ali alia alias allocate allow alter always analyze ancillary and any anydata anydataset anyschema anytype apply archive archived archivelog are as asc ascii asin assembly assertion associate asynchronous at atan atn2 attr attri attrib attribu attribut attribute attributes audit authenticated authentication authid authors auto autoallocate autodblink autoextend automatic availability avg backup badfile basicfile before begin beginning benchmark between bfile bfile_base big bigfile bin binary_double binary_float binlog bit_and bit_count bit_length bit_or bit_xor bitmap blob_base block blocksize body both bound buffer_cache buffer_pool build bulk by byte byteordermark bytes cache caching call calling cancel capacity cascade cascaded case cast catalog category ceil ceiling chain change changed char_base char_length character_length characters characterset charindex charset charsetform charsetid check checksum checksum_agg child choose chr chunk class cleanup clear client clob clob_base clone close cluster_id cluster_probability cluster_set clustering coalesce coercibility col collate collation collect colu colum column column_value columns columns_updated comment commit compact compatibility compiled complete composite_limit compound compress compute concat concat_ws concurrent confirm conn connec connect connect_by_iscycle connect_by_isleaf connect_by_root connect_time connection consider consistent constant constraint constraints constructor container content contents context contributors controlfile conv convert convert_tz corr corr_k corr_s corresponding corruption cos cost count count_big counted covar_pop covar_samp cpu_per_call cpu_per_session crc32 create creation critical cross cube cume_dist curdate current current_date current_time current_timestamp current_user cursor curtime customdatum cycle data database databases datafile datafiles datalength date_add date_cache date_format date_sub dateadd datediff datefromparts datename datepart datetime2fromparts day day_to_second dayname dayofmonth dayofweek dayofyear days db_role_change dbtimezone ddl deallocate declare decode decompose decrement decrypt deduplicate def defa defau defaul default defaults deferred defi defin define degrees delayed delegate delete delete_all delimited demand dense_rank depth dequeue des_decrypt des_encrypt des_key_file desc descr descri describ describe descriptor deterministic diagnostics difference dimension direct_load directory disable disable_all disallow disassociate discardfile disconnect diskgroup distinct distinctrow distribute distributed div do document domain dotnet double downgrade drop dumpfile duplicate duration each edition editionable editions element ellipsis else elsif elt empty enable enable_all enclosed encode encoding encrypt end end-exec endian enforced engine engines enqueue enterprise entityescaping eomonth error errors escaped evalname evaluate event eventdata events except exception exceptions exchange exclude excluding execu execut execute exempt exists exit exp expire explain export export_set extended extent external external_1 external_2 externally extract failed failed_login_attempts failover failure far fast feature_set feature_value fetch field fields file file_name_convert filesystem_like_logging final finish first first_value fixed flash_cache flashback floor flush following follows for forall force form forma format found found_rows freelist freelists freepools fresh from from_base64 from_days ftp full function general generated get get_format get_lock getdate getutcdate global global_name globally go goto grant grants greatest group group_concat group_id grouping grouping_id groups gtid_subtract guarantee guard handler hash hashkeys having hea head headi headin heading heap help hex hierarchy high high_priority hosts hour http id ident_current ident_incr ident_seed identified identity idle_time if ifnull ignore iif ilike ilm immediate import in include including increment index indexes indexing indextype indicator indices inet6_aton inet6_ntoa inet_aton inet_ntoa infile initial initialized initially initrans inmemory inner innodb input insert install instance instantiable instr interface interleaved intersect into invalidate invisible is is_free_lock is_ipv4 is_ipv4_compat is_not is_not_null is_used_lock isdate isnull isolation iterate java join json json_exists keep keep_duplicates key keys kill language large last last_day last_insert_id last_value lax lcase lead leading least leaves left len lenght length less level levels library like like2 like4 likec limit lines link list listagg little ln load load_file lob lobs local localtime localtimestamp locate locator lock locked log log10 log2 logfile logfiles logging logical logical_reads_per_call logoff logon logs long loop low low_priority lower lpad lrtrim ltrim main make_set makedate maketime managed management manual map mapping mask master master_pos_wait match matched materialized max maxextents maximize maxinstances maxlen maxlogfiles maxloghistory maxlogmembers maxsize maxtrans md5 measures median medium member memcompress memory merge microsecond mid migration min minextents minimum mining minus minute minvalue missing mod mode model modification modify module monitoring month months mount move movement multiset mutex name name_const names nan national native natural nav nchar nclob nested never new newline next nextval no no_write_to_binlog noarchivelog noaudit nobadfile nocheck nocompress nocopy nocycle nodelay nodiscardfile noentityescaping noguarantee nokeep nologfile nomapping nomaxvalue nominimize nominvalue nomonitoring none noneditionable nonschema noorder nopr nopro noprom nopromp noprompt norely noresetlogs noreverse normal norowdependencies noschemacheck noswitch not nothing notice notrim novalidate now nowait nth_value nullif nulls num numb numbe nvarchar nvarchar2 object ocicoll ocidate ocidatetime ociduration ociinterval ociloblocator ocinumber ociref ocirefcursor ocirowid ocistring ocitype oct octet_length of off offline offset oid oidindex old on online only opaque open operations operator optimal optimize option optionally or oracle oracle_date oradata ord ordaudio orddicom orddoc order ordimage ordinality ordvideo organization orlany orlvary out outer outfile outline output over overflow overriding package pad parallel parallel_enable parameters parent parse partial partition partitions pascal passing password password_grace_time password_lock_time password_reuse_max password_reuse_time password_verify_function patch path patindex pctincrease pctthreshold pctused pctversion percent percent_rank percentile_cont percentile_disc performance period period_add period_diff permanent physical pi pipe pipelined pivot pluggable plugin policy position post_transaction pow power pragma prebuilt precedes preceding precision prediction prediction_cost prediction_details prediction_probability prediction_set prepare present preserve prior priority private private_sga privileges procedural procedure procedure_analyze processlist profiles project prompt protection public publishingservername purge quarter query quick quiesce quota quotename radians raise rand range rank raw read reads readsize rebuild record records recover recovery recursive recycle redo reduced ref reference referenced references referencing refresh regexp_like register regr_avgx regr_avgy regr_count regr_intercept regr_r2 regr_slope regr_sxx regr_sxy reject rekey relational relative relaylog release release_lock relies_on relocate rely rem remainder rename repair repeat replace replicate replication required reset resetlogs resize resource respect restore restricted result result_cache resumable resume retention return returning returns reuse reverse revoke right rlike role roles rollback rolling rollup round row row_count rowdependencies rowid rownum rows rtrim rules safe salt sample save savepoint sb1 sb2 sb4 scan schema schemacheck scn scope scroll sdo_georaster sdo_topo_geometry search sec_to_time second section securefile security seed segment select self sequence sequential serializable server servererror session session_user sessions_per_user set sets settings sha sha1 sha2 share shared shared_pool short show shrink shutdown si_averagecolor si_colorhistogram si_featurelist si_positionalcolor si_stillimage si_texture siblings sid sign sin size size_t sizes skip slave sleep smalldatetimefromparts smallfile snapshot some soname sort soundex source space sparse spfile split sql sql_big_result sql_buffer_result sql_cache sql_calc_found_rows sql_small_result sql_variant_property sqlcode sqldata sqlerror sqlname sqlstate sqrt square standalone standby start starting startup statement static statistics stats_binomial_test stats_crosstab stats_ks_test stats_mode stats_mw_test stats_one_way_anova stats_t_test_ stats_t_test_indep stats_t_test_one stats_t_test_paired stats_wsr_test status std stddev stddev_pop stddev_samp stdev stop storage store stored str str_to_date straight_join strcmp strict string struct stuff style subdate subpartition subpartitions substitutable substr substring subtime subtring_index subtype success sum suspend switch switchoffset switchover sync synchronous synonym sys sys_xmlagg sysasm sysaux sysdate sysdatetimeoffset sysdba sysoper system system_user sysutcdatetime table tables tablespace tan tdo template temporary terminated tertiary_weights test than then thread through tier ties time time_format time_zone timediff timefromparts timeout timestamp timestampadd timestampdiff timezone_abbr timezone_minute timezone_region to to_base64 to_date to_days to_seconds todatetimeoffset trace tracking transaction transactional translate translation treat trigger trigger_nestlevel triggers trim truncate try_cast try_convert try_parse type ub1 ub2 ub4 ucase unarchived unbounded uncompress under undo unhex unicode uniform uninstall union unique unix_timestamp unknown unlimited unlock unpivot unrecoverable unsafe unsigned until untrusted unusable unused update updated upgrade upped upper upsert url urowid usable usage use use_stored_outlines user user_data user_resources users using utc_date utc_timestamp uuid uuid_short validate validate_password_strength validation valist value values var var_samp varcharc vari varia variab variabl variable variables variance varp varraw varrawc varray verify version versions view virtual visible void wait wallet warning warnings week weekday weekofyear wellformed when whene whenev wheneve whenever where while whitespace with within without work wrapped xdb xml xmlagg xmlattributes xmlcast xmlcolattval xmlelement xmlexists xmlforest xmlindex xmlnamespaces xmlpi xmlquery xmlroot xmlschema xmlserialize xmltable xmltype xor year year_to_month years yearweek",literal:"true false null",built_in:"array bigint binary bit blob boolean char character date dec decimal float int int8 integer interval number numeric real record serial serial8 smallint text varchar varying void"},c:[{cN:"string",b:"'",e:"'",c:[e.BE,{b:"''"}]},{cN:"string",b:'"',e:'"',c:[e.BE,{b:'""'}]},{cN:"string",b:"`",e:"`",c:[e.BE]},e.CNM,e.CBCM,t]},e.CBCM,t]}});hljs.registerLanguage("perl",function(e){var t="getpwent getservent quotemeta msgrcv scalar kill dbmclose undef lc ma syswrite tr send umask sysopen shmwrite vec qx utime local oct semctl localtime readpipe do return format read sprintf dbmopen pop getpgrp not getpwnam rewinddir qqfileno qw endprotoent wait sethostent bless s|0 opendir continue each sleep endgrent shutdown dump chomp connect getsockname die socketpair close flock exists index shmgetsub for endpwent redo lstat msgctl setpgrp abs exit select print ref gethostbyaddr unshift fcntl syscall goto getnetbyaddr join gmtime symlink semget splice x|0 getpeername recv log setsockopt cos last reverse gethostbyname getgrnam study formline endhostent times chop length gethostent getnetent pack getprotoent getservbyname rand mkdir pos chmod y|0 substr endnetent printf next open msgsnd readdir use unlink getsockopt getpriority rindex wantarray hex system getservbyport endservent int chr untie rmdir prototype tell listen fork shmread ucfirst setprotoent else sysseek link getgrgid shmctl waitpid unpack getnetbyname reset chdir grep split require caller lcfirst until warn while values shift telldir getpwuid my getprotobynumber delete and sort uc defined srand accept package seekdir getprotobyname semop our rename seek if q|0 chroot sysread setpwent no crypt getc chown sqrt write setnetent setpriority foreach tie sin msgget map stat getlogin unless elsif truncate exec keys glob tied closedirioctl socket readlink eval xor readline binmode setservent eof ord bind alarm pipe atan2 getgrent exp time push setgrent gt lt or ne m|0 break given say state when",r={cN:"subst",b:"[$@]\\{",e:"\\}",k:t},s={b:"->{",e:"}"},n={v:[{b:/\$\d/},{b:/[\$%@](\^\w\b|#\w+(::\w+)*|{\w+}|\w+(::\w*)*)/},{b:/[\$%@][^\s\w{]/,r:0}]},i=[e.BE,r,n],o=[n,e.HCM,e.C("^\\=\\w","\\=cut",{eW:!0}),s,{cN:"string",c:i,v:[{b:"q[qwxr]?\\s*\\(",e:"\\)",r:5},{b:"q[qwxr]?\\s*\\[",e:"\\]",r:5},{b:"q[qwxr]?\\s*\\{",e:"\\}",r:5},{b:"q[qwxr]?\\s*\\|",e:"\\|",r:5},{b:"q[qwxr]?\\s*\\<",e:"\\>",r:5},{b:"qw\\s+q",e:"q",r:5},{b:"'",e:"'",c:[e.BE]},{b:'"',e:'"'},{b:"`",e:"`",c:[e.BE]},{b:"{\\w+}",c:[],r:0},{b:"-?\\w+\\s*\\=\\>",c:[],r:0}]},{cN:"number",b:"(\\b0[0-7_]+)|(\\b0x[0-9a-fA-F_]+)|(\\b[1-9][0-9_]*(\\.[0-9_]+)?)|[0_]\\b",r:0},{b:"(\\/\\/|"+e.RSR+"|\\b(split|return|print|reverse|grep)\\b)\\s*",k:"split return print reverse grep",r:0,c:[e.HCM,{cN:"regexp",b:"(s|tr|y)/(\\\\.|[^/])*/(\\\\.|[^/])*/[a-z]*",r:10},{cN:"regexp",b:"(m|qr)?/",e:"/[a-z]*",c:[e.BE],r:0}]},{cN:"function",bK:"sub",e:"(\\s*\\(.*?\\))?[;{]",eE:!0,r:5,c:[e.TM]},{b:"-\\w\\b",r:0},{b:"^__DATA__$",e:"^__END__$",sL:"mojolicious",c:[{b:"^@@.*",e:"$",cN:"comment"}]}];return r.c=o,s.c=o,{aliases:["pl","pm"],l:/[\w\.]+/,k:t,c:o}});hljs.registerLanguage("ini",function(e){var b={cN:"string",c:[e.BE],v:[{b:"'''",e:"'''",r:10},{b:'"""',e:'"""',r:10},{b:'"',e:'"'},{b:"'",e:"'"}]};return{aliases:["toml"],cI:!0,i:/\S/,c:[e.C(";","$"),e.HCM,{cN:"section",b:/^\s*\[+/,e:/\]+/},{b:/^[a-z0-9\[\]_-]+\s*=\s*/,e:"$",rB:!0,c:[{cN:"attr",b:/[a-z0-9\[\]_-]+/},{b:/=/,eW:!0,r:0,c:[{cN:"literal",b:/\bon|off|true|false|yes|no\b/},{cN:"variable",v:[{b:/\$[\w\d"][\w\d_]*/},{b:/\$\{(.*?)}/}]},b,{cN:"number",b:/([\+\-]+)?[\d]+_[\d_]+/},e.NM]}]}]}});hljs.registerLanguage("diff",function(e){return{aliases:["patch"],c:[{cN:"meta",r:10,v:[{b:/^@@ +\-\d+,\d+ +\+\d+,\d+ +@@$/},{b:/^\*\*\* +\d+,\d+ +\*\*\*\*$/},{b:/^\-\-\- +\d+,\d+ +\-\-\-\-$/}]},{cN:"comment",v:[{b:/Index: /,e:/$/},{b:/={3,}/,e:/$/},{b:/^\-{3}/,e:/$/},{b:/^\*{3} /,e:/$/},{b:/^\+{3}/,e:/$/},{b:/\*{5}/,e:/\*{5}$/}]},{cN:"addition",b:"^\\+",e:"$"},{cN:"deletion",b:"^\\-",e:"$"},{cN:"addition",b:"^\\!",e:"$"}]}});hljs.registerLanguage("bash",function(e){var t={cN:"variable",v:[{b:/\$[\w\d#@][\w\d_]*/},{b:/\$\{(.*?)}/}]},s={cN:"string",b:/"/,e:/"/,c:[e.BE,t,{cN:"variable",b:/\$\(/,e:/\)/,c:[e.BE]}]},a={cN:"string",b:/'/,e:/'/};return{aliases:["sh","zsh"],l:/\b-?[a-z\._]+\b/,k:{keyword:"if then else elif fi for while in do done case esac function",literal:"true false",built_in:"break cd continue eval exec exit export getopts hash pwd readonly return shift test times trap umask unset alias bind builtin caller command declare echo enable help let local logout mapfile printf read readarray source type typeset ulimit unalias set shopt autoload bg bindkey bye cap chdir clone comparguments compcall compctl compdescribe compfiles compgroups compquote comptags comptry compvalues dirs disable disown echotc echoti emulate fc fg float functions getcap getln history integer jobs kill limit log noglob popd print pushd pushln rehash sched setcap setopt stat suspend ttyctl unfunction unhash unlimit unsetopt vared wait whence where which zcompile zformat zftp zle zmodload zparseopts zprof zpty zregexparse zsocket zstyle ztcp",_:"-ne -eq -lt -gt -f -d -e -s -l -a"},c:[{cN:"meta",b:/^#![^\n]+sh\s*$/,r:10},{cN:"function",b:/\w[\w\d_]*\s*\(\s*\)\s*\{/,rB:!0,c:[e.inherit(e.TM,{b:/\w[\w\d_]*/})],r:0},e.HCM,s,a,t]}});hljs.registerLanguage("php",function(e){var c={b:"\\$+[a-zA-Z_-ÿ][a-zA-Z0-9_-ÿ]*"},i={cN:"meta",b:/<\?(php)?|\?>/},t={cN:"string",c:[e.BE,i],v:[{b:'b"',e:'"'},{b:"b'",e:"'"},e.inherit(e.ASM,{i:null}),e.inherit(e.QSM,{i:null})]},a={v:[e.BNM,e.CNM]};return{aliases:["php3","php4","php5","php6"],cI:!0,k:"and include_once list abstract global private echo interface as static endswitch array null if endwhile or const for endforeach self var while isset public protected exit foreach throw elseif include __FILE__ empty require_once do xor return parent clone use __CLASS__ __LINE__ else break print eval new catch __METHOD__ case exception default die require __FUNCTION__ enddeclare final try switch continue endfor endif declare unset true false trait goto instanceof insteadof __DIR__ __NAMESPACE__ yield finally",c:[e.HCM,e.C("//","$",{c:[i]}),e.C("/\\*","\\*/",{c:[{cN:"doctag",b:"@[A-Za-z]+"}]}),e.C("__halt_compiler.+?;",!1,{eW:!0,k:"__halt_compiler",l:e.UIR}),{cN:"string",b:/<<<['"]?\w+['"]?$/,e:/^\w+;?$/,c:[e.BE,{cN:"subst",v:[{b:/\$\w+/},{b:/\{\$/,e:/\}/}]}]},i,{cN:"keyword",b:/\$this\b/},c,{b:/(::|->)+[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/},{cN:"function",bK:"function",e:/[;{]/,eE:!0,i:"\\$|\\[|%",c:[e.UTM,{cN:"params",b:"\\(",e:"\\)",c:["self",c,e.CBCM,t,a]}]},{cN:"class",bK:"class interface",e:"{",eE:!0,i:/[:\(\$"]/,c:[{bK:"extends implements"},e.UTM]},{bK:"namespace",e:";",i:/[\.']/,c:[e.UTM]},{bK:"use",e:";",c:[e.UTM]},{b:"=>"},t,a]}});hljs.registerLanguage("python",function(e){var r={keyword:"and elif is global as in if from raise for except finally print import pass return exec else break not with class assert yield try while continue del or def lambda async await nonlocal|10 None True False",built_in:"Ellipsis NotImplemented"},b={cN:"meta",b:/^(>>>|\.\.\.) /},c={cN:"subst",b:/\{/,e:/\}/,k:r,i:/#/},a={cN:"string",c:[e.BE],v:[{b:/(u|b)?r?'''/,e:/'''/,c:[b],r:10},{b:/(u|b)?r?"""/,e:/"""/,c:[b],r:10},{b:/(fr|rf|f)'''/,e:/'''/,c:[b,c]},{b:/(fr|rf|f)"""/,e:/"""/,c:[b,c]},{b:/(u|r|ur)'/,e:/'/,r:10},{b:/(u|r|ur)"/,e:/"/,r:10},{b:/(b|br)'/,e:/'/},{b:/(b|br)"/,e:/"/},{b:/(fr|rf|f)'/,e:/'/,c:[c]},{b:/(fr|rf|f)"/,e:/"/,c:[c]},e.ASM,e.QSM]},s={cN:"number",r:0,v:[{b:e.BNR+"[lLjJ]?"},{b:"\\b(0o[0-7]+)[lLjJ]?"},{b:e.CNR+"[lLjJ]?"}]},i={cN:"params",b:/\(/,e:/\)/,c:["self",b,s,a]};return c.c=[a,s,b],{aliases:["py","gyp"],k:r,i:/(<\/|->|\?)|=>/,c:[b,s,a,e.HCM,{v:[{cN:"function",bK:"def"},{cN:"class",bK:"class"}],e:/:/,i:/[${=;\n,]/,c:[e.UTM,i,{b:/->/,eW:!0,k:"None"}]},{cN:"meta",b:/^[\t ]*@/,e:/$/},{b:/\b(print|exec)\(/}]}});hljs.registerLanguage("coffeescript",function(e){var c={keyword:"in if for while finally new do return else break catch instanceof throw try this switch continue typeof delete debugger super yield import export from as default await then unless until loop of by when and or is isnt not",literal:"true false null undefined yes no on off",built_in:"npm require console print module global window document"},n="[A-Za-z$_][0-9A-Za-z$_]*",r={cN:"subst",b:/#\{/,e:/}/,k:c},i=[e.BNM,e.inherit(e.CNM,{starts:{e:"(\\s*/)?",r:0}}),{cN:"string",v:[{b:/'''/,e:/'''/,c:[e.BE]},{b:/'/,e:/'/,c:[e.BE]},{b:/"""/,e:/"""/,c:[e.BE,r]},{b:/"/,e:/"/,c:[e.BE,r]}]},{cN:"regexp",v:[{b:"///",e:"///",c:[r,e.HCM]},{b:"//[gim]*",r:0},{b:/\/(?![ *])(\\\/|.)*?\/[gim]*(?=\W|$)/}]},{b:"@"+n},{sL:"javascript",eB:!0,eE:!0,v:[{b:"```",e:"```"},{b:"`",e:"`"}]}];r.c=i;var s=e.inherit(e.TM,{b:n}),t="(\\(.*\\))?\\s*\\B[-=]>",o={cN:"params",b:"\\([^\\(]",rB:!0,c:[{b:/\(/,e:/\)/,k:c,c:["self"].concat(i)}]};return{aliases:["coffee","cson","iced"],k:c,i:/\/\*/,c:i.concat([e.C("###","###"),e.HCM,{cN:"function",b:"^\\s*"+n+"\\s*=\\s*"+t,e:"[-=]>",rB:!0,c:[s,o]},{b:/[:\(,=]\s*/,r:0,c:[{cN:"function",b:t,e:"[-=]>",rB:!0,c:[o]}]},{cN:"class",bK:"class",e:"$",i:/[:="\[\]]/,c:[{bK:"extends",eW:!0,i:/[:="\[\]]/,c:[s]},s]},{b:n+":",e:":",rB:!0,rE:!0,r:0}])}});hljs.registerLanguage("ruby",function(e){var b="[a-zA-Z_]\\w*[!?=]?|[-+~]\\@|<<|>>|=~|===?|<=>|[<>]=?|\\*\\*|[-/+%^&*~`|]|\\[\\]=?",r={keyword:"and then defined module in return redo if BEGIN retry end for self when next until do begin unless END rescue else break undef not super class case require yield alias while ensure elsif or include attr_reader attr_writer attr_accessor",literal:"true false nil"},c={cN:"doctag",b:"@[A-Za-z]+"},a={b:"#<",e:">"},s=[e.C("#","$",{c:[c]}),e.C("^\\=begin","^\\=end",{c:[c],r:10}),e.C("^__END__","\\n$")],n={cN:"subst",b:"#\\{",e:"}",k:r},t={cN:"string",c:[e.BE,n],v:[{b:/'/,e:/'/},{b:/"/,e:/"/},{b:/`/,e:/`/},{b:"%[qQwWx]?\\(",e:"\\)"},{b:"%[qQwWx]?\\[",e:"\\]"},{b:"%[qQwWx]?{",e:"}"},{b:"%[qQwWx]?<",e:">"},{b:"%[qQwWx]?/",e:"/"},{b:"%[qQwWx]?%",e:"%"},{b:"%[qQwWx]?-",e:"-"},{b:"%[qQwWx]?\\|",e:"\\|"},{b:/\B\?(\\\d{1,3}|\\x[A-Fa-f0-9]{1,2}|\\u[A-Fa-f0-9]{4}|\\?\S)\b/},{b:/<<(-?)\w+$/,e:/^\s*\w+$/}]},i={cN:"params",b:"\\(",e:"\\)",endsParent:!0,k:r},d=[t,a,{cN:"class",bK:"class module",e:"$|;",i:/=/,c:[e.inherit(e.TM,{b:"[A-Za-z_]\\w*(::\\w+)*(\\?|\\!)?"}),{b:"<\\s*",c:[{b:"("+e.IR+"::)?"+e.IR}]}].concat(s)},{cN:"function",bK:"def",e:"$|;",c:[e.inherit(e.TM,{b:b}),i].concat(s)},{b:e.IR+"::"},{cN:"symbol",b:e.UIR+"(\\!|\\?)?:",r:0},{cN:"symbol",b:":(?!\\s)",c:[t,{b:b}],r:0},{cN:"number",b:"(\\b0[0-7_]+)|(\\b0x[0-9a-fA-F_]+)|(\\b[1-9][0-9_]*(\\.[0-9_]+)?)|[0_]\\b",r:0},{b:"(\\$\\W)|((\\$|\\@\\@?)(\\w+))"},{cN:"params",b:/\|/,e:/\|/,k:r},{b:"("+e.RSR+"|unless)\\s*",k:"unless",c:[a,{cN:"regexp",c:[e.BE,n],i:/\n/,v:[{b:"/",e:"/[a-z]*"},{b:"%r{",e:"}[a-z]*"},{b:"%r\\(",e:"\\)[a-z]*"},{b:"%r!",e:"![a-z]*"},{b:"%r\\[",e:"\\][a-z]*"}]}].concat(s),r:0}].concat(s);n.c=d,i.c=d;var l="[>?]>",o="[\\w#]+\\(\\w+\\):\\d+:\\d+>",u="(\\w+-)?\\d+\\.\\d+\\.\\d(p\\d+)?[^>]+>",w=[{b:/^\s*=>/,starts:{e:"$",c:d}},{cN:"meta",b:"^("+l+"|"+o+"|"+u+")",starts:{e:"$",c:d}}];return{aliases:["rb","gemspec","podspec","thor","irb"],k:r,i:/\/\*/,c:s.concat(w).concat(d)}});hljs.registerLanguage("yaml",function(e){var b="true false yes no null",a="^[ \\-]*",r="[a-zA-Z_][\\w\\-]*",t={cN:"attr",v:[{b:a+r+":"},{b:a+'"'+r+'":'},{b:a+"'"+r+"':"}]},c={cN:"template-variable",v:[{b:"{{",e:"}}"},{b:"%{",e:"}"}]},l={cN:"string",r:0,v:[{b:/'/,e:/'/},{b:/"/,e:/"/},{b:/\S+/}],c:[e.BE,c]};return{cI:!0,aliases:["yml","YAML","yaml"],c:[t,{cN:"meta",b:"^---s*$",r:10},{cN:"string",b:"[\\|>] *$",rE:!0,c:l.c,e:t.v[0].b},{b:"<%[%=-]?",e:"[%-]?%>",sL:"ruby",eB:!0,eE:!0,r:0},{cN:"type",b:"!!"+e.UIR},{cN:"meta",b:"&"+e.UIR+"$"},{cN:"meta",b:"\\*"+e.UIR+"$"},{cN:"bullet",b:"^ *-",r:0},e.HCM,{bK:b,k:{literal:b}},e.CNM,l]}});hljs.registerLanguage("cpp",function(t){var e={cN:"keyword",b:"\\b[a-z\\d_]*_t\\b"},r={cN:"string",v:[{b:'(u8?|U)?L?"',e:'"',i:"\\n",c:[t.BE]},{b:'(u8?|U)?R"',e:'"',c:[t.BE]},{b:"'\\\\?.",e:"'",i:"."}]},s={cN:"number",v:[{b:"\\b(0b[01']+)"},{b:"(-?)\\b([\\d']+(\\.[\\d']*)?|\\.[\\d']+)(u|U|l|L|ul|UL|f|F|b|B)"},{b:"(-?)(\\b0[xX][a-fA-F0-9']+|(\\b[\\d']+(\\.[\\d']*)?|\\.[\\d']+)([eE][-+]?[\\d']+)?)"}],r:0},i={cN:"meta",b:/#\s*[a-z]+\b/,e:/$/,k:{"meta-keyword":"if else elif endif define undef warning error line pragma ifdef ifndef include"},c:[{b:/\\\n/,r:0},t.inherit(r,{cN:"meta-string"}),{cN:"meta-string",b:/<[^\n>]*>/,e:/$/,i:"\\n"},t.CLCM,t.CBCM]},a=t.IR+"\\s*\\(",c={keyword:"int float while private char catch import module export virtual operator sizeof dynamic_cast|10 typedef const_cast|10 const for static_cast|10 union namespace unsigned long volatile static protected bool template mutable if public friend do goto auto void enum else break extern using asm case typeid short reinterpret_cast|10 default double register explicit signed typename try this switch continue inline delete alignof constexpr decltype noexcept static_assert thread_local restrict _Bool complex _Complex _Imaginary atomic_bool atomic_char atomic_schar atomic_uchar atomic_short atomic_ushort atomic_int atomic_uint atomic_long atomic_ulong atomic_llong atomic_ullong new throw return and or not",built_in:"std string cin cout cerr clog stdin stdout stderr stringstream istringstream ostringstream auto_ptr deque list queue stack vector map set bitset multiset multimap unordered_set unordered_map unordered_multiset unordered_multimap array shared_ptr abort abs acos asin atan2 atan calloc ceil cosh cos exit exp fabs floor fmod fprintf fputs free frexp fscanf isalnum isalpha iscntrl isdigit isgraph islower isprint ispunct isspace isupper isxdigit tolower toupper labs ldexp log10 log malloc realloc memchr memcmp memcpy memset modf pow printf putchar puts scanf sinh sin snprintf sprintf sqrt sscanf strcat strchr strcmp strcpy strcspn strlen strncat strncmp strncpy strpbrk strrchr strspn strstr tanh tan vfprintf vprintf vsprintf endl initializer_list unique_ptr",literal:"true false nullptr NULL"},n=[e,t.CLCM,t.CBCM,s,r];return{aliases:["c","cc","h","c++","h++","hpp"],k:c,i:"",k:c,c:["self",e]},{b:t.IR+"::",k:c},{v:[{b:/=/,e:/;/},{b:/\(/,e:/\)/},{bK:"new throw return else",e:/;/}],k:c,c:n.concat([{b:/\(/,e:/\)/,k:c,c:n.concat(["self"]),r:0}]),r:0},{cN:"function",b:"("+t.IR+"[\\*&\\s]+)+"+a,rB:!0,e:/[{;=]/,eE:!0,k:c,i:/[^\w\s\*&]/,c:[{b:a,rB:!0,c:[t.TM],r:0},{cN:"params",b:/\(/,e:/\)/,k:c,r:0,c:[t.CLCM,t.CBCM,r,s,e]},t.CLCM,t.CBCM,i]},{cN:"class",bK:"class struct",e:/[{;:]/,c:[{b://,c:["self"]},t.TM]}]),exports:{preprocessor:i,strings:r,k:c}}});hljs.registerLanguage("cs",function(e){var i={keyword:"abstract as base bool break byte case catch char checked const continue decimal default delegate do double enum event explicit extern finally fixed float for foreach goto if implicit in int interface internal is lock long nameof object operator out override params private protected public readonly ref sbyte sealed short sizeof stackalloc static string struct switch this try typeof uint ulong unchecked unsafe ushort using virtual void volatile while add alias ascending async await by descending dynamic equals from get global group into join let on orderby partial remove select set value var where yield",literal:"null false true"},t={cN:"string",b:'@"',e:'"',c:[{b:'""'}]},r=e.inherit(t,{i:/\n/}),a={cN:"subst",b:"{",e:"}",k:i},c=e.inherit(a,{i:/\n/}),n={cN:"string",b:/\$"/,e:'"',i:/\n/,c:[{b:"{{"},{b:"}}"},e.BE,c]},s={cN:"string",b:/\$@"/,e:'"',c:[{b:"{{"},{b:"}}"},{b:'""'},a]},o=e.inherit(s,{i:/\n/,c:[{b:"{{"},{b:"}}"},{b:'""'},c]});a.c=[s,n,t,e.ASM,e.QSM,e.CNM,e.CBCM],c.c=[o,n,r,e.ASM,e.QSM,e.CNM,e.inherit(e.CBCM,{i:/\n/})];var l={v:[s,n,t,e.ASM,e.QSM]},b=e.IR+"(<"+e.IR+"(\\s*,\\s*"+e.IR+")*>)?(\\[\\])?";return{aliases:["csharp"],k:i,i:/::/,c:[e.C("///","$",{rB:!0,c:[{cN:"doctag",v:[{b:"///",r:0},{b:""},{b:""}]}]}),e.CLCM,e.CBCM,{cN:"meta",b:"#",e:"$",k:{"meta-keyword":"if else elif endif define undef warning error line region endregion pragma checksum"}},l,e.CNM,{bK:"class interface",e:/[{;=]/,i:/[^\s:]/,c:[e.TM,e.CLCM,e.CBCM]},{bK:"namespace",e:/[{;=]/,i:/[^\s:]/,c:[e.inherit(e.TM,{b:"[a-zA-Z](\\.?\\w)*"}),e.CLCM,e.CBCM]},{cN:"meta",b:"^\\s*\\[",eB:!0,e:"\\]",eE:!0,c:[{cN:"meta-string",b:/"/,e:/"/}]},{bK:"new return throw await else",r:0},{cN:"function",b:"("+b+"\\s+)+"+e.IR+"\\s*\\(",rB:!0,e:/[{;=]/,eE:!0,k:i,c:[{b:e.IR+"\\s*\\(",rB:!0,c:[e.TM],r:0},{cN:"params",b:/\(/,e:/\)/,eB:!0,eE:!0,k:i,r:0,c:[l,e.CNM,e.CBCM]},e.CLCM,e.CBCM]}]}});hljs.registerLanguage("shell",function(s){return{aliases:["console"],c:[{cN:"meta",b:"^\\s{0,3}[\\w\\d\\[\\]()@-]*[>%$#]",starts:{e:"$",sL:"bash"}}]}});hljs.registerLanguage("less",function(e){var r="[\\w-]+",t="("+r+"|@{"+r+"})",a=[],c=[],s=function(e){return{cN:"string",b:"~?"+e+".*?"+e}},b=function(e,r,t){return{cN:e,b:r,r:t}},n={b:"\\(",e:"\\)",c:c,r:0};c.push(e.CLCM,e.CBCM,s("'"),s('"'),e.CSSNM,{b:"(url|data-uri)\\(",starts:{cN:"string",e:"[\\)\\n]",eE:!0}},b("number","#[0-9A-Fa-f]+\\b"),n,b("variable","@@?"+r,10),b("variable","@{"+r+"}"),b("built_in","~?`[^`]*?`"),{cN:"attribute",b:r+"\\s*:",e:":",rB:!0,eE:!0},{cN:"meta",b:"!important"});var i=c.concat({b:"{",e:"}",c:a}),o={bK:"when",eW:!0,c:[{bK:"and not"}].concat(c)},u={b:t+"\\s*:",rB:!0,e:"[;}]",r:0,c:[{cN:"attribute",b:t,e:":",eE:!0,starts:{eW:!0,i:"[<=$]",r:0,c:c}}]},l={cN:"keyword",b:"@(import|media|charset|font-face|(-[a-z]+-)?keyframes|supports|document|namespace|page|viewport|host)\\b",starts:{e:"[;{}]",rE:!0,c:c,r:0}},C={cN:"variable",v:[{b:"@"+r+"\\s*:",r:15},{b:"@"+r}],starts:{e:"[;}]",rE:!0,c:i}},p={v:[{b:"[\\.#:&\\[>]",e:"[;{}]"},{b:t,e:"{"}],rB:!0,rE:!0,i:"[<='$\"]",r:0,c:[e.CLCM,e.CBCM,o,b("keyword","all\\b"),b("variable","@{"+r+"}"),b("selector-tag",t+"%?",0),b("selector-id","#"+t),b("selector-class","\\."+t,0),b("selector-tag","&",0),{cN:"selector-attr",b:"\\[",e:"\\]"},{cN:"selector-pseudo",b:/:(:)?[a-zA-Z0-9\_\-\+\(\)"'.]+/},{b:"\\(",e:"\\)",c:i},{b:"!important"}]};return a.push(e.CLCM,e.CBCM,l,C,u,p),{cI:!0,i:"[=>'/<($\"]",c:a}});hljs.registerLanguage("css",function(e){var c="[a-zA-Z-][a-zA-Z0-9_-]*",t={b:/[A-Z\_\.\-]+\s*:/,rB:!0,e:";",eW:!0,c:[{cN:"attribute",b:/\S/,e:":",eE:!0,starts:{eW:!0,eE:!0,c:[{b:/[\w-]+\(/,rB:!0,c:[{cN:"built_in",b:/[\w-]+/},{b:/\(/,e:/\)/,c:[e.ASM,e.QSM]}]},e.CSSNM,e.QSM,e.ASM,e.CBCM,{cN:"number",b:"#[0-9A-Fa-f]+"},{cN:"meta",b:"!important"}]}}]};return{cI:!0,i:/[=\/|'\$]/,c:[e.CBCM,{cN:"selector-id",b:/#[A-Za-z0-9_-]+/},{cN:"selector-class",b:/\.[A-Za-z0-9_-]+/},{cN:"selector-attr",b:/\[/,e:/\]/,i:"$"},{cN:"selector-pseudo",b:/:(:)?[a-zA-Z0-9\_\-\+\(\)"'.]+/},{b:"@(font-face|page)",l:"[a-z-]+",k:"font-face page"},{b:"@",e:"[{;]",i:/:/,c:[{cN:"keyword",b:/\w+/},{b:/\s/,eW:!0,eE:!0,r:0,c:[e.ASM,e.QSM,e.CSSNM]}]},{cN:"selector-tag",b:c,r:0},{b:"{",e:"}",i:/\S/,c:[e.CBCM,t]}]}});hljs.registerLanguage("nginx",function(e){var r={cN:"variable",v:[{b:/\$\d+/},{b:/\$\{/,e:/}/},{b:"[\\$\\@]"+e.UIR}]},b={eW:!0,l:"[a-z/_]+",k:{literal:"on off yes no true false none blocked debug info notice warn error crit select break last permanent redirect kqueue rtsig epoll poll /dev/poll"},r:0,i:"=>",c:[e.HCM,{cN:"string",c:[e.BE,r],v:[{b:/"/,e:/"/},{b:/'/,e:/'/}]},{b:"([a-z]+):/",e:"\\s",eW:!0,eE:!0,c:[r]},{cN:"regexp",c:[e.BE,r],v:[{b:"\\s\\^",e:"\\s|{|;",rE:!0},{b:"~\\*?\\s+",e:"\\s|{|;",rE:!0},{b:"\\*(\\.[a-z\\-]+)+"},{b:"([a-z\\-]+\\.)+\\*"}]},{cN:"number",b:"\\b\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}(:\\d{1,5})?\\b"},{cN:"number",b:"\\b\\d+[kKmMgGdshdwy]*\\b",r:0},r]};return{aliases:["nginxconf"],c:[e.HCM,{b:e.UIR+"\\s+{",rB:!0,e:"{",c:[{cN:"section",b:e.UIR}],r:0},{b:e.UIR+"\\s",e:";|{",rB:!0,c:[{cN:"attribute",b:e.UIR,starts:b}],r:0}],i:"[^\\s\\}]"}});hljs.registerLanguage("makefile",function(e){var i={cN:"variable",v:[{b:"\\$\\("+e.UIR+"\\)",c:[e.BE]},{b:/\$[@%)?",r="false synchronized int abstract float private char boolean static null if const for true while long strictfp finally protected import native final void enum else break transient catch instanceof byte super volatile case assert short package default double public try this switch continue throws protected public private module requires exports do",s="\\b(0[bB]([01]+[01_]+[01]+|[01]+)|0[xX]([a-fA-F0-9]+[a-fA-F0-9_]+[a-fA-F0-9]+|[a-fA-F0-9]+)|(([\\d]+[\\d_]+[\\d]+|[\\d]+)(\\.([\\d]+[\\d_]+[\\d]+|[\\d]+))?|\\.([\\d]+[\\d_]+[\\d]+|[\\d]+))([eE][-+]?\\d+)?)[lLfF]?",c={cN:"number",b:s,r:0};return{aliases:["jsp"],k:r,i:/<\/|#/,c:[e.C("/\\*\\*","\\*/",{r:0,c:[{b:/\w+@/,r:0},{cN:"doctag",b:"@[A-Za-z]+"}]}),e.CLCM,e.CBCM,e.ASM,e.QSM,{cN:"class",bK:"class interface",e:/[{;=]/,eE:!0,k:"class interface",i:/[:"\[\]]/,c:[{bK:"extends implements"},e.UTM]},{bK:"new throw return else",r:0},{cN:"function",b:"("+t+"\\s+)+"+e.UIR+"\\s*\\(",rB:!0,e:/[{;=]/,eE:!0,k:r,c:[{b:e.UIR+"\\s*\\(",rB:!0,r:0,c:[e.UTM]},{cN:"params",b:/\(/,e:/\)/,k:r,r:0,c:[e.ASM,e.QSM,e.CNM,e.CBCM]},e.CLCM,e.CBCM]},c,{cN:"meta",b:"@[A-Za-z]+"}]}});hljs.registerLanguage("http",function(e){var t="HTTP/[0-9\\.]+";return{aliases:["https"],i:"\\S",c:[{b:"^"+t,e:"$",c:[{cN:"number",b:"\\b\\d{3}\\b"}]},{b:"^[A-Z]+ (.*?) "+t+"$",rB:!0,e:"$",c:[{cN:"string",b:" ",e:" ",eB:!0,eE:!0},{b:t},{cN:"keyword",b:"[A-Z]+"}]},{cN:"attribute",b:"^\\w",e:": ",eE:!0,i:"\\n|\\s|=",starts:{e:"$",r:0}},{b:"\\n\\n",starts:{sL:[],eW:!0}}]}});hljs.registerLanguage("objectivec",function(e){var t={cN:"built_in",b:"\\b(AV|CA|CF|CG|CI|CL|CM|CN|CT|MK|MP|MTK|MTL|NS|SCN|SK|UI|WK|XC)\\w+"},_={keyword:"int float while char export sizeof typedef const struct for union unsigned long volatile static bool mutable if do return goto void enum else break extern asm case short default double register explicit signed typename this switch continue wchar_t inline readonly assign readwrite self @synchronized id typeof nonatomic super unichar IBOutlet IBAction strong weak copy in out inout bycopy byref oneway __strong __weak __block __autoreleasing @private @protected @public @try @property @end @throw @catch @finally @autoreleasepool @synthesize @dynamic @selector @optional @required @encode @package @import @defs @compatibility_alias __bridge __bridge_transfer __bridge_retained __bridge_retain __covariant __contravariant __kindof _Nonnull _Nullable _Null_unspecified __FUNCTION__ __PRETTY_FUNCTION__ __attribute__ getter setter retain unsafe_unretained nonnull nullable null_unspecified null_resettable class instancetype NS_DESIGNATED_INITIALIZER NS_UNAVAILABLE NS_REQUIRES_SUPER NS_RETURNS_INNER_POINTER NS_INLINE NS_AVAILABLE NS_DEPRECATED NS_ENUM NS_OPTIONS NS_SWIFT_UNAVAILABLE NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_END NS_REFINED_FOR_SWIFT NS_SWIFT_NAME NS_SWIFT_NOTHROW NS_DURING NS_HANDLER NS_ENDHANDLER NS_VALUERETURN NS_VOIDRETURN",literal:"false true FALSE TRUE nil YES NO NULL",built_in:"BOOL dispatch_once_t dispatch_queue_t dispatch_sync dispatch_async dispatch_once"},i=/[a-zA-Z@][a-zA-Z0-9_]*/,n="@interface @class @protocol @implementation";return{aliases:["mm","objc","obj-c"],k:_,l:i,i:""}]}]},{cN:"class",b:"("+n.split(" ").join("|")+")\\b",e:"({|$)",eE:!0,k:n,l:i,c:[e.UTM]},{b:"\\."+e.UIR,r:0}]}});hljs.registerLanguage("javascript",function(e){var r="[A-Za-z$_][0-9A-Za-z$_]*",t={keyword:"in of if for while finally var new function do return void else break catch instanceof with throw case default try this switch continue typeof delete let yield const export super debugger as async await static import from as",literal:"true false null undefined NaN Infinity",built_in:"eval isFinite isNaN parseFloat parseInt decodeURI decodeURIComponent encodeURI encodeURIComponent escape unescape Object Function Boolean Error EvalError InternalError RangeError ReferenceError StopIteration SyntaxError TypeError URIError Number Math Date String RegExp Array Float32Array Float64Array Int16Array Int32Array Int8Array Uint16Array Uint32Array Uint8Array Uint8ClampedArray ArrayBuffer DataView JSON Intl arguments require module console window document Symbol Set Map WeakSet WeakMap Proxy Reflect Promise"},a={cN:"number",v:[{b:"\\b(0[bB][01]+)"},{b:"\\b(0[oO][0-7]+)"},{b:e.CNR}],r:0},n={cN:"subst",b:"\\$\\{",e:"\\}",k:t,c:[]},c={cN:"string",b:"`",e:"`",c:[e.BE,n]};n.c=[e.ASM,e.QSM,c,a,e.RM];var s=n.c.concat([e.CBCM,e.CLCM]);return{aliases:["js","jsx"],k:t,c:[{cN:"meta",r:10,b:/^\s*['"]use (strict|asm)['"]/},{cN:"meta",b:/^#!/,e:/$/},e.ASM,e.QSM,c,e.CLCM,e.CBCM,a,{b:/[{,]\s*/,r:0,c:[{b:r+"\\s*:",rB:!0,r:0,c:[{cN:"attr",b:r,r:0}]}]},{b:"("+e.RSR+"|\\b(case|return|throw)\\b)\\s*",k:"return throw case",c:[e.CLCM,e.CBCM,e.RM,{cN:"function",b:"(\\(.*?\\)|"+r+")\\s*=>",rB:!0,e:"\\s*=>",c:[{cN:"params",v:[{b:r},{b:/\(\s*\)/},{b:/\(/,e:/\)/,eB:!0,eE:!0,k:t,c:s}]}]},{b://,sL:"xml",c:[{b:/<\w+\s*\/>/,skip:!0},{b:/<\w+/,e:/(\/\w+|\w+\/)>/,skip:!0,c:[{b:/<\w+\s*\/>/,skip:!0},"self"]}]}],r:0},{cN:"function",bK:"function",e:/\{/,eE:!0,c:[e.inherit(e.TM,{b:r}),{cN:"params",b:/\(/,e:/\)/,eB:!0,eE:!0,c:s}],i:/\[|%/},{b:/\$[(.]/},e.METHOD_GUARD,{cN:"class",bK:"class",e:/[{;=]/,eE:!0,i:/[:"\[\]]/,c:[{bK:"extends"},e.UTM]},{bK:"constructor",e:/\{/,eE:!0}],i:/#(?!!)/}});hljs.registerLanguage("apache",function(e){var r={cN:"number",b:"[\\$%]\\d+"};return{aliases:["apacheconf"],cI:!0,c:[e.HCM,{cN:"section",b:""},{cN:"attribute",b:/\w+/,r:0,k:{nomarkup:"order deny allow setenv rewriterule rewriteengine rewritecond documentroot sethandler errordocument loadmodule options header listen serverroot servername"},starts:{e:/$/,r:0,k:{literal:"on off all"},c:[{cN:"meta",b:"\\s\\[",e:"\\]$"},{cN:"variable",b:"[\\$%]\\{",e:"\\}",c:["self",r]},r,e.QSM]}}],i:/\S/}});hljs.registerLanguage("xml",function(s){var e="[A-Za-z0-9\\._:-]+",t={eW:!0,i:/`]+/}]}]}]};return{aliases:["html","xhtml","rss","atom","xjb","xsd","xsl","plist"],cI:!0,c:[{cN:"meta",b:"",r:10,c:[{b:"\\[",e:"\\]"}]},s.C("",{r:10}),{b:"<\\!\\[CDATA\\[",e:"\\]\\]>",r:10},{b:/<\?(php)?/,e:/\?>/,sL:"php",c:[{b:"/\\*",e:"\\*/",skip:!0}]},{cN:"tag",b:"|$)",e:">",k:{name:"style"},c:[t],starts:{e:"",rE:!0,sL:["css","xml"]}},{cN:"tag",b:"|$)",e:">",k:{name:"script"},c:[t],starts:{e:"",rE:!0,sL:["actionscript","javascript","handlebars","xml"]}},{cN:"meta",v:[{b:/<\?xml/,e:/\?>/,r:10},{b:/<\?\w+/,e:/\?>/}]},{cN:"tag",b:"",c:[{cN:"name",b:/[^\/><\s]+/,r:0},t]}]}});hljs.registerLanguage("markdown",function(e){return{aliases:["md","mkdown","mkd"],c:[{cN:"section",v:[{b:"^#{1,6}",e:"$"},{b:"^.+?\\n[=-]{2,}$"}]},{b:"<",e:">",sL:"xml",r:0},{cN:"bullet",b:"^([*+-]|(\\d+\\.))\\s+"},{cN:"strong",b:"[*_]{2}.+?[*_]{2}"},{cN:"emphasis",v:[{b:"\\*.+?\\*"},{b:"_.+?_",r:0}]},{cN:"quote",b:"^>\\s+",e:"$"},{cN:"code",v:[{b:"^```w*s*$",e:"^```s*$"},{b:"`.+?`"},{b:"^( {4}| )",e:"$",r:0}]},{b:"^[-\\*]{3,}",e:"$"},{b:"\\[.+?\\][\\(\\[].*?[\\)\\]]",rB:!0,c:[{cN:"string",b:"\\[",e:"\\]",eB:!0,rE:!0,r:0},{cN:"link",b:"\\]\\(",e:"\\)",eB:!0,eE:!0},{cN:"symbol",b:"\\]\\[",e:"\\]",eB:!0,eE:!0}],r:10},{b:/^\[[^\n]+\]:/,rB:!0,c:[{cN:"symbol",b:/\[/,e:/\]/,eB:!0,eE:!0},{cN:"link",b:/:\s*/,e:/$/,eB:!0}]}]}});hljs.registerLanguage("twig",function(e){var t={cN:"params",b:"\\(",e:"\\)"},a="attribute block constant cycle date dump include max min parent random range source template_from_string",r={bK:a,k:{name:a},r:0,c:[t]},c={b:/\|[A-Za-z_]+:?/,k:"abs batch capitalize convert_encoding date date_modify default escape first format join json_encode keys last length lower merge nl2br number_format raw replace reverse round slice sort split striptags title trim upper url_encode",c:[r]},s="autoescape block do embed extends filter flush for if import include macro sandbox set spaceless use verbatim";return s=s+" "+s.split(" ").map(function(e){return"end"+e}).join(" "),{aliases:["craftcms"],cI:!0,sL:"xml",c:[e.C(/\{#/,/#}/),{cN:"template-tag",b:/\{%/,e:/%}/,c:[{cN:"name",b:/\w+/,k:s,starts:{eW:!0,c:[c,r],r:0}}]},{cN:"template-variable",b:/\{\{/,e:/}}/,c:["self",c,r]}]}});hljs.registerLanguage("json",function(e){var i={literal:"true false null"},n=[e.QSM,e.CNM],r={e:",",eW:!0,eE:!0,c:n,k:i},t={b:"{",e:"}",c:[{cN:"attr",b:/"/,e:/"/,c:[e.BE],i:"\\n"},e.inherit(r,{b:/:/})],i:"\\S"},c={b:"\\[",e:"\\]",c:[e.inherit(r)],i:"\\S"};return n.splice(n.length,0,t,c),{c:n,k:i,i:"\\S"}}); \ No newline at end of file diff --git a/lib/highlight/styles/agate.css b/lib/highlight/styles/agate.css new file mode 100644 index 000000000..8d64547c5 --- /dev/null +++ b/lib/highlight/styles/agate.css @@ -0,0 +1,108 @@ +/*! + * Agate by Taufik Nurrohman + * ---------------------------------------------------- + * + * #ade5fc + * #a2fca2 + * #c6b4f0 + * #d36363 + * #fcc28c + * #fc9b9b + * #ffa + * #fff + * #333 + * #62c8f3 + * #888 + * + */ + +.hljs { + display: block; + overflow-x: auto; + padding: 0.5em; + background: #333; + color: white; +} + +.hljs-name, +.hljs-strong { + font-weight: bold; +} + +.hljs-code, +.hljs-emphasis { + font-style: italic; +} + +.hljs-tag { + color: #62c8f3; +} + +.hljs-variable, +.hljs-template-variable, +.hljs-selector-id, +.hljs-selector-class { + color: #ade5fc; +} + +.hljs-string, +.hljs-bullet { + color: #a2fca2; +} + +.hljs-type, +.hljs-title, +.hljs-section, +.hljs-attribute, +.hljs-quote, +.hljs-built_in, +.hljs-builtin-name { + color: #ffa; +} + +.hljs-number, +.hljs-symbol, +.hljs-bullet { + color: #d36363; +} + +.hljs-keyword, +.hljs-selector-tag, +.hljs-literal { + color: #fcc28c; +} + +.hljs-comment, +.hljs-deletion, +.hljs-code { + color: #888; +} + +.hljs-regexp, +.hljs-link { + color: #c6b4f0; +} + +.hljs-meta { + color: #fc9b9b; +} + +.hljs-deletion { + background-color: #fc9b9b; + color: #333; +} + +.hljs-addition { + background-color: #a2fca2; + color: #333; +} + +.hljs a { + color: inherit; +} + +.hljs a:focus, +.hljs a:hover { + color: inherit; + text-decoration: underline; +} diff --git a/lib/highlight/styles/androidstudio.css b/lib/highlight/styles/androidstudio.css new file mode 100644 index 000000000..bc8e473b5 --- /dev/null +++ b/lib/highlight/styles/androidstudio.css @@ -0,0 +1,66 @@ +/* +Date: 24 Fev 2015 +Author: Pedro Oliveira +*/ + +.hljs { + color: #a9b7c6; + background: #282b2e; + display: block; + overflow-x: auto; + padding: 0.5em; +} + +.hljs-number, +.hljs-literal, +.hljs-symbol, +.hljs-bullet { + color: #6897BB; +} + +.hljs-keyword, +.hljs-selector-tag, +.hljs-deletion { + color: #cc7832; +} + +.hljs-variable, +.hljs-template-variable, +.hljs-link { + color: #629755; +} + +.hljs-comment, +.hljs-quote { + color: #808080; +} + +.hljs-meta { + color: #bbb529; +} + +.hljs-string, +.hljs-attribute, +.hljs-addition { + color: #6A8759; +} + +.hljs-section, +.hljs-title, +.hljs-type { + color: #ffc66d; +} + +.hljs-name, +.hljs-selector-id, +.hljs-selector-class { + color: #e8bf6a; +} + +.hljs-emphasis { + font-style: italic; +} + +.hljs-strong { + font-weight: bold; +} diff --git a/lib/highlight/styles/arduino-light.css b/lib/highlight/styles/arduino-light.css new file mode 100644 index 000000000..4b8b7fd3c --- /dev/null +++ b/lib/highlight/styles/arduino-light.css @@ -0,0 +1,88 @@ +/* + +Arduino® Light Theme - Stefania Mellai + +*/ + +.hljs { + display: block; + overflow-x: auto; + padding: 0.5em; + background: #FFFFFF; +} + +.hljs, +.hljs-subst { + color: #434f54; +} + +.hljs-keyword, +.hljs-attribute, +.hljs-selector-tag, +.hljs-doctag, +.hljs-name { + color: #00979D; +} + +.hljs-built_in, +.hljs-literal, +.hljs-bullet, +.hljs-code, +.hljs-addition { + color: #D35400; +} + +.hljs-regexp, +.hljs-symbol, +.hljs-variable, +.hljs-template-variable, +.hljs-link, +.hljs-selector-attr, +.hljs-selector-pseudo { + color: #00979D; +} + +.hljs-type, +.hljs-string, +.hljs-selector-id, +.hljs-selector-class, +.hljs-quote, +.hljs-template-tag, +.hljs-deletion { + color: #005C5F; +} + +.hljs-title, +.hljs-section { + color: #880000; + font-weight: bold; +} + +.hljs-comment { + color: rgba(149,165,166,.8); +} + +.hljs-meta-keyword { + color: #728E00; +} + +.hljs-meta { + color: #728E00; + color: #434f54; +} + +.hljs-emphasis { + font-style: italic; +} + +.hljs-strong { + font-weight: bold; +} + +.hljs-function { + color: #728E00; +} + +.hljs-number { + color: #8A7B52; +} diff --git a/lib/highlight/styles/arta.css b/lib/highlight/styles/arta.css new file mode 100644 index 000000000..75ef3a9e5 --- /dev/null +++ b/lib/highlight/styles/arta.css @@ -0,0 +1,73 @@ +/* +Date: 17.V.2011 +Author: pumbur +*/ + +.hljs { + display: block; + overflow-x: auto; + padding: 0.5em; + background: #222; +} + +.hljs, +.hljs-subst { + color: #aaa; +} + +.hljs-section { + color: #fff; +} + +.hljs-comment, +.hljs-quote, +.hljs-meta { + color: #444; +} + +.hljs-string, +.hljs-symbol, +.hljs-bullet, +.hljs-regexp { + color: #ffcc33; +} + +.hljs-number, +.hljs-addition { + color: #00cc66; +} + +.hljs-built_in, +.hljs-builtin-name, +.hljs-literal, +.hljs-type, +.hljs-template-variable, +.hljs-attribute, +.hljs-link { + color: #32aaee; +} + +.hljs-keyword, +.hljs-selector-tag, +.hljs-name, +.hljs-selector-id, +.hljs-selector-class { + color: #6644aa; +} + +.hljs-title, +.hljs-variable, +.hljs-deletion, +.hljs-template-tag { + color: #bb1166; +} + +.hljs-section, +.hljs-doctag, +.hljs-strong { + font-weight: bold; +} + +.hljs-emphasis { + font-style: italic; +} diff --git a/lib/highlight/styles/ascetic.css b/lib/highlight/styles/ascetic.css new file mode 100644 index 000000000..48397e889 --- /dev/null +++ b/lib/highlight/styles/ascetic.css @@ -0,0 +1,45 @@ +/* + +Original style from softwaremaniacs.org (c) Ivan Sagalaev + +*/ + +.hljs { + display: block; + overflow-x: auto; + padding: 0.5em; + background: white; + color: black; +} + +.hljs-string, +.hljs-variable, +.hljs-template-variable, +.hljs-symbol, +.hljs-bullet, +.hljs-section, +.hljs-addition, +.hljs-attribute, +.hljs-link { + color: #888; +} + +.hljs-comment, +.hljs-quote, +.hljs-meta, +.hljs-deletion { + color: #ccc; +} + +.hljs-keyword, +.hljs-selector-tag, +.hljs-section, +.hljs-name, +.hljs-type, +.hljs-strong { + font-weight: bold; +} + +.hljs-emphasis { + font-style: italic; +} diff --git a/lib/highlight/styles/atelier-cave-dark.css b/lib/highlight/styles/atelier-cave-dark.css new file mode 100644 index 000000000..65428f3b1 --- /dev/null +++ b/lib/highlight/styles/atelier-cave-dark.css @@ -0,0 +1,83 @@ +/* Base16 Atelier Cave Dark - Theme */ +/* by Bram de Haan (http://atelierbram.github.io/syntax-highlighting/atelier-schemes/cave) */ +/* Original Base16 color scheme by Chris Kempson (https://github.com/chriskempson/base16) */ + +/* Atelier-Cave Comment */ +.hljs-comment, +.hljs-quote { + color: #7e7887; +} + +/* Atelier-Cave Red */ +.hljs-variable, +.hljs-template-variable, +.hljs-attribute, +.hljs-regexp, +.hljs-link, +.hljs-tag, +.hljs-name, +.hljs-selector-id, +.hljs-selector-class { + color: #be4678; +} + +/* Atelier-Cave Orange */ +.hljs-number, +.hljs-meta, +.hljs-built_in, +.hljs-builtin-name, +.hljs-literal, +.hljs-type, +.hljs-params { + color: #aa573c; +} + +/* Atelier-Cave Green */ +.hljs-string, +.hljs-symbol, +.hljs-bullet { + color: #2a9292; +} + +/* Atelier-Cave Blue */ +.hljs-title, +.hljs-section { + color: #576ddb; +} + +/* Atelier-Cave Purple */ +.hljs-keyword, +.hljs-selector-tag { + color: #955ae7; +} + +.hljs-deletion, +.hljs-addition { + color: #19171c; + display: inline-block; + width: 100%; +} + +.hljs-deletion { + background-color: #be4678; +} + +.hljs-addition { + background-color: #2a9292; +} + +.hljs { + display: block; + overflow-x: auto; + background: #19171c; + color: #8b8792; + padding: 0.5em; +} + +.hljs-emphasis { + font-style: italic; +} + +.hljs-strong { + font-weight: bold; +} diff --git a/lib/highlight/styles/atelier-cave-light.css b/lib/highlight/styles/atelier-cave-light.css new file mode 100644 index 000000000..b419f9fd8 --- /dev/null +++ b/lib/highlight/styles/atelier-cave-light.css @@ -0,0 +1,85 @@ +/* Base16 Atelier Cave Light - Theme */ +/* by Bram de Haan (http://atelierbram.github.io/syntax-highlighting/atelier-schemes/cave) */ +/* Original Base16 color scheme by Chris Kempson (https://github.com/chriskempson/base16) */ + +/* Atelier-Cave Comment */ +.hljs-comment, +.hljs-quote { + color: #655f6d; +} + +/* Atelier-Cave Red */ +.hljs-variable, +.hljs-template-variable, +.hljs-attribute, +.hljs-tag, +.hljs-name, +.hljs-regexp, +.hljs-link, +.hljs-name, +.hljs-name, +.hljs-selector-id, +.hljs-selector-class { + color: #be4678; +} + +/* Atelier-Cave Orange */ +.hljs-number, +.hljs-meta, +.hljs-built_in, +.hljs-builtin-name, +.hljs-literal, +.hljs-type, +.hljs-params { + color: #aa573c; +} + +/* Atelier-Cave Green */ +.hljs-string, +.hljs-symbol, +.hljs-bullet { + color: #2a9292; +} + +/* Atelier-Cave Blue */ +.hljs-title, +.hljs-section { + color: #576ddb; +} + +/* Atelier-Cave Purple */ +.hljs-keyword, +.hljs-selector-tag { + color: #955ae7; +} + +.hljs-deletion, +.hljs-addition { + color: #19171c; + display: inline-block; + width: 100%; +} + +.hljs-deletion { + background-color: #be4678; +} + +.hljs-addition { + background-color: #2a9292; +} + +.hljs { + display: block; + overflow-x: auto; + background: #efecf4; + color: #585260; + padding: 0.5em; +} + +.hljs-emphasis { + font-style: italic; +} + +.hljs-strong { + font-weight: bold; +} diff --git a/lib/highlight/styles/atelier-dune-dark.css b/lib/highlight/styles/atelier-dune-dark.css new file mode 100644 index 000000000..1684f5225 --- /dev/null +++ b/lib/highlight/styles/atelier-dune-dark.css @@ -0,0 +1,69 @@ +/* Base16 Atelier Dune Dark - Theme */ +/* by Bram de Haan (http://atelierbram.github.io/syntax-highlighting/atelier-schemes/dune) */ +/* Original Base16 color scheme by Chris Kempson (https://github.com/chriskempson/base16) */ + +/* Atelier-Dune Comment */ +.hljs-comment, +.hljs-quote { + color: #999580; +} + +/* Atelier-Dune Red */ +.hljs-variable, +.hljs-template-variable, +.hljs-attribute, +.hljs-tag, +.hljs-name, +.hljs-regexp, +.hljs-link, +.hljs-name, +.hljs-selector-id, +.hljs-selector-class { + color: #d73737; +} + +/* Atelier-Dune Orange */ +.hljs-number, +.hljs-meta, +.hljs-built_in, +.hljs-builtin-name, +.hljs-literal, +.hljs-type, +.hljs-params { + color: #b65611; +} + +/* Atelier-Dune Green */ +.hljs-string, +.hljs-symbol, +.hljs-bullet { + color: #60ac39; +} + +/* Atelier-Dune Blue */ +.hljs-title, +.hljs-section { + color: #6684e1; +} + +/* Atelier-Dune Purple */ +.hljs-keyword, +.hljs-selector-tag { + color: #b854d4; +} + +.hljs { + display: block; + overflow-x: auto; + background: #20201d; + color: #a6a28c; + padding: 0.5em; +} + +.hljs-emphasis { + font-style: italic; +} + +.hljs-strong { + font-weight: bold; +} diff --git a/lib/highlight/styles/atelier-dune-light.css b/lib/highlight/styles/atelier-dune-light.css new file mode 100644 index 000000000..547719de8 --- /dev/null +++ b/lib/highlight/styles/atelier-dune-light.css @@ -0,0 +1,69 @@ +/* Base16 Atelier Dune Light - Theme */ +/* by Bram de Haan (http://atelierbram.github.io/syntax-highlighting/atelier-schemes/dune) */ +/* Original Base16 color scheme by Chris Kempson (https://github.com/chriskempson/base16) */ + +/* Atelier-Dune Comment */ +.hljs-comment, +.hljs-quote { + color: #7d7a68; +} + +/* Atelier-Dune Red */ +.hljs-variable, +.hljs-template-variable, +.hljs-attribute, +.hljs-tag, +.hljs-name, +.hljs-regexp, +.hljs-link, +.hljs-name, +.hljs-selector-id, +.hljs-selector-class { + color: #d73737; +} + +/* Atelier-Dune Orange */ +.hljs-number, +.hljs-meta, +.hljs-built_in, +.hljs-builtin-name, +.hljs-literal, +.hljs-type, +.hljs-params { + color: #b65611; +} + +/* Atelier-Dune Green */ +.hljs-string, +.hljs-symbol, +.hljs-bullet { + color: #60ac39; +} + +/* Atelier-Dune Blue */ +.hljs-title, +.hljs-section { + color: #6684e1; +} + +/* Atelier-Dune Purple */ +.hljs-keyword, +.hljs-selector-tag { + color: #b854d4; +} + +.hljs { + display: block; + overflow-x: auto; + background: #fefbec; + color: #6e6b5e; + padding: 0.5em; +} + +.hljs-emphasis { + font-style: italic; +} + +.hljs-strong { + font-weight: bold; +} diff --git a/lib/highlight/styles/atelier-estuary-dark.css b/lib/highlight/styles/atelier-estuary-dark.css new file mode 100644 index 000000000..a5e507187 --- /dev/null +++ b/lib/highlight/styles/atelier-estuary-dark.css @@ -0,0 +1,84 @@ +/* Base16 Atelier Estuary Dark - Theme */ +/* by Bram de Haan (http://atelierbram.github.io/syntax-highlighting/atelier-schemes/estuary) */ +/* Original Base16 color scheme by Chris Kempson (https://github.com/chriskempson/base16) */ + +/* Atelier-Estuary Comment */ +.hljs-comment, +.hljs-quote { + color: #878573; +} + +/* Atelier-Estuary Red */ +.hljs-variable, +.hljs-template-variable, +.hljs-attribute, +.hljs-tag, +.hljs-name, +.hljs-regexp, +.hljs-link, +.hljs-name, +.hljs-selector-id, +.hljs-selector-class { + color: #ba6236; +} + +/* Atelier-Estuary Orange */ +.hljs-number, +.hljs-meta, +.hljs-built_in, +.hljs-builtin-name, +.hljs-literal, +.hljs-type, +.hljs-params { + color: #ae7313; +} + +/* Atelier-Estuary Green */ +.hljs-string, +.hljs-symbol, +.hljs-bullet { + color: #7d9726; +} + +/* Atelier-Estuary Blue */ +.hljs-title, +.hljs-section { + color: #36a166; +} + +/* Atelier-Estuary Purple */ +.hljs-keyword, +.hljs-selector-tag { + color: #5f9182; +} + +.hljs-deletion, +.hljs-addition { + color: #22221b; + display: inline-block; + width: 100%; +} + +.hljs-deletion { + background-color: #ba6236; +} + +.hljs-addition { + background-color: #7d9726; +} + +.hljs { + display: block; + overflow-x: auto; + background: #22221b; + color: #929181; + padding: 0.5em; +} + +.hljs-emphasis { + font-style: italic; +} + +.hljs-strong { + font-weight: bold; +} diff --git a/lib/highlight/styles/atelier-estuary-light.css b/lib/highlight/styles/atelier-estuary-light.css new file mode 100644 index 000000000..1daee5d98 --- /dev/null +++ b/lib/highlight/styles/atelier-estuary-light.css @@ -0,0 +1,84 @@ +/* Base16 Atelier Estuary Light - Theme */ +/* by Bram de Haan (http://atelierbram.github.io/syntax-highlighting/atelier-schemes/estuary) */ +/* Original Base16 color scheme by Chris Kempson (https://github.com/chriskempson/base16) */ + +/* Atelier-Estuary Comment */ +.hljs-comment, +.hljs-quote { + color: #6c6b5a; +} + +/* Atelier-Estuary Red */ +.hljs-variable, +.hljs-template-variable, +.hljs-attribute, +.hljs-tag, +.hljs-name, +.hljs-regexp, +.hljs-link, +.hljs-name, +.hljs-selector-id, +.hljs-selector-class { + color: #ba6236; +} + +/* Atelier-Estuary Orange */ +.hljs-number, +.hljs-meta, +.hljs-built_in, +.hljs-builtin-name, +.hljs-literal, +.hljs-type, +.hljs-params { + color: #ae7313; +} + +/* Atelier-Estuary Green */ +.hljs-string, +.hljs-symbol, +.hljs-bullet { + color: #7d9726; +} + +/* Atelier-Estuary Blue */ +.hljs-title, +.hljs-section { + color: #36a166; +} + +/* Atelier-Estuary Purple */ +.hljs-keyword, +.hljs-selector-tag { + color: #5f9182; +} + +.hljs-deletion, +.hljs-addition { + color: #22221b; + display: inline-block; + width: 100%; +} + +.hljs-deletion { + background-color: #ba6236; +} + +.hljs-addition { + background-color: #7d9726; +} + +.hljs { + display: block; + overflow-x: auto; + background: #f4f3ec; + color: #5f5e4e; + padding: 0.5em; +} + +.hljs-emphasis { + font-style: italic; +} + +.hljs-strong { + font-weight: bold; +} diff --git a/lib/highlight/styles/atelier-forest-dark.css b/lib/highlight/styles/atelier-forest-dark.css new file mode 100644 index 000000000..0ef4fae31 --- /dev/null +++ b/lib/highlight/styles/atelier-forest-dark.css @@ -0,0 +1,69 @@ +/* Base16 Atelier Forest Dark - Theme */ +/* by Bram de Haan (http://atelierbram.github.io/syntax-highlighting/atelier-schemes/forest) */ +/* Original Base16 color scheme by Chris Kempson (https://github.com/chriskempson/base16) */ + +/* Atelier-Forest Comment */ +.hljs-comment, +.hljs-quote { + color: #9c9491; +} + +/* Atelier-Forest Red */ +.hljs-variable, +.hljs-template-variable, +.hljs-attribute, +.hljs-tag, +.hljs-name, +.hljs-regexp, +.hljs-link, +.hljs-name, +.hljs-selector-id, +.hljs-selector-class { + color: #f22c40; +} + +/* Atelier-Forest Orange */ +.hljs-number, +.hljs-meta, +.hljs-built_in, +.hljs-builtin-name, +.hljs-literal, +.hljs-type, +.hljs-params { + color: #df5320; +} + +/* Atelier-Forest Green */ +.hljs-string, +.hljs-symbol, +.hljs-bullet { + color: #7b9726; +} + +/* Atelier-Forest Blue */ +.hljs-title, +.hljs-section { + color: #407ee7; +} + +/* Atelier-Forest Purple */ +.hljs-keyword, +.hljs-selector-tag { + color: #6666ea; +} + +.hljs { + display: block; + overflow-x: auto; + background: #1b1918; + color: #a8a19f; + padding: 0.5em; +} + +.hljs-emphasis { + font-style: italic; +} + +.hljs-strong { + font-weight: bold; +} diff --git a/lib/highlight/styles/atelier-forest-light.css b/lib/highlight/styles/atelier-forest-light.css new file mode 100644 index 000000000..bbedde18a --- /dev/null +++ b/lib/highlight/styles/atelier-forest-light.css @@ -0,0 +1,69 @@ +/* Base16 Atelier Forest Light - Theme */ +/* by Bram de Haan (http://atelierbram.github.io/syntax-highlighting/atelier-schemes/forest) */ +/* Original Base16 color scheme by Chris Kempson (https://github.com/chriskempson/base16) */ + +/* Atelier-Forest Comment */ +.hljs-comment, +.hljs-quote { + color: #766e6b; +} + +/* Atelier-Forest Red */ +.hljs-variable, +.hljs-template-variable, +.hljs-attribute, +.hljs-tag, +.hljs-name, +.hljs-regexp, +.hljs-link, +.hljs-name, +.hljs-selector-id, +.hljs-selector-class { + color: #f22c40; +} + +/* Atelier-Forest Orange */ +.hljs-number, +.hljs-meta, +.hljs-built_in, +.hljs-builtin-name, +.hljs-literal, +.hljs-type, +.hljs-params { + color: #df5320; +} + +/* Atelier-Forest Green */ +.hljs-string, +.hljs-symbol, +.hljs-bullet { + color: #7b9726; +} + +/* Atelier-Forest Blue */ +.hljs-title, +.hljs-section { + color: #407ee7; +} + +/* Atelier-Forest Purple */ +.hljs-keyword, +.hljs-selector-tag { + color: #6666ea; +} + +.hljs { + display: block; + overflow-x: auto; + background: #f1efee; + color: #68615e; + padding: 0.5em; +} + +.hljs-emphasis { + font-style: italic; +} + +.hljs-strong { + font-weight: bold; +} diff --git a/lib/highlight/styles/atelier-heath-dark.css b/lib/highlight/styles/atelier-heath-dark.css new file mode 100644 index 000000000..fe01ff721 --- /dev/null +++ b/lib/highlight/styles/atelier-heath-dark.css @@ -0,0 +1,69 @@ +/* Base16 Atelier Heath Dark - Theme */ +/* by Bram de Haan (http://atelierbram.github.io/syntax-highlighting/atelier-schemes/heath) */ +/* Original Base16 color scheme by Chris Kempson (https://github.com/chriskempson/base16) */ + +/* Atelier-Heath Comment */ +.hljs-comment, +.hljs-quote { + color: #9e8f9e; +} + +/* Atelier-Heath Red */ +.hljs-variable, +.hljs-template-variable, +.hljs-attribute, +.hljs-tag, +.hljs-name, +.hljs-regexp, +.hljs-link, +.hljs-name, +.hljs-selector-id, +.hljs-selector-class { + color: #ca402b; +} + +/* Atelier-Heath Orange */ +.hljs-number, +.hljs-meta, +.hljs-built_in, +.hljs-builtin-name, +.hljs-literal, +.hljs-type, +.hljs-params { + color: #a65926; +} + +/* Atelier-Heath Green */ +.hljs-string, +.hljs-symbol, +.hljs-bullet { + color: #918b3b; +} + +/* Atelier-Heath Blue */ +.hljs-title, +.hljs-section { + color: #516aec; +} + +/* Atelier-Heath Purple */ +.hljs-keyword, +.hljs-selector-tag { + color: #7b59c0; +} + +.hljs { + display: block; + overflow-x: auto; + background: #1b181b; + color: #ab9bab; + padding: 0.5em; +} + +.hljs-emphasis { + font-style: italic; +} + +.hljs-strong { + font-weight: bold; +} diff --git a/lib/highlight/styles/atelier-heath-light.css b/lib/highlight/styles/atelier-heath-light.css new file mode 100644 index 000000000..ee43786d1 --- /dev/null +++ b/lib/highlight/styles/atelier-heath-light.css @@ -0,0 +1,69 @@ +/* Base16 Atelier Heath Light - Theme */ +/* by Bram de Haan (http://atelierbram.github.io/syntax-highlighting/atelier-schemes/heath) */ +/* Original Base16 color scheme by Chris Kempson (https://github.com/chriskempson/base16) */ + +/* Atelier-Heath Comment */ +.hljs-comment, +.hljs-quote { + color: #776977; +} + +/* Atelier-Heath Red */ +.hljs-variable, +.hljs-template-variable, +.hljs-attribute, +.hljs-tag, +.hljs-name, +.hljs-regexp, +.hljs-link, +.hljs-name, +.hljs-selector-id, +.hljs-selector-class { + color: #ca402b; +} + +/* Atelier-Heath Orange */ +.hljs-number, +.hljs-meta, +.hljs-built_in, +.hljs-builtin-name, +.hljs-literal, +.hljs-type, +.hljs-params { + color: #a65926; +} + +/* Atelier-Heath Green */ +.hljs-string, +.hljs-symbol, +.hljs-bullet { + color: #918b3b; +} + +/* Atelier-Heath Blue */ +.hljs-title, +.hljs-section { + color: #516aec; +} + +/* Atelier-Heath Purple */ +.hljs-keyword, +.hljs-selector-tag { + color: #7b59c0; +} + +.hljs { + display: block; + overflow-x: auto; + background: #f7f3f7; + color: #695d69; + padding: 0.5em; +} + +.hljs-emphasis { + font-style: italic; +} + +.hljs-strong { + font-weight: bold; +} diff --git a/lib/highlight/styles/atelier-lakeside-dark.css b/lib/highlight/styles/atelier-lakeside-dark.css new file mode 100644 index 000000000..a937d3bf5 --- /dev/null +++ b/lib/highlight/styles/atelier-lakeside-dark.css @@ -0,0 +1,69 @@ +/* Base16 Atelier Lakeside Dark - Theme */ +/* by Bram de Haan (http://atelierbram.github.io/syntax-highlighting/atelier-schemes/lakeside) */ +/* Original Base16 color scheme by Chris Kempson (https://github.com/chriskempson/base16) */ + +/* Atelier-Lakeside Comment */ +.hljs-comment, +.hljs-quote { + color: #7195a8; +} + +/* Atelier-Lakeside Red */ +.hljs-variable, +.hljs-template-variable, +.hljs-attribute, +.hljs-tag, +.hljs-name, +.hljs-regexp, +.hljs-link, +.hljs-name, +.hljs-selector-id, +.hljs-selector-class { + color: #d22d72; +} + +/* Atelier-Lakeside Orange */ +.hljs-number, +.hljs-meta, +.hljs-built_in, +.hljs-builtin-name, +.hljs-literal, +.hljs-type, +.hljs-params { + color: #935c25; +} + +/* Atelier-Lakeside Green */ +.hljs-string, +.hljs-symbol, +.hljs-bullet { + color: #568c3b; +} + +/* Atelier-Lakeside Blue */ +.hljs-title, +.hljs-section { + color: #257fad; +} + +/* Atelier-Lakeside Purple */ +.hljs-keyword, +.hljs-selector-tag { + color: #6b6bb8; +} + +.hljs { + display: block; + overflow-x: auto; + background: #161b1d; + color: #7ea2b4; + padding: 0.5em; +} + +.hljs-emphasis { + font-style: italic; +} + +.hljs-strong { + font-weight: bold; +} diff --git a/lib/highlight/styles/atelier-lakeside-light.css b/lib/highlight/styles/atelier-lakeside-light.css new file mode 100644 index 000000000..6c7e8f9ef --- /dev/null +++ b/lib/highlight/styles/atelier-lakeside-light.css @@ -0,0 +1,69 @@ +/* Base16 Atelier Lakeside Light - Theme */ +/* by Bram de Haan (http://atelierbram.github.io/syntax-highlighting/atelier-schemes/lakeside) */ +/* Original Base16 color scheme by Chris Kempson (https://github.com/chriskempson/base16) */ + +/* Atelier-Lakeside Comment */ +.hljs-comment, +.hljs-quote { + color: #5a7b8c; +} + +/* Atelier-Lakeside Red */ +.hljs-variable, +.hljs-template-variable, +.hljs-attribute, +.hljs-tag, +.hljs-name, +.hljs-regexp, +.hljs-link, +.hljs-name, +.hljs-selector-id, +.hljs-selector-class { + color: #d22d72; +} + +/* Atelier-Lakeside Orange */ +.hljs-number, +.hljs-meta, +.hljs-built_in, +.hljs-builtin-name, +.hljs-literal, +.hljs-type, +.hljs-params { + color: #935c25; +} + +/* Atelier-Lakeside Green */ +.hljs-string, +.hljs-symbol, +.hljs-bullet { + color: #568c3b; +} + +/* Atelier-Lakeside Blue */ +.hljs-title, +.hljs-section { + color: #257fad; +} + +/* Atelier-Lakeside Purple */ +.hljs-keyword, +.hljs-selector-tag { + color: #6b6bb8; +} + +.hljs { + display: block; + overflow-x: auto; + background: #ebf8ff; + color: #516d7b; + padding: 0.5em; +} + +.hljs-emphasis { + font-style: italic; +} + +.hljs-strong { + font-weight: bold; +} diff --git a/lib/highlight/styles/atelier-plateau-dark.css b/lib/highlight/styles/atelier-plateau-dark.css new file mode 100644 index 000000000..3bb052693 --- /dev/null +++ b/lib/highlight/styles/atelier-plateau-dark.css @@ -0,0 +1,84 @@ +/* Base16 Atelier Plateau Dark - Theme */ +/* by Bram de Haan (http://atelierbram.github.io/syntax-highlighting/atelier-schemes/plateau) */ +/* Original Base16 color scheme by Chris Kempson (https://github.com/chriskempson/base16) */ + +/* Atelier-Plateau Comment */ +.hljs-comment, +.hljs-quote { + color: #7e7777; +} + +/* Atelier-Plateau Red */ +.hljs-variable, +.hljs-template-variable, +.hljs-attribute, +.hljs-tag, +.hljs-name, +.hljs-regexp, +.hljs-link, +.hljs-name, +.hljs-selector-id, +.hljs-selector-class { + color: #ca4949; +} + +/* Atelier-Plateau Orange */ +.hljs-number, +.hljs-meta, +.hljs-built_in, +.hljs-builtin-name, +.hljs-literal, +.hljs-type, +.hljs-params { + color: #b45a3c; +} + +/* Atelier-Plateau Green */ +.hljs-string, +.hljs-symbol, +.hljs-bullet { + color: #4b8b8b; +} + +/* Atelier-Plateau Blue */ +.hljs-title, +.hljs-section { + color: #7272ca; +} + +/* Atelier-Plateau Purple */ +.hljs-keyword, +.hljs-selector-tag { + color: #8464c4; +} + +.hljs-deletion, +.hljs-addition { + color: #1b1818; + display: inline-block; + width: 100%; +} + +.hljs-deletion { + background-color: #ca4949; +} + +.hljs-addition { + background-color: #4b8b8b; +} + +.hljs { + display: block; + overflow-x: auto; + background: #1b1818; + color: #8a8585; + padding: 0.5em; +} + +.hljs-emphasis { + font-style: italic; +} + +.hljs-strong { + font-weight: bold; +} diff --git a/lib/highlight/styles/atelier-plateau-light.css b/lib/highlight/styles/atelier-plateau-light.css new file mode 100644 index 000000000..5f0222bec --- /dev/null +++ b/lib/highlight/styles/atelier-plateau-light.css @@ -0,0 +1,84 @@ +/* Base16 Atelier Plateau Light - Theme */ +/* by Bram de Haan (http://atelierbram.github.io/syntax-highlighting/atelier-schemes/plateau) */ +/* Original Base16 color scheme by Chris Kempson (https://github.com/chriskempson/base16) */ + +/* Atelier-Plateau Comment */ +.hljs-comment, +.hljs-quote { + color: #655d5d; +} + +/* Atelier-Plateau Red */ +.hljs-variable, +.hljs-template-variable, +.hljs-attribute, +.hljs-tag, +.hljs-name, +.hljs-regexp, +.hljs-link, +.hljs-name, +.hljs-selector-id, +.hljs-selector-class { + color: #ca4949; +} + +/* Atelier-Plateau Orange */ +.hljs-number, +.hljs-meta, +.hljs-built_in, +.hljs-builtin-name, +.hljs-literal, +.hljs-type, +.hljs-params { + color: #b45a3c; +} + +/* Atelier-Plateau Green */ +.hljs-string, +.hljs-symbol, +.hljs-bullet { + color: #4b8b8b; +} + +/* Atelier-Plateau Blue */ +.hljs-title, +.hljs-section { + color: #7272ca; +} + +/* Atelier-Plateau Purple */ +.hljs-keyword, +.hljs-selector-tag { + color: #8464c4; +} + +.hljs-deletion, +.hljs-addition { + color: #1b1818; + display: inline-block; + width: 100%; +} + +.hljs-deletion { + background-color: #ca4949; +} + +.hljs-addition { + background-color: #4b8b8b; +} + +.hljs { + display: block; + overflow-x: auto; + background: #f4ecec; + color: #585050; + padding: 0.5em; +} + +.hljs-emphasis { + font-style: italic; +} + +.hljs-strong { + font-weight: bold; +} diff --git a/lib/highlight/styles/atelier-savanna-dark.css b/lib/highlight/styles/atelier-savanna-dark.css new file mode 100644 index 000000000..38f831431 --- /dev/null +++ b/lib/highlight/styles/atelier-savanna-dark.css @@ -0,0 +1,84 @@ +/* Base16 Atelier Savanna Dark - Theme */ +/* by Bram de Haan (http://atelierbram.github.io/syntax-highlighting/atelier-schemes/savanna) */ +/* Original Base16 color scheme by Chris Kempson (https://github.com/chriskempson/base16) */ + +/* Atelier-Savanna Comment */ +.hljs-comment, +.hljs-quote { + color: #78877d; +} + +/* Atelier-Savanna Red */ +.hljs-variable, +.hljs-template-variable, +.hljs-attribute, +.hljs-tag, +.hljs-name, +.hljs-regexp, +.hljs-link, +.hljs-name, +.hljs-selector-id, +.hljs-selector-class { + color: #b16139; +} + +/* Atelier-Savanna Orange */ +.hljs-number, +.hljs-meta, +.hljs-built_in, +.hljs-builtin-name, +.hljs-literal, +.hljs-type, +.hljs-params { + color: #9f713c; +} + +/* Atelier-Savanna Green */ +.hljs-string, +.hljs-symbol, +.hljs-bullet { + color: #489963; +} + +/* Atelier-Savanna Blue */ +.hljs-title, +.hljs-section { + color: #478c90; +} + +/* Atelier-Savanna Purple */ +.hljs-keyword, +.hljs-selector-tag { + color: #55859b; +} + +.hljs-deletion, +.hljs-addition { + color: #171c19; + display: inline-block; + width: 100%; +} + +.hljs-deletion { + background-color: #b16139; +} + +.hljs-addition { + background-color: #489963; +} + +.hljs { + display: block; + overflow-x: auto; + background: #171c19; + color: #87928a; + padding: 0.5em; +} + +.hljs-emphasis { + font-style: italic; +} + +.hljs-strong { + font-weight: bold; +} diff --git a/lib/highlight/styles/atelier-savanna-light.css b/lib/highlight/styles/atelier-savanna-light.css new file mode 100644 index 000000000..1ccd7c685 --- /dev/null +++ b/lib/highlight/styles/atelier-savanna-light.css @@ -0,0 +1,84 @@ +/* Base16 Atelier Savanna Light - Theme */ +/* by Bram de Haan (http://atelierbram.github.io/syntax-highlighting/atelier-schemes/savanna) */ +/* Original Base16 color scheme by Chris Kempson (https://github.com/chriskempson/base16) */ + +/* Atelier-Savanna Comment */ +.hljs-comment, +.hljs-quote { + color: #5f6d64; +} + +/* Atelier-Savanna Red */ +.hljs-variable, +.hljs-template-variable, +.hljs-attribute, +.hljs-tag, +.hljs-name, +.hljs-regexp, +.hljs-link, +.hljs-name, +.hljs-selector-id, +.hljs-selector-class { + color: #b16139; +} + +/* Atelier-Savanna Orange */ +.hljs-number, +.hljs-meta, +.hljs-built_in, +.hljs-builtin-name, +.hljs-literal, +.hljs-type, +.hljs-params { + color: #9f713c; +} + +/* Atelier-Savanna Green */ +.hljs-string, +.hljs-symbol, +.hljs-bullet { + color: #489963; +} + +/* Atelier-Savanna Blue */ +.hljs-title, +.hljs-section { + color: #478c90; +} + +/* Atelier-Savanna Purple */ +.hljs-keyword, +.hljs-selector-tag { + color: #55859b; +} + +.hljs-deletion, +.hljs-addition { + color: #171c19; + display: inline-block; + width: 100%; +} + +.hljs-deletion { + background-color: #b16139; +} + +.hljs-addition { + background-color: #489963; +} + +.hljs { + display: block; + overflow-x: auto; + background: #ecf4ee; + color: #526057; + padding: 0.5em; +} + +.hljs-emphasis { + font-style: italic; +} + +.hljs-strong { + font-weight: bold; +} diff --git a/lib/highlight/styles/atelier-seaside-dark.css b/lib/highlight/styles/atelier-seaside-dark.css new file mode 100644 index 000000000..df29949c6 --- /dev/null +++ b/lib/highlight/styles/atelier-seaside-dark.css @@ -0,0 +1,69 @@ +/* Base16 Atelier Seaside Dark - Theme */ +/* by Bram de Haan (http://atelierbram.github.io/syntax-highlighting/atelier-schemes/seaside) */ +/* Original Base16 color scheme by Chris Kempson (https://github.com/chriskempson/base16) */ + +/* Atelier-Seaside Comment */ +.hljs-comment, +.hljs-quote { + color: #809980; +} + +/* Atelier-Seaside Red */ +.hljs-variable, +.hljs-template-variable, +.hljs-attribute, +.hljs-tag, +.hljs-name, +.hljs-regexp, +.hljs-link, +.hljs-name, +.hljs-selector-id, +.hljs-selector-class { + color: #e6193c; +} + +/* Atelier-Seaside Orange */ +.hljs-number, +.hljs-meta, +.hljs-built_in, +.hljs-builtin-name, +.hljs-literal, +.hljs-type, +.hljs-params { + color: #87711d; +} + +/* Atelier-Seaside Green */ +.hljs-string, +.hljs-symbol, +.hljs-bullet { + color: #29a329; +} + +/* Atelier-Seaside Blue */ +.hljs-title, +.hljs-section { + color: #3d62f5; +} + +/* Atelier-Seaside Purple */ +.hljs-keyword, +.hljs-selector-tag { + color: #ad2bee; +} + +.hljs { + display: block; + overflow-x: auto; + background: #131513; + color: #8ca68c; + padding: 0.5em; +} + +.hljs-emphasis { + font-style: italic; +} + +.hljs-strong { + font-weight: bold; +} diff --git a/lib/highlight/styles/atelier-seaside-light.css b/lib/highlight/styles/atelier-seaside-light.css new file mode 100644 index 000000000..9d960f29f --- /dev/null +++ b/lib/highlight/styles/atelier-seaside-light.css @@ -0,0 +1,69 @@ +/* Base16 Atelier Seaside Light - Theme */ +/* by Bram de Haan (http://atelierbram.github.io/syntax-highlighting/atelier-schemes/seaside) */ +/* Original Base16 color scheme by Chris Kempson (https://github.com/chriskempson/base16) */ + +/* Atelier-Seaside Comment */ +.hljs-comment, +.hljs-quote { + color: #687d68; +} + +/* Atelier-Seaside Red */ +.hljs-variable, +.hljs-template-variable, +.hljs-attribute, +.hljs-tag, +.hljs-name, +.hljs-regexp, +.hljs-link, +.hljs-name, +.hljs-selector-id, +.hljs-selector-class { + color: #e6193c; +} + +/* Atelier-Seaside Orange */ +.hljs-number, +.hljs-meta, +.hljs-built_in, +.hljs-builtin-name, +.hljs-literal, +.hljs-type, +.hljs-params { + color: #87711d; +} + +/* Atelier-Seaside Green */ +.hljs-string, +.hljs-symbol, +.hljs-bullet { + color: #29a329; +} + +/* Atelier-Seaside Blue */ +.hljs-title, +.hljs-section { + color: #3d62f5; +} + +/* Atelier-Seaside Purple */ +.hljs-keyword, +.hljs-selector-tag { + color: #ad2bee; +} + +.hljs { + display: block; + overflow-x: auto; + background: #f4fbf4; + color: #5e6e5e; + padding: 0.5em; +} + +.hljs-emphasis { + font-style: italic; +} + +.hljs-strong { + font-weight: bold; +} diff --git a/lib/highlight/styles/atelier-sulphurpool-dark.css b/lib/highlight/styles/atelier-sulphurpool-dark.css new file mode 100644 index 000000000..c2ab7938d --- /dev/null +++ b/lib/highlight/styles/atelier-sulphurpool-dark.css @@ -0,0 +1,69 @@ +/* Base16 Atelier Sulphurpool Dark - Theme */ +/* by Bram de Haan (http://atelierbram.github.io/syntax-highlighting/atelier-schemes/sulphurpool) */ +/* Original Base16 color scheme by Chris Kempson (https://github.com/chriskempson/base16) */ + +/* Atelier-Sulphurpool Comment */ +.hljs-comment, +.hljs-quote { + color: #898ea4; +} + +/* Atelier-Sulphurpool Red */ +.hljs-variable, +.hljs-template-variable, +.hljs-attribute, +.hljs-tag, +.hljs-name, +.hljs-regexp, +.hljs-link, +.hljs-name, +.hljs-selector-id, +.hljs-selector-class { + color: #c94922; +} + +/* Atelier-Sulphurpool Orange */ +.hljs-number, +.hljs-meta, +.hljs-built_in, +.hljs-builtin-name, +.hljs-literal, +.hljs-type, +.hljs-params { + color: #c76b29; +} + +/* Atelier-Sulphurpool Green */ +.hljs-string, +.hljs-symbol, +.hljs-bullet { + color: #ac9739; +} + +/* Atelier-Sulphurpool Blue */ +.hljs-title, +.hljs-section { + color: #3d8fd1; +} + +/* Atelier-Sulphurpool Purple */ +.hljs-keyword, +.hljs-selector-tag { + color: #6679cc; +} + +.hljs { + display: block; + overflow-x: auto; + background: #202746; + color: #979db4; + padding: 0.5em; +} + +.hljs-emphasis { + font-style: italic; +} + +.hljs-strong { + font-weight: bold; +} diff --git a/lib/highlight/styles/atelier-sulphurpool-light.css b/lib/highlight/styles/atelier-sulphurpool-light.css new file mode 100644 index 000000000..96c47d086 --- /dev/null +++ b/lib/highlight/styles/atelier-sulphurpool-light.css @@ -0,0 +1,69 @@ +/* Base16 Atelier Sulphurpool Light - Theme */ +/* by Bram de Haan (http://atelierbram.github.io/syntax-highlighting/atelier-schemes/sulphurpool) */ +/* Original Base16 color scheme by Chris Kempson (https://github.com/chriskempson/base16) */ + +/* Atelier-Sulphurpool Comment */ +.hljs-comment, +.hljs-quote { + color: #6b7394; +} + +/* Atelier-Sulphurpool Red */ +.hljs-variable, +.hljs-template-variable, +.hljs-attribute, +.hljs-tag, +.hljs-name, +.hljs-regexp, +.hljs-link, +.hljs-name, +.hljs-selector-id, +.hljs-selector-class { + color: #c94922; +} + +/* Atelier-Sulphurpool Orange */ +.hljs-number, +.hljs-meta, +.hljs-built_in, +.hljs-builtin-name, +.hljs-literal, +.hljs-type, +.hljs-params { + color: #c76b29; +} + +/* Atelier-Sulphurpool Green */ +.hljs-string, +.hljs-symbol, +.hljs-bullet { + color: #ac9739; +} + +/* Atelier-Sulphurpool Blue */ +.hljs-title, +.hljs-section { + color: #3d8fd1; +} + +/* Atelier-Sulphurpool Purple */ +.hljs-keyword, +.hljs-selector-tag { + color: #6679cc; +} + +.hljs { + display: block; + overflow-x: auto; + background: #f5f7ff; + color: #5e6687; + padding: 0.5em; +} + +.hljs-emphasis { + font-style: italic; +} + +.hljs-strong { + font-weight: bold; +} diff --git a/lib/highlight/styles/atom-one-dark.css b/lib/highlight/styles/atom-one-dark.css new file mode 100644 index 000000000..1616aafe3 --- /dev/null +++ b/lib/highlight/styles/atom-one-dark.css @@ -0,0 +1,96 @@ +/* + +Atom One Dark by Daniel Gamage +Original One Dark Syntax theme from https://github.com/atom/one-dark-syntax + +base: #282c34 +mono-1: #abb2bf +mono-2: #818896 +mono-3: #5c6370 +hue-1: #56b6c2 +hue-2: #61aeee +hue-3: #c678dd +hue-4: #98c379 +hue-5: #e06c75 +hue-5-2: #be5046 +hue-6: #d19a66 +hue-6-2: #e6c07b + +*/ + +.hljs { + display: block; + overflow-x: auto; + padding: 0.5em; + color: #abb2bf; + background: #282c34; +} + +.hljs-comment, +.hljs-quote { + color: #5c6370; + font-style: italic; +} + +.hljs-doctag, +.hljs-keyword, +.hljs-formula { + color: #c678dd; +} + +.hljs-section, +.hljs-name, +.hljs-selector-tag, +.hljs-deletion, +.hljs-subst { + color: #e06c75; +} + +.hljs-literal { + color: #56b6c2; +} + +.hljs-string, +.hljs-regexp, +.hljs-addition, +.hljs-attribute, +.hljs-meta-string { + color: #98c379; +} + +.hljs-built_in, +.hljs-class .hljs-title { + color: #e6c07b; +} + +.hljs-attr, +.hljs-variable, +.hljs-template-variable, +.hljs-type, +.hljs-selector-class, +.hljs-selector-attr, +.hljs-selector-pseudo, +.hljs-number { + color: #d19a66; +} + +.hljs-symbol, +.hljs-bullet, +.hljs-link, +.hljs-meta, +.hljs-selector-id, +.hljs-title { + color: #61aeee; +} + +.hljs-emphasis { + font-style: italic; +} + +.hljs-strong { + font-weight: bold; +} + +.hljs-link { + text-decoration: underline; +} diff --git a/lib/highlight/styles/atom-one-light.css b/lib/highlight/styles/atom-one-light.css new file mode 100644 index 000000000..d5bd1d2a9 --- /dev/null +++ b/lib/highlight/styles/atom-one-light.css @@ -0,0 +1,96 @@ +/* + +Atom One Light by Daniel Gamage +Original One Light Syntax theme from https://github.com/atom/one-light-syntax + +base: #fafafa +mono-1: #383a42 +mono-2: #686b77 +mono-3: #a0a1a7 +hue-1: #0184bb +hue-2: #4078f2 +hue-3: #a626a4 +hue-4: #50a14f +hue-5: #e45649 +hue-5-2: #c91243 +hue-6: #986801 +hue-6-2: #c18401 + +*/ + +.hljs { + display: block; + overflow-x: auto; + padding: 0.5em; + color: #383a42; + background: #fafafa; +} + +.hljs-comment, +.hljs-quote { + color: #a0a1a7; + font-style: italic; +} + +.hljs-doctag, +.hljs-keyword, +.hljs-formula { + color: #a626a4; +} + +.hljs-section, +.hljs-name, +.hljs-selector-tag, +.hljs-deletion, +.hljs-subst { + color: #e45649; +} + +.hljs-literal { + color: #0184bb; +} + +.hljs-string, +.hljs-regexp, +.hljs-addition, +.hljs-attribute, +.hljs-meta-string { + color: #50a14f; +} + +.hljs-built_in, +.hljs-class .hljs-title { + color: #c18401; +} + +.hljs-attr, +.hljs-variable, +.hljs-template-variable, +.hljs-type, +.hljs-selector-class, +.hljs-selector-attr, +.hljs-selector-pseudo, +.hljs-number { + color: #986801; +} + +.hljs-symbol, +.hljs-bullet, +.hljs-link, +.hljs-meta, +.hljs-selector-id, +.hljs-title { + color: #4078f2; +} + +.hljs-emphasis { + font-style: italic; +} + +.hljs-strong { + font-weight: bold; +} + +.hljs-link { + text-decoration: underline; +} diff --git a/lib/highlight/styles/brown-paper.css b/lib/highlight/styles/brown-paper.css new file mode 100644 index 000000000..f0197b924 --- /dev/null +++ b/lib/highlight/styles/brown-paper.css @@ -0,0 +1,64 @@ +/* + +Brown Paper style from goldblog.com.ua (c) Zaripov Yura + +*/ + +.hljs { + display: block; + overflow-x: auto; + padding: 0.5em; + background:#b7a68e url(./brown-papersq.png); +} + +.hljs-keyword, +.hljs-selector-tag, +.hljs-literal { + color:#005599; + font-weight:bold; +} + +.hljs, +.hljs-subst { + color: #363c69; +} + +.hljs-string, +.hljs-title, +.hljs-section, +.hljs-type, +.hljs-attribute, +.hljs-symbol, +.hljs-bullet, +.hljs-built_in, +.hljs-addition, +.hljs-variable, +.hljs-template-tag, +.hljs-template-variable, +.hljs-link, +.hljs-name { + color: #2c009f; +} + +.hljs-comment, +.hljs-quote, +.hljs-meta, +.hljs-deletion { + color: #802022; +} + +.hljs-keyword, +.hljs-selector-tag, +.hljs-literal, +.hljs-doctag, +.hljs-title, +.hljs-section, +.hljs-type, +.hljs-name, +.hljs-strong { + font-weight: bold; +} + +.hljs-emphasis { + font-style: italic; +} diff --git a/lib/highlight/styles/brown-papersq.png b/lib/highlight/styles/brown-papersq.png new file mode 100644 index 000000000..3813903db Binary files /dev/null and b/lib/highlight/styles/brown-papersq.png differ diff --git a/lib/highlight/styles/codepen-embed.css b/lib/highlight/styles/codepen-embed.css new file mode 100644 index 000000000..195c4a078 --- /dev/null +++ b/lib/highlight/styles/codepen-embed.css @@ -0,0 +1,60 @@ +/* + codepen.io Embed Theme + Author: Justin Perry + Original theme - https://github.com/chriskempson/tomorrow-theme +*/ + +.hljs { + display: block; + overflow-x: auto; + padding: 0.5em; + background: #222; + color: #fff; +} + +.hljs-comment, +.hljs-quote { + color: #777; +} + +.hljs-variable, +.hljs-template-variable, +.hljs-tag, +.hljs-regexp, +.hljs-meta, +.hljs-number, +.hljs-built_in, +.hljs-builtin-name, +.hljs-literal, +.hljs-params, +.hljs-symbol, +.hljs-bullet, +.hljs-link, +.hljs-deletion { + color: #ab875d; +} + +.hljs-section, +.hljs-title, +.hljs-name, +.hljs-selector-id, +.hljs-selector-class, +.hljs-type, +.hljs-attribute { + color: #9b869b; +} + +.hljs-string, +.hljs-keyword, +.hljs-selector-tag, +.hljs-addition { + color: #8f9c6c; +} + +.hljs-emphasis { + font-style: italic; +} + +.hljs-strong { + font-weight: bold; +} diff --git a/lib/highlight/styles/color-brewer.css b/lib/highlight/styles/color-brewer.css new file mode 100644 index 000000000..7934d986a --- /dev/null +++ b/lib/highlight/styles/color-brewer.css @@ -0,0 +1,71 @@ +/* + +Colorbrewer theme +Original: https://github.com/mbostock/colorbrewer-theme (c) Mike Bostock +Ported by Fabrício Tavares de Oliveira + +*/ + +.hljs { + display: block; + overflow-x: auto; + padding: 0.5em; + background: #fff; +} + +.hljs, +.hljs-subst { + color: #000; +} + +.hljs-string, +.hljs-meta, +.hljs-symbol, +.hljs-template-tag, +.hljs-template-variable, +.hljs-addition { + color: #756bb1; +} + +.hljs-comment, +.hljs-quote { + color: #636363; +} + +.hljs-number, +.hljs-regexp, +.hljs-literal, +.hljs-bullet, +.hljs-link { + color: #31a354; +} + +.hljs-deletion, +.hljs-variable { + color: #88f; +} + + + +.hljs-keyword, +.hljs-selector-tag, +.hljs-title, +.hljs-section, +.hljs-built_in, +.hljs-doctag, +.hljs-type, +.hljs-tag, +.hljs-name, +.hljs-selector-id, +.hljs-selector-class, +.hljs-strong { + color: #3182bd; +} + +.hljs-emphasis { + font-style: italic; +} + +.hljs-attribute { + color: #e6550d; +} diff --git a/lib/highlight/styles/darcula.css b/lib/highlight/styles/darcula.css new file mode 100644 index 000000000..be182d0b5 --- /dev/null +++ b/lib/highlight/styles/darcula.css @@ -0,0 +1,77 @@ +/* + +Darcula color scheme from the JetBrains family of IDEs + +*/ + + +.hljs { + display: block; + overflow-x: auto; + padding: 0.5em; + background: #2b2b2b; +} + +.hljs { + color: #bababa; +} + +.hljs-strong, +.hljs-emphasis { + color: #a8a8a2; +} + +.hljs-bullet, +.hljs-quote, +.hljs-link, +.hljs-number, +.hljs-regexp, +.hljs-literal { + color: #6896ba; +} + +.hljs-code, +.hljs-selector-class { + color: #a6e22e; +} + +.hljs-emphasis { + font-style: italic; +} + +.hljs-keyword, +.hljs-selector-tag, +.hljs-section, +.hljs-attribute, +.hljs-name, +.hljs-variable { + color: #cb7832; +} + +.hljs-params { + color: #b9b9b9; +} + +.hljs-string { + color: #6a8759; +} + +.hljs-subst, +.hljs-type, +.hljs-built_in, +.hljs-builtin-name, +.hljs-symbol, +.hljs-selector-id, +.hljs-selector-attr, +.hljs-selector-pseudo, +.hljs-template-tag, +.hljs-template-variable, +.hljs-addition { + color: #e0c46c; +} + +.hljs-comment, +.hljs-deletion, +.hljs-meta { + color: #7f7f7f; +} diff --git a/lib/highlight/styles/dark.css b/lib/highlight/styles/dark.css new file mode 100644 index 000000000..b4724f5f5 --- /dev/null +++ b/lib/highlight/styles/dark.css @@ -0,0 +1,63 @@ +/* + +Dark style from softwaremaniacs.org (c) Ivan Sagalaev + +*/ + +.hljs { + display: block; + overflow-x: auto; + padding: 0.5em; + background: #444; +} + +.hljs-keyword, +.hljs-selector-tag, +.hljs-literal, +.hljs-section, +.hljs-link { + color: white; +} + +.hljs, +.hljs-subst { + color: #ddd; +} + +.hljs-string, +.hljs-title, +.hljs-name, +.hljs-type, +.hljs-attribute, +.hljs-symbol, +.hljs-bullet, +.hljs-built_in, +.hljs-addition, +.hljs-variable, +.hljs-template-tag, +.hljs-template-variable { + color: #d88; +} + +.hljs-comment, +.hljs-quote, +.hljs-deletion, +.hljs-meta { + color: #777; +} + +.hljs-keyword, +.hljs-selector-tag, +.hljs-literal, +.hljs-title, +.hljs-section, +.hljs-doctag, +.hljs-type, +.hljs-name, +.hljs-strong { + font-weight: bold; +} + +.hljs-emphasis { + font-style: italic; +} diff --git a/lib/highlight/styles/darkula.css b/lib/highlight/styles/darkula.css new file mode 100644 index 000000000..f4646c3c5 --- /dev/null +++ b/lib/highlight/styles/darkula.css @@ -0,0 +1,6 @@ +/* + Deprecated due to a typo in the name and left here for compatibility purpose only. + Please use darcula.css instead. +*/ + +@import url('darcula.css'); diff --git a/lib/highlight/styles/default.css b/lib/highlight/styles/default.css new file mode 100644 index 000000000..f1bfade31 --- /dev/null +++ b/lib/highlight/styles/default.css @@ -0,0 +1,99 @@ +/* + +Original highlight.js style (c) Ivan Sagalaev + +*/ + +.hljs { + display: block; + overflow-x: auto; + padding: 0.5em; + background: #F0F0F0; +} + + +/* Base color: saturation 0; */ + +.hljs, +.hljs-subst { + color: #444; +} + +.hljs-comment { + color: #888888; +} + +.hljs-keyword, +.hljs-attribute, +.hljs-selector-tag, +.hljs-meta-keyword, +.hljs-doctag, +.hljs-name { + font-weight: bold; +} + + +/* User color: hue: 0 */ + +.hljs-type, +.hljs-string, +.hljs-number, +.hljs-selector-id, +.hljs-selector-class, +.hljs-quote, +.hljs-template-tag, +.hljs-deletion { + color: #880000; +} + +.hljs-title, +.hljs-section { + color: #880000; + font-weight: bold; +} + +.hljs-regexp, +.hljs-symbol, +.hljs-variable, +.hljs-template-variable, +.hljs-link, +.hljs-selector-attr, +.hljs-selector-pseudo { + color: #BC6060; +} + + +/* Language color: hue: 90; */ + +.hljs-literal { + color: #78A960; +} + +.hljs-built_in, +.hljs-bullet, +.hljs-code, +.hljs-addition { + color: #397300; +} + + +/* Meta color: hue: 200 */ + +.hljs-meta { + color: #1f7199; +} + +.hljs-meta-string { + color: #4d99bf; +} + + +/* Misc effects */ + +.hljs-emphasis { + font-style: italic; +} + +.hljs-strong { + font-weight: bold; +} diff --git a/lib/highlight/styles/docco.css b/lib/highlight/styles/docco.css new file mode 100644 index 000000000..db366be37 --- /dev/null +++ b/lib/highlight/styles/docco.css @@ -0,0 +1,97 @@ +/* +Docco style used in http://jashkenas.github.com/docco/ converted by Simon Madine (@thingsinjars) +*/ + +.hljs { + display: block; + overflow-x: auto; + padding: 0.5em; + color: #000; + background: #f8f8ff; +} + +.hljs-comment, +.hljs-quote { + color: #408080; + font-style: italic; +} + +.hljs-keyword, +.hljs-selector-tag, +.hljs-literal, +.hljs-subst { + color: #954121; +} + +.hljs-number { + color: #40a070; +} + +.hljs-string, +.hljs-doctag { + color: #219161; +} + +.hljs-selector-id, +.hljs-selector-class, +.hljs-section, +.hljs-type { + color: #19469d; +} + +.hljs-params { + color: #00f; +} + +.hljs-title { + color: #458; + font-weight: bold; +} + +.hljs-tag, +.hljs-name, +.hljs-attribute { + color: #000080; + font-weight: normal; +} + +.hljs-variable, +.hljs-template-variable { + color: #008080; +} + +.hljs-regexp, +.hljs-link { + color: #b68; +} + +.hljs-symbol, +.hljs-bullet { + color: #990073; +} + +.hljs-built_in, +.hljs-builtin-name { + color: #0086b3; +} + +.hljs-meta { + color: #999; + font-weight: bold; +} + +.hljs-deletion { + background: #fdd; +} + +.hljs-addition { + background: #dfd; +} + +.hljs-emphasis { + font-style: italic; +} + +.hljs-strong { + font-weight: bold; +} diff --git a/lib/highlight/styles/dracula.css b/lib/highlight/styles/dracula.css new file mode 100644 index 000000000..d591db680 --- /dev/null +++ b/lib/highlight/styles/dracula.css @@ -0,0 +1,76 @@ +/* + +Dracula Theme v1.2.0 + +https://github.com/zenorocha/dracula-theme + +Copyright 2015, All rights reserved + +Code licensed under the MIT license +http://zenorocha.mit-license.org + +@author Éverton Ribeiro +@author Zeno Rocha + +*/ + +.hljs { + display: block; + overflow-x: auto; + padding: 0.5em; + background: #282a36; +} + +.hljs-keyword, +.hljs-selector-tag, +.hljs-literal, +.hljs-section, +.hljs-link { + color: #8be9fd; +} + +.hljs-function .hljs-keyword { + color: #ff79c6; +} + +.hljs, +.hljs-subst { + color: #f8f8f2; +} + +.hljs-string, +.hljs-title, +.hljs-name, +.hljs-type, +.hljs-attribute, +.hljs-symbol, +.hljs-bullet, +.hljs-addition, +.hljs-variable, +.hljs-template-tag, +.hljs-template-variable { + color: #f1fa8c; +} + +.hljs-comment, +.hljs-quote, +.hljs-deletion, +.hljs-meta { + color: #6272a4; +} + +.hljs-keyword, +.hljs-selector-tag, +.hljs-literal, +.hljs-title, +.hljs-section, +.hljs-doctag, +.hljs-type, +.hljs-name, +.hljs-strong { + font-weight: bold; +} + +.hljs-emphasis { + font-style: italic; +} diff --git a/lib/highlight/styles/far.css b/lib/highlight/styles/far.css new file mode 100644 index 000000000..2b3f87b56 --- /dev/null +++ b/lib/highlight/styles/far.css @@ -0,0 +1,71 @@ +/* + +FAR Style (c) MajestiC + +*/ + +.hljs { + display: block; + overflow-x: auto; + padding: 0.5em; + background: #000080; +} + +.hljs, +.hljs-subst { + color: #0ff; +} + +.hljs-string, +.hljs-attribute, +.hljs-symbol, +.hljs-bullet, +.hljs-built_in, +.hljs-builtin-name, +.hljs-template-tag, +.hljs-template-variable, +.hljs-addition { + color: #ff0; +} + +.hljs-keyword, +.hljs-selector-tag, +.hljs-section, +.hljs-type, +.hljs-name, +.hljs-selector-id, +.hljs-selector-class, +.hljs-variable { + color: #fff; +} + +.hljs-comment, +.hljs-quote, +.hljs-doctag, +.hljs-deletion { + color: #888; +} + +.hljs-number, +.hljs-regexp, +.hljs-literal, +.hljs-link { + color: #0f0; +} + +.hljs-meta { + color: #008080; +} + +.hljs-keyword, +.hljs-selector-tag, +.hljs-title, +.hljs-section, +.hljs-name, +.hljs-strong { + font-weight: bold; +} + +.hljs-emphasis { + font-style: italic; +} diff --git a/lib/highlight/styles/foundation.css b/lib/highlight/styles/foundation.css new file mode 100644 index 000000000..f1fe64b37 --- /dev/null +++ b/lib/highlight/styles/foundation.css @@ -0,0 +1,88 @@ +/* +Description: Foundation 4 docs style for highlight.js +Author: Dan Allen +Website: http://foundation.zurb.com/docs/ +Version: 1.0 +Date: 2013-04-02 +*/ + +.hljs { + display: block; + overflow-x: auto; + padding: 0.5em; + background: #eee; color: black; +} + +.hljs-link, +.hljs-emphasis, +.hljs-attribute, +.hljs-addition { + color: #070; +} + +.hljs-emphasis { + font-style: italic; +} + +.hljs-strong, +.hljs-string, +.hljs-deletion { + color: #d14; +} + +.hljs-strong { + font-weight: bold; +} + +.hljs-quote, +.hljs-comment { + color: #998; + font-style: italic; +} + +.hljs-section, +.hljs-title { + color: #900; +} + +.hljs-class .hljs-title, +.hljs-type { + color: #458; +} + +.hljs-variable, +.hljs-template-variable { + color: #336699; +} + +.hljs-bullet { + color: #997700; +} + +.hljs-meta { + color: #3344bb; +} + +.hljs-code, +.hljs-number, +.hljs-literal, +.hljs-keyword, +.hljs-selector-tag { + color: #099; +} + +.hljs-regexp { + background-color: #fff0ff; + color: #880088; +} + +.hljs-symbol { + color: #990073; +} + +.hljs-tag, +.hljs-name, +.hljs-selector-id, +.hljs-selector-class { + color: #007700; +} diff --git a/lib/highlight/styles/github-gist.css b/lib/highlight/styles/github-gist.css new file mode 100644 index 000000000..155f0b916 --- /dev/null +++ b/lib/highlight/styles/github-gist.css @@ -0,0 +1,71 @@ +/** + * GitHub Gist Theme + * Author : Louis Barranqueiro - https://github.com/LouisBarranqueiro + */ + +.hljs { + display: block; + background: white; + padding: 0.5em; + color: #333333; + overflow-x: auto; +} + +.hljs-comment, +.hljs-meta { + color: #969896; +} + +.hljs-string, +.hljs-variable, +.hljs-template-variable, +.hljs-strong, +.hljs-emphasis, +.hljs-quote { + color: #df5000; +} + +.hljs-keyword, +.hljs-selector-tag, +.hljs-type { + color: #a71d5d; +} + +.hljs-literal, +.hljs-symbol, +.hljs-bullet, +.hljs-attribute { + color: #0086b3; +} + +.hljs-section, +.hljs-name { + color: #63a35c; +} + +.hljs-tag { + color: #333333; +} + +.hljs-title, +.hljs-attr, +.hljs-selector-id, +.hljs-selector-class, +.hljs-selector-attr, +.hljs-selector-pseudo { + color: #795da3; +} + +.hljs-addition { + color: #55a532; + background-color: #eaffea; +} + +.hljs-deletion { + color: #bd2c00; + background-color: #ffecec; +} + +.hljs-link { + text-decoration: underline; +} diff --git a/lib/highlight/styles/github.css b/lib/highlight/styles/github.css new file mode 100644 index 000000000..791932b87 --- /dev/null +++ b/lib/highlight/styles/github.css @@ -0,0 +1,99 @@ +/* + +github.com style (c) Vasily Polovnyov + +*/ + +.hljs { + display: block; + overflow-x: auto; + padding: 0.5em; + color: #333; + background: #f8f8f8; +} + +.hljs-comment, +.hljs-quote { + color: #998; + font-style: italic; +} + +.hljs-keyword, +.hljs-selector-tag, +.hljs-subst { + color: #333; + font-weight: bold; +} + +.hljs-number, +.hljs-literal, +.hljs-variable, +.hljs-template-variable, +.hljs-tag .hljs-attr { + color: #008080; +} + +.hljs-string, +.hljs-doctag { + color: #d14; +} + +.hljs-title, +.hljs-section, +.hljs-selector-id { + color: #900; + font-weight: bold; +} + +.hljs-subst { + font-weight: normal; +} + +.hljs-type, +.hljs-class .hljs-title { + color: #458; + font-weight: bold; +} + +.hljs-tag, +.hljs-name, +.hljs-attribute { + color: #000080; + font-weight: normal; +} + +.hljs-regexp, +.hljs-link { + color: #009926; +} + +.hljs-symbol, +.hljs-bullet { + color: #990073; +} + +.hljs-built_in, +.hljs-builtin-name { + color: #0086b3; +} + +.hljs-meta { + color: #999; + font-weight: bold; +} + +.hljs-deletion { + background: #fdd; +} + +.hljs-addition { + background: #dfd; +} + +.hljs-emphasis { + font-style: italic; +} + +.hljs-strong { + font-weight: bold; +} diff --git a/lib/highlight/styles/googlecode.css b/lib/highlight/styles/googlecode.css new file mode 100644 index 000000000..884ad6353 --- /dev/null +++ b/lib/highlight/styles/googlecode.css @@ -0,0 +1,89 @@ +/* + +Google Code style (c) Aahan Krish + +*/ + +.hljs { + display: block; + overflow-x: auto; + padding: 0.5em; + background: white; + color: black; +} + +.hljs-comment, +.hljs-quote { + color: #800; +} + +.hljs-keyword, +.hljs-selector-tag, +.hljs-section, +.hljs-title, +.hljs-name { + color: #008; +} + +.hljs-variable, +.hljs-template-variable { + color: #660; +} + +.hljs-string, +.hljs-selector-attr, +.hljs-selector-pseudo, +.hljs-regexp { + color: #080; +} + +.hljs-literal, +.hljs-symbol, +.hljs-bullet, +.hljs-meta, +.hljs-number, +.hljs-link { + color: #066; +} + +.hljs-title, +.hljs-doctag, +.hljs-type, +.hljs-attr, +.hljs-built_in, +.hljs-builtin-name, +.hljs-params { + color: #606; +} + +.hljs-attribute, +.hljs-subst { + color: #000; +} + +.hljs-formula { + background-color: #eee; + font-style: italic; +} + +.hljs-selector-id, +.hljs-selector-class { + color: #9B703F +} + +.hljs-addition { + background-color: #baeeba; +} + +.hljs-deletion { + background-color: #ffc8bd; +} + +.hljs-doctag, +.hljs-strong { + font-weight: bold; +} + +.hljs-emphasis { + font-style: italic; +} diff --git a/lib/highlight/styles/grayscale.css b/lib/highlight/styles/grayscale.css new file mode 100644 index 000000000..5376f3406 --- /dev/null +++ b/lib/highlight/styles/grayscale.css @@ -0,0 +1,101 @@ +/* + +grayscale style (c) MY Sun + +*/ + +.hljs { + display: block; + overflow-x: auto; + padding: 0.5em; + color: #333; + background: #fff; +} + +.hljs-comment, +.hljs-quote { + color: #777; + font-style: italic; +} + +.hljs-keyword, +.hljs-selector-tag, +.hljs-subst { + color: #333; + font-weight: bold; +} + +.hljs-number, +.hljs-literal { + color: #777; +} + +.hljs-string, +.hljs-doctag, +.hljs-formula { + color: #333; + background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAAECAYAAACp8Z5+AAAAJ0lEQVQIW2O8e/fufwYGBgZBQUEQxcCIIfDu3Tuwivfv30NUoAsAALHpFMMLqZlPAAAAAElFTkSuQmCC) repeat; +} + +.hljs-title, +.hljs-section, +.hljs-selector-id { + color: #000; + font-weight: bold; +} + +.hljs-subst { + font-weight: normal; +} + +.hljs-class .hljs-title, +.hljs-type, +.hljs-name { + color: #333; + font-weight: bold; +} + +.hljs-tag { + color: #333; +} + +.hljs-regexp { + color: #333; + background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAICAYAAADA+m62AAAAPUlEQVQYV2NkQAN37979r6yszIgujiIAU4RNMVwhuiQ6H6wQl3XI4oy4FMHcCJPHcDS6J2A2EqUQpJhohQDexSef15DBCwAAAABJRU5ErkJggg==) repeat; +} + +.hljs-symbol, +.hljs-bullet, +.hljs-link { + color: #000; + background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAKElEQVQIW2NkQAO7d+/+z4gsBhJwdXVlhAvCBECKwIIwAbhKZBUwBQA6hBpm5efZsgAAAABJRU5ErkJggg==) repeat; +} + +.hljs-built_in, +.hljs-builtin-name { + color: #000; + text-decoration: underline; +} + +.hljs-meta { + color: #999; + font-weight: bold; +} + +.hljs-deletion { + color: #fff; + background:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAADCAYAAABS3WWCAAAAE0lEQVQIW2MMDQ39zzhz5kwIAQAyxweWgUHd1AAAAABJRU5ErkJggg==) repeat; +} + +.hljs-addition { + color: #000; + background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAkAAAAJCAYAAADgkQYQAAAALUlEQVQYV2N89+7dfwYk8P79ewZBQUFkIQZGOiu6e/cuiptQHAPl0NtNxAQBAM97Oejj3Dg7AAAAAElFTkSuQmCC) repeat; +} + +.hljs-emphasis { + font-style: italic; +} + +.hljs-strong { + font-weight: bold; +} diff --git a/lib/highlight/styles/gruvbox-dark.css b/lib/highlight/styles/gruvbox-dark.css new file mode 100644 index 000000000..f563811a8 --- /dev/null +++ b/lib/highlight/styles/gruvbox-dark.css @@ -0,0 +1,108 @@ +/* + +Gruvbox style (dark) (c) Pavel Pertsev (original style at https://github.com/morhetz/gruvbox) + +*/ + +.hljs { + display: block; + overflow-x: auto; + padding: 0.5em; + background: #282828; +} + +.hljs, +.hljs-subst { + color: #ebdbb2; +} + +/* Gruvbox Red */ +.hljs-deletion, +.hljs-formula, +.hljs-keyword, +.hljs-link, +.hljs-selector-tag { + color: #fb4934; +} + +/* Gruvbox Blue */ +.hljs-built_in, +.hljs-emphasis, +.hljs-name, +.hljs-quote, +.hljs-strong, +.hljs-title, +.hljs-variable { + color: #83a598; +} + +/* Gruvbox Yellow */ +.hljs-attr, +.hljs-params, +.hljs-template-tag, +.hljs-type { + color: #fabd2f; +} + +/* Gruvbox Purple */ +.hljs-builtin-name, +.hljs-doctag, +.hljs-literal, +.hljs-number { + color: #8f3f71; +} + +/* Gruvbox Orange */ +.hljs-code, +.hljs-meta, +.hljs-regexp, +.hljs-selector-id, +.hljs-template-variable { + color: #fe8019; +} + +/* Gruvbox Green */ +.hljs-addition, +.hljs-meta-string, +.hljs-section, +.hljs-selector-attr, +.hljs-selector-class, +.hljs-string, +.hljs-symbol { + color: #b8bb26; +} + +/* Gruvbox Aqua */ +.hljs-attribute, +.hljs-bullet, +.hljs-class, +.hljs-function, +.hljs-function .hljs-keyword, +.hljs-meta-keyword, +.hljs-selector-pseudo, +.hljs-tag { + color: #8ec07c; +} + +/* Gruvbox Gray */ +.hljs-comment { + color: #928374; +} + +/* Gruvbox Purple */ +.hljs-link_label, +.hljs-literal, +.hljs-number { + color: #d3869b; +} + +.hljs-comment, +.hljs-emphasis { + font-style: italic; +} + +.hljs-section, +.hljs-strong, +.hljs-tag { + font-weight: bold; +} diff --git a/lib/highlight/styles/gruvbox-light.css b/lib/highlight/styles/gruvbox-light.css new file mode 100644 index 000000000..ff45468eb --- /dev/null +++ b/lib/highlight/styles/gruvbox-light.css @@ -0,0 +1,108 @@ +/* + +Gruvbox style (light) (c) Pavel Pertsev (original style at https://github.com/morhetz/gruvbox) + +*/ + +.hljs { + display: block; + overflow-x: auto; + padding: 0.5em; + background: #fbf1c7; +} + +.hljs, +.hljs-subst { + color: #3c3836; +} + +/* Gruvbox Red */ +.hljs-deletion, +.hljs-formula, +.hljs-keyword, +.hljs-link, +.hljs-selector-tag { + color: #9d0006; +} + +/* Gruvbox Blue */ +.hljs-built_in, +.hljs-emphasis, +.hljs-name, +.hljs-quote, +.hljs-strong, +.hljs-title, +.hljs-variable { + color: #076678; +} + +/* Gruvbox Yellow */ +.hljs-attr, +.hljs-params, +.hljs-template-tag, +.hljs-type { + color: #b57614; +} + +/* Gruvbox Purple */ +.hljs-builtin-name, +.hljs-doctag, +.hljs-literal, +.hljs-number { + color: #8f3f71; +} + +/* Gruvbox Orange */ +.hljs-code, +.hljs-meta, +.hljs-regexp, +.hljs-selector-id, +.hljs-template-variable { + color: #af3a03; +} + +/* Gruvbox Green */ +.hljs-addition, +.hljs-meta-string, +.hljs-section, +.hljs-selector-attr, +.hljs-selector-class, +.hljs-string, +.hljs-symbol { + color: #79740e; +} + +/* Gruvbox Aqua */ +.hljs-attribute, +.hljs-bullet, +.hljs-class, +.hljs-function, +.hljs-function .hljs-keyword, +.hljs-meta-keyword, +.hljs-selector-pseudo, +.hljs-tag { + color: #427b58; +} + +/* Gruvbox Gray */ +.hljs-comment { + color: #928374; +} + +/* Gruvbox Purple */ +.hljs-link_label, +.hljs-literal, +.hljs-number { + color: #8f3f71; +} + +.hljs-comment, +.hljs-emphasis { + font-style: italic; +} + +.hljs-section, +.hljs-strong, +.hljs-tag { + font-weight: bold; +} diff --git a/lib/highlight/styles/hopscotch.css b/lib/highlight/styles/hopscotch.css new file mode 100644 index 000000000..32e60d230 --- /dev/null +++ b/lib/highlight/styles/hopscotch.css @@ -0,0 +1,83 @@ +/* + * Hopscotch + * by Jan T. Sott + * https://github.com/idleberg/Hopscotch + * + * This work is licensed under the Creative Commons CC0 1.0 Universal License + */ + +/* Comment */ +.hljs-comment, +.hljs-quote { + color: #989498; +} + +/* Red */ +.hljs-variable, +.hljs-template-variable, +.hljs-attribute, +.hljs-tag, +.hljs-name, +.hljs-selector-id, +.hljs-selector-class, +.hljs-regexp, +.hljs-link, +.hljs-deletion { + color: #dd464c; +} + +/* Orange */ +.hljs-number, +.hljs-built_in, +.hljs-builtin-name, +.hljs-literal, +.hljs-type, +.hljs-params { + color: #fd8b19; +} + +/* Yellow */ +.hljs-class .hljs-title { + color: #fdcc59; +} + +/* Green */ +.hljs-string, +.hljs-symbol, +.hljs-bullet, +.hljs-addition { + color: #8fc13e; +} + +/* Aqua */ +.hljs-meta { + color: #149b93; +} + +/* Blue */ +.hljs-function, +.hljs-section, +.hljs-title { + color: #1290bf; +} + +/* Purple */ +.hljs-keyword, +.hljs-selector-tag { + color: #c85e7c; +} + +.hljs { + display: block; + background: #322931; + color: #b9b5b8; + padding: 0.5em; +} + +.hljs-emphasis { + font-style: italic; +} + +.hljs-strong { + font-weight: bold; +} diff --git a/lib/highlight/styles/hybrid.css b/lib/highlight/styles/hybrid.css new file mode 100644 index 000000000..29735a189 --- /dev/null +++ b/lib/highlight/styles/hybrid.css @@ -0,0 +1,102 @@ +/* + +vim-hybrid theme by w0ng (https://github.com/w0ng/vim-hybrid) + +*/ + +/*background color*/ +.hljs { + display: block; + overflow-x: auto; + padding: 0.5em; + background: #1d1f21; +} + +/*selection color*/ +.hljs::selection, +.hljs span::selection { + background: #373b41; +} + +.hljs::-moz-selection, +.hljs span::-moz-selection { + background: #373b41; +} + +/*foreground color*/ +.hljs { + color: #c5c8c6; +} + +/*color: fg_yellow*/ +.hljs-title, +.hljs-name { + color: #f0c674; +} + +/*color: fg_comment*/ +.hljs-comment, +.hljs-meta, +.hljs-meta .hljs-keyword { + color: #707880; +} + +/*color: fg_red*/ +.hljs-number, +.hljs-symbol, +.hljs-literal, +.hljs-deletion, +.hljs-link { + color: #cc6666 +} + +/*color: fg_green*/ +.hljs-string, +.hljs-doctag, +.hljs-addition, +.hljs-regexp, +.hljs-selector-attr, +.hljs-selector-pseudo { + color: #b5bd68; +} + +/*color: fg_purple*/ +.hljs-attribute, +.hljs-code, +.hljs-selector-id { + color: #b294bb; +} + +/*color: fg_blue*/ +.hljs-keyword, +.hljs-selector-tag, +.hljs-bullet, +.hljs-tag { + color: #81a2be; +} + +/*color: fg_aqua*/ +.hljs-subst, +.hljs-variable, +.hljs-template-tag, +.hljs-template-variable { + color: #8abeb7; +} + +/*color: fg_orange*/ +.hljs-type, +.hljs-built_in, +.hljs-builtin-name, +.hljs-quote, +.hljs-section, +.hljs-selector-class { + color: #de935f; +} + +.hljs-emphasis { + font-style: italic; +} + +.hljs-strong { + font-weight: bold; +} diff --git a/lib/highlight/styles/idea.css b/lib/highlight/styles/idea.css new file mode 100644 index 000000000..3bf1892bd --- /dev/null +++ b/lib/highlight/styles/idea.css @@ -0,0 +1,97 @@ +/* + +Intellij Idea-like styling (c) Vasily Polovnyov + +*/ + +.hljs { + display: block; + overflow-x: auto; + padding: 0.5em; + color: #000; + background: #fff; +} + +.hljs-subst, +.hljs-title { + font-weight: normal; + color: #000; +} + +.hljs-comment, +.hljs-quote { + color: #808080; + font-style: italic; +} + +.hljs-meta { + color: #808000; +} + +.hljs-tag { + background: #efefef; +} + +.hljs-section, +.hljs-name, +.hljs-literal, +.hljs-keyword, +.hljs-selector-tag, +.hljs-type, +.hljs-selector-id, +.hljs-selector-class { + font-weight: bold; + color: #000080; +} + +.hljs-attribute, +.hljs-number, +.hljs-regexp, +.hljs-link { + font-weight: bold; + color: #0000ff; +} + +.hljs-number, +.hljs-regexp, +.hljs-link { + font-weight: normal; +} + +.hljs-string { + color: #008000; + font-weight: bold; +} + +.hljs-symbol, +.hljs-bullet, +.hljs-formula { + color: #000; + background: #d0eded; + font-style: italic; +} + +.hljs-doctag { + text-decoration: underline; +} + +.hljs-variable, +.hljs-template-variable { + color: #660e7a; +} + +.hljs-addition { + background: #baeeba; +} + +.hljs-deletion { + background: #ffc8bd; +} + +.hljs-emphasis { + font-style: italic; +} + +.hljs-strong { + font-weight: bold; +} diff --git a/lib/highlight/styles/ir-black.css b/lib/highlight/styles/ir-black.css new file mode 100644 index 000000000..bd4c755ed --- /dev/null +++ b/lib/highlight/styles/ir-black.css @@ -0,0 +1,73 @@ +/* + IR_Black style (c) Vasily Mikhailitchenko +*/ + +.hljs { + display: block; + overflow-x: auto; + padding: 0.5em; + background: #000; + color: #f8f8f8; +} + +.hljs-comment, +.hljs-quote, +.hljs-meta { + color: #7c7c7c; +} + +.hljs-keyword, +.hljs-selector-tag, +.hljs-tag, +.hljs-name { + color: #96cbfe; +} + +.hljs-attribute, +.hljs-selector-id { + color: #ffffb6; +} + +.hljs-string, +.hljs-selector-attr, +.hljs-selector-pseudo, +.hljs-addition { + color: #a8ff60; +} + +.hljs-subst { + color: #daefa3; +} + +.hljs-regexp, +.hljs-link { + color: #e9c062; +} + +.hljs-title, +.hljs-section, +.hljs-type, +.hljs-doctag { + color: #ffffb6; +} + +.hljs-symbol, +.hljs-bullet, +.hljs-variable, +.hljs-template-variable, +.hljs-literal { + color: #c6c5fe; +} + +.hljs-number, +.hljs-deletion { + color:#ff73fd; +} + +.hljs-emphasis { + font-style: italic; +} + +.hljs-strong { + font-weight: bold; +} diff --git a/lib/highlight/styles/kimbie.dark.css b/lib/highlight/styles/kimbie.dark.css new file mode 100644 index 000000000..d139cb5d0 --- /dev/null +++ b/lib/highlight/styles/kimbie.dark.css @@ -0,0 +1,74 @@ +/* + Name: Kimbie (dark) + Author: Jan T. Sott + License: Creative Commons Attribution-ShareAlike 4.0 Unported License + URL: https://github.com/idleberg/Kimbie-highlight.js +*/ + +/* Kimbie Comment */ +.hljs-comment, +.hljs-quote { + color: #d6baad; +} + +/* Kimbie Red */ +.hljs-variable, +.hljs-template-variable, +.hljs-tag, +.hljs-name, +.hljs-selector-id, +.hljs-selector-class, +.hljs-regexp, +.hljs-meta { + color: #dc3958; +} + +/* Kimbie Orange */ +.hljs-number, +.hljs-built_in, +.hljs-builtin-name, +.hljs-literal, +.hljs-type, +.hljs-params, +.hljs-deletion, +.hljs-link { + color: #f79a32; +} + +/* Kimbie Yellow */ +.hljs-title, +.hljs-section, +.hljs-attribute { + color: #f06431; +} + +/* Kimbie Green */ +.hljs-string, +.hljs-symbol, +.hljs-bullet, +.hljs-addition { + color: #889b4a; +} + +/* Kimbie Purple */ +.hljs-keyword, +.hljs-selector-tag, +.hljs-function { + color: #98676a; +} + +.hljs { + display: block; + overflow-x: auto; + background: #221a0f; + color: #d3af86; + padding: 0.5em; +} + +.hljs-emphasis { + font-style: italic; +} + +.hljs-strong { + font-weight: bold; +} diff --git a/lib/highlight/styles/kimbie.light.css b/lib/highlight/styles/kimbie.light.css new file mode 100644 index 000000000..04ff6ed3a --- /dev/null +++ b/lib/highlight/styles/kimbie.light.css @@ -0,0 +1,74 @@ +/* + Name: Kimbie (light) + Author: Jan T. Sott + License: Creative Commons Attribution-ShareAlike 4.0 Unported License + URL: https://github.com/idleberg/Kimbie-highlight.js +*/ + +/* Kimbie Comment */ +.hljs-comment, +.hljs-quote { + color: #a57a4c; +} + +/* Kimbie Red */ +.hljs-variable, +.hljs-template-variable, +.hljs-tag, +.hljs-name, +.hljs-selector-id, +.hljs-selector-class, +.hljs-regexp, +.hljs-meta { + color: #dc3958; +} + +/* Kimbie Orange */ +.hljs-number, +.hljs-built_in, +.hljs-builtin-name, +.hljs-literal, +.hljs-type, +.hljs-params, +.hljs-deletion, +.hljs-link { + color: #f79a32; +} + +/* Kimbie Yellow */ +.hljs-title, +.hljs-section, +.hljs-attribute { + color: #f06431; +} + +/* Kimbie Green */ +.hljs-string, +.hljs-symbol, +.hljs-bullet, +.hljs-addition { + color: #889b4a; +} + +/* Kimbie Purple */ +.hljs-keyword, +.hljs-selector-tag, +.hljs-function { + color: #98676a; +} + +.hljs { + display: block; + overflow-x: auto; + background: #fbebd4; + color: #84613d; + padding: 0.5em; +} + +.hljs-emphasis { + font-style: italic; +} + +.hljs-strong { + font-weight: bold; +} diff --git a/lib/highlight/styles/magula.css b/lib/highlight/styles/magula.css new file mode 100644 index 000000000..44dee5e8e --- /dev/null +++ b/lib/highlight/styles/magula.css @@ -0,0 +1,70 @@ +/* +Description: Magula style for highligh.js +Author: Ruslan Keba +Website: http://rukeba.com/ +Version: 1.0 +Date: 2009-01-03 +Music: Aphex Twin / Xtal +*/ + +.hljs { + display: block; + overflow-x: auto; + padding: 0.5em; + background-color: #f4f4f4; +} + +.hljs, +.hljs-subst { + color: black; +} + +.hljs-string, +.hljs-title, +.hljs-symbol, +.hljs-bullet, +.hljs-attribute, +.hljs-addition, +.hljs-variable, +.hljs-template-tag, +.hljs-template-variable { + color: #050; +} + +.hljs-comment, +.hljs-quote { + color: #777; +} + +.hljs-number, +.hljs-regexp, +.hljs-literal, +.hljs-type, +.hljs-link { + color: #800; +} + +.hljs-deletion, +.hljs-meta { + color: #00e; +} + +.hljs-keyword, +.hljs-selector-tag, +.hljs-doctag, +.hljs-title, +.hljs-section, +.hljs-built_in, +.hljs-tag, +.hljs-name { + font-weight: bold; + color: navy; +} + +.hljs-emphasis { + font-style: italic; +} + +.hljs-strong { + font-weight: bold; +} diff --git a/lib/highlight/styles/mono-blue.css b/lib/highlight/styles/mono-blue.css new file mode 100644 index 000000000..884c97c76 --- /dev/null +++ b/lib/highlight/styles/mono-blue.css @@ -0,0 +1,59 @@ +/* + Five-color theme from a single blue hue. +*/ +.hljs { + display: block; + overflow-x: auto; + padding: 0.5em; + background: #eaeef3; +} + +.hljs { + color: #00193a; +} + +.hljs-keyword, +.hljs-selector-tag, +.hljs-title, +.hljs-section, +.hljs-doctag, +.hljs-name, +.hljs-strong { + font-weight: bold; +} + +.hljs-comment { + color: #738191; +} + +.hljs-string, +.hljs-title, +.hljs-section, +.hljs-built_in, +.hljs-literal, +.hljs-type, +.hljs-addition, +.hljs-tag, +.hljs-quote, +.hljs-name, +.hljs-selector-id, +.hljs-selector-class { + color: #0048ab; +} + +.hljs-meta, +.hljs-subst, +.hljs-symbol, +.hljs-regexp, +.hljs-attribute, +.hljs-deletion, +.hljs-variable, +.hljs-template-variable, +.hljs-link, +.hljs-bullet { + color: #4c81c9; +} + +.hljs-emphasis { + font-style: italic; +} diff --git a/lib/highlight/styles/monokai-sublime.css b/lib/highlight/styles/monokai-sublime.css new file mode 100644 index 000000000..2864170da --- /dev/null +++ b/lib/highlight/styles/monokai-sublime.css @@ -0,0 +1,83 @@ +/* + +Monokai Sublime style. Derived from Monokai by noformnocontent http://nn.mit-license.org/ + +*/ + +.hljs { + display: block; + overflow-x: auto; + padding: 0.5em; + background: #23241f; +} + +.hljs, +.hljs-tag, +.hljs-subst { + color: #f8f8f2; +} + +.hljs-strong, +.hljs-emphasis { + color: #a8a8a2; +} + +.hljs-bullet, +.hljs-quote, +.hljs-number, +.hljs-regexp, +.hljs-literal, +.hljs-link { + color: #ae81ff; +} + +.hljs-code, +.hljs-title, +.hljs-section, +.hljs-selector-class { + color: #a6e22e; +} + +.hljs-strong { + font-weight: bold; +} + +.hljs-emphasis { + font-style: italic; +} + +.hljs-keyword, +.hljs-selector-tag, +.hljs-name, +.hljs-attr { + color: #f92672; +} + +.hljs-symbol, +.hljs-attribute { + color: #66d9ef; +} + +.hljs-params, +.hljs-class .hljs-title { + color: #f8f8f2; +} + +.hljs-string, +.hljs-type, +.hljs-built_in, +.hljs-builtin-name, +.hljs-selector-id, +.hljs-selector-attr, +.hljs-selector-pseudo, +.hljs-addition, +.hljs-variable, +.hljs-template-variable { + color: #e6db74; +} + +.hljs-comment, +.hljs-deletion, +.hljs-meta { + color: #75715e; +} diff --git a/lib/highlight/styles/monokai.css b/lib/highlight/styles/monokai.css new file mode 100644 index 000000000..775d53f91 --- /dev/null +++ b/lib/highlight/styles/monokai.css @@ -0,0 +1,70 @@ +/* +Monokai style - ported by Luigi Maselli - http://grigio.org +*/ + +.hljs { + display: block; + overflow-x: auto; + padding: 0.5em; + background: #272822; color: #ddd; +} + +.hljs-tag, +.hljs-keyword, +.hljs-selector-tag, +.hljs-literal, +.hljs-strong, +.hljs-name { + color: #f92672; +} + +.hljs-code { + color: #66d9ef; +} + +.hljs-class .hljs-title { + color: white; +} + +.hljs-attribute, +.hljs-symbol, +.hljs-regexp, +.hljs-link { + color: #bf79db; +} + +.hljs-string, +.hljs-bullet, +.hljs-subst, +.hljs-title, +.hljs-section, +.hljs-emphasis, +.hljs-type, +.hljs-built_in, +.hljs-builtin-name, +.hljs-selector-attr, +.hljs-selector-pseudo, +.hljs-addition, +.hljs-variable, +.hljs-template-tag, +.hljs-template-variable { + color: #a6e22e; +} + +.hljs-comment, +.hljs-quote, +.hljs-deletion, +.hljs-meta { + color: #75715e; +} + +.hljs-keyword, +.hljs-selector-tag, +.hljs-literal, +.hljs-doctag, +.hljs-title, +.hljs-section, +.hljs-type, +.hljs-selector-id { + font-weight: bold; +} diff --git a/lib/highlight/styles/obsidian.css b/lib/highlight/styles/obsidian.css new file mode 100644 index 000000000..356630fa2 --- /dev/null +++ b/lib/highlight/styles/obsidian.css @@ -0,0 +1,88 @@ +/** + * Obsidian style + * ported by Alexander Marenin (http://github.com/ioncreature) + */ + +.hljs { + display: block; + overflow-x: auto; + padding: 0.5em; + background: #282b2e; +} + +.hljs-keyword, +.hljs-selector-tag, +.hljs-literal, +.hljs-selector-id { + color: #93c763; +} + +.hljs-number { + color: #ffcd22; +} + +.hljs { + color: #e0e2e4; +} + +.hljs-attribute { + color: #668bb0; +} + +.hljs-code, +.hljs-class .hljs-title, +.hljs-section { + color: white; +} + +.hljs-regexp, +.hljs-link { + color: #d39745; +} + +.hljs-meta { + color: #557182; +} + +.hljs-tag, +.hljs-name, +.hljs-bullet, +.hljs-subst, +.hljs-emphasis, +.hljs-type, +.hljs-built_in, +.hljs-selector-attr, +.hljs-selector-pseudo, +.hljs-addition, +.hljs-variable, +.hljs-template-tag, +.hljs-template-variable { + color: #8cbbad; +} + +.hljs-string, +.hljs-symbol { + color: #ec7600; +} + +.hljs-comment, +.hljs-quote, +.hljs-deletion { + color: #818e96; +} + +.hljs-selector-class { + color: #A082BD +} + +.hljs-keyword, +.hljs-selector-tag, +.hljs-literal, +.hljs-doctag, +.hljs-title, +.hljs-section, +.hljs-type, +.hljs-name, +.hljs-strong { + font-weight: bold; +} diff --git a/lib/highlight/styles/ocean.css b/lib/highlight/styles/ocean.css new file mode 100644 index 000000000..5901581b4 --- /dev/null +++ b/lib/highlight/styles/ocean.css @@ -0,0 +1,74 @@ +/* Ocean Dark Theme */ +/* https://github.com/gavsiu */ +/* Original theme - https://github.com/chriskempson/base16 */ + +/* Ocean Comment */ +.hljs-comment, +.hljs-quote { + color: #65737e; +} + +/* Ocean Red */ +.hljs-variable, +.hljs-template-variable, +.hljs-tag, +.hljs-name, +.hljs-selector-id, +.hljs-selector-class, +.hljs-regexp, +.hljs-deletion { + color: #bf616a; +} + +/* Ocean Orange */ +.hljs-number, +.hljs-built_in, +.hljs-builtin-name, +.hljs-literal, +.hljs-type, +.hljs-params, +.hljs-meta, +.hljs-link { + color: #d08770; +} + +/* Ocean Yellow */ +.hljs-attribute { + color: #ebcb8b; +} + +/* Ocean Green */ +.hljs-string, +.hljs-symbol, +.hljs-bullet, +.hljs-addition { + color: #a3be8c; +} + +/* Ocean Blue */ +.hljs-title, +.hljs-section { + color: #8fa1b3; +} + +/* Ocean Purple */ +.hljs-keyword, +.hljs-selector-tag { + color: #b48ead; +} + +.hljs { + display: block; + overflow-x: auto; + background: #2b303b; + color: #c0c5ce; + padding: 0.5em; +} + +.hljs-emphasis { + font-style: italic; +} + +.hljs-strong { + font-weight: bold; +} diff --git a/lib/highlight/styles/paraiso-dark.css b/lib/highlight/styles/paraiso-dark.css new file mode 100644 index 000000000..e7292401c --- /dev/null +++ b/lib/highlight/styles/paraiso-dark.css @@ -0,0 +1,72 @@ +/* + Paraíso (dark) + Created by Jan T. Sott (http://github.com/idleberg) + Inspired by the art of Rubens LP (http://www.rubenslp.com.br) +*/ + +/* Paraíso Comment */ +.hljs-comment, +.hljs-quote { + color: #8d8687; +} + +/* Paraíso Red */ +.hljs-variable, +.hljs-template-variable, +.hljs-tag, +.hljs-name, +.hljs-selector-id, +.hljs-selector-class, +.hljs-regexp, +.hljs-link, +.hljs-meta { + color: #ef6155; +} + +/* Paraíso Orange */ +.hljs-number, +.hljs-built_in, +.hljs-builtin-name, +.hljs-literal, +.hljs-type, +.hljs-params, +.hljs-deletion { + color: #f99b15; +} + +/* Paraíso Yellow */ +.hljs-title, +.hljs-section, +.hljs-attribute { + color: #fec418; +} + +/* Paraíso Green */ +.hljs-string, +.hljs-symbol, +.hljs-bullet, +.hljs-addition { + color: #48b685; +} + +/* Paraíso Purple */ +.hljs-keyword, +.hljs-selector-tag { + color: #815ba4; +} + +.hljs { + display: block; + overflow-x: auto; + background: #2f1e2e; + color: #a39e9b; + padding: 0.5em; +} + +.hljs-emphasis { + font-style: italic; +} + +.hljs-strong { + font-weight: bold; +} diff --git a/lib/highlight/styles/paraiso-light.css b/lib/highlight/styles/paraiso-light.css new file mode 100644 index 000000000..944857cd8 --- /dev/null +++ b/lib/highlight/styles/paraiso-light.css @@ -0,0 +1,72 @@ +/* + Paraíso (light) + Created by Jan T. Sott (http://github.com/idleberg) + Inspired by the art of Rubens LP (http://www.rubenslp.com.br) +*/ + +/* Paraíso Comment */ +.hljs-comment, +.hljs-quote { + color: #776e71; +} + +/* Paraíso Red */ +.hljs-variable, +.hljs-template-variable, +.hljs-tag, +.hljs-name, +.hljs-selector-id, +.hljs-selector-class, +.hljs-regexp, +.hljs-link, +.hljs-meta { + color: #ef6155; +} + +/* Paraíso Orange */ +.hljs-number, +.hljs-built_in, +.hljs-builtin-name, +.hljs-literal, +.hljs-type, +.hljs-params, +.hljs-deletion { + color: #f99b15; +} + +/* Paraíso Yellow */ +.hljs-title, +.hljs-section, +.hljs-attribute { + color: #fec418; +} + +/* Paraíso Green */ +.hljs-string, +.hljs-symbol, +.hljs-bullet, +.hljs-addition { + color: #48b685; +} + +/* Paraíso Purple */ +.hljs-keyword, +.hljs-selector-tag { + color: #815ba4; +} + +.hljs { + display: block; + overflow-x: auto; + background: #e7e9db; + color: #4f424c; + padding: 0.5em; +} + +.hljs-emphasis { + font-style: italic; +} + +.hljs-strong { + font-weight: bold; +} diff --git a/lib/highlight/styles/pojoaque.css b/lib/highlight/styles/pojoaque.css new file mode 100644 index 000000000..2e07847b2 --- /dev/null +++ b/lib/highlight/styles/pojoaque.css @@ -0,0 +1,83 @@ +/* + +Pojoaque Style by Jason Tate +http://web-cms-designs.com/ftopict-10-pojoaque-style-for-highlight-js-code-highlighter.html +Based on Solarized Style from http://ethanschoonover.com/solarized + +*/ + +.hljs { + display: block; + overflow-x: auto; + padding: 0.5em; + color: #dccf8f; + background: url(./pojoaque.jpg) repeat scroll left top #181914; +} + +.hljs-comment, +.hljs-quote { + color: #586e75; + font-style: italic; +} + +.hljs-keyword, +.hljs-selector-tag, +.hljs-literal, +.hljs-addition { + color: #b64926; +} + +.hljs-number, +.hljs-string, +.hljs-doctag, +.hljs-regexp { + color: #468966; +} + +.hljs-title, +.hljs-section, +.hljs-built_in, +.hljs-name { + color: #ffb03b; +} + +.hljs-variable, +.hljs-template-variable, +.hljs-class .hljs-title, +.hljs-type, +.hljs-tag { + color: #b58900; +} + +.hljs-attribute { + color: #b89859; +} + +.hljs-symbol, +.hljs-bullet, +.hljs-link, +.hljs-subst, +.hljs-meta { + color: #cb4b16; +} + +.hljs-deletion { + color: #dc322f; +} + +.hljs-selector-id, +.hljs-selector-class { + color: #d3a60c; +} + +.hljs-formula { + background: #073642; +} + +.hljs-emphasis { + font-style: italic; +} + +.hljs-strong { + font-weight: bold; +} diff --git a/lib/highlight/styles/pojoaque.jpg b/lib/highlight/styles/pojoaque.jpg new file mode 100644 index 000000000..9c07d4ab4 Binary files /dev/null and b/lib/highlight/styles/pojoaque.jpg differ diff --git a/lib/highlight/styles/purebasic.css b/lib/highlight/styles/purebasic.css new file mode 100644 index 000000000..5ce9b9e07 --- /dev/null +++ b/lib/highlight/styles/purebasic.css @@ -0,0 +1,96 @@ +/* + +PureBASIC native IDE style ( version 1.0 - April 2016 ) + +by Tristano Ajmone + +Public Domain + +NOTE_1: PureBASIC code syntax highlighting only applies the following classes: + .hljs-comment + .hljs-function + .hljs-keywords + .hljs-string + .hljs-symbol + + Other classes are added here for the benefit of styling other languages with the look and feel of PureBASIC native IDE style. + If you need to customize a stylesheet for PureBASIC only, remove all non-relevant classes -- PureBASIC-related classes are followed by + a "--- used for PureBASIC ... ---" comment on same line. + +NOTE_2: Color names provided in comments were derived using "Name that Color" online tool: + http://chir.ag/projects/name-that-color +*/ + +.hljs { /* Common set of rules required by highlight.js (don'r remove!) */ + display: block; + overflow-x: auto; + padding: 0.5em; + background: #FFFFDF; /* Half and Half (approx.) */ +/* --- Uncomment to add PureBASIC native IDE styled font! + font-family: Consolas; +*/ +} + +.hljs, /* --- used for PureBASIC base color --- */ +.hljs-type, /* --- used for PureBASIC Procedures return type --- */ +.hljs-function, /* --- used for wrapping PureBASIC Procedures definitions --- */ +.hljs-name, +.hljs-number, +.hljs-attr, +.hljs-params, +.hljs-subst { + color: #000000; /* Black */ +} + +.hljs-comment, /* --- used for PureBASIC Comments --- */ +.hljs-regexp, +.hljs-section, +.hljs-selector-pseudo, +.hljs-addition { + color: #00AAAA; /* Persian Green (approx.) */ +} + +.hljs-title, /* --- used for PureBASIC Procedures Names --- */ +.hljs-tag, +.hljs-variable, +.hljs-code { + color: #006666; /* Blue Stone (approx.) */ +} + +.hljs-keyword, /* --- used for PureBASIC Keywords --- */ +.hljs-class, +.hljs-meta-keyword, +.hljs-selector-class, +.hljs-built_in, +.hljs-builtin-name { + color: #006666; /* Blue Stone (approx.) */ + font-weight: bold; +} + +.hljs-string, /* --- used for PureBASIC Strings --- */ +.hljs-selector-attr { + color: #0080FF; /* Azure Radiance (approx.) */ +} + +.hljs-symbol, /* --- used for PureBASIC Constants --- */ +.hljs-link, +.hljs-deletion, +.hljs-attribute { + color: #924B72; /* Cannon Pink (approx.) */ +} + +.hljs-meta, +.hljs-literal, +.hljs-selector-id { + color: #924B72; /* Cannon Pink (approx.) */ + font-weight: bold; +} + +.hljs-strong, +.hljs-name { + font-weight: bold; +} + +.hljs-emphasis { + font-style: italic; +} diff --git a/lib/highlight/styles/qtcreator_dark.css b/lib/highlight/styles/qtcreator_dark.css new file mode 100644 index 000000000..7aa56a365 --- /dev/null +++ b/lib/highlight/styles/qtcreator_dark.css @@ -0,0 +1,83 @@ +/* + +Qt Creator dark color scheme + +*/ + + +.hljs { + display: block; + overflow-x: auto; + padding: 0.5em; + background: #000000; +} + +.hljs, +.hljs-subst, +.hljs-tag, +.hljs-title { + color: #aaaaaa; +} + +.hljs-strong, +.hljs-emphasis { + color: #a8a8a2; +} + +.hljs-bullet, +.hljs-quote, +.hljs-number, +.hljs-regexp, +.hljs-literal { + color: #ff55ff; +} + +.hljs-code +.hljs-selector-class { + color: #aaaaff; +} + +.hljs-emphasis, +.hljs-stronge, +.hljs-type { + font-style: italic; +} + +.hljs-keyword, +.hljs-selector-tag, +.hljs-function, +.hljs-section, +.hljs-symbol, +.hljs-name { + color: #ffff55; +} + +.hljs-attribute { + color: #ff5555; +} + +.hljs-variable, +.hljs-params, +.hljs-class .hljs-title { + color: #8888ff; +} + +.hljs-string, +.hljs-selector-id, +.hljs-selector-attr, +.hljs-selector-pseudo, +.hljs-type, +.hljs-built_in, +.hljs-builtin-name, +.hljs-template-tag, +.hljs-template-variable, +.hljs-addition, +.hljs-link { + color: #ff55ff; +} + +.hljs-comment, +.hljs-meta, +.hljs-deletion { + color: #55ffff; +} diff --git a/lib/highlight/styles/qtcreator_light.css b/lib/highlight/styles/qtcreator_light.css new file mode 100644 index 000000000..1efa2c660 --- /dev/null +++ b/lib/highlight/styles/qtcreator_light.css @@ -0,0 +1,83 @@ +/* + +Qt Creator light color scheme + +*/ + + +.hljs { + display: block; + overflow-x: auto; + padding: 0.5em; + background: #ffffff; +} + +.hljs, +.hljs-subst, +.hljs-tag, +.hljs-title { + color: #000000; +} + +.hljs-strong, +.hljs-emphasis { + color: #000000; +} + +.hljs-bullet, +.hljs-quote, +.hljs-number, +.hljs-regexp, +.hljs-literal { + color: #000080; +} + +.hljs-code +.hljs-selector-class { + color: #800080; +} + +.hljs-emphasis, +.hljs-stronge, +.hljs-type { + font-style: italic; +} + +.hljs-keyword, +.hljs-selector-tag, +.hljs-function, +.hljs-section, +.hljs-symbol, +.hljs-name { + color: #808000; +} + +.hljs-attribute { + color: #800000; +} + +.hljs-variable, +.hljs-params, +.hljs-class .hljs-title { + color: #0055AF; +} + +.hljs-string, +.hljs-selector-id, +.hljs-selector-attr, +.hljs-selector-pseudo, +.hljs-type, +.hljs-built_in, +.hljs-builtin-name, +.hljs-template-tag, +.hljs-template-variable, +.hljs-addition, +.hljs-link { + color: #008000; +} + +.hljs-comment, +.hljs-meta, +.hljs-deletion { + color: #008000; +} diff --git a/lib/highlight/styles/railscasts.css b/lib/highlight/styles/railscasts.css new file mode 100644 index 000000000..008cdc5bf --- /dev/null +++ b/lib/highlight/styles/railscasts.css @@ -0,0 +1,106 @@ +/* + +Railscasts-like style (c) Visoft, Inc. (Damien White) + +*/ + +.hljs { + display: block; + overflow-x: auto; + padding: 0.5em; + background: #232323; + color: #e6e1dc; +} + +.hljs-comment, +.hljs-quote { + color: #bc9458; + font-style: italic; +} + +.hljs-keyword, +.hljs-selector-tag { + color: #c26230; +} + +.hljs-string, +.hljs-number, +.hljs-regexp, +.hljs-variable, +.hljs-template-variable { + color: #a5c261; +} + +.hljs-subst { + color: #519f50; +} + +.hljs-tag, +.hljs-name { + color: #e8bf6a; +} + +.hljs-type { + color: #da4939; +} + + +.hljs-symbol, +.hljs-bullet, +.hljs-built_in, +.hljs-builtin-name, +.hljs-attr, +.hljs-link { + color: #6d9cbe; +} + +.hljs-params { + color: #d0d0ff; +} + +.hljs-attribute { + color: #cda869; +} + +.hljs-meta { + color: #9b859d; +} + +.hljs-title, +.hljs-section { + color: #ffc66d; +} + +.hljs-addition { + background-color: #144212; + color: #e6e1dc; + display: inline-block; + width: 100%; +} + +.hljs-deletion { + background-color: #600; + color: #e6e1dc; + display: inline-block; + width: 100%; +} + +.hljs-selector-class { + color: #9b703f; +} + +.hljs-selector-id { + color: #8b98ab; +} + +.hljs-emphasis { + font-style: italic; +} + +.hljs-strong { + font-weight: bold; +} + +.hljs-link { + text-decoration: underline; +} diff --git a/lib/highlight/styles/rainbow.css b/lib/highlight/styles/rainbow.css new file mode 100644 index 000000000..905eb8ef1 --- /dev/null +++ b/lib/highlight/styles/rainbow.css @@ -0,0 +1,85 @@ +/* + +Style with support for rainbow parens + +*/ + +.hljs { + display: block; + overflow-x: auto; + padding: 0.5em; + background: #474949; + color: #d1d9e1; +} + + +.hljs-comment, +.hljs-quote { + color: #969896; + font-style: italic; +} + +.hljs-keyword, +.hljs-selector-tag, +.hljs-literal, +.hljs-type, +.hljs-addition { + color: #cc99cc; +} + +.hljs-number, +.hljs-selector-attr, +.hljs-selector-pseudo { + color: #f99157; +} + +.hljs-string, +.hljs-doctag, +.hljs-regexp { + color: #8abeb7; +} + +.hljs-title, +.hljs-name, +.hljs-section, +.hljs-built_in { + color: #b5bd68; +} + +.hljs-variable, +.hljs-template-variable, +.hljs-selector-id, +.hljs-class .hljs-title { + color: #ffcc66; +} + +.hljs-section, +.hljs-name, +.hljs-strong { + font-weight: bold; +} + +.hljs-symbol, +.hljs-bullet, +.hljs-subst, +.hljs-meta, +.hljs-link { + color: #f99157; +} + +.hljs-deletion { + color: #dc322f; +} + +.hljs-formula { + background: #eee8d5; +} + +.hljs-attr, +.hljs-attribute { + color: #81a2be; +} + +.hljs-emphasis { + font-style: italic; +} diff --git a/lib/highlight/styles/routeros.css b/lib/highlight/styles/routeros.css new file mode 100644 index 000000000..ebe23990d --- /dev/null +++ b/lib/highlight/styles/routeros.css @@ -0,0 +1,108 @@ +/* + + highlight.js style for Microtik RouterOS script + +*/ + +.hljs { + display: block; + overflow-x: auto; + padding: 0.5em; + background: #F0F0F0; +} + +/* Base color: saturation 0; */ + +.hljs, +.hljs-subst { + color: #444; +} + +.hljs-comment { + color: #888888; +} + +.hljs-keyword, +.hljs-selector-tag, +.hljs-meta-keyword, +.hljs-doctag, +.hljs-name { + font-weight: bold; +} + +.hljs-attribute { + color: #0E9A00; +} + +.hljs-function { + color: #99069A; +} + +.hljs-builtin-name { + color: #99069A; +} + +/* User color: hue: 0 */ + +.hljs-type, +.hljs-string, +.hljs-number, +.hljs-selector-id, +.hljs-selector-class, +.hljs-quote, +.hljs-template-tag, +.hljs-deletion { + color: #880000; +} + +.hljs-title, +.hljs-section { + color: #880000; + font-weight: bold; +} + +.hljs-regexp, +.hljs-symbol, +.hljs-variable, +.hljs-template-variable, +.hljs-link, +.hljs-selector-attr, +.hljs-selector-pseudo { + color: #BC6060; +} + + +/* Language color: hue: 90; */ + +.hljs-literal { + color: #78A960; +} + +.hljs-built_in, +.hljs-bullet, +.hljs-code, +.hljs-addition { + color: #0C9A9A; +} + + +/* Meta color: hue: 200 */ + +.hljs-meta { + color: #1f7199; +} + +.hljs-meta-string { + color: #4d99bf; +} + + +/* Misc effects */ + +.hljs-emphasis { + font-style: italic; +} + +.hljs-strong { + font-weight: bold; +} diff --git a/lib/highlight/styles/school-book.css b/lib/highlight/styles/school-book.css new file mode 100644 index 000000000..964b51d84 --- /dev/null +++ b/lib/highlight/styles/school-book.css @@ -0,0 +1,72 @@ +/* + +School Book style from goldblog.com.ua (c) Zaripov Yura + +*/ + +.hljs { + display: block; + overflow-x: auto; + padding: 15px 0.5em 0.5em 30px; + font-size: 11px; + line-height:16px; +} + +pre{ + background:#f6f6ae url(./school-book.png); + border-top: solid 2px #d2e8b9; + border-bottom: solid 1px #d2e8b9; +} + +.hljs-keyword, +.hljs-selector-tag, +.hljs-literal { + color:#005599; + font-weight:bold; +} + +.hljs, +.hljs-subst { + color: #3e5915; +} + +.hljs-string, +.hljs-title, +.hljs-section, +.hljs-type, +.hljs-symbol, +.hljs-bullet, +.hljs-attribute, +.hljs-built_in, +.hljs-builtin-name, +.hljs-addition, +.hljs-variable, +.hljs-template-tag, +.hljs-template-variable, +.hljs-link { + color: #2c009f; +} + +.hljs-comment, +.hljs-quote, +.hljs-deletion, +.hljs-meta { + color: #e60415; +} + +.hljs-keyword, +.hljs-selector-tag, +.hljs-literal, +.hljs-doctag, +.hljs-title, +.hljs-section, +.hljs-type, +.hljs-name, +.hljs-selector-id, +.hljs-strong { + font-weight: bold; +} + +.hljs-emphasis { + font-style: italic; +} diff --git a/lib/highlight/styles/school-book.png b/lib/highlight/styles/school-book.png new file mode 100644 index 000000000..956e9790a Binary files /dev/null and b/lib/highlight/styles/school-book.png differ diff --git a/lib/highlight/styles/solarized-dark.css b/lib/highlight/styles/solarized-dark.css new file mode 100644 index 000000000..b4c0da1f7 --- /dev/null +++ b/lib/highlight/styles/solarized-dark.css @@ -0,0 +1,84 @@ +/* + +Orginal Style from ethanschoonover.com/solarized (c) Jeremy Hull + +*/ + +.hljs { + display: block; + overflow-x: auto; + padding: 0.5em; + background: #002b36; + color: #839496; +} + +.hljs-comment, +.hljs-quote { + color: #586e75; +} + +/* Solarized Green */ +.hljs-keyword, +.hljs-selector-tag, +.hljs-addition { + color: #859900; +} + +/* Solarized Cyan */ +.hljs-number, +.hljs-string, +.hljs-meta .hljs-meta-string, +.hljs-literal, +.hljs-doctag, +.hljs-regexp { + color: #2aa198; +} + +/* Solarized Blue */ +.hljs-title, +.hljs-section, +.hljs-name, +.hljs-selector-id, +.hljs-selector-class { + color: #268bd2; +} + +/* Solarized Yellow */ +.hljs-attribute, +.hljs-attr, +.hljs-variable, +.hljs-template-variable, +.hljs-class .hljs-title, +.hljs-type { + color: #b58900; +} + +/* Solarized Orange */ +.hljs-symbol, +.hljs-bullet, +.hljs-subst, +.hljs-meta, +.hljs-meta .hljs-keyword, +.hljs-selector-attr, +.hljs-selector-pseudo, +.hljs-link { + color: #cb4b16; +} + +/* Solarized Red */ +.hljs-built_in, +.hljs-deletion { + color: #dc322f; +} + +.hljs-formula { + background: #073642; +} + +.hljs-emphasis { + font-style: italic; +} + +.hljs-strong { + font-weight: bold; +} diff --git a/lib/highlight/styles/solarized-light.css b/lib/highlight/styles/solarized-light.css new file mode 100644 index 000000000..fdcfcc72c --- /dev/null +++ b/lib/highlight/styles/solarized-light.css @@ -0,0 +1,84 @@ +/* + +Orginal Style from ethanschoonover.com/solarized (c) Jeremy Hull + +*/ + +.hljs { + display: block; + overflow-x: auto; + padding: 0.5em; + background: #fdf6e3; + color: #657b83; +} + +.hljs-comment, +.hljs-quote { + color: #93a1a1; +} + +/* Solarized Green */ +.hljs-keyword, +.hljs-selector-tag, +.hljs-addition { + color: #859900; +} + +/* Solarized Cyan */ +.hljs-number, +.hljs-string, +.hljs-meta .hljs-meta-string, +.hljs-literal, +.hljs-doctag, +.hljs-regexp { + color: #2aa198; +} + +/* Solarized Blue */ +.hljs-title, +.hljs-section, +.hljs-name, +.hljs-selector-id, +.hljs-selector-class { + color: #268bd2; +} + +/* Solarized Yellow */ +.hljs-attribute, +.hljs-attr, +.hljs-variable, +.hljs-template-variable, +.hljs-class .hljs-title, +.hljs-type { + color: #b58900; +} + +/* Solarized Orange */ +.hljs-symbol, +.hljs-bullet, +.hljs-subst, +.hljs-meta, +.hljs-meta .hljs-keyword, +.hljs-selector-attr, +.hljs-selector-pseudo, +.hljs-link { + color: #cb4b16; +} + +/* Solarized Red */ +.hljs-built_in, +.hljs-deletion { + color: #dc322f; +} + +.hljs-formula { + background: #eee8d5; +} + +.hljs-emphasis { + font-style: italic; +} + +.hljs-strong { + font-weight: bold; +} diff --git a/lib/highlight/styles/sunburst.css b/lib/highlight/styles/sunburst.css new file mode 100644 index 000000000..f56dd5e9b --- /dev/null +++ b/lib/highlight/styles/sunburst.css @@ -0,0 +1,102 @@ +/* + +Sunburst-like style (c) Vasily Polovnyov + +*/ + +.hljs { + display: block; + overflow-x: auto; + padding: 0.5em; + background: #000; + color: #f8f8f8; +} + +.hljs-comment, +.hljs-quote { + color: #aeaeae; + font-style: italic; +} + +.hljs-keyword, +.hljs-selector-tag, +.hljs-type { + color: #e28964; +} + +.hljs-string { + color: #65b042; +} + +.hljs-subst { + color: #daefa3; +} + +.hljs-regexp, +.hljs-link { + color: #e9c062; +} + +.hljs-title, +.hljs-section, +.hljs-tag, +.hljs-name { + color: #89bdff; +} + +.hljs-class .hljs-title, +.hljs-doctag { + text-decoration: underline; +} + +.hljs-symbol, +.hljs-bullet, +.hljs-number { + color: #3387cc; +} + +.hljs-params, +.hljs-variable, +.hljs-template-variable { + color: #3e87e3; +} + +.hljs-attribute { + color: #cda869; +} + +.hljs-meta { + color: #8996a8; +} + +.hljs-formula { + background-color: #0e2231; + color: #f8f8f8; + font-style: italic; +} + +.hljs-addition { + background-color: #253b22; + color: #f8f8f8; +} + +.hljs-deletion { + background-color: #420e09; + color: #f8f8f8; +} + +.hljs-selector-class { + color: #9b703f; +} + +.hljs-selector-id { + color: #8b98ab; +} + +.hljs-emphasis { + font-style: italic; +} + +.hljs-strong { + font-weight: bold; +} diff --git a/lib/highlight/styles/tomorrow-night-blue.css b/lib/highlight/styles/tomorrow-night-blue.css new file mode 100644 index 000000000..78e59cc8c --- /dev/null +++ b/lib/highlight/styles/tomorrow-night-blue.css @@ -0,0 +1,75 @@ +/* Tomorrow Night Blue Theme */ +/* http://jmblog.github.com/color-themes-for-google-code-highlightjs */ +/* Original theme - https://github.com/chriskempson/tomorrow-theme */ +/* http://jmblog.github.com/color-themes-for-google-code-highlightjs */ + +/* Tomorrow Comment */ +.hljs-comment, +.hljs-quote { + color: #7285b7; +} + +/* Tomorrow Red */ +.hljs-variable, +.hljs-template-variable, +.hljs-tag, +.hljs-name, +.hljs-selector-id, +.hljs-selector-class, +.hljs-regexp, +.hljs-deletion { + color: #ff9da4; +} + +/* Tomorrow Orange */ +.hljs-number, +.hljs-built_in, +.hljs-builtin-name, +.hljs-literal, +.hljs-type, +.hljs-params, +.hljs-meta, +.hljs-link { + color: #ffc58f; +} + +/* Tomorrow Yellow */ +.hljs-attribute { + color: #ffeead; +} + +/* Tomorrow Green */ +.hljs-string, +.hljs-symbol, +.hljs-bullet, +.hljs-addition { + color: #d1f1a9; +} + +/* Tomorrow Blue */ +.hljs-title, +.hljs-section { + color: #bbdaff; +} + +/* Tomorrow Purple */ +.hljs-keyword, +.hljs-selector-tag { + color: #ebbbff; +} + +.hljs { + display: block; + overflow-x: auto; + background: #002451; + color: white; + padding: 0.5em; +} + +.hljs-emphasis { + font-style: italic; +} + +.hljs-strong { + font-weight: bold; +} diff --git a/lib/highlight/styles/tomorrow-night-bright.css b/lib/highlight/styles/tomorrow-night-bright.css new file mode 100644 index 000000000..e05af8ae2 --- /dev/null +++ b/lib/highlight/styles/tomorrow-night-bright.css @@ -0,0 +1,74 @@ +/* Tomorrow Night Bright Theme */ +/* Original theme - https://github.com/chriskempson/tomorrow-theme */ +/* http://jmblog.github.com/color-themes-for-google-code-highlightjs */ + +/* Tomorrow Comment */ +.hljs-comment, +.hljs-quote { + color: #969896; +} + +/* Tomorrow Red */ +.hljs-variable, +.hljs-template-variable, +.hljs-tag, +.hljs-name, +.hljs-selector-id, +.hljs-selector-class, +.hljs-regexp, +.hljs-deletion { + color: #d54e53; +} + +/* Tomorrow Orange */ +.hljs-number, +.hljs-built_in, +.hljs-builtin-name, +.hljs-literal, +.hljs-type, +.hljs-params, +.hljs-meta, +.hljs-link { + color: #e78c45; +} + +/* Tomorrow Yellow */ +.hljs-attribute { + color: #e7c547; +} + +/* Tomorrow Green */ +.hljs-string, +.hljs-symbol, +.hljs-bullet, +.hljs-addition { + color: #b9ca4a; +} + +/* Tomorrow Blue */ +.hljs-title, +.hljs-section { + color: #7aa6da; +} + +/* Tomorrow Purple */ +.hljs-keyword, +.hljs-selector-tag { + color: #c397d8; +} + +.hljs { + display: block; + overflow-x: auto; + background: black; + color: #eaeaea; + padding: 0.5em; +} + +.hljs-emphasis { + font-style: italic; +} + +.hljs-strong { + font-weight: bold; +} diff --git a/lib/highlight/styles/tomorrow-night-eighties.css b/lib/highlight/styles/tomorrow-night-eighties.css new file mode 100644 index 000000000..08fd51c74 --- /dev/null +++ b/lib/highlight/styles/tomorrow-night-eighties.css @@ -0,0 +1,74 @@ +/* Tomorrow Night Eighties Theme */ +/* Original theme - https://github.com/chriskempson/tomorrow-theme */ +/* http://jmblog.github.com/color-themes-for-google-code-highlightjs */ + +/* Tomorrow Comment */ +.hljs-comment, +.hljs-quote { + color: #999999; +} + +/* Tomorrow Red */ +.hljs-variable, +.hljs-template-variable, +.hljs-tag, +.hljs-name, +.hljs-selector-id, +.hljs-selector-class, +.hljs-regexp, +.hljs-deletion { + color: #f2777a; +} + +/* Tomorrow Orange */ +.hljs-number, +.hljs-built_in, +.hljs-builtin-name, +.hljs-literal, +.hljs-type, +.hljs-params, +.hljs-meta, +.hljs-link { + color: #f99157; +} + +/* Tomorrow Yellow */ +.hljs-attribute { + color: #ffcc66; +} + +/* Tomorrow Green */ +.hljs-string, +.hljs-symbol, +.hljs-bullet, +.hljs-addition { + color: #99cc99; +} + +/* Tomorrow Blue */ +.hljs-title, +.hljs-section { + color: #6699cc; +} + +/* Tomorrow Purple */ +.hljs-keyword, +.hljs-selector-tag { + color: #cc99cc; +} + +.hljs { + display: block; + overflow-x: auto; + background: #2d2d2d; + color: #cccccc; + padding: 0.5em; +} + +.hljs-emphasis { + font-style: italic; +} + +.hljs-strong { + font-weight: bold; +} diff --git a/lib/highlight/styles/tomorrow-night.css b/lib/highlight/styles/tomorrow-night.css new file mode 100644 index 000000000..ddd270a4e --- /dev/null +++ b/lib/highlight/styles/tomorrow-night.css @@ -0,0 +1,75 @@ +/* Tomorrow Night Theme */ +/* http://jmblog.github.com/color-themes-for-google-code-highlightjs */ +/* Original theme - https://github.com/chriskempson/tomorrow-theme */ +/* http://jmblog.github.com/color-themes-for-google-code-highlightjs */ + +/* Tomorrow Comment */ +.hljs-comment, +.hljs-quote { + color: #969896; +} + +/* Tomorrow Red */ +.hljs-variable, +.hljs-template-variable, +.hljs-tag, +.hljs-name, +.hljs-selector-id, +.hljs-selector-class, +.hljs-regexp, +.hljs-deletion { + color: #cc6666; +} + +/* Tomorrow Orange */ +.hljs-number, +.hljs-built_in, +.hljs-builtin-name, +.hljs-literal, +.hljs-type, +.hljs-params, +.hljs-meta, +.hljs-link { + color: #de935f; +} + +/* Tomorrow Yellow */ +.hljs-attribute { + color: #f0c674; +} + +/* Tomorrow Green */ +.hljs-string, +.hljs-symbol, +.hljs-bullet, +.hljs-addition { + color: #b5bd68; +} + +/* Tomorrow Blue */ +.hljs-title, +.hljs-section { + color: #81a2be; +} + +/* Tomorrow Purple */ +.hljs-keyword, +.hljs-selector-tag { + color: #b294bb; +} + +.hljs { + display: block; + overflow-x: auto; + background: #1d1f21; + color: #c5c8c6; + padding: 0.5em; +} + +.hljs-emphasis { + font-style: italic; +} + +.hljs-strong { + font-weight: bold; +} diff --git a/lib/highlight/styles/tomorrow.css b/lib/highlight/styles/tomorrow.css new file mode 100644 index 000000000..026a62fe3 --- /dev/null +++ b/lib/highlight/styles/tomorrow.css @@ -0,0 +1,72 @@ +/* http://jmblog.github.com/color-themes-for-google-code-highlightjs */ + +/* Tomorrow Comment */ +.hljs-comment, +.hljs-quote { + color: #8e908c; +} + +/* Tomorrow Red */ +.hljs-variable, +.hljs-template-variable, +.hljs-tag, +.hljs-name, +.hljs-selector-id, +.hljs-selector-class, +.hljs-regexp, +.hljs-deletion { + color: #c82829; +} + +/* Tomorrow Orange */ +.hljs-number, +.hljs-built_in, +.hljs-builtin-name, +.hljs-literal, +.hljs-type, +.hljs-params, +.hljs-meta, +.hljs-link { + color: #f5871f; +} + +/* Tomorrow Yellow */ +.hljs-attribute { + color: #eab700; +} + +/* Tomorrow Green */ +.hljs-string, +.hljs-symbol, +.hljs-bullet, +.hljs-addition { + color: #718c00; +} + +/* Tomorrow Blue */ +.hljs-title, +.hljs-section { + color: #4271ae; +} + +/* Tomorrow Purple */ +.hljs-keyword, +.hljs-selector-tag { + color: #8959a8; +} + +.hljs { + display: block; + overflow-x: auto; + background: white; + color: #4d4d4c; + padding: 0.5em; +} + +.hljs-emphasis { + font-style: italic; +} + +.hljs-strong { + font-weight: bold; +} diff --git a/lib/highlight/styles/vs.css b/lib/highlight/styles/vs.css new file mode 100644 index 000000000..c5d07d311 --- /dev/null +++ b/lib/highlight/styles/vs.css @@ -0,0 +1,68 @@ +/* + +Visual Studio-like style based on original C# coloring by Jason Diamond + +*/ +.hljs { + display: block; + overflow-x: auto; + padding: 0.5em; + background: white; + color: black; +} + +.hljs-comment, +.hljs-quote, +.hljs-variable { + color: #008000; +} + +.hljs-keyword, +.hljs-selector-tag, +.hljs-built_in, +.hljs-name, +.hljs-tag { + color: #00f; +} + +.hljs-string, +.hljs-title, +.hljs-section, +.hljs-attribute, +.hljs-literal, +.hljs-template-tag, +.hljs-template-variable, +.hljs-type, +.hljs-addition { + color: #a31515; +} + +.hljs-deletion, +.hljs-selector-attr, +.hljs-selector-pseudo, +.hljs-meta { + color: #2b91af; +} + +.hljs-doctag { + color: #808080; +} + +.hljs-attr { + color: #f00; +} + +.hljs-symbol, +.hljs-bullet, +.hljs-link { + color: #00b0e8; +} + + +.hljs-emphasis { + font-style: italic; +} + +.hljs-strong { + font-weight: bold; +} diff --git a/lib/highlight/styles/vs2015.css b/lib/highlight/styles/vs2015.css new file mode 100644 index 000000000..d1d9be3ca --- /dev/null +++ b/lib/highlight/styles/vs2015.css @@ -0,0 +1,115 @@ +/* + * Visual Studio 2015 dark style + * Author: Nicolas LLOBERA + */ + +.hljs { + display: block; + overflow-x: auto; + padding: 0.5em; + background: #1E1E1E; + color: #DCDCDC; +} + +.hljs-keyword, +.hljs-literal, +.hljs-symbol, +.hljs-name { + color: #569CD6; +} +.hljs-link { + color: #569CD6; + text-decoration: underline; +} + +.hljs-built_in, +.hljs-type { + color: #4EC9B0; +} + +.hljs-number, +.hljs-class { + color: #B8D7A3; +} + +.hljs-string, +.hljs-meta-string { + color: #D69D85; +} + +.hljs-regexp, +.hljs-template-tag { + color: #9A5334; +} + +.hljs-subst, +.hljs-function, +.hljs-title, +.hljs-params, +.hljs-formula { + color: #DCDCDC; +} + +.hljs-comment, +.hljs-quote { + color: #57A64A; + font-style: italic; +} + +.hljs-doctag { + color: #608B4E; +} + +.hljs-meta, +.hljs-meta-keyword, +.hljs-tag { + color: #9B9B9B; +} + +.hljs-variable, +.hljs-template-variable { + color: #BD63C5; +} + +.hljs-attr, +.hljs-attribute, +.hljs-builtin-name { + color: #9CDCFE; +} + +.hljs-section { + color: gold; +} + +.hljs-emphasis { + font-style: italic; +} + +.hljs-strong { + font-weight: bold; +} + +/*.hljs-code { + font-family:'Monospace'; +}*/ + +.hljs-bullet, +.hljs-selector-tag, +.hljs-selector-id, +.hljs-selector-class, +.hljs-selector-attr, +.hljs-selector-pseudo { + color: #D7BA7D; +} + +.hljs-addition { + background-color: #144212; + display: inline-block; + width: 100%; +} + +.hljs-deletion { + background-color: #600; + display: inline-block; + width: 100%; +} diff --git a/lib/highlight/styles/xcode.css b/lib/highlight/styles/xcode.css new file mode 100644 index 000000000..43dddad84 --- /dev/null +++ b/lib/highlight/styles/xcode.css @@ -0,0 +1,93 @@ +/* + +XCode style (c) Angel Garcia + +*/ + +.hljs { + display: block; + overflow-x: auto; + padding: 0.5em; + background: #fff; + color: black; +} + +.hljs-comment, +.hljs-quote { + color: #006a00; +} + +.hljs-keyword, +.hljs-selector-tag, +.hljs-literal { + color: #aa0d91; +} + +.hljs-name { + color: #008; +} + +.hljs-variable, +.hljs-template-variable { + color: #660; +} + +.hljs-string { + color: #c41a16; +} + +.hljs-regexp, +.hljs-link { + color: #080; +} + +.hljs-title, +.hljs-tag, +.hljs-symbol, +.hljs-bullet, +.hljs-number, +.hljs-meta { + color: #1c00cf; +} + +.hljs-section, +.hljs-class .hljs-title, +.hljs-type, +.hljs-attr, +.hljs-built_in, +.hljs-builtin-name, +.hljs-params { + color: #5c2699; +} + +.hljs-attribute, +.hljs-subst { + color: #000; +} + +.hljs-formula { + background-color: #eee; + font-style: italic; +} + +.hljs-addition { + background-color: #baeeba; +} + +.hljs-deletion { + background-color: #ffc8bd; +} + +.hljs-selector-id, +.hljs-selector-class { + color: #9b703f; +} + +.hljs-doctag, +.hljs-strong { + font-weight: bold; +} + +.hljs-emphasis { + font-style: italic; +} diff --git a/lib/highlight/styles/xt256.css b/lib/highlight/styles/xt256.css new file mode 100644 index 000000000..58df82cb7 --- /dev/null +++ b/lib/highlight/styles/xt256.css @@ -0,0 +1,92 @@ + +/* + xt256.css + + Contact: initbar [at] protonmail [dot] ch + : github.com/initbar +*/ + +.hljs { + display: block; + overflow-x: auto; + color: #eaeaea; + background: #000; + padding: 0.5; +} + +.hljs-subst { + color: #eaeaea; +} + +.hljs-emphasis { + font-style: italic; +} + +.hljs-strong { + font-weight: bold; +} + +.hljs-builtin-name, +.hljs-type { + color: #eaeaea; +} + +.hljs-params { + color: #da0000; +} + +.hljs-literal, +.hljs-number, +.hljs-name { + color: #ff0000; + font-weight: bolder; +} + +.hljs-comment { + color: #969896; +} + +.hljs-selector-id, +.hljs-quote { + color: #00ffff; +} + +.hljs-template-variable, +.hljs-variable, +.hljs-title { + color: #00ffff; + font-weight: bold; +} + +.hljs-selector-class, +.hljs-keyword, +.hljs-symbol { + color: #fff000; +} + +.hljs-string, +.hljs-bullet { + color: #00ff00; +} + +.hljs-tag, +.hljs-section { + color: #000fff; +} + +.hljs-selector-tag { + color: #000fff; + font-weight: bold; +} + +.hljs-attribute, +.hljs-built_in, +.hljs-regexp, +.hljs-link { + color: #ff00ff; +} + +.hljs-meta { + color: #fff; + font-weight: bolder; +} diff --git a/lib/highlight/styles/zenburn.css b/lib/highlight/styles/zenburn.css new file mode 100644 index 000000000..07be50201 --- /dev/null +++ b/lib/highlight/styles/zenburn.css @@ -0,0 +1,80 @@ +/* + +Zenburn style from voldmar.ru (c) Vladimir Epifanov +based on dark.css by Ivan Sagalaev + +*/ + +.hljs { + display: block; + overflow-x: auto; + padding: 0.5em; + background: #3f3f3f; + color: #dcdcdc; +} + +.hljs-keyword, +.hljs-selector-tag, +.hljs-tag { + color: #e3ceab; +} + +.hljs-template-tag { + color: #dcdcdc; +} + +.hljs-number { + color: #8cd0d3; +} + +.hljs-variable, +.hljs-template-variable, +.hljs-attribute { + color: #efdcbc; +} + +.hljs-literal { + color: #efefaf; +} + +.hljs-subst { + color: #8f8f8f; +} + +.hljs-title, +.hljs-name, +.hljs-selector-id, +.hljs-selector-class, +.hljs-section, +.hljs-type { + color: #efef8f; +} + +.hljs-symbol, +.hljs-bullet, +.hljs-link { + color: #dca3a3; +} + +.hljs-deletion, +.hljs-string, +.hljs-built_in, +.hljs-builtin-name { + color: #cc9393; +} + +.hljs-addition, +.hljs-comment, +.hljs-quote, +.hljs-meta { + color: #7f9f7f; +} + + +.hljs-emphasis { + font-style: italic; +} + +.hljs-strong { + font-weight: bold; +} diff --git a/lib/tabcollapse/bootstrap-tabcollapse.js b/lib/tabcollapse/bootstrap-tabcollapse.js new file mode 100644 index 000000000..76e12791a --- /dev/null +++ b/lib/tabcollapse/bootstrap-tabcollapse.js @@ -0,0 +1,237 @@ +!function ($) { + + "use strict"; + + // TABCOLLAPSE CLASS DEFINITION + // ====================== + + var TabCollapse = function (el, options) { + this.options = options; + this.$tabs = $(el); + + this._accordionVisible = false; //content is attached to tabs at first + this._initAccordion(); + this._checkStateOnResize(); + + + // checkState() has gone to setTimeout for making it possible to attach listeners to + // shown-accordion.bs.tabcollapse event on page load. + // See https://github.com/flatlogic/bootstrap-tabcollapse/issues/23 + var that = this; + setTimeout(function() { + that.checkState(); + }, 0); + }; + + TabCollapse.DEFAULTS = { + accordionClass: 'visible-xs', + tabsClass: 'hidden-xs', + accordionTemplate: function(heading, groupId, parentId, active) { + return '
' + + '
' + + '

' + + '

' + + '
' + + '
' + + '
' + + '
' + + '
' + + '
' + + } + }; + + TabCollapse.prototype.checkState = function(){ + if (this.$tabs.is(':visible') && this._accordionVisible){ + this.showTabs(); + this._accordionVisible = false; + } else if (this.$accordion.is(':visible') && !this._accordionVisible){ + this.showAccordion(); + this._accordionVisible = true; + } + }; + + TabCollapse.prototype.showTabs = function(){ + var view = this; + this.$tabs.trigger($.Event('show-tabs.bs.tabcollapse')); + + var $panelHeadings = this.$accordion.find('.js-tabcollapse-panel-heading').detach(); + + $panelHeadings.each(function() { + var $panelHeading = $(this), + $parentLi = $panelHeading.data('bs.tabcollapse.parentLi'); + + var $oldHeading = view._panelHeadingToTabHeading($panelHeading); + + $parentLi.removeClass('active'); + if ($parentLi.parent().hasClass('dropdown-menu') && !$parentLi.siblings('li').hasClass('active')) { + $parentLi.parent().parent().removeClass('active'); + } + + if (!$oldHeading.hasClass('collapsed')) { + $parentLi.addClass('active'); + if ($parentLi.parent().hasClass('dropdown-menu')) { + $parentLi.parent().parent().addClass('active'); + } + } else { + $oldHeading.removeClass('collapsed'); + } + + $parentLi.append($panelHeading); + }); + + if (!$('li').hasClass('active')) { + $('li').first().addClass('active') + } + + var $panelBodies = this.$accordion.find('.js-tabcollapse-panel-body'); + $panelBodies.each(function(){ + var $panelBody = $(this), + $tabPane = $panelBody.data('bs.tabcollapse.tabpane'); + $tabPane.append($panelBody.contents().detach()); + }); + this.$accordion.html(''); + + if(this.options.updateLinks) { + var $tabContents = this.getTabContentElement(); + $tabContents.find('[data-toggle-was="tab"], [data-toggle-was="pill"]').each(function() { + var $el = $(this); + var href = $el.attr('href').replace(/-collapse$/g, ''); + $el.attr({ + 'data-toggle': $el.attr('data-toggle-was'), + 'data-toggle-was': '', + 'data-parent': '', + href: href + }); + }); + } + + this.$tabs.trigger($.Event('shown-tabs.bs.tabcollapse')); + }; + + TabCollapse.prototype.getTabContentElement = function(){ + var $tabContents = $(this.options.tabContentSelector); + if($tabContents.length === 0) { + $tabContents = this.$tabs.siblings('.tab-content'); + } + return $tabContents; + }; + + TabCollapse.prototype.showAccordion = function(){ + this.$tabs.trigger($.Event('show-accordion.bs.tabcollapse')); + + var $headings = this.$tabs.find('li:not(.dropdown) [data-toggle="tab"], li:not(.dropdown) [data-toggle="pill"]'), + view = this; + $headings.each(function(){ + var $heading = $(this), + $parentLi = $heading.parent(); + $heading.data('bs.tabcollapse.parentLi', $parentLi); + view.$accordion.append(view._createAccordionGroup(view.$accordion.attr('id'), $heading.detach())); + }); + + if(this.options.updateLinks) { + var parentId = this.$accordion.attr('id'); + var $selector = this.$accordion.find('.js-tabcollapse-panel-body'); + $selector.find('[data-toggle="tab"], [data-toggle="pill"]').each(function() { + var $el = $(this); + var href = $el.attr('href') + '-collapse'; + $el.attr({ + 'data-toggle-was': $el.attr('data-toggle'), + 'data-toggle': 'collapse', + 'data-parent': '#' + parentId, + href: href + }); + }); + } + + this.$tabs.trigger($.Event('shown-accordion.bs.tabcollapse')); + }; + + TabCollapse.prototype._panelHeadingToTabHeading = function($heading) { + var href = $heading.attr('href').replace(/-collapse$/g, ''); + $heading.attr({ + 'data-toggle': 'tab', + 'href': href, + 'data-parent': '' + }); + return $heading; + }; + + TabCollapse.prototype._tabHeadingToPanelHeading = function($heading, groupId, parentId, active) { + $heading.addClass('js-tabcollapse-panel-heading ' + (active ? '' : 'collapsed')); + $heading.attr({ + 'data-toggle': 'collapse', + 'data-parent': '#' + parentId, + 'href': '#' + groupId + }); + return $heading; + }; + + TabCollapse.prototype._checkStateOnResize = function(){ + var view = this; + $(window).resize(function(){ + clearTimeout(view._resizeTimeout); + view._resizeTimeout = setTimeout(function(){ + view.checkState(); + }, 100); + }); + }; + + + TabCollapse.prototype._initAccordion = function(){ + var randomString = function() { + var result = "", + possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; + for( var i=0; i < 5; i++ ) { + result += possible.charAt(Math.floor(Math.random() * possible.length)); + } + return result; + }; + + var srcId = this.$tabs.attr('id'), + accordionId = (srcId ? srcId : randomString()) + '-accordion'; + + this.$accordion = $('
'); + this.$tabs.after(this.$accordion); + this.$tabs.addClass(this.options.tabsClass); + this.getTabContentElement().addClass(this.options.tabsClass); + }; + + TabCollapse.prototype._createAccordionGroup = function(parentId, $heading){ + var tabSelector = $heading.attr('data-target'), + active = $heading.data('bs.tabcollapse.parentLi').is('.active'); + + if (!tabSelector) { + tabSelector = $heading.attr('href'); + tabSelector = tabSelector && tabSelector.replace(/.*(?=#[^\s]*$)/, ''); //strip for ie7 + } + + var $tabPane = $(tabSelector), + groupId = $tabPane.attr('id') + '-collapse', + $panel = $(this.options.accordionTemplate($heading, groupId, parentId, active)); + $panel.find('.panel-heading > .panel-title').append(this._tabHeadingToPanelHeading($heading, groupId, parentId, active)); + $panel.find('.panel-body').append($tabPane.contents().detach()) + .data('bs.tabcollapse.tabpane', $tabPane); + + return $panel; + }; + + + + // TABCOLLAPSE PLUGIN DEFINITION + // ======================= + + $.fn.tabCollapse = function (option) { + return this.each(function () { + var $this = $(this); + var data = $this.data('bs.tabcollapse'); + var options = $.extend({}, TabCollapse.DEFAULTS, $this.data(), typeof option === 'object' && option); + + if (!data) $this.data('bs.tabcollapse', new TabCollapse(this, options)); + }); + }; + + $.fn.tabCollapse.Constructor = TabCollapse; + + +}(window.jQuery); diff --git a/phpcs.xml b/phpcs.xml deleted file mode 100644 index 016503f46..000000000 --- a/phpcs.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - The Phpfastcache Coding Standards - - - - - - - tests/* - bin/* - docs/* - vendor/* - - - - - - - - diff --git a/phpmd.xml b/phpmd.xml deleted file mode 100644 index ec3cf8754..000000000 --- a/phpmd.xml +++ /dev/null @@ -1,96 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/phpstan.neon b/phpstan.neon deleted file mode 100644 index 773bdfb27..000000000 --- a/phpstan.neon +++ /dev/null @@ -1,24 +0,0 @@ -################################################### -# Complete PHPSTAN configuration for Travis CI -################################################### -parameters: - treatPhpDocTypesAsCertain: false - ignoreErrors: - # (Really) Annoying PHPDoc tag issues... - - '#PHPDoc tag @(.*)#' - # Phpstan is not able to know the magic of Ssdb __call() implementation - - '#Call to an undefined method phpssdb(.*)#' - - # Phpstan not differencing couchbase and couchbase_v3 stubs from jetbrains/phpstorm-stubs - - - message: '#(Method|Class) Couchbase(.*)#' - path: lib/Phpfastcache/Drivers/Couchbasev3/Driver.php - - # See https://github.com/phpstan/phpstan/issues/10315 - - - message: '#Dead catch - Phpfastcache\\Exceptions\\PhpfastcacheUnsupportedMethodException is never thrown in the try block.#' - path: lib/Phpfastcache/Core/Pool/CacheItemPoolTrait.php - # See https://github.com/phpstan/phpstan/issues/10316 - - - message: '#(.*)RedisCluster(.*)#' - path: lib/Phpfastcache/Drivers/Rediscluster/Driver.php diff --git a/phpstan_lite.neon b/phpstan_lite.neon deleted file mode 100644 index 589d98f1b..000000000 --- a/phpstan_lite.neon +++ /dev/null @@ -1,11 +0,0 @@ -################################################### -# Lite PHPSTAN configuration for Github CI -# or any Phpfastcache contributing user -################################################### -parameters: - treatPhpDocTypesAsCertain: false - excludePaths: - - lib/Phpfastcache/Drivers/*/Driver.php - - lib/Phpfastcache/Drivers/*/Config.php - ignoreErrors: - - '#PHPDoc tag @(.*)#' # (Really) Annoying PHPDoc tag issues... diff --git a/quality.bat b/quality.bat deleted file mode 100644 index bb5b909bb..000000000 --- a/quality.bat +++ /dev/null @@ -1,9 +0,0 @@ -@echo off -setlocal - -call vendor\bin\phpcbf lib/ --report=summary -call vendor\bin\phpcs lib/ --report=summary -call vendor\bin\phpmd lib/ ansi phpmd.xml -call vendor\bin\phpstan analyse lib/ -l 6 -c phpstan.neon 2>&1 - -endlocal diff --git a/robots.txt b/robots.txt new file mode 100644 index 000000000..f1ca65ed2 --- /dev/null +++ b/robots.txt @@ -0,0 +1,4 @@ +User-agent: * +Allow: /ajax/ + +Sitemap: http://www.phpfastcache.com/sitemap.xml \ No newline at end of file diff --git a/sitemap.xml b/sitemap.xml new file mode 100644 index 000000000..de8c52298 --- /dev/null +++ b/sitemap.xml @@ -0,0 +1,48 @@ + + + + http://www.phpfastcache.com/ + 2017-11-01T13:08:01+00:00 + weekly + 1.00 + + + http://www.phpfastcache.com/#readme + 2017-11-01T13:08:01+00:00 + weekly + 0.90 + + + http://www.phpfastcache.com/#config-options + 2017-11-01T13:08:01+00:00 + weekly + 0.90 + + + http://www.phpfastcache.com/#events + 2017-11-01T13:08:01+00:00 + weekly + 0.90 + + + http://www.phpfastcache.com/#authors + 2017-11-01T13:08:01+00:00 + weekly + 0.90 + + + http://www.phpfastcache.com/#credits + 2017-11-01T13:08:01+00:00 + weekly + 0.90 + + + http://www.phpfastcache.com/#licence + 2017-11-01T13:08:01+00:00 + weekly + 0.90 + + \ No newline at end of file diff --git a/tests/RunTests.php b/tests/RunTests.php deleted file mode 100644 index 224b1006f..000000000 --- a/tests/RunTests.php +++ /dev/null @@ -1,89 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ -declare(strict_types=1); -require __DIR__ . '/../vendor/autoload.php'; - -define('PFC_TEST_DIR', \realpath(__DIR__)); - -$timestamp = microtime(true); -$climate = new League\CLImate\CLImate; -$climate->forceAnsiOn(); -$phpBinPath = 'php '; -$status = 0; -$dir = __DIR__; -$projectDir = dirname($dir, 2); -$driver = $argv[ 1 ] ?? 'Files'; -$phpBinPath = $_SERVER['PHP_BIN_PATH'] ?? 'php'; -$failedTests = []; -$skippedTests = []; - -/** - * @param string $pattern - * @param int $flags - * @return array - */ -$globCallback = static function (string $pattern, int $flags = 0) use (&$globCallback): array { - $files = \glob($pattern, $flags); - $subFiles = []; - - foreach (\glob(\dirname($pattern) . '/*', GLOB_ONLYDIR | GLOB_NOSORT) as $dir) { - $subFiles[] = $globCallback($dir . '/' . \basename($pattern), $flags); - } - - return \array_merge(...$subFiles, ...[$files]); -}; - -foreach ($globCallback(PFC_TEST_DIR . DIRECTORY_SEPARATOR . '*.test.php') as $filename) { - $climate->backgroundLightYellow()->blue()->out('---'); - $command = "{$phpBinPath} -f {$filename} {$driver}"; - $shortCommand = str_replace(dirname(PFC_TEST_DIR), '~', $command); - - $climate->out("phpfastcache@unit-tests {$projectDir} # $shortCommand"); - - \exec($command, $output, $return_var); - $climate->out('====================================='); - $climate->out(\implode("\n", $output)); - $climate->out('====================================='); - if ($return_var === 0) { - $climate->green("Test finished successfully"); - } elseif ($return_var === 2) { - $climate->yellow("Test skipped due to unmeet dependencies"); - $skippedTests[] = basename($filename); - } else { - $climate->red("Test finished with a least one error"); - $status = 1; - $failedTests[] = basename($filename); - } - - $climate->out(''); - /** - * Reset $output to prevent override effects - */ - unset($output); -} - -$execTime = gmdate('i\m s\s', (int) round(microtime(true) - $timestamp, 3)); -$climate->out('Total tests duration: ' . $execTime . ''); - -if (!$failedTests) { - $climate->backgroundGreen()->white()->flank('[OK] The build has passed successfully', '#')->out(''); -} else { - $climate->backgroundRed()->white()->flank('[KO] The build has failed miserably', '~')->out(''); - $climate->red()->out('[TESTS FAILED] ' . PHP_EOL . '- '. implode(PHP_EOL . '- ', $failedTests))->out(''); -} - -if ($skippedTests) { - $climate->yellow()->out('[TESTS SKIPPED] ' . PHP_EOL . '- '. implode(PHP_EOL . '- ', $skippedTests))->out(''); -} - -exit($status); diff --git a/tests/cases/AbstractProxy.test.php b/tests/cases/AbstractProxy.test.php deleted file mode 100644 index f2e88b1f0..000000000 --- a/tests/cases/AbstractProxy.test.php +++ /dev/null @@ -1,27 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -use Phpfastcache\Core\Item\ExtendedCacheItemInterface; -use Phpfastcache\Tests\Helper\TestHelper; -use Phpfastcache\Proxy\PhpfastcacheAbstractProxy; - -chdir(__DIR__); -require_once __DIR__ . '/../../vendor/autoload.php'; -$testHelper = new TestHelper('phpfastcacheAbstractProxy class'); -$defaultDriver = (!empty($argv[1]) ? ucfirst($argv[1]) : 'Files'); - -$testHelper->runCRUDTests( - new class($defaultDriver) extends PhpfastcacheAbstractProxy{} -); -$testHelper->terminateTest(); diff --git a/tests/cases/Apcu.test.php b/tests/cases/Apcu.test.php deleted file mode 100644 index 297f85935..000000000 --- a/tests/cases/Apcu.test.php +++ /dev/null @@ -1,24 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -use Phpfastcache\CacheManager; -use Phpfastcache\Tests\Helper\TestHelper; - -chdir(__DIR__); -require_once __DIR__ . '/../../vendor/autoload.php'; -$testHelper = new TestHelper('Apcu test (CRUD)'); -$pool = CacheManager::getInstance('Apcu'); -$pool->clear(); -$testHelper->runCRUDTests($pool); -$testHelper->terminateTest(); diff --git a/tests/cases/Api.test.php b/tests/cases/Api.test.php deleted file mode 100644 index 84a9483d0..000000000 --- a/tests/cases/Api.test.php +++ /dev/null @@ -1,63 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -use Phpfastcache\Api; -use Phpfastcache\Exceptions\PhpfastcacheRootException; -use Phpfastcache\Tests\Helper\TestHelper; - -chdir(__DIR__); -require_once __DIR__ . '/../../vendor/autoload.php'; -$testHelper = new TestHelper('API class'); - -/** - * Testing API version - */ -try { - $version = Api::getVersion(); - $testHelper->assertPass(sprintf('Successfully retrieved the API version: %s', $version)); -} catch (PhpfastcacheRootException $e) { - $testHelper->assertFail(sprintf('Failed to retrieve the API version with the following error error: %s', $e->getMessage())); -} - -/** - * Testing PhpFastCache version - */ -try { - $version = Api::getPhpfastcacheVersion(); - $testHelper->assertPass(sprintf('Successfully retrieved PhpFastCache version: %s', $version)); -} catch (PhpfastcacheRootException $e) { - $testHelper->assertFail(sprintf('Failed to retrieve the PhpFastCache version with the following error error: %s', $e->getMessage())); -} - -/** - * Testing API changelog - */ -try { - $changelog = Api::getChangelog(); - $testHelper->assertPass(sprintf("Successfully retrieved API changelog:\n%s", $changelog)); -} catch (PhpfastcacheRootException $e) { - $testHelper->assertFail(sprintf('Failed to retrieve the API changelog with the following error error: %s', $e->getMessage())); -} - -/** - * Testing PhpFastCache changelog - */ -try { - $changelog = Api::getPhpfastcacheChangelog(); - $testHelper->assertPass(sprintf("Successfully retrieved PhpFastCache changelog:\n%s", $changelog)); -} catch (PhpfastcacheRootException $e) { - $testHelper->assertFail(sprintf('Failed to retrieve the PhpFastCache changelog with the following error error: %s', $e->getMessage())); -} - -$testHelper->terminateTest(); diff --git a/tests/cases/AtomicOperations.test.php b/tests/cases/AtomicOperations.test.php deleted file mode 100644 index cf9dcdc4f..000000000 --- a/tests/cases/AtomicOperations.test.php +++ /dev/null @@ -1,130 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -use Phpfastcache\CacheManager; -use Phpfastcache\Tests\Helper\TestHelper; - -chdir(__DIR__); -require_once __DIR__ . '/../../vendor/autoload.php'; -require_once __DIR__ . '/../mock/Autoload.php'; -$testHelper = new TestHelper('Atomic Operations'); -$pool = CacheManager::getInstance('Memstatic'); -$testHelper->printInfoText('Testing APPEND/PREPEND methods...'); - -{ - $cacheItem = $pool->getItem($testHelper->getRandomKey()); - $cacheItem->set(['alpha', 'bravo']); - $cacheItem->append('charlie'); - $pool->save($cacheItem); - - $target = ['alpha', 'bravo', 'charlie']; - if(count(array_intersect($cacheItem->get(), $target)) === count($target)){ - $testHelper->assertPass('Atomic operation APPEND on ARRAY works as expected'); - } else { - $testHelper->assertFail('Atomic operation APPEND on ARRAY did not worked as expected'); - } -} - -// Reset pool -unset($target, $cacheItem); -$pool->clear(); - - -{ - $cacheItem = $pool->getItem($testHelper->getRandomKey()); - $cacheItem->set('alpha_bravo'); - $cacheItem->append('_charlie'); - $pool->save($cacheItem); - - $target = 'alpha_bravo_charlie'; - if($cacheItem->get() === $target){ - $testHelper->assertPass('Atomic operation APPEND on STRING works as expected'); - } else { - $testHelper->assertFail('Atomic operation APPEND on STRING did not worked as expected'); - } -} - -// Reset pool -unset($target, $cacheItem); -$pool->clear(); - -{ - $cacheItem = $pool->getItem($testHelper->getRandomKey()); - $cacheItem->set(['bravo', 'charlie']); - $cacheItem->prepend('alpha'); - $pool->save($cacheItem); - - $target = ['alpha', 'bravo', 'charlie']; - if(count(array_intersect($cacheItem->get(), $target)) === count($target)){ - $testHelper->assertPass('Atomic operation PREPEND on ARRAY works as expected'); - } else { - $testHelper->assertFail('Atomic operation PREPEND on ARRAY did not worked as expected'); - } -} - -// Reset pool -unset($target, $cacheItem); -$pool->clear(); - -{ - $cacheItem = $pool->getItem($testHelper->getRandomKey()); - $cacheItem->set('bravo_charlie'); - $cacheItem->prepend('alpha_'); - $pool->save($cacheItem); - - $target = 'alpha_bravo_charlie'; - if($cacheItem->get() === $target){ - $testHelper->assertPass('Atomic operation PREPEND on STRING works as expected'); - } else { - $testHelper->assertFail('Atomic operation PREPEND on STRING did not worked as expected'); - } -} - -// Reset pool -unset($target, $cacheItem); -$pool->clear(); - -$testHelper->printInfoText('Testing INCREMENT/DECREMENT methods...'); - -{ - $cacheItem = $pool->getItem($testHelper->getRandomKey()); - $cacheItem->set(1330); - $cacheItem->increment(3 + 4); - $pool->save($cacheItem); - - if($cacheItem->get() === 1337){ - $testHelper->assertPass('Atomic operation INCREMENT on INT works as expected'); - } else { - $testHelper->assertFail('Atomic operation INCREMENT on INT did not worked as expected'); - } -} - -// Reset pool -unset($target, $cacheItem); -$pool->clear(); - -{ - $cacheItem = $pool->getItem($testHelper->getRandomKey()); - $cacheItem->set(1340); - $cacheItem->decrement(4 - 1); - $pool->save($cacheItem); - - if($cacheItem->get() === 1337){ - $testHelper->assertPass('Atomic operation DECREMENT on INT works as expected'); - } else { - $testHelper->assertFail('Atomic operation DECREMENT on INT did not worked as expected'); - } -} - -$testHelper->terminateTest(); diff --git a/tests/cases/AttachingDetachingMethods.test.php b/tests/cases/AttachingDetachingMethods.test.php deleted file mode 100644 index df07898dd..000000000 --- a/tests/cases/AttachingDetachingMethods.test.php +++ /dev/null @@ -1,55 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -use Phpfastcache\CacheManager; -use Phpfastcache\Exceptions\PhpfastcacheLogicException; -use Phpfastcache\Tests\Helper\TestHelper; -use Psr\Cache\CacheItemPoolInterface; - -chdir(__DIR__); -require_once __DIR__ . '/../../vendor/autoload.php'; -$testHelper = new TestHelper('[A|De]ttaching methods'); -$defaultDriver = (!empty($argv[1]) ? ucfirst($argv[1]) : 'Files'); - -/** - * Testing memcached as it is declared in .travis.yml - */ -$driverInstance = CacheManager::getInstance($defaultDriver); - -if (!is_object($driverInstance)) { - $testHelper->assertFail('CacheManager::getInstance() returned an invalid variable type:' . gettype($driverInstance)); -} elseif (!($driverInstance instanceof CacheItemPoolInterface)) { - $testHelper->assertFail('CacheManager::getInstance() returned an invalid class:' . get_class($driverInstance)); -} else { - $key = 'test_attaching_detaching'; - - $itemDetached = $driverInstance->getItem($key); - $driverInstance->detachItem($itemDetached); - $itemAttached = $driverInstance->getItem($key); - - if ($driverInstance->isAttached($itemDetached) !== true) { - $testHelper->assertPass('ExtendedCacheItemPoolInterface::isAttached() identified $itemDetached as being detached.'); - } else { - $testHelper->assertFail('ExtendedCacheItemPoolInterface::isAttached() failed to identify $itemDetached as to be detached.'); - } - - try { - $driverInstance->attachItem($itemDetached); - $testHelper->assertFail('ExtendedCacheItemPoolInterface::attachItem() attached $itemDetached without trowing an error.'); - } catch (PhpfastcacheLogicException $e) { - $testHelper->assertPass('ExtendedCacheItemPoolInterface::attachItem() failed to attach $itemDetached by trowing a phpfastcacheLogicException exception.'); - } -} - -$testHelper->terminateTest(); diff --git a/tests/cases/CacheClearSingleInstance.test.php b/tests/cases/CacheClearSingleInstance.test.php deleted file mode 100644 index d2ad5d1c3..000000000 --- a/tests/cases/CacheClearSingleInstance.test.php +++ /dev/null @@ -1,51 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -use Phpfastcache\Core\Pool\ExtendedCacheItemPoolInterface; -use Phpfastcache\CacheManager; -use Phpfastcache\Exceptions\PhpfastcacheInstanceNotFoundException; -use Phpfastcache\Tests\Helper\TestHelper; - -chdir(__DIR__); -require_once __DIR__ . '/../../vendor/autoload.php'; -$testHelper = new TestHelper('Clear single cache instance'); -$defaultDriver = (!empty($argv[1]) ? \ucfirst($argv[1]) : 'Files'); -$instanceId = str_shuffle(md5(\time() - \random_int(0, 86400))); -$instanceId2 = str_shuffle(md5(\time() - \random_int(0, 86400))); -$instanceId3 = str_shuffle(md5(\time() - \random_int(0, 86400))); -$instanceId4 = str_shuffle(md5(\time() - \random_int(0, 86400))); - -$driverInstance = CacheManager::getInstance($defaultDriver, null, $instanceId); -$driverInstance2 = CacheManager::getInstance($defaultDriver, null, $instanceId2); -$driverInstance3 = CacheManager::getInstance($defaultDriver, null, $instanceId3); -$driverInstance4 = CacheManager::getInstance($defaultDriver, null, $instanceId4); - -CacheManager::clearInstance($driverInstance2); - -$cacheInstances = CacheManager::getInstances(); -if (\count($cacheInstances) === 3) { - $testHelper->assertPass('A single cache instance have been cleared'); -} else { - $testHelper->assertFail('A single cache instance have NOT been cleared'); -} - -$driverInstance2Hash = spl_object_hash($driverInstance2); -foreach ($cacheInstances as $cacheInstance) { - $driverInstanceHash = spl_object_hash($cacheInstance); - if ($driverInstanceHash !== $driverInstance2Hash) { - $testHelper->assertPass("Compared cache instance #{$driverInstanceHash} does not match with previously cleared cache instance #" . $driverInstance2Hash); - } else { - $testHelper->assertFail("Compared cache instance #{$driverInstanceHash} unfortunately match with previously cleared cache instance #" . $driverInstance2Hash); - } -} diff --git a/tests/cases/CacheContract.test.php b/tests/cases/CacheContract.test.php deleted file mode 100644 index 47acf4f89..000000000 --- a/tests/cases/CacheContract.test.php +++ /dev/null @@ -1,143 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -use Phpfastcache\CacheManager; -use Phpfastcache\Core\Item\ExtendedCacheItemInterface; -use Phpfastcache\CacheContract; -use Phpfastcache\Tests\Helper\TestHelper; -use Psr\Cache\CacheItemInterface; - -chdir(__DIR__); -require_once __DIR__ . '/../../vendor/autoload.php'; -$testHelper = new TestHelper('Cache Contract'); -$defaultDriver = (!empty($argv[ 1 ]) ? ucfirst($argv[ 1 ]) : 'Files'); -$cacheInstance = CacheManager::getInstance($defaultDriver); -$cacheKey = 'cacheKey'; -$RandomCacheValue = str_shuffle(uniqid('pfc', true)); -$cacheInstance->clear(); - -/** - * Missing cache item test - */ -$cacheValue = (new CacheContract($cacheInstance))->get($cacheKey, static function () use ($testHelper, $RandomCacheValue) { - if (func_get_arg(0) instanceof ExtendedCacheItemInterface) { - $testHelper->assertPass('The callback has been received the cache item as a parameter (introduced in 8.0.6).'); - } else { - $testHelper->assertFail('The callback has not received the cache item as a parameter (introduced in 8.0.6).'); - } - /** - * No parameters are passed - * to this closure - */ - $testHelper->printText('Entering in closure as the cache item does not come from the cache backend.'); - - /** - * Here's your database/webservice/etc. stuff - */ - - return $RandomCacheValue . '-1337'; -}); - -if ($cacheValue === $RandomCacheValue . '-1337') { - $testHelper->assertPass(sprintf('The cache contract successfully returned expected value "%s".', $cacheValue)); -} else { - $testHelper->assertFail(sprintf('The cache contract returned an unexpected value "%s".', $cacheValue)); -} - -/** - * Existing cache item test - */ -$cacheItem = $cacheInstance->getItem($cacheKey); -$RandomCacheValue = str_shuffle(uniqid('pfc', true)); -$cacheItem->set($RandomCacheValue); -$cacheInstance->save($cacheItem); - -/** - * Remove objects references - */ -$cacheInstance->detachAllItems(); -unset($cacheItem); - -$cacheValue = (new CacheContract($cacheInstance))->get($cacheKey, static function () use ($cacheKey, $testHelper, $RandomCacheValue) { - /** - * No parameter are passed - * to this closure - */ - $testHelper->assertFail('Unexpected closure call.'); - return $RandomCacheValue . '-1337'; -}); - -if ($cacheValue === $RandomCacheValue) { - $testHelper->assertPass(sprintf('The cache contract successfully returned expected value "%s".', $cacheValue)); -} else { - $testHelper->assertFail(sprintf('The cache contract returned an unexpected value "%s".', $cacheValue)); -} - -$cacheInstance->clear(); - -/** - * Test TTL - * @since 7.0 - */ -$ttl = 5; -$RandomCacheValue = str_shuffle(uniqid('pfc', true)); -$cacheInstance->detachAllItems(); -unset($cacheItem); - -$cacheValue = (new CacheContract($cacheInstance))->get($cacheKey, static fn() => $RandomCacheValue, $ttl); - -$testHelper->printText(sprintf('Sleeping for %d seconds...', $ttl)); -sleep($ttl + 1); -$cacheInstance->detachAllItems(); -$cacheItem = $cacheInstance->getItem($cacheKey); - -if (!$cacheItem->isHit()) { - $testHelper->assertPass(sprintf('The cache contract ttl successfully expired the cache after %d seconds', $ttl)); -} else { - $testHelper->assertFail(sprintf('The cache contract ttl does not expired the cache after %d seconds', $ttl)); -} - -/** - * Test closure first argument - * @since 8.0.6 - */ -$cacheInstance->clear(); -(new CacheContract($cacheInstance))->get($cacheKey, static function () use ($testHelper) { - $args = func_get_args(); - if (isset($args[0]) && $args[0] instanceof CacheItemInterface) { - $testHelper->assertPass('The callback has been received the cache item as the first parameter'); - } else { - $testHelper->assertFail('The callback did not received the cache item as the first parameter'); - } -}); - - -/** - * Test callable cache contract syntax via __invoke() - * @since 8.0.6 - */ -$cacheInstance->clear(); -try { - $value = (new CacheContract($cacheInstance))($cacheKey, static function () use ($testHelper) { - $testHelper->assertPass('The CacheContract class is callable via __invoke()'); - return null; - }); -} catch (\Error $e) { - $testHelper->assertFail('The CacheContract class is not callable via __invoke()'); -} catch (\Throwable $e) { - $testHelper->assertFail('Got an unknown error: ' . $e->getMessage()); -} - -$cacheInstance->clear(); -$testHelper->terminateTest(); diff --git a/tests/cases/CacheInstanceId.test.php b/tests/cases/CacheInstanceId.test.php deleted file mode 100644 index 53b62a7ff..000000000 --- a/tests/cases/CacheInstanceId.test.php +++ /dev/null @@ -1,41 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -use Phpfastcache\Core\Pool\ExtendedCacheItemPoolInterface; -use Phpfastcache\CacheManager; -use Phpfastcache\Exceptions\PhpfastcacheInstanceNotFoundException; -use Phpfastcache\Tests\Helper\TestHelper; - -chdir(__DIR__); -require_once __DIR__ . '/../../vendor/autoload.php'; -$testHelper = new TestHelper('New cache instance'); -$defaultDriver = (!empty($argv[1]) ? ucfirst($argv[1]) : 'Files'); -$instanceId = str_shuffle(md5(time() - mt_rand(0, 86400))); - -$driverInstance = CacheManager::getInstance($defaultDriver, null, $instanceId); - -if ($driverInstance->getInstanceId() !== $instanceId) { - $testHelper->assertFail('Unexpected instance ID: ' . $driverInstance->getInstanceId()); -} else { - $testHelper->assertPass('Got expected instance ID: ' . $instanceId); -} - -try { - CacheManager::getInstanceById(str_shuffle($instanceId)); - $testHelper->assertFail('Non-existing instance ID has thrown no exception'); -} catch (PhpfastcacheInstanceNotFoundException $e) { - $testHelper->assertPass('Non-existing instance ID has thrown an exception'); -} - -$testHelper->terminateTest(); diff --git a/tests/cases/CacheItemAtomicMethods.test.php b/tests/cases/CacheItemAtomicMethods.test.php deleted file mode 100644 index 7a9baa505..000000000 --- a/tests/cases/CacheItemAtomicMethods.test.php +++ /dev/null @@ -1,56 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -use Phpfastcache\Core\Pool\ExtendedCacheItemPoolInterface; -use Phpfastcache\CacheManager; -use Phpfastcache\Exceptions\PhpfastcacheInstanceNotFoundException; -use Phpfastcache\Tests\Helper\TestHelper; - -chdir(__DIR__); -require_once __DIR__ . '/../../vendor/autoload.php'; -$testHelper = new TestHelper('Cache Item Atomic Methods'); -$defaultDriver = (!empty($argv[1]) ? ucfirst($argv[1]) : 'Files'); - -$driverInstance = CacheManager::getInstance($defaultDriver); -$testItem = $driverInstance->getItem('test-item'); -$cacheTestData = 'I <3 PhpFastCache'; - -$testItem->set($cacheTestData)->expiresAfter(600); -$driverInstance->save($testItem); -unset($testItem); -$driverInstance->detachAllItems(); - -$testItem = $driverInstance->getItem('test-item'); - -if ($testItem->getLength() === \strlen($cacheTestData)) { - $testHelper->assertPass('Atomic method getLength() returned the exact length'); -} else { - $testHelper->assertPass('Atomic method getLength() returned an unexpected length' . $testItem->getLength()); -} - -if (!$testItem->isNull()) { - $testHelper->assertPass('Atomic method isNull() returned FALSE'); -} else { - $testHelper->assertPass('Atomic method isNull() returned TRUE'); -} - -if (!$testItem->isEmpty()) { - $testHelper->assertPass('Atomic method isEmpty() returned FALSE'); -} else { - $testHelper->assertPass('Atomic method isEmpty() returned TRUE'); -} - - - -$testHelper->terminateTest(); diff --git a/tests/cases/CacheItemDetailedDate.test.php b/tests/cases/CacheItemDetailedDate.test.php deleted file mode 100644 index 07dd760a3..000000000 --- a/tests/cases/CacheItemDetailedDate.test.php +++ /dev/null @@ -1,106 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -use Phpfastcache\CacheManager; -use Phpfastcache\Config\ConfigurationOption; -use Phpfastcache\Exceptions\PhpfastcacheLogicException; -use Phpfastcache\CacheContract as CacheConditional; -use Phpfastcache\Tests\Helper\TestHelper; -use Psr\Cache\CacheItemPoolInterface; - -chdir(__DIR__); -require_once __DIR__ . '/../../vendor/autoload.php'; -$testHelper = new TestHelper('Cache option: itemDetailedDate'); -$defaultDriver = (!empty($argv[ 1 ]) ? ucfirst($argv[ 1 ]) : 'Files'); -$cacheInstance = CacheManager::getInstance($defaultDriver, new ConfigurationOption([ - 'itemDetailedDate' => true, - 'path' => __DIR__ . '/../cache/' -])); -$cacheKey = 'cacheKey'; -$RandomCacheValue = str_shuffle(uniqid('pfc', true)); - -$testHelper->printText('Preparing cache test item...'); -$realCreationDate = new \DateTime(); -$cacheItem = $cacheInstance->getItem($cacheKey); -$cacheItem->set($RandomCacheValue)->expiresAfter(60); -$cacheInstance->save($cacheItem); -$cacheInstance->detachAllItems(); -$diffSeconds = 3; - -unset($cacheItem); -for ($i = 0; $i < $diffSeconds; $i++) { - $testHelper->printText(sprintf("Sleeping {$diffSeconds} seconds (%ds elapsed)", $i + 1)); - sleep(1); -} -$testHelper->printText('Triggering modification date...'); - -$cacheItem = $cacheInstance->getItem($cacheKey); -$cacheItem->set(str_shuffle($RandomCacheValue)); -$realModificationDate = new \DateTime(); -$cacheInstance->save($cacheItem); -$cacheInstance->detachAllItems(); -unset($cacheItem); - -for ($i = 0; $i < $diffSeconds; $i++) { - $testHelper->printText(sprintf("Sleeping {$diffSeconds} additional seconds (%ds elapsed)", $i + 1)); - sleep(1); -} -$cacheItem = $cacheInstance->getItem($cacheKey); - -try { - $creationDate = $cacheItem->getCreationDate(); - if ($creationDate instanceof \DateTimeInterface) { - $testHelper->assertPass('The method getCreationDate() returned a DateTimeInterface object'); - if ($creationDate->format(DateTime::W3C) === $realCreationDate->format(DateTime::W3C)) { - $testHelper->assertPass('The item creation date effectively represents the real creation date (obviously).'); - } else { - $testHelper->assertFail('The item creation date does not represents the real creation date.'); - } - } else { - $testHelper->assertFail('The method getCreationDate() does not returned a DateTimeInterface object, got: ' . var_export($creationDate, true)); - } -} catch (PhpfastcacheLogicException $e) { - $testHelper->assertFail('The method getCreationDate() unexpectedly thrown a phpfastcacheLogicException'); -} - -try { - $modificationDate = $cacheItem->getModificationDate(); - if ($modificationDate instanceof \DateTimeInterface) { - $testHelper->assertPass('The method getModificationDate() returned a DateTimeInterface object'); - if ($modificationDate->format(DateTime::W3C) === $realModificationDate->format(DateTime::W3C)) { - $testHelper->assertPass('The item modification date effectively represents the real modification date (obviously).'); - } else { - $testHelper->assertFail('The item modification date does not represents the real modification date.'); - } - /** - * Using >= operator instead of === due to a possible micro time - * offset that can often results to a value of 6 seconds (rounded) - */ - if ($modificationDate->getTimestamp() - $cacheItem->getCreationDate()->getTimestamp() >= $diffSeconds) { - $testHelper->assertPass("The item modification date is effectively {$diffSeconds} seconds greater than the creation date."); - } else { - $testHelper->assertFail('The item modification date effectively is not greater than the creation date.'); - } - } else { - $testHelper->assertFail('The method getModificationDate() does not returned a DateTimeInterface object, got: ' . var_export($modificationDate, true)); - } -} catch (PhpfastcacheLogicException $e) { - $testHelper->assertFail('The method getModificationDate() unexpectedly thrown a phpfastcacheLogicException'); -} - -$cacheInstance->clear(); -unset($cacheInstance); -CacheManager::clearInstances(); - -$testHelper->terminateTest(); diff --git a/tests/cases/CacheSlamsProtection.test.php b/tests/cases/CacheSlamsProtection.test.php deleted file mode 100644 index 20521ebb7..000000000 --- a/tests/cases/CacheSlamsProtection.test.php +++ /dev/null @@ -1,64 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -use Phpfastcache\CacheManager; -use Phpfastcache\Config\IOConfigurationOption; -use Phpfastcache\Core\Pool\ExtendedCacheItemPoolInterface; -use Phpfastcache\Entities\ItemBatch; -use Phpfastcache\EventManager; -use Phpfastcache\Tests\Helper\TestHelper; - -chdir(__DIR__); -require_once __DIR__ . '/../../vendor/autoload.php'; -$testHelper = new TestHelper('Cache Slams Protection'); -$defaultDriver = (!empty($argv[ 1 ]) ? ucfirst($argv[ 1 ]) : 'Files'); -$driverInstance = CacheManager::getInstance($defaultDriver, new IOConfigurationOption([ - 'preventCacheSlams' => true, - 'cacheSlamsTimeout' => 20 -])); - -if (!$testHelper->isHHVM()) { - EventManager::getInstance()->onCacheGetItemInSlamBatch(function (ExtendedCacheItemPoolInterface $itemPool, ItemBatch $driverData, $cacheSlamsSpendSeconds) use ($testHelper) { - $testHelper->printText("Looping in batch for {$cacheSlamsSpendSeconds} second(s) with a batch from " . $driverData->getItemDate()->format(\DateTime::W3C)); - }); - - $testHelper->runSubProcess('CacheSlamsProtection'); - /** - * Give some time to the - * subprocess to start - * just like a concurrent - * php request - */ - usleep(mt_rand(250000, 800000)); - - $item = $driverInstance->getItem('TestCacheSlamsProtection'); - - /** - * @see CacheSlamsProtection.subprocess.php:28 - */ - if ($item->isHit() && $item->get() === 1337) { - $testHelper->assertPass('The batch has expired and returned a non-empty item with expected value: ' . $item->get()); - } else { - $testHelper->assertFail('The batch has expired and returned an empty item with expected value: ' . print_r($item->get(), true)); - } - - /** - * Cleanup the driver - */ - $driverInstance->deleteItem($item->getKey()); -} else { - $testHelper->assertSkip('Test ignored on HHVM builds due to sub-process issues with C.I.'); -} - -$testHelper->terminateTest(); diff --git a/tests/cases/Casssandra.test.php b/tests/cases/Casssandra.test.php deleted file mode 100644 index 9e04e5e31..000000000 --- a/tests/cases/Casssandra.test.php +++ /dev/null @@ -1,24 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -use Phpfastcache\CacheManager; -use Phpfastcache\Tests\Helper\TestHelper; - -chdir(__DIR__); -require_once __DIR__ . '/../../vendor/autoload.php'; -$testHelper = new TestHelper('Apcu test (CRUD)'); -$pool = CacheManager::getInstance('Cassandra'); -$pool->clear(); -$testHelper->runCRUDTests($pool); -$testHelper->terminateTest(); diff --git a/tests/cases/ClusterFullReplication.test.php b/tests/cases/ClusterFullReplication.test.php deleted file mode 100644 index b37a8d287..000000000 --- a/tests/cases/ClusterFullReplication.test.php +++ /dev/null @@ -1,34 +0,0 @@ -ClusterFullReplication.test.php - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -use Phpfastcache\Api; -use Phpfastcache\CacheManager; -use Phpfastcache\Cluster\AggregatorInterface; -use Phpfastcache\Cluster\ClusterAggregator; -use Phpfastcache\Exceptions\PhpfastcacheRootException; -use Phpfastcache\Tests\Helper\TestHelper; - -chdir(__DIR__); -require_once __DIR__ . '/../../vendor/autoload.php'; -$testHelper = new TestHelper('Full Replication Cluster'); - -$clusterAggregator = new ClusterAggregator('test_20'); -$clusterAggregator->aggregateDriver(CacheManager::getInstance('Redis')); -$clusterAggregator->aggregateDriver(CacheManager::getInstance('Files')); -$clusterAggregator->aggregateDriver(CacheManager::getInstance('Sqlite')); -$cluster = $clusterAggregator->getCluster(AggregatorInterface::STRATEGY_FULL_REPLICATION); - -$testHelper->runCRUDTests($cluster); - -$testHelper->terminateTest(); diff --git a/tests/cases/ClusterMasterSlaveReplication.test.php b/tests/cases/ClusterMasterSlaveReplication.test.php deleted file mode 100644 index 53d20a878..000000000 --- a/tests/cases/ClusterMasterSlaveReplication.test.php +++ /dev/null @@ -1,90 +0,0 @@ -ClusterFullReplication.test.php - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -use Phpfastcache\CacheManager; -use Phpfastcache\Cluster\AggregatorInterface; -use Phpfastcache\Cluster\ClusterAggregator; -use Phpfastcache\Cluster\ItemAbstract; -use Phpfastcache\Core\Pool\ExtendedCacheItemPoolInterface; -use Phpfastcache\Drivers\Failfiles\Driver as FailFilesDriver; -use Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException; -use Phpfastcache\Tests\Helper\TestHelper; - -chdir(__DIR__); -require_once __DIR__ . '/../../vendor/autoload.php'; -require_once __DIR__ . '/../mock/Autoload.php'; -$testHelper = new TestHelper('Master/Slave Replication Cluster'); - -CacheManager::addCustomDriver('Failfiles', FailFilesDriver::class); -$clusterAggregator = new ClusterAggregator('test_10'); -$unwantedPool = CacheManager::getInstance('Redis'); -$clusterAggregator->aggregateDriver(CacheManager::getInstance('Failfiles')); -$clusterAggregator->aggregateDriver(CacheManager::getInstance('Sqlite')); -$clusterAggregator->aggregateDriver($unwantedPool); - -try { - $cluster = $clusterAggregator->getCluster(AggregatorInterface::STRATEGY_MASTER_SLAVE); - $testHelper->assertFail('The Master/Slave cluster did not thrown an exception with more than 2 pools aggregated.'); -} catch (PhpfastcacheInvalidArgumentException $e) { - $testHelper->assertPass('The Master/Slave cluster thrown an exception with more than 2 pools aggregated.'); -} -$clusterAggregator->disaggregateDriver($unwantedPool); -$cluster = $clusterAggregator->getCluster(AggregatorInterface::STRATEGY_MASTER_SLAVE); - -$testPasses = false; -$cluster->getEventManager()->onCacheReplicationSlaveFallback( - static function (ExtendedCacheItemPoolInterface $pool, string $actionName) use (&$testPasses) { - if ($actionName === 'getItem') { - $testPasses = true; - } - } -); -$cacheItem = $cluster->getItem('test-test'); - -if ($testPasses && $cacheItem instanceof ItemAbstract) { - $testHelper->assertPass('The Master/Slave cluster successfully switched to slave cluster after backend I/O error.'); -} else { - $testHelper->assertFail('The Master/Slave cluster failed to switch to slave cluster after backend I/O error.'); -} -unset($unwantedPool, $cacheItem, $testPasses, $cluster, $clusterAggregator); -CacheManager::clearInstances(); - -$clusterAggregator = new ClusterAggregator('test_20'); -$clusterAggregator->aggregateDriver(CacheManager::getInstance('Redis')); -$clusterAggregator->aggregateDriver(CacheManager::getInstance('Files')); -$cluster = $clusterAggregator->getCluster(AggregatorInterface::STRATEGY_MASTER_SLAVE); -$cluster->clear(); -$cacheKey = 'cache_' . \bin2hex(\random_bytes(12)); -$cacheValue = 'cache_' . \random_int(1000, 999999); -$cacheItem = $cluster->getItem($cacheKey); - -$cacheItem->set($cacheValue); -$cacheItem->expiresAfter(600); -if ($cluster->save($cacheItem)) { - $testHelper->assertPass('The Master/Slave cluster successfully saved an item.'); -} else { - $testHelper->assertFail('The Master/Slave cluster failed to save an item.'); -} -unset($clusterAggregator, $cluster, $cacheItem); -CacheManager::clearInstances(); - -$clusterAggregator = new ClusterAggregator('test_20'); -$clusterAggregator->aggregateDriver(CacheManager::getInstance('Redis')); -$clusterAggregator->aggregateDriver(CacheManager::getInstance('Files')); -$cluster = $clusterAggregator->getCluster(AggregatorInterface::STRATEGY_MASTER_SLAVE); -$cluster->clear(); - -$testHelper->runCRUDTests($cluster); - -$testHelper->terminateTest(); diff --git a/tests/cases/ClusterRandomReplication.test.php b/tests/cases/ClusterRandomReplication.test.php deleted file mode 100644 index 777951348..000000000 --- a/tests/cases/ClusterRandomReplication.test.php +++ /dev/null @@ -1,44 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -use Phpfastcache\CacheManager; -use Phpfastcache\Cluster\AggregatorInterface; -use Phpfastcache\Cluster\ClusterAggregator; -use Phpfastcache\Drivers\Files\Config as FilesConfig; -use Phpfastcache\Drivers\Sqlite\Config as SqliteConfig; -use Phpfastcache\Tests\Helper\TestHelper; - -chdir(__DIR__); -require_once __DIR__ . '/../../vendor/autoload.php'; -require_once __DIR__ . '/../mock/Autoload.php'; -$testHelper = new TestHelper('Master/Slave Replication Cluster'); - -CacheManager::clearInstances(); - -$clusterAggregator = new ClusterAggregator('test_20'); -$clusterAggregator->aggregateDriver(CacheManager::getInstance('Redis')); -$clusterAggregator->aggregateDriver(CacheManager::getInstance('Sqlite', new SqliteConfig(['securityKey' => 'unit_tests']))); -$clusterAggregator->aggregateDriver(CacheManager::getInstance('Files', new FilesConfig(['securityKey' => 'unit_tests']))); -$cluster = $clusterAggregator->getCluster(AggregatorInterface::STRATEGY_RANDOM_REPLICATION); -$cluster->clear(); - -$testHelper->runCRUDTests($cluster); - -if($cluster->getClusterPools()[0]->isAggregatedBy() === $cluster){ - $testHelper->assertPass('The cluster aggregator set is the same as the cluster container.'); -} else { - $testHelper->assertFail('The cluster aggregator set is NOT the same as the cluster container.'); -} - -$testHelper->terminateTest(); diff --git a/tests/cases/ClusterSemiReplication.test.php b/tests/cases/ClusterSemiReplication.test.php deleted file mode 100644 index 49179d450..000000000 --- a/tests/cases/ClusterSemiReplication.test.php +++ /dev/null @@ -1,33 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -use Phpfastcache\Api; -use Phpfastcache\CacheManager; -use Phpfastcache\Cluster\AggregatorInterface; -use Phpfastcache\Cluster\ClusterAggregator; -use Phpfastcache\Exceptions\PhpfastcacheRootException; -use Phpfastcache\Tests\Helper\TestHelper; - -chdir(__DIR__); -require_once __DIR__ . '/../../vendor/autoload.php'; -$testHelper = new TestHelper('Semi Replication Cluster'); - -$clusterAggregator = new ClusterAggregator('test_20'); -$clusterAggregator->aggregateDriver(CacheManager::getInstance('Files')); -$clusterAggregator->aggregateDriver(CacheManager::getInstance('Redis')); -$clusterAggregator->aggregateDriver(CacheManager::getInstance('Sqlite')); -$cluster = $clusterAggregator->getCluster(AggregatorInterface::STRATEGY_SEMI_REPLICATION); -$cluster->clear(); -$testHelper->runCRUDTests($cluster); -$testHelper->terminateTest(); diff --git a/tests/cases/ConfigurationValidator.test.php b/tests/cases/ConfigurationValidator.test.php deleted file mode 100644 index 66504fffe..000000000 --- a/tests/cases/ConfigurationValidator.test.php +++ /dev/null @@ -1,58 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -use Phpfastcache\CacheManager; -use Phpfastcache\Exceptions\PhpfastcacheInvalidConfigurationException; -use Phpfastcache\Exceptions\PhpfastcacheInvalidTypeException; -use Phpfastcache\Tests\Helper\TestHelper; -use Phpfastcache\Drivers\Files\Config as FilesConfig; - -chdir(__DIR__); -require_once __DIR__ . '/../../vendor/autoload.php'; -$testHelper = new TestHelper('Configuration validator'); - - -$tests = [ - [ - 'Files' => [ - 'path' => new \StdClass, - ], - ], - [ - 'Files' => [ - 'htaccess' => new \StdClass, - ], - ], - [ - 'Files' => [ - 'defaultTtl' => [], - ], - ], - [ - 'Files' =>[ - 'unwantedOption' => new \StdClass, - ], - ], -]; - -foreach ($tests as $test) { - try { - CacheManager::getInstance(key($test), new FilesConfig(current($test))); - $testHelper->assertFail('Configuration validator has failed to correctly validate a driver configuration option'); - } catch (PhpfastcacheInvalidTypeException|PhpfastcacheInvalidConfigurationException $e) { - $testHelper->assertPass('Configuration validator has successfully validated a driver configuration option by throwing an Exception --- ' . $e->getMessage()); - } -} - -$testHelper->terminateTest(); diff --git a/tests/cases/CoreDriverOverride.test.php b/tests/cases/CoreDriverOverride.test.php deleted file mode 100644 index d0b3d03c8..000000000 --- a/tests/cases/CoreDriverOverride.test.php +++ /dev/null @@ -1,102 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -use Phpfastcache\CacheManager; -use Phpfastcache\DriverTest\Files2\Config; -use Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException; -use Phpfastcache\Exceptions\PhpfastcacheLogicException; -use Phpfastcache\CacheContract as CacheConditional; -use Phpfastcache\Tests\Helper\TestHelper; - -chdir(__DIR__); -require_once __DIR__ . '/../../vendor/autoload.php'; -require_once __DIR__ . '/../mock/Autoload.php'; -$testHelper = new TestHelper('Core driver override'); - -if (!class_exists(Phpfastcache\DriverTest\Files2\Item::class) - || !class_exists(Phpfastcache\DriverTest\Files2\Driver::class) - || !class_exists(Phpfastcache\DriverTest\Files2\Config::class) -) { - $testHelper->assertFail('The php classes of driver "Files2" do not exist'); - $testHelper->terminateTest(); -} else { - $testHelper->assertPass('The php classes of driver "Files2" were found'); -} - -try { - CacheManager::addCoreDriverOverride('Files2', \Phpfastcache\DriverTest\Files2\Driver::class); - $testHelper->assertFail('No exception thrown while trying to override an non-existing driver'); -} catch (PhpfastcacheLogicException $e) { - $testHelper->assertPass('An exception has been thrown while trying to override an non-existing driver'); -} - -try { - CacheManager::addCoreDriverOverride('', \Phpfastcache\DriverTest\Files2\Driver::class); - $testHelper->assertFail('No exception thrown while trying to override an empty driver'); -} catch (PhpfastcacheInvalidArgumentException $e) { - $testHelper->assertPass('An exception has been thrown while trying to override an empty driver'); -} - -CacheManager::addCoreDriverOverride('Files', \Phpfastcache\DriverTest\Files2\Driver::class); - -$cacheInstance = CacheManager::getInstance('Files', new Config(['customOption' => true])); -$cacheKey = 'cacheKey'; -$RandomCacheValue = str_shuffle(uniqid('pfc', true)); - -if ($cacheInstance instanceof \Phpfastcache\DriverTest\Files2\Driver) { - $testHelper->assertPass('The cache instance is effectively an instance of an override class'); -} else { - $testHelper->assertFail('The cache instance is not an instance of an override class'); -} - -/** - * Existing cache item test - */ -$cacheItem = $cacheInstance->getItem($cacheKey); -$RandomCacheValue = str_shuffle(uniqid('pfc', true)); -$cacheItem->set($RandomCacheValue); -$cacheInstance->save($cacheItem); - -/** - * Remove objects references - */ -$cacheInstance->detachAllItems(); -unset($cacheItem); - -$cacheValue = (new CacheConditional($cacheInstance))->get($cacheKey, function () use ($cacheKey, $testHelper, $RandomCacheValue) { - /** - * No parameter are passed - * to this closure - */ - $testHelper->assertFail('Unexpected closure call.'); - return $RandomCacheValue . '-1337'; -}); - -if ($cacheValue === $RandomCacheValue) { - $testHelper->assertPass(sprintf('The cache promise successfully returned expected value "%s".', $cacheValue)); -} else { - $testHelper->assertFail(sprintf('The cache promise returned an unexpected value "%s".', $cacheValue)); -} - -CacheManager::removeCoreDriverOverride('Files'); -$cacheInstance = CacheManager::getInstance('Files'); - -if ($cacheInstance instanceof \Phpfastcache\DriverTest\Files2\Driver) { - $testHelper->assertFail('The cache instance is still an instance of an override class'); -} else { - $testHelper->assertPass('The cache instance is no longer an instance of an override class'); -} - -$cacheInstance->clear(); -$testHelper->terminateTest(); diff --git a/tests/cases/Couchbasev3.test.php b/tests/cases/Couchbasev3.test.php deleted file mode 100644 index 2f7f58d56..000000000 --- a/tests/cases/Couchbasev3.test.php +++ /dev/null @@ -1,39 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -use Phpfastcache\CacheManager; -use Phpfastcache\Drivers\Couchbasev3\Config as CouchbaseConfig; -use Phpfastcache\Exceptions\PhpfastcacheDriverConnectException; -use Phpfastcache\Tests\Helper\TestHelper; - -chdir(__DIR__); -require_once __DIR__ . '/../../vendor/autoload.php'; -$testHelper = new TestHelper('Couchbasev3 driver'); - -$config = new CouchbaseConfig(); -$config->setBucketName('phpfastcache'); -$config->setItemDetailedDate(true); -try { - $config->setUsername('test'); - $config->setPassword('phpfastcache'); - $config->setBucketName('phpfastcache'); - $config->setScopeName('_default'); - $config->setCollectionName('_default'); - $cacheInstance = CacheManager::getInstance('Couchbasev3', $config); - $testHelper->runCRUDTests($cacheInstance); -} catch (PhpfastcacheDriverConnectException $e) { - $testHelper->assertSkip('Couchbase server unavailable: ' . $e->getMessage()); - $testHelper->terminateTest(); -} -$testHelper->terminateTest(); diff --git a/tests/cases/CustomDefaultFileNameFunction.php b/tests/cases/CustomDefaultFileNameFunction.php deleted file mode 100644 index 1518c5696..000000000 --- a/tests/cases/CustomDefaultFileNameFunction.php +++ /dev/null @@ -1,54 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -use Phpfastcache\CacheManager; -use Phpfastcache\Config\ConfigurationOption; -use Phpfastcache\Core\Pool\ExtendedCacheItemPoolInterface; -use Phpfastcache\Drivers\Files\Driver; -use Phpfastcache\EventManager; -use Phpfastcache\Tests\Helper\TestHelper; - -chdir(__DIR__); -require_once __DIR__ . '/../../vendor/autoload.php'; -$testHelper = new TestHelper('Custom filename function'); -$driverInstance = CacheManager::getInstance( - 'Files', - new ConfigurationOption( - [ - 'defaultFileNameHashFunction' => static function (string $str) { - return hash('sha256', $str); - } - ] - ) -); - -$testPasses = false; -EventManager::getInstance()->onCacheWriteFileOnDisk( - static function (ExtendedCacheItemPoolInterface $itemPool, $file) use ($driverInstance, &$testPasses) { - /** @var $driverInstance Driver */ - $testPasses = strlen(basename($file, '.' . $driverInstance->getConfig()->getCacheFileExtension())) === 64; - } -); - -$item = $driverInstance->getItem('TestCustomDefaultFileNameFunction'); -$item->set(bin2hex(random_bytes(random_int(10, 100)))); -$driverInstance->save($item); - -if ($testPasses) { - $testHelper->assertPass('Custom filename function returned expected hash length'); -} else { - $testHelper->assertFail('Custom filename function did not returned expected hash length'); -} - -$testHelper->terminateTest(); diff --git a/tests/cases/CustomDefaultKeyHashFunction.php b/tests/cases/CustomDefaultKeyHashFunction.php deleted file mode 100644 index 9fa27d06b..000000000 --- a/tests/cases/CustomDefaultKeyHashFunction.php +++ /dev/null @@ -1,42 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -use Phpfastcache\CacheManager; -use Phpfastcache\Config\ConfigurationOption; -use Phpfastcache\Tests\Helper\TestHelper; - -chdir(__DIR__); -require_once __DIR__ . '/../../vendor/autoload.php'; -$testHelper = new TestHelper('Custom key hash function'); -$driverInstance = CacheManager::getInstance( - 'sqlite', - new ConfigurationOption( - [ - 'defaultKeyHashFunction' => static function (string $str) { - return hash('sha256', $str); - } - ] - ) -); -$item = $driverInstance->getItem('TestCustomDefaultKeyHashFunction'); -$item->set(bin2hex(random_bytes(random_int(10, 100)))); -$driverInstance->save($item); - -if (strlen($item->getEncodedKey()) === 64) { - $testHelper->assertPass('Custom key hash function returned expected hash length'); -} else { - $testHelper->assertFail('Custom key hash function did not returned expected hash length'); -} - -$testHelper->terminateTest(); diff --git a/tests/cases/CustomDriver.test.php b/tests/cases/CustomDriver.test.php deleted file mode 100644 index 6d49a2b41..000000000 --- a/tests/cases/CustomDriver.test.php +++ /dev/null @@ -1,73 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -use Phpfastcache\CacheManager; -use Phpfastcache\Drivers\Fakefiles\Config; -use Phpfastcache\Exceptions\PhpfastcacheDriverCheckException; -use Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException; -use Phpfastcache\Tests\Helper\TestHelper; - -chdir(__DIR__); -require_once __DIR__ . '/../../vendor/autoload.php'; -require_once __DIR__ . '/../mock/Autoload.php'; -$testHelper = new TestHelper('Custom driver'); - -if (!class_exists(Phpfastcache\Drivers\Fakefiles\Item::class) - || !class_exists(Phpfastcache\Drivers\Fakefiles\Driver::class) - || !class_exists(Phpfastcache\Drivers\Fakefiles\Config::class) -) { - $testHelper->assertFail('The php classes of driver "Fakefiles" do not exist'); - $testHelper->terminateTest(); -} else { - $testHelper->assertPass('The php classes of driver "Fakefiles" were found'); -} - -try { - CacheManager::addCustomDriver('Fakefiles', \Phpfastcache\Drivers\Fakefiles\Driver::class); - $testHelper->assertPass('No exception thrown while trying to add a custom driver'); -} catch (\Throwable $e) { - $testHelper->assertFail('An exception has been thrown while trying to add a custom driver'); -} - -try { - CacheManager::addCustomDriver('Fakefiles', \Phpfastcache\Drivers\Fakefiles\Driver::class); - $testHelper->assertFail('No exception thrown while trying to re-add a the same custom driver'); -} catch (\Throwable $e) { - $testHelper->assertPass('An exception has been thrown while trying to re-add a the same custom driver'); -} - -try { - CacheManager::addCustomDriver('', \Phpfastcache\Drivers\Fakefiles\Driver::class); - $testHelper->assertFail('No exception thrown while trying to override an empty driver'); -} catch (PhpfastcacheInvalidArgumentException $e) { - $testHelper->assertPass('An exception has been thrown while trying to override an empty driver'); -} - -try { - $cacheInstance = CacheManager::getInstance('Fakefiles', new Config(['customOption' => true])); - $testHelper->assertPass('The custom driver is unavailable at the moment and no exception has been thrown.'); -} catch (PhpfastcacheDriverCheckException $e) { - $testHelper->assertPass('The custom driver is unavailable at the moment and the exception has been catch.'); -} - -CacheManager::removeCustomDriver('Fakefiles'); - -try { - $cacheInstance = CacheManager::getInstance('Fakefiles'); - $testHelper->assertPass('The custom driver has been removed but is still active.'); -} catch (PhpfastcacheDriverCheckException $e) { - $testHelper->assertPass('The custom driver is unavailable at the moment and the exception has been catch.'); -} - -$testHelper->terminateTest(); diff --git a/tests/cases/CustomKeyHashFunction.test.php b/tests/cases/CustomKeyHashFunction.test.php deleted file mode 100644 index f264d4ab2..000000000 --- a/tests/cases/CustomKeyHashFunction.test.php +++ /dev/null @@ -1,41 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -use Phpfastcache\CacheManager; -use Phpfastcache\Config\ConfigurationOption; -use Phpfastcache\Exceptions\PhpfastcacheInvalidConfigurationException; -use Phpfastcache\Tests\Helper\TestHelper; - -chdir(__DIR__); -require_once __DIR__ . '/../../vendor/autoload.php'; -$testHelper = new TestHelper('Custom key hash function'); - -function myAwesomeHashFunction($string) -{ - return 'customHash.' . sha1($string); -} - -$cacheInstance = CacheManager::getInstance('Files', new ConfigurationOption(['defaultKeyHashFunction' => 'myAwesomeHashFunction'])); - -$item = $cacheInstance->getItem(str_shuffle(uniqid('pfc', true))); -$item->set(true)->expiresAfter(300); -$cacheInstance->save($item); - -if ($item->getEncodedKey() === 'customHash.' . sha1($item->getKey())) { - $testHelper->assertPass('The custom key hash function returned expected hash string: ' . $item->getEncodedKey()); -} else { - $testHelper->assertFail('The custom key hash function returned unexpected hash string: ' . $item->getEncodedKey()); -} - -$testHelper->terminateTest(); diff --git a/tests/cases/DisabledStaticItemCaching.test.php b/tests/cases/DisabledStaticItemCaching.test.php deleted file mode 100644 index 4601811ad..000000000 --- a/tests/cases/DisabledStaticItemCaching.test.php +++ /dev/null @@ -1,65 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -use Phpfastcache\CacheManager; -use Phpfastcache\Config\ConfigurationOption; -use Phpfastcache\Core\Item\ExtendedCacheItemInterface; -use Phpfastcache\Core\Pool\ExtendedCacheItemPoolInterface; -use Phpfastcache\Entities\ItemBatch; -use Phpfastcache\EventManager; -use Phpfastcache\Tests\Helper\TestHelper; - -chdir(__DIR__); -require_once __DIR__ . '/../../vendor/autoload.php'; -$testHelper = new TestHelper('Testing disabling static item caching'); -$defaultDriver = (!empty($argv[ 1 ]) ? ucfirst($argv[ 1 ]) : 'Files'); -$driverInstance = CacheManager::getInstance($defaultDriver, new ConfigurationOption([ - 'useStaticItemCaching' => false, -])); - -if (!$testHelper->isHHVM()) { - $testHelper->runSubProcess('DisabledStaticItemCaching'); - /** - * Give some time to the - * subprocess to start - * just like a concurrent - * php request - */ - $item = $driverInstance->getItem('TestUseStaticItemCaching'); - $item->set('654321-fedcba'); - $driverInstance->save($item); - $testHelper->runSubProcess('DisabledStaticItemCaching'); - usleep(random_int(250000, 800000)); - - // We don't want to clear cache instance since we disabled the static item caching - $item = $driverInstance->getItem('TestUseStaticItemCaching'); - - /** - * @see CacheSlamsProtection.subprocess.php:28 - */ - if ($item->isHit() && $item->get() === 'abcdef-123456') { - $testHelper->assertPass('The static item caching being disabled, the cache item has been fetched straight from backend.' . $item->get()); - } else { - $testHelper->assertFail('The static item caching may not have been disabled since the cache item value does not match the expected value.'); - } - - /** - * Cleanup the driver - */ - $driverInstance->deleteItem($item->getKey()); -} else { - $testHelper->assertSkip('Test ignored on HHVM builds due to sub-process issues with C.I.'); -} - -$testHelper->terminateTest(); diff --git a/tests/cases/DriverIO.test.php b/tests/cases/DriverIO.test.php deleted file mode 100644 index 034dffe8e..000000000 --- a/tests/cases/DriverIO.test.php +++ /dev/null @@ -1,37 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -use Phpfastcache\CacheManager; -use Phpfastcache\Entities\DriverIO; -use Phpfastcache\Tests\Helper\TestHelper; - -chdir(__DIR__); -require_once __DIR__ . '/../../vendor/autoload.php'; -$testHelper = new TestHelper('Driver list resolver'); - -$cache = CacheManager::getInstance('Redis'); - -for ($i=0; $i<10; $i++) { - $testHelper->printNoteText(sprintf('Running CRUD tests, loop %d/10', $i)); - $testHelper->runCRUDTests($cache); -} -$driverIO = $cache->getIO(); - -if ($driverIO instanceof DriverIO && $driverIO->getReadHit() && $driverIO->getReadMiss() && $driverIO->getWriteHit()) { - $testHelper->assertPass('Driver IO entity returned some hit info.'); -} else { - $testHelper->assertFail('Driver IO entity did not returned some hit info as expected.'); -} - -$testHelper->terminateTest(); diff --git a/tests/cases/DriverListResolver.test.php b/tests/cases/DriverListResolver.test.php deleted file mode 100644 index d6e7370ff..000000000 --- a/tests/cases/DriverListResolver.test.php +++ /dev/null @@ -1,47 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -use Phpfastcache\CacheManager; -use Phpfastcache\Tests\Helper\TestHelper; - -chdir(__DIR__); -require_once __DIR__ . '/../../vendor/autoload.php'; -$testHelper = new TestHelper('Driver list resolver'); - -$subClasses = [ - 'Config', - 'Driver', - 'Item', -]; - -$driverList = CacheManager::getDriverList(); - -if(count($driverList)){ - foreach ($driverList as $driver) { - foreach ($subClasses as $subClass) { - $className = "Phpfastcache\\Drivers\\{$driver}\\{$subClass}"; - if (class_exists($className)) { - $testHelper->assertPass(sprintf('Found the %s %s class: "%s"', $driver, $subClass, $className)); - } else { - $testHelper->assertFail(sprintf('Class "%s" not found', $className)); - } - } - } -} else { - $testHelper->assertFail('Driver list is empty'); -} - - - -$testHelper->terminateTest(); diff --git a/tests/cases/EventManager.test.php b/tests/cases/EventManager.test.php deleted file mode 100644 index cb632a2ce..000000000 --- a/tests/cases/EventManager.test.php +++ /dev/null @@ -1,94 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -use Phpfastcache\CacheManager; -use Phpfastcache\Core\Item\ExtendedCacheItemInterface; -use Phpfastcache\Core\Pool\ExtendedCacheItemPoolInterface; -use Phpfastcache\Event\EventReferenceParameter; -use Phpfastcache\EventManager; -use Phpfastcache\Exceptions\PhpfastcacheInvalidTypeException; -use Phpfastcache\Tests\Helper\TestHelper; - -chdir(__DIR__); -require_once __DIR__ . '/../../vendor/autoload.php'; -$testHelper = new TestHelper('EventManager (Unscoped)'); -$defaultDriver = (!empty($argv[1]) ? ucfirst($argv[1]) : 'Files'); - -$cacheInstance = CacheManager::getInstance($defaultDriver); -$eventInstance = $cacheInstance->getEventManager(); -$testHelper->debugEvents($eventInstance); -$eventInstance->onCacheSaveItem(static function (ExtendedCacheItemPoolInterface $itemPool, ExtendedCacheItemInterface $item) { - if ($item->_getData() === 1000) { - $item->increment(337); - } -}); - -$eventInstance->onCacheItemSet(static function (ExtendedCacheItemInterface $item, EventReferenceParameter $eventReferenceParameter) use ($testHelper) { - try{ - $eventReferenceParameter->setParameterValue(1000); - $testHelper->assertPass('The event reference parameter accepted a value type change'); - } catch(PhpfastcacheInvalidTypeException){ - $testHelper->assertFail('The event reference parameter denied a value type change'); - } -}); - -$cacheKey = 'testItem'; -$cacheKey2 = 'testItem2'; - -$item = $cacheInstance->getItem($cacheKey); -$item->set(false)->expiresAfter(60); -$cacheInstance->save($item); - -if ($cacheInstance->getItem($cacheKey)->get() === 1337) { - $testHelper->assertPass('The dispatched event executed the custom callback to alter the item'); -} else { - $testHelper->assertFail("The dispatched event is not working properly, the expected value '1337', got '" . $cacheInstance->getItem($cacheKey)->get() . "'"); -} -$cacheInstance->clear(); -unset($item); -$eventInstance->unbindAllEventCallbacks(); -$testHelper->debugEvents($eventInstance); - -$eventInstance->onCacheSaveMultipleItems(static function (ExtendedCacheItemPoolInterface $itemPool, EventReferenceParameter $eventReferenceParameter) use ($testHelper) { - $parameterValue = $eventReferenceParameter->getParameterValue(); - - try{ - $eventReferenceParameter->setParameterValue(null); - $testHelper->assertFail('The event reference parameter accepted a value type change'); - } catch(PhpfastcacheInvalidTypeException){ - $testHelper->assertPass('The event reference parameter denied a value type change'); - $eventReferenceParameter->setParameterValue([]); - } - - if (is_array($parameterValue) && count($parameterValue) === 2) { - $testHelper->assertPass('The event reference parameter returned an array of 2 cache items'); - } else { - $testHelper->assertFail('The event reference parameter returned an unexpected value'); - } -}); - -$item = $cacheInstance->getItem($cacheKey); -$item2 = $cacheInstance->getItem($cacheKey2); -$item->set(1000)->expiresAfter(60); -$item2->set(2000)->expiresAfter(60); - -$saveMultipleResult = $cacheInstance->saveMultiple($item, $item2); - -if (!$saveMultipleResult) { - $testHelper->assertPass('Method saveMultiple() returned false since it has nothing to save, as expected.'); -} else { - $testHelper->assertFail('Method saveMultiple() unexpectedly returned true.'); -} - -$testHelper->terminateTest(); diff --git a/tests/cases/EventManagerScoped.test.php b/tests/cases/EventManagerScoped.test.php deleted file mode 100644 index 61efb9e96..000000000 --- a/tests/cases/EventManagerScoped.test.php +++ /dev/null @@ -1,136 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -use Phpfastcache\CacheManager; -use Phpfastcache\Core\Item\ExtendedCacheItemInterface; -use Phpfastcache\Core\Pool\ExtendedCacheItemPoolInterface; -use Phpfastcache\Event\EventReferenceParameter; -use Phpfastcache\EventManager; -use Phpfastcache\Exceptions\PhpfastcacheInvalidTypeException; -use Phpfastcache\Tests\Helper\TestHelper; - -chdir(__DIR__); -require_once __DIR__ . '/../../vendor/autoload.php'; -$testHelper = new TestHelper('EventManager (Scoped)'); -$defaultDriver = (!empty($argv[1]) ? ucfirst($argv[1]) : 'Files'); - -$filesCacheInstance = CacheManager::getInstance($defaultDriver); -$redisCacheInstance = CacheManager::getInstance('redis'); - -$globalEveryEventsEvents = []; -$filesEveryEventsEventEvents = []; -$redisEveryEventsEventEvents = []; - -$globalGetItemEventManagerCount = 0; -$filesGetItemEventManagerCount = 0; -$redisGetItemEventManagerCount = 0; - -EventManager::getInstance()->onEveryEvents(static function (string $eventName) use ($testHelper, &$globalEveryEventsEvents) { - $testHelper->printInfoText(sprintf('[Global] Global "onEveryEvents" has been called for "%s"', $eventName)); - $globalEveryEventsEvents[$eventName] = ($globalEveryEventsEvents[$eventName] ?? 0) + 1; -}, 'GlobalEveryEvent'); - -EventManager::getInstance()->onCacheGetItem(static function (ExtendedCacheItemPoolInterface $itemPool, ExtendedCacheItemInterface $item, string $eventName) use ($testHelper, &$globalGetItemEventManagerCount) { - $testHelper->assertPass('[Global] Global event manager received events from multiple pool instances'); - $globalGetItemEventManagerCount++; -}); - -$filesCacheInstance->getEventManager()->onEveryEvents(static function (string $eventName) use ($testHelper, &$filesEveryEventsEventEvents) { - $testHelper->printInfoText(sprintf('[Files] Scoped "onEveryEvents" has been called for "%s"', $eventName)); - $filesEveryEventsEventEvents[$eventName] = ($filesEveryEventsEventEvents[$eventName] ?? 0) + 1; -}, 'GlobalEveryEvent'); - - -$filesCacheInstance->getEventManager()->onCacheGetItem(static function (ExtendedCacheItemPoolInterface $itemPool, ExtendedCacheItemInterface $item, string $eventName) use ($testHelper, &$filesGetItemEventManagerCount) { - if($itemPool->getDriverName() === 'Files') { - $testHelper->assertPass('[Files] Scoped event manager received only events of its own pool instance'); - $filesGetItemEventManagerCount++; - } -}); - -$redisCacheInstance->getEventManager()->onEveryEvents(static function (string $eventName) use ($testHelper, &$redisEveryEventsEventEvents) { - $testHelper->printInfoText(sprintf('[Redis] Scoped "onEveryEvents" has been called for "%s"', $eventName)); - $redisEveryEventsEventEvents[$eventName] = ($redisEveryEventsEventEvents[$eventName] ?? 0) + 1; -}, 'GlobalEveryEvent'); - -$redisCacheInstance->getEventManager()->onCacheGetItem(static function (ExtendedCacheItemPoolInterface $itemPool, ExtendedCacheItemInterface $item, string $eventName) use ($testHelper, &$redisGetItemEventManagerCount) { - if($itemPool->getDriverName() === 'Redis') { - $testHelper->assertPass('[Files] Scoped event manager received only events of its own pool instance'); - $redisGetItemEventManagerCount++; - } -}); - -// Trigger "CacheGetItem" event -$filesItem = $filesCacheInstance->getItem('FilesItem')->set('LoremIpsum'); -$redisItem = $redisCacheInstance->getItem('RedisItem')->set('LoremIpsum'); - -$testHelper->printNewLine(); -if($globalGetItemEventManagerCount === 2) { - $testHelper->assertPass('[Global] Unscoped listener has been fired exactly 2 times'); -} else { - $testHelper->assertFail(sprintf('[Global] Unscoped listener has been fired exactly %s times instead of 2.', $globalGetItemEventManagerCount)); -} - -if($filesGetItemEventManagerCount === 1) { - $testHelper->assertPass('[Files] Scoped listener has been fired exactly 1 time'); -} else { - $testHelper->assertFail(sprintf('[Files] Scoped listener has been fired exactly %s times instead of 1.', $filesGetItemEventManagerCount)); -} - -if($redisGetItemEventManagerCount === 1) { - $testHelper->assertPass('[Redis] Scoped listener has been fired exactly 1 time'); -} else { - $testHelper->assertFail(sprintf('[Redis] Scoped listener has been fired exactly %s times instead of 1.', $redisGetItemEventManagerCount)); -} - -if($globalEveryEventsEvents['CacheGetItem'] === 2 && $globalEveryEventsEvents['CacheItemSet'] === 2) { - $testHelper->assertPass('[Global] Unscoped listener has been fired exactly 2 times each CacheGetItem and CacheItemSet'); -} else { - $testHelper->assertFail( - sprintf( - '[Global] Unscoped listener has been fired exactly %s times CacheGetItem and %s times CacheItemSet.', - $globalEveryEventsEvents['CacheGetItem'] ?? 0, - $globalEveryEventsEvents['CacheItemSet'] ?? 0, - ) - ); -} - -if($filesEveryEventsEventEvents['CacheGetItem'] === 1 && $filesEveryEventsEventEvents['CacheItemSet'] === 1) { - $testHelper->assertPass('[Files] Scoped listener has been fired exactly 1 times each CacheGetItem and CacheItemSet'); -} else { - $testHelper->assertFail( - sprintf( - '[Files] Scoped listener has been fired exactly %s times CacheGetItem and %s times CacheItemSet.', - $filesEveryEventsEventEvents['CacheGetItem'] ?? 0, - $filesEveryEventsEventEvents['CacheItemSet'] ?? 0, - ) - ); -} - - -if($redisEveryEventsEventEvents['CacheGetItem'] === 1 && $redisEveryEventsEventEvents['CacheItemSet'] === 1) { - $testHelper->assertPass('[Redis] Scoped listener has been fired exactly 1 times each CacheGetItem and CacheItemSet'); -} else { - $testHelper->assertFail( - sprintf( - '[Redis] Scoped listener has been fired exactly %s times CacheGetItem and %s times CacheItemSet.', - $redisEveryEventsEventEvents['CacheGetItem'] ?? 0, - $redisEveryEventsEventEvents['CacheItemSet'] ?? 0, - ) - ); -} - - - -$testHelper->terminateTest(); diff --git a/tests/cases/ExtensionManager.test.php b/tests/cases/ExtensionManager.test.php deleted file mode 100644 index bdff618af..000000000 --- a/tests/cases/ExtensionManager.test.php +++ /dev/null @@ -1,66 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -use Phpfastcache\CacheManager; -use Phpfastcache\Exceptions\PhpfastcacheDriverNotFoundException; -use Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException; -use Phpfastcache\Exceptions\PhpfastcacheExtensionNotInstalledException; -use Phpfastcache\Tests\Helper\TestHelper; - -chdir(__DIR__); -require_once __DIR__ . '/../../vendor/autoload.php'; -require_once __DIR__ . '/../mock/Autoload.php'; -$testHelper = new TestHelper('Apcu test (CRUD)'); - -try { - $pool = CacheManager::getInstance('Arangodb'); - $testHelper->assertFail('CacheManager didnt thrown an Exception'); -} catch (PhpfastcacheExtensionNotInstalledException) { - $testHelper->assertPass('CacheManager thrown a PhpfastcacheExtensionNotInstalledException.'); -} catch (\Throwable $e) { - $testHelper->assertFail('CacheManager thrown a ' . $e::class); -} - -try { - $pool = CacheManager::getInstance(bin2hex(random_bytes(8))); - $testHelper->assertFail('CacheManager didnt thrown an Exception'); -} catch (PhpfastcacheDriverNotFoundException $e) { - if ($e::class === PhpfastcacheDriverNotFoundException::class) { - $testHelper->assertPass('CacheManager thrown a PhpfastcacheDriverNotFoundException.'); - } else { - $testHelper->assertFail('CacheManager thrown a ' . $e::class); - } -} catch (\Throwable $e) { - $testHelper->assertFail('CacheManager thrown a ' . $e::class); -} - -try { - \Phpfastcache\ExtensionManager::registerExtension( - 'Extensiontest', - \Phpfastcache\Extensions\Drivers\Extensiontest\Driver::class - ); - $testHelper->assertPass('Registered a test extension.'); -} catch (PhpfastcacheInvalidArgumentException) { - $testHelper->assertFail('Failed to register a test extension.'); -} - -try { - CacheManager::getInstance('Extensiontest'); - $testHelper->assertPass('Retrieved a test extension cache pool.'); -} catch (PhpfastcacheDriverNotFoundException) { - $testHelper->assertFail('Failed to retrieve a test extension cache pool.'); -} - - -$testHelper->terminateTest(); diff --git a/tests/cases/GetAllItems.test.php b/tests/cases/GetAllItems.test.php deleted file mode 100644 index 239714eef..000000000 --- a/tests/cases/GetAllItems.test.php +++ /dev/null @@ -1,145 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -use Phpfastcache\CacheManager; -use Phpfastcache\Event\Event; -use Phpfastcache\Exceptions\PhpfastcacheDriverCheckException; -use Phpfastcache\Exceptions\PhpfastcacheDriverConnectException; -use Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException; -use Phpfastcache\Exceptions\PhpfastcacheUnsupportedMethodException; -use Phpfastcache\Tests\Helper\TestHelper; -use Phpfastcache\Tests\Config\ConfigFactory; -use Phpfastcache\Core\Pool\ExtendedCacheItemPoolInterface; -use Phpfastcache\Event\EventReferenceParameter; -use Phpfastcache\EventManager; - -chdir(__DIR__); -require_once __DIR__ . '/../../vendor/autoload.php'; - -$testHelper = new TestHelper('Testing getAllItems() method'); - -/** - * https://github.com/PHPSocialNetwork/phpfastcache/wiki/%5BV5%CB%96%5D-Fetching-all-keys - */ -EventManager::getInstance()->on([Event::CACHE_GET_ALL_ITEMS], static function(ExtendedCacheItemPoolInterface $driver, EventReferenceParameter $referenceParameter) use ($testHelper, &$eventFlag){ - $callback = $referenceParameter->getParameterValue(); - $referenceParameter->setParameterValue(function(string $pattern) use ($callback, &$eventFlag, $testHelper) { - $eventFlag = true; - $testHelper->printInfoText('The custom event Event::CACHE_GET_ALL_ITEMS has been called.'); - return $callback($pattern); - }); -}); - -$drivers = [ - 'Memory', - 'Predis', - 'Redis', - 'RedisCluster', -]; - -$driversConfigs = ConfigFactory::getDefaultConfigs(); -foreach ($drivers as $i => $driverName) { - $testHelper->printNoteText( - sprintf( - "Testing %s against getAllItems() method (%d/%d)", - strtoupper($driverName), - $i + 1, - count($drivers), - ) - ); - try { - $poolCache = CacheManager::getInstance($driverName, $driversConfigs[$driverName] ?? null); - } catch (PhpfastcacheDriverConnectException|PhpfastcacheDriverCheckException $e){ - $testHelper->assertSkip( - sprintf( - "Skipping %s against getAllItems() method (Caught %s: %s)", - strtoupper($driverName), - $e::class, - $e->getMessage(), - ) - ); - $testHelper->printNewLine(); - continue; - } - - $eventFlag = false; - - $poolCache->clear(); - $item1 = $poolCache->getItem('cache-test1'); - $item2 = $poolCache->getItem('cache-test2'); - $item3 = $poolCache->getItem('cache-test3'); - - $item1->set('test1')->expiresAfter(3600); - $item2->set('test2')->expiresAfter(3600); - $item3->set('test3')->expiresAfter(3600); - - $poolCache->saveMultiple($item1, $item2, $item3); - $poolCache->detachAllItems(); - unset($item1, $item2, $item3); - - - $items = $poolCache->getAllItems(); - $itemCount = count($items); - if ($itemCount === 3) { - $testHelper->assertPass('getAllItems() returned 3 cache items as expected.'); - } else { - $testHelper->assertFail(sprintf('getAllItems() unexpectedly returned %d cache items.', $itemCount)); - } - - foreach ($items as $key => $item) { - if ($item->isHit()) { - $testHelper->assertPass(sprintf('Item #%s is hit.', $item->getKey())); - } else { - $testHelper->assertFail(sprintf('Item #%s is not hit.', $item->getKey())); - } - - if ($key === $item->getKey()) { - $testHelper->assertPass(sprintf('Cache item #%s object is identified by its cache key.', $item->getKey())); - } else { - $testHelper->assertFail(sprintf('Cache item #%s object is identified by "%s".', $item->getKey(), $key)); - } - } - - $testHelper->printNoteText("Testing getAllItems() method (with pattern)"); - - try { - $items = $poolCache->getAllItems('*test1*'); - if (count($items) === 1) { - $testHelper->assertPass('Found 1 item using $pattern argument'); - } else { - $testHelper->assertFail(sprintf('Found %d items using $pattern argument', count($items))); - } - - } catch (PhpfastcacheInvalidArgumentException) { - $testHelper->assertSkip("Pattern argument unsupported by $driverName driver"); - } - - $testHelper->printNewLine(1); -} - -$filesCache = CacheManager::getInstance('Files'); - -try { - $filesCache->getAllItems(); -} catch (PhpfastcacheUnsupportedMethodException) { - $testHelper->assertPass('getAllItems() is not supported by Files driver as expected and thrown a PhpfastcacheUnsupportedMethodException.'); -} catch (\Throwable $e) { - $testHelper->assertFail(sprintf('getAllItems() returned a exception "%s" instead of a PhpfastcacheUnsupportedMethodException.', $e::class)); -} - -if ($eventFlag) { - $testHelper->assertPass('The Event::CACHE_GET_ALL_ITEMS has been triggered allowing the callback to be customized.'); -} - -$testHelper->terminateTest(); diff --git a/tests/cases/ItemTags.test.php b/tests/cases/ItemTags.test.php deleted file mode 100644 index 9d0a2707a..000000000 --- a/tests/cases/ItemTags.test.php +++ /dev/null @@ -1,401 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -use Phpfastcache\CacheManager; -use Phpfastcache\Core\Item\TaggableCacheItemInterface; -use Phpfastcache\Core\Pool\TaggableCacheItemPoolInterface; -use Phpfastcache\Tests\Helper\TestHelper; - -chdir(__DIR__); -require_once __DIR__ . '/../../vendor/autoload.php'; -$testHelper = new TestHelper('Items tags features'); -$defaultDriver = (!empty($argv[ 1 ]) ? ucfirst($argv[ 1 ]) : 'Redis'); -$driverInstance = CacheManager::getInstance($defaultDriver); - -$driverInstance->clear(); -/** - * Item tag test // Init tags/items - */ - -$createItemsCallback = static function () use ($driverInstance) { - $item1 = $driverInstance->getItem('tag-test1'); - $item2 = $driverInstance->getItem('tag-test2'); - $item3 = $driverInstance->getItem('tag-test3'); - - $item1->set('item-test_1') - ->expiresAfter(600) - ->addTag('tag-test_1') - ->addTag('tag-test_all') - ->addTag('tag-test_all2') - ->addTag('tag-test_all3'); - - $item2->set('item-test_2') - ->expiresAfter(600) - ->addTag('tag-test_1') - ->addTag('tag-test_2') - ->addTag('tag-test_all') - ->addTag('tag-test_all2') - ->addTag('tag-test_all3'); - - $item3->set('item-test_3') - ->expiresAfter(600) - ->addTag('tag-test_1') - ->addTag('tag-test_2') - ->addTag('tag-test_3') - ->addTag('tag-test_all') - ->addTag('tag-test_all2') - ->addTag('tag-test_all3') - ->addTag('tag-test_all4'); - - $driverInstance->saveMultiple($item1, $item2, $item3); - - return [ - 'item1' => $item1, - 'item2' => $item2, - 'item3' => $item3 - ]; -}; - -$testHelper->printNoteText('##### TESTING POOL TAGS GETTERS'); - -/** - * Item tag test // Step 1 - */ -$testHelper->printNewLine()->printText('#1 Testing getter: getItemsByTag() with strategy TAG_STRATEGY_ONE // Expecting 3 results'); -$createItemsCallback(); - -$tagsItems = $driverInstance->getItemsByTag('tag-test_all', TaggableCacheItemPoolInterface::TAG_STRATEGY_ONE); -if (is_array($tagsItems)) { - if (count($tagsItems) === 3) { - foreach ($tagsItems as $tagsItem) { - if (!in_array($tagsItem->getKey(), ['tag-test1', 'tag-test2', 'tag-test3'])) { - $testHelper->assertFail('STEP#1 // Got unexpected tagged item key:' . $tagsItem->getKey()); - goto itemTagTest2; - } - } - $testHelper->assertPass('STEP#1 // Successfully retrieved 3 tagged item keys'); - } else { - $testHelper->assertFail('STEP#1 //Got wrong count of item:' . count($tagsItems)); - goto itemTagTest2; - } -} else { - $testHelper->assertFail('STEP#1 // Expected $tagsItems to be an array, got: ' . gettype($tagsItems)); - goto itemTagTest2; -} - -/** - * Item tag test // Step 2 - */ -itemTagTest2: -$testHelper->printNewLine()->printText('#2 Testing getter: getItemsByTags() with strategy TAG_STRATEGY_ALL // Expecting 3 results'); -$driverInstance->deleteItems(['item-test_1', 'item-test_2', 'item-test_3']); -$createItemsCallback(); - -$tagsItems = $driverInstance->getItemsByTags(['tag-test_all', 'tag-test_all2', 'tag-test_all3'], TaggableCacheItemPoolInterface::TAG_STRATEGY_ALL); - -if (is_array($tagsItems)) { - if (count($tagsItems) === 3) { - foreach ($tagsItems as $tagsItem) { - if (!in_array($tagsItem->getKey(), ['tag-test1', 'tag-test2', 'tag-test3'])) { - $testHelper->assertFail('STEP#2 // Got unexpected tagged item key:' . $tagsItem->getKey()); - goto itemTagTest3; - } - } - $testHelper->assertPass('STEP#2 // Successfully retrieved 3 tagged item key'); - } else { - $testHelper->assertFail('STEP#2 // Got wrong count of item:' . count($tagsItems)); - goto itemTagTest3; - } -} else { - $testHelper->assertFail('STEP#2 // Expected $tagsItems to be an array, got: ' . gettype($tagsItems)); - goto itemTagTest3; -} - -/** - * Item tag test // Step 3 - */ -itemTagTest3: -$testHelper->printNewLine()->printText('#3 Testing getter: getItemsByTags() with strategy TAG_STRATEGY_ALL // Expecting 1 result'); -$driverInstance->deleteItems(['item-test_1', 'item-test_2', 'item-test_3']); -$createItemsCallback(); - -$tagsItems = $driverInstance->getItemsByTags(['tag-test_all', 'tag-test_all2', 'tag-test_all3', 'tag-test_all4'], TaggableCacheItemPoolInterface::TAG_STRATEGY_ALL); - -if (is_array($tagsItems)) { - if (count($tagsItems) === 1) { - if (isset($tagsItems['tag-test3'])) { - if ($tagsItems['tag-test3']->getKey() !== 'tag-test3') { - $testHelper->assertFail('STEP#3 // Got unexpected tagged item key:' . $tagsItems['tag-test3']->getKey()); - goto itemTagTest4; - } - $testHelper->assertPass('STEP#3 // Successfully retrieved 1 tagged item keys'); - } else { - $testHelper->assertFail('STEP#3 // Got wrong array key, expected "tag-test3", got "' . key($tagsItems) . '"'); - goto itemTagTest4; - } - } else { - $testHelper->assertFail('STEP#3 // Got wrong count of item:' . count($tagsItems)); - goto itemTagTest4; - } -} else { - $testHelper->assertFail('STEP#3 // Expected $tagsItems to be an array, got: ' . gettype($tagsItems)); - goto itemTagTest4; -} - -/** - * Item tag test // Step 4 - */ -itemTagTest4: -$testHelper->printNewLine()->printText('#4 Testing deleter: deleteItemsByTag() // Expecting no item left'); -$driverInstance->deleteItems(['item-test_1', 'item-test_2', 'item-test_3']); -$createItemsCallback(); -$driverInstance->deleteItemsByTag('tag-test_all'); - -if (count($driverInstance->getItemsByTag('tag-test_all')) > 0) { - $testHelper->assertFail('[FAIL] STEP#4 // Getter getItemsByTag() found item(s), possible memory leak'); -} else { - $testHelper->assertPass('STEP#4 // Getter getItemsByTag() found no item'); -} - -$i = 0; -while (++$i <= 3) { - if ($driverInstance->getItem("tag-test{$i}")->isHit()) { - $testHelper->assertFail("STEP#4 // Item 'tag-test{$i}' should've been deleted and is still in cache storage"); - } else { - $testHelper->assertPass("STEP#4 // Item 'tag-test{$i}' have been deleted and is no longer in cache storage"); - } -} - -/** - * Item tag test // Step 5 - */ -itemTagTest5: -$testHelper->printNewLine()->printText('#5 Testing deleter: deleteItemsByTags() with strategy TAG_STRATEGY_ALL // Expecting no item left'); -$driverInstance->deleteItems(['item-test_1', 'item-test_2', 'item-test_3']); -$createItemsCallback(); - -$driverInstance->deleteItemsByTags(['tag-test_all', 'tag-test_all2', 'tag-test_all3'], TaggableCacheItemPoolInterface::TAG_STRATEGY_ALL); - -if (count($driverInstance->getItemsByTag('tag-test_all')) > 0) { - $testHelper->assertFail('STEP#5 // Getter getItemsByTag() found item(s), possible memory leak'); -} else { - $testHelper->assertPass('STEP#5 // Getter getItemsByTag() found no item'); -} - -$i = 0; -while (++$i <= 3) { - if ($driverInstance->getItem("tag-test{$i}")->isHit()) { - $testHelper->assertFail("STEP#5 // Item 'tag-test{$i}' should've been deleted and is still in cache storage"); - } else { - $testHelper->assertPass("STEP#5 // Item 'tag-test{$i}' have been deleted and is no longer in cache storage"); - } -} - -/** - * Item tag test // Step 6 - */ -itemTagTest6: -$testHelper->printNewLine()->printText('#6 Testing deleter: deleteItemsByTags() with strategy TAG_STRATEGY_ALL // Expecting a specific item to be deleted'); -$driverInstance->deleteItems(['item-test_1', 'item-test_2', 'item-test_3']); -$createItemsCallback(); - -/** - * Only item 'item-test_3' got all those tags - */ -$driverInstance->deleteItemsByTags(['tag-test_all', 'tag-test_all2', 'tag-test_all3', 'tag-test_all4'], TaggableCacheItemPoolInterface::TAG_STRATEGY_ALL); - -if ($driverInstance->getItem('item-test_3')->isHit()) { - $testHelper->assertFail('STEP#6 // Getter getItem() found item \'item-test_3\', possible memory leak'); -} else { - $testHelper->assertPass('STEP#6 // Getter getItem() did not found item \'item-test_3\''); -} - -/** - * Item tag test // Step 7 - */ -itemTagTest7: -$testHelper->printNewLine()->printText('#7 Testing appender: appendItemsByTags() with strategy TAG_STRATEGY_ALL // Expecting items value to get an appended part of string'); -$driverInstance->deleteItems(['item-test_1', 'item-test_2', 'item-test_3']); -$createItemsCallback(); -$appendStr = '$*#*$'; -$driverInstance->appendItemsByTags(['tag-test_all', 'tag-test_all2', 'tag-test_all3'], $appendStr, TaggableCacheItemPoolInterface::TAG_STRATEGY_ALL); - -foreach ($driverInstance->getItems(['tag-test1', 'tag-test2', 'tag-test3']) as $item) { - if (strpos($item->get(), $appendStr) === false) { - $testHelper->assertFail("STEP#7 // Item '{$item->getKey()}' does not have the string part '{$appendStr}' in it's value"); - } else { - $testHelper->assertPass("STEP#7 // Item 'tag-test{$item->getKey()}' does have the string part '{$appendStr}' in it's value"); - } -} - -/** - * Item tag test // Step 7 - */ -itemTagTest8: -$testHelper->printNewLine()->printText('#8 Testing prepender: prependItemsByTags() with strategy TAG_STRATEGY_ALL // Expecting items value to get a prepended part of string'); -$driverInstance->deleteItems(['item-test_1', 'item-test_2', 'item-test_3']); -$createItemsCallback(); -$prependStr = '&+_+&'; -$driverInstance->prependItemsByTags(['tag-test_all', 'tag-test_all2', 'tag-test_all3'], $prependStr, TaggableCacheItemPoolInterface::TAG_STRATEGY_ALL); - -foreach ($driverInstance->getItems(['tag-test1', 'tag-test2', 'tag-test3']) as $item) { - if (strpos($item->get(), $prependStr) === false) { - $testHelper->assertFail("STEP#8 // Item '{$item->getKey()}' does not have the string part '{$prependStr}' in it's value"); - } else { - $testHelper->assertPass("STEP#8 // Item 'tag-test{$item->getKey()}' does have the string part '{$prependStr}' in it's value"); - } -} - - - -/** - * Item tag test // Step 9 - */ -itemTagTest9: -$testHelper->printNewLine()->printText('#9 Testing getter: getItemsByTags() with strategy TAG_STRATEGY_ONLY // Expecting 1 result'); -$driverInstance->clear(); -$createItemsCallback(); - -$tagsItems = $driverInstance->getItemsByTags(['tag-test_1', 'tag-test_all', 'tag-test_all2', 'tag-test_all3'], TaggableCacheItemPoolInterface::TAG_STRATEGY_ONLY); - -if (is_array($tagsItems)) { - if (count($tagsItems) === 1) { - if (isset($tagsItems['tag-test1'])) { - if ($tagsItems['tag-test1']->getKey() !== 'tag-test1') { - $testHelper->assertFail('STEP#9 // Got unexpected tagged item key:' . $tagsItems['tag-test1']->getKey()); - goto itemTagTest10; - } - $testHelper->assertPass('STEP#9 // Successfully retrieved 1 tagged item keys'); - } else { - $testHelper->assertFail('STEP#9 // Got wrong array key, expected "tag-test3", got "' . key($tagsItems) . '"'); - goto itemTagTest10; - } - } else { - $testHelper->assertFail('STEP#9 // Got wrong count of item:' . count($tagsItems)); - goto itemTagTest10; - } -} else { - $testHelper->assertFail('STEP#9 // Expected $tagsItems to be an array, got: ' . gettype($tagsItems)); - goto itemTagTest10; -} - -/** - * Item tag test // Step 10 - */ -itemTagTest10: -$testHelper->printNewLine()->printText('#10 Testing getter: getItemsByTags() with strategy TAG_STRATEGY_ONLY // Expecting 0 result'); -$driverInstance->clear(); -$createItemsCallback(); - -$tagsItems = $driverInstance->getItemsByTags(['tag-test_1', 'tag-test_all', 'tag-test_all2', /*'tag-test_all3'*/], TaggableCacheItemPoolInterface::TAG_STRATEGY_ONLY); - -if (is_array($tagsItems)) { - if (count($tagsItems) === 0) { - $testHelper->assertPass('STEP#10 // Successfully retrieved 0 tagged item keys'); - } else { - $testHelper->assertFail('STEP#10 // Got wrong count of item:' . count($tagsItems)); - goto itemTagTest11; - } -} else { - $testHelper->assertFail('STEP#10 // Expected $tagsItems to be an array, got: ' . gettype($tagsItems)); - goto itemTagTest11; -} - -itemTagTest11: - -$testHelper->printNewLine()->printNoteText('##### TESTING ITEM TAGS HASSERS'); - -$testHelper->printNewLine()->printText('#1 Testing ExtendedCacheItemInterface::hasTag()'); -$driverInstance->clear(); -$createItemsCallback(); -$cacheItem = $driverInstance->getItem('tag-test1'); - -if ($cacheItem->hasTag('tag-test_1')) { - $testHelper->assertPass('STEP#1 // Successfully found the expected tag'); -} else { - $testHelper->assertFail('STEP#1 // Failed finding the expected tag'); -} - -if (!$cacheItem->hasTag('non_existing_tag')) { - $testHelper->assertPass('STEP#2 // Successfully not found an unknown tag'); -} else { - $testHelper->assertFail('STEP#2 // Failed not finding an unknown tag'); -} - - -$testHelper->printNewLine()->printText('#2 Testing ExtendedCacheItemInterface::hasTags() with strategy "TAG_STRATEGY_ONE"'); -$driverInstance->clear(); -$createItemsCallback(); -$cacheItem = $driverInstance->getItem('tag-test2'); - -if ($cacheItem->hasTags(['tag-test_1', 'tag-test_2'], TaggableCacheItemInterface::TAG_STRATEGY_ONE)) { - $testHelper->assertPass('STEP#1 // Successfully finding both the known tags'); -} else { - $testHelper->assertFail('STEP#1 // Failed finding both the known tags'); -} - -if ($cacheItem->hasTags(['tag-test_1', 'non_existing_tag'], TaggableCacheItemInterface::TAG_STRATEGY_ONE)) { - $testHelper->assertPass('STEP#2 // Successfully finding one of the known tags'); -} else { - $testHelper->assertFail('STEP#2 // Failed finding one of the known tags'); -} - -if (!$cacheItem->hasTags(['non_existing_tag', 'non_existing_tag2'], TaggableCacheItemInterface::TAG_STRATEGY_ONE)) { - $testHelper->assertPass('STEP#3 // Successfully not finding one of the unknown tags'); -} else { - $testHelper->assertFail('STEP#3 // Failed not finding one of the unknown tags'); -} - -$testHelper->printNewLine()->printText('#3 Testing ExtendedCacheItemInterface::hasTags() with strategy "TAG_STRATEGY_ALL"'); -$driverInstance->clear(); -$createItemsCallback(); -$cacheItem = $driverInstance->getItem('tag-test2'); - -if ($cacheItem->hasTags(['tag-test_1', 'tag-test_2'], TaggableCacheItemInterface::TAG_STRATEGY_ALL)) { - $testHelper->assertPass('STEP#1 // Successfully found both the known tags'); -} else { - $testHelper->assertFail('STEP#1 // Failed finding both the known tags'); -} - -if ($cacheItem->hasTags(['tag-test_1', 'non_existing_tag'], TaggableCacheItemInterface::TAG_STRATEGY_ALL)) { - $testHelper->assertPass('STEP#2 // Successfully not finding both of the known and unknown tags'); -} else { - $testHelper->assertPass('STEP#2 // Failed not finding both of the known and unknown tags'); -} - - -$testHelper->printNewLine()->printText('#4 Testing ExtendedCacheItemInterface::hasTags() with strategy "TAG_STRATEGY_ONLY"'); -$driverInstance->clear(); -$createItemsCallback(); -$cacheItem = $driverInstance->getItem('tag-test3'); - -if ($cacheItem->hasTags($cacheItem->getTags(), TaggableCacheItemInterface::TAG_STRATEGY_ONLY)) { - $testHelper->assertPass('STEP#1 // Successfully matching only and exclusively the known tags'); -} else { - $testHelper->assertFail('STEP#1 // Failed matching only and exclusively the known tags'); -} - -if (!$cacheItem->hasTags(['tag-test_1', 'tag-test_2', /*'tag-test_3',*/ 'tag-test_all', 'tag-test_all2', 'tag-test_all3', 'tag-test_all4'], TaggableCacheItemInterface::TAG_STRATEGY_ONLY)) { - $testHelper->assertPass('STEP#1 // Successfully not matching only the known tags with some of them omitted'); -} else { - $testHelper->assertPass('STEP#1 // Failed not matching only the known tags with some of them omitted'); -} - -if (!$cacheItem->hasTags(array_merge($cacheItem->getTags(), ['non_existing_tag']), TaggableCacheItemInterface::TAG_STRATEGY_ONLY)) { - $testHelper->assertPass('STEP#1 // Successfully matching only the known tags plus an unknown tag'); -} else { - $testHelper->assertFail('STEP#1 // Failed matching only the known tags plus an unknown tag'); -} - -$testHelper->terminateTest(); diff --git a/tests/cases/Memcache.test.php b/tests/cases/Memcache.test.php deleted file mode 100644 index cf995df20..000000000 --- a/tests/cases/Memcache.test.php +++ /dev/null @@ -1,36 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -use Phpfastcache\CacheManager; -use Phpfastcache\Drivers\Memcache\Config as MemcacheConfig; -use Phpfastcache\Tests\Helper\TestHelper; - -chdir(__DIR__); -require_once __DIR__ . '/../../vendor/autoload.php'; -$testHelper = new TestHelper('Memcache driver'); - - -$config = new MemcacheConfig([ - 'servers' => [ - [ - 'path' => '', - 'host' => '127.0.0.1', - 'port' => 11211, - ] - ] -]); -$config->setItemDetailedDate(true); -$cacheInstance = CacheManager::getInstance('Memcache', $config); -$testHelper->runCRUDTests($cacheInstance); -$testHelper->terminateTest(); diff --git a/tests/cases/Memcached.test.php b/tests/cases/Memcached.test.php deleted file mode 100644 index 51d8e4a78..000000000 --- a/tests/cases/Memcached.test.php +++ /dev/null @@ -1,88 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -use Phpfastcache\CacheManager; -use Phpfastcache\Core\Pool\ExtendedCacheItemPoolInterface; -use Phpfastcache\Drivers\Memcached\Config as MemcachedConfig; -use Phpfastcache\Tests\Helper\TestHelper; - -chdir(__DIR__); -require_once __DIR__ . '/../../vendor/autoload.php'; -$testHelper = new TestHelper('Memcached'); - -$cacheInstanceDefSyntax = CacheManager::getInstance('Memcached'); - -$cacheInstanceOldSyntax = CacheManager::getInstance('Memcached', new MemcachedConfig([ - 'servers' => [ - [ - 'host' => '127.0.0.1', - 'port' => 11211, - 'saslUser' => null, - 'saslPassword' => null, - ] - ] -])); - -$cacheInstanceNewSyntax = CacheManager::getInstance('Memcached', new MemcachedConfig([ - 'host' => '127.0.0.1', - 'port' => 11211, -])); - -$cacheKey = 'cacheKey'; -$RandomCacheValue = str_shuffle(uniqid('pfc', true)); - -$cacheItem = $cacheInstanceDefSyntax->getItem($cacheKey); -$cacheItem->set($RandomCacheValue)->expiresAfter(600); -$cacheInstanceDefSyntax->save($cacheItem); -unset($cacheItem); -$cacheInstanceDefSyntax->detachAllItems(); - - -$cacheItem = $cacheInstanceOldSyntax->getItem($cacheKey); -$cacheItem->set($RandomCacheValue)->expiresAfter(600); -$cacheInstanceOldSyntax->save($cacheItem); -unset($cacheItem); -$cacheInstanceOldSyntax->detachAllItems(); - -$cacheItem = $cacheInstanceNewSyntax->getItem($cacheKey); -$cacheItem->set($RandomCacheValue)->expiresAfter(600); -$cacheInstanceNewSyntax->save($cacheItem); -unset($cacheItem); -$cacheInstanceNewSyntax->detachAllItems(); - - -if ($cacheInstanceDefSyntax->getItem($cacheKey)->isHit()) { - $testHelper->assertPass('The default Memcached syntax is working well'); -} else { - $testHelper->assertFail('The default Memcached syntax is not working'); -} - -if ($cacheInstanceOldSyntax->getItem($cacheKey)->isHit()) { - $testHelper->assertPass('The old Memcached syntax is working well'); -} else { - $testHelper->assertFail('The old Memcached syntax is not working'); -} - -if ($cacheInstanceNewSyntax->getItem($cacheKey)->isHit()) { - $testHelper->assertPass('The new Memcached syntax is working well'); -} else { - $testHelper->assertFail('The new Memcached syntax is not working'); -} - -$cacheInstanceDefSyntax->clear(); -$cacheInstanceOldSyntax->clear(); -$cacheInstanceNewSyntax->clear(); - -$testHelper->runCRUDTests($cacheInstanceNewSyntax); -$testHelper->terminateTest(); diff --git a/tests/cases/Memory.test.php b/tests/cases/Memory.test.php deleted file mode 100644 index 7aebcdaaa..000000000 --- a/tests/cases/Memory.test.php +++ /dev/null @@ -1,24 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -use Phpfastcache\CacheManager; -use Phpfastcache\Tests\Helper\TestHelper; - -chdir(__DIR__); -require_once __DIR__ . '/../../vendor/autoload.php'; -$testHelper = new TestHelper('Memstatic driver'); -$cacheInstance = CacheManager::getInstance('Memory'); - -$testHelper->runCRUDTests($cacheInstance); -$testHelper->terminateTest(); diff --git a/tests/cases/NewCacheInstance.test.php b/tests/cases/NewCacheInstance.test.php deleted file mode 100644 index bd1f67651..000000000 --- a/tests/cases/NewCacheInstance.test.php +++ /dev/null @@ -1,35 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -use Phpfastcache\Core\Pool\ExtendedCacheItemPoolInterface; -use Phpfastcache\CacheManager; -use Phpfastcache\Tests\Helper\TestHelper; - -chdir(__DIR__); -require_once __DIR__ . '/../../vendor/autoload.php'; -$testHelper = new TestHelper('New cache instance'); -$defaultDriver = (!empty($argv[1]) ? ucfirst($argv[1]) : 'Files'); - -/** - * Testing memcached as it is declared in .travis.yml - */ -$driverInstance = CacheManager::getInstance($defaultDriver); - -if (!is_object($driverInstance) || !($driverInstance instanceof ExtendedCacheItemPoolInterface)) { - $testHelper->assertFail('CacheManager::getInstance() returned wrong data hint:' . gettype($driverInstance)); -} else { - $testHelper->assertPass('CacheManager::getInstance() returned an expected object that implements ExtendedCacheItemPoolInterface'); -} - -$testHelper->terminateTest(); diff --git a/tests/cases/Predis.test.php b/tests/cases/Predis.test.php deleted file mode 100644 index 635b774cd..000000000 --- a/tests/cases/Predis.test.php +++ /dev/null @@ -1,32 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -use Phpfastcache\CacheManager; -use Phpfastcache\Exceptions\PhpfastcacheDriverCheckException; -use Phpfastcache\Tests\Helper\TestHelper; -use Phpfastcache\Drivers\Predis\Config as PredisConfig; -use Redis as RedisClient; - -chdir(__DIR__); -require_once __DIR__ . '/../../vendor/autoload.php'; -$testHelper = new TestHelper('Predis bundled client'); - -try { - $cacheInstance = CacheManager::getInstance('Predis', new PredisConfig()); - $testHelper->runCRUDTests($cacheInstance); -} catch (\RedisException $e) { - $testHelper->assertFail('A Redis exception occurred: ' . $e->getMessage()); -} - -$testHelper->terminateTest(); diff --git a/tests/cases/PredisCustomClient.test.php b/tests/cases/PredisCustomClient.test.php deleted file mode 100644 index 4e3e34787..000000000 --- a/tests/cases/PredisCustomClient.test.php +++ /dev/null @@ -1,52 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -use Phpfastcache\CacheManager; -use Phpfastcache\Exceptions\PhpfastcacheDriverCheckException; -use Phpfastcache\Exceptions\PhpfastcacheDriverConnectException; -use Phpfastcache\Tests\Helper\TestHelper; -use Phpfastcache\Drivers\Predis\Config as PredisConfig; -use Predis\Client as PredisClient; -use Predis\Connection\ConnectionException as PredisConnectionException; - -chdir(__DIR__); -require_once __DIR__ . '/../../vendor/autoload.php'; -$testHelper = new TestHelper('Predis custom client'); - -try { - if (!class_exists(PredisClient::class)) { - throw new PhpfastcacheDriverCheckException('Predis library is not installed'); - } - - $testHelper->mutePhpNotices(); - - try{ - $predisClient = new PredisClient([ - 'host' => '127.0.0.1', - 'port' => 6379, - 'password' => null, - 'database' => 0, - ]); - $predisClient->connect(); - }catch (PredisConnectionException $e){ - throw new PhpfastcacheDriverConnectException('Redis server unreachable.'); - } - - $cacheInstance = CacheManager::getInstance('Predis', (new PredisConfig())->setPredisClient($predisClient)); - $testHelper->runCRUDTests($cacheInstance); -} catch (\RedisException $e) { - $testHelper->assertFail('A Predis exception occurred: ' . $e->getMessage()); -} - -$testHelper->terminateTest(); diff --git a/tests/cases/Psr16Adapter.test.php b/tests/cases/Psr16Adapter.test.php deleted file mode 100644 index 383033630..000000000 --- a/tests/cases/Psr16Adapter.test.php +++ /dev/null @@ -1,132 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -use Phpfastcache\Helper\Psr16Adapter; -use Phpfastcache\Tests\Helper\TestHelper; - -chdir(__DIR__); -require_once __DIR__ . '/../../vendor/autoload.php'; -$testHelper = new TestHelper('Psr16Adapter helper'); -$defaultDriver = (!empty($argv[1]) ? ucfirst($argv[1]) : 'Files'); -$Psr16Adapter = new Psr16Adapter($defaultDriver); - -$value = str_shuffle(uniqid('pfc', true)); - -if (!$Psr16Adapter->has('test-key')) { - $testHelper->assertPass('1/9 Psr16 hasser returned expected boolean (false)'); -} else { - $testHelper->assertFail('1/9 Psr16 hasser returned unexpected boolean (true)'); -} - -$testHelper->printNewLine()->printText('Setting up value to "test-key"...')->printNewLine(); -$Psr16Adapter->set('test-key', $value); - -if ($Psr16Adapter->get('test-key') === $value) { - $testHelper->assertPass('2/9 Psr16 getter returned expected value: ' . $value); -} else { - $testHelper->assertFail('2/9 Psr16 getter returned unexpected value: ' . $value); -} - -$testHelper->printNewLine()->printText('Deleting key "test-key"...')->printNewLine(); -$Psr16Adapter->delete('test-key'); - -if (!$Psr16Adapter->has('test-key')) { - $testHelper->assertPass('3/9 Psr16 hasser returned expected boolean (false)'); -} else { - $testHelper->assertFail('3/9 Psr16 hasser returned unexpected boolean (true)'); -} - -$testHelper->printNewLine()->printText('Setting up value to "test-key, test-key2, test-key3"...')->printNewLine(); -$Psr16Adapter->setMultiple([ - 'test-key' => $value, - 'test-key2' => $value, - 'test-key3' => $value -]); - - -$values = $Psr16Adapter->getMultiple(['test-key', 'test-key2', 'test-key3']); -if (count(array_filter($values)) === 3) { - $testHelper->assertPass('4/9 Psr16 multiple getters returned expected values (3)'); -} else { - $testHelper->assertFail('4/9 Psr16 getters(3) returned unexpected values.'); -} - -$values = $Psr16Adapter->getMultiple(new ArrayObject(['test-key', 'test-key2', 'test-key3'])); -if (count(array_filter($values)) === 3) { - $testHelper->assertPass('5/9 Psr16 multiple getters with Traversable returned expected values (3)'); -} else { - $testHelper->assertFail('5/9 Psr16 getters(3) with Traversable returned unexpected values.'); -} - -$testHelper->printNewLine()->printText('Clearing whole cache ...')->printNewLine(); -$Psr16Adapter->clear(); - -$testHelper->printText('Setting up value to "test-key, test-key2, test-key3"...')->printNewLine(); -$Psr16Adapter->setMultiple([ - 'test-key' => $value, - 'test-key2' => $value, - 'test-key3' => $value -]); - -if ($Psr16Adapter->has('test-key') && $Psr16Adapter->has('test-key2') && $Psr16Adapter->has('test-key3')) { - $testHelper->assertPass('6/9 Psr16 hasser returned expected booleans (true)'); -} else { - $testHelper->assertFail('6/9 Psr16 hasser returned one or more unexpected boolean (false)'); -} - -$testHelper->printNewLine()->printText('Clearing whole cache ...')->printNewLine(); -$Psr16Adapter->clear(); - -$testHelper->printText('Setting multiple values using a Traversable to "test-key, test-key2, test-key3"...')->printNewLine(); -$Psr16Adapter->setMultiple(new ArrayObject([ - 'test-key' => $value, - 'test-key2' => $value, - 'test-key3' => $value -])); - -if ($Psr16Adapter->has('test-key') && $Psr16Adapter->has('test-key2') && $Psr16Adapter->has('test-key3')) { - $testHelper->assertPass('7/9 Psr16 hasser returned expected booleans (true)'); -} else { - $testHelper->assertFail('7/9 Psr16 hasser returned one or more unexpected boolean (false)'); -} - -$testHelper->printNewLine()->printText('Deleting up keys "test-key, test-key2, test-key3"...')->printNewLine(); -$Psr16Adapter->deleteMultiple(['test-key', 'test-key2', 'test-key3']); - -if (!$Psr16Adapter->has('test-key') && !$Psr16Adapter->has('test-key2') && !$Psr16Adapter->has('test-key3')) { - $testHelper->assertPass('8/9 Psr16 hasser returned expected booleans (false)'); -} else { - $testHelper->assertFail('8/9 Psr16 hasser returned one or more unexpected boolean (true)'); -} - -$testHelper->printNewLine()->printText('Clearing whole cache ...')->printNewLine(); -$Psr16Adapter->clear(); -$testHelper->printText('Setting up value to "test-key, test-key2, test-key3"...')->printNewLine(); -$Psr16Adapter->setMultiple([ - 'test-key' => $value, - 'test-key2' => $value, - 'test-key3' => $value -]); - -$testHelper->printText('Deleting up keys "test-key, test-key2, test-key3"... from a Traversable')->printNewLine(); -$traversable = new ArrayObject(['test-key', 'test-key2', 'test-key3']); -$Psr16Adapter->deleteMultiple($traversable); - -if (!$Psr16Adapter->has('test-key') && !$Psr16Adapter->has('test-key2') && !$Psr16Adapter->has('test-key3')) { - $testHelper->assertPass('9/9 Psr16 hasser returned expected booleans (false)'); -} else { - $testHelper->assertFail('9/9 Psr16 hasser returned one or more unexpected boolean (true)'); -} - -$testHelper->terminateTest(); diff --git a/tests/cases/Psr6InterfaceImplements.test.php b/tests/cases/Psr6InterfaceImplements.test.php deleted file mode 100644 index 4ad6a62a9..000000000 --- a/tests/cases/Psr6InterfaceImplements.test.php +++ /dev/null @@ -1,37 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -use Phpfastcache\CacheManager; -use Phpfastcache\Tests\Helper\TestHelper; -use Psr\Cache\CacheItemPoolInterface; - -chdir(__DIR__); -require_once __DIR__ . '/../../vendor/autoload.php'; -$testHelper = new TestHelper('PSR6 Interface Implements'); -$defaultDriver = (!empty($argv[1]) ? ucfirst($argv[1]) : 'Files'); - -/** - * Testing memcached as it is declared in .travis.yml - */ -$driverInstance = CacheManager::getInstance($defaultDriver); - -if (!is_object($driverInstance)) { - $testHelper->assertFail('CacheManager::getInstance() returned an invalid variable type:' . gettype($driverInstance)); -} elseif (!($driverInstance instanceof CacheItemPoolInterface)) { - $testHelper->assertFail('CacheManager::getInstance() returned an invalid class:' . get_class($driverInstance)); -} else { - $testHelper->assertPass('CacheManager::getInstance() returned a valid CacheItemPoolInterface object: ' . get_class($driverInstance)); -} - -$testHelper->terminateTest(); diff --git a/tests/cases/ReadWriteOperations.test.php b/tests/cases/ReadWriteOperations.test.php deleted file mode 100644 index 129fa71ba..000000000 --- a/tests/cases/ReadWriteOperations.test.php +++ /dev/null @@ -1,87 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -use Phpfastcache\CacheManager; -use Phpfastcache\Config\ConfigurationOption; -use Phpfastcache\Drivers\Files\Config as FilesConfig; -use Phpfastcache\Core\Item\ExtendedCacheItemInterface; -use Phpfastcache\Tests\Helper\TestHelper; - -chdir(__DIR__); -require_once __DIR__ . '/../../vendor/autoload.php'; -$testHelper = new TestHelper('Read/Write operations (I/O)'); -CacheManager::setDefaultConfig(new ConfigurationOption(['path' => __DIR__ . '/../../cache'])); - -/** - * @var $items ExtendedCacheItemInterface[] - */ -$items = []; -$instances = []; -$keys = []; - -$dirs = [ - __DIR__ . '/../var/cache-cache/IO-', - sys_get_temp_dir() . '/phpfastcache/IO-1', - sys_get_temp_dir() . '/phpfastcache/IO-2', -]; - - -foreach ($dirs as $dirIndex => $dir) { - for ($i = 1; $i <= 20; $i++) { - $keys[ $dirIndex ][] = 'test' . $i; - } - - for ($i = 1; $i <= 20; $i++) { - $cacheInstanceName = 'cacheInstance' . $i; - - $instances[ $dirIndex ][ $cacheInstanceName ] = CacheManager::getInstance('Files', new FilesConfig([ - 'path' => $dir . str_pad($i, 3, '0', STR_PAD_LEFT), - 'secureFileManipulation' => true, - 'cacheFileExtension' => 'pfc', - 'securityKey' => '_cache', - ])); - - foreach ($keys[ $dirIndex ] as $index => $key) { - $items[ $dirIndex ][ $index ] = $instances[ $dirIndex ][ $cacheInstanceName ]->getItem($key); - $items[ $dirIndex ][ $index ]->set("test-$dirIndex-$index")->expiresAfter(600); - $instances[ $dirIndex ][ $cacheInstanceName ]->saveDeferred($items[ $dirIndex ][ $index ]); - } - $instances[ $dirIndex ][ $cacheInstanceName ]->commit(); - $instances[ $dirIndex ][ $cacheInstanceName ]->detachAllItems(); - } - - foreach ($instances[ $dirIndex ] as $cacheInstanceName => $instance) { - foreach ($keys[ $dirIndex ] as $index => $key) { - if ($instances[ $dirIndex ][ $cacheInstanceName ]->getItem($key)->get() === "test-$dirIndex-$index") { - $testHelper->assertPass("Item #{$key} of instance #{$cacheInstanceName} of dir #{$dirIndex} has returned the expected value (" . gettype("test-$dirIndex-$index") . ":'" . "test-$dirIndex-$index" . "')"); - } else { - $testHelper->assertFail("Item #{$key} of instance #{$cacheInstanceName} of dir #{$dirIndex} returned an unexpected value (" . gettype($instances[ $dirIndex ][ $cacheInstanceName ]->getItem($key) - ->get()) . ":'" . $instances[ $dirIndex ][ $cacheInstanceName ]->getItem($key) - ->get() . "') expected (" . gettype("test-$dirIndex-$index") . ":'" . "test-$dirIndex-$index" . "') \n"); - } - } - $instances[ $dirIndex ][ $cacheInstanceName ]->detachAllItems(); - } -} - -foreach ($dirs as $dirIndex => $dir) { - for ($i = 1; $i <= 20; $i++) { - $cacheInstanceName = 'cacheInstance' . $i; - - $testHelper->printDebugText(sprintf('Clearing cache instance %s#%s data', $dir, $cacheInstanceName)); - $instances[ $dirIndex ][ $cacheInstanceName ]->clear(); - } -} - -$testHelper->terminateTest(); diff --git a/tests/cases/Redis.test.php b/tests/cases/Redis.test.php deleted file mode 100644 index 4c8573df8..000000000 --- a/tests/cases/Redis.test.php +++ /dev/null @@ -1,35 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -use Phpfastcache\CacheManager; -use Phpfastcache\Exceptions\PhpfastcacheDriverCheckException; -use Phpfastcache\Tests\Helper\TestHelper; -use Phpfastcache\Drivers\Redis\Config as RedisConfig; -use Redis as RedisClient; - -chdir(__DIR__); -require_once __DIR__ . '/../../vendor/autoload.php'; -$testHelper = new TestHelper('Redis bundled client'); - -try { - if (!class_exists(RedisClient::class)) { - throw new PhpfastcacheDriverCheckException('Unable to test Redis client because the extension seems to be missing'); - } - $cacheInstance = CacheManager::getInstance('Redis', new RedisConfig()); - $testHelper->runCRUDTests($cacheInstance); -} catch (\RedisException $e) { - $testHelper->assertFail('A Redis exception occurred: ' . $e->getMessage()); -} - -$testHelper->terminateTest(); diff --git a/tests/cases/RedisCluster.test.php b/tests/cases/RedisCluster.test.php deleted file mode 100644 index af75f362a..000000000 --- a/tests/cases/RedisCluster.test.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -use Phpfastcache\CacheManager; -use Phpfastcache\Tests\Helper\TestHelper; -use Phpfastcache\Drivers\Rediscluster\Config as RedisConfig; - -chdir(__DIR__); -require_once __DIR__ . '/../../vendor/autoload.php'; -$testHelper = new TestHelper('Redis cluster'); - -try { - $config = new RedisConfig(); - $config->setClusters( '127.0.0.1:7001', '127.0.0.1:7002', '127.0.0.1:7003', '127.0.0.1:7004', '127.0.0.1:7005', '127.0.0.1:7006'); - $config->setOptPrefix('pfc_'); - $config->setSlaveFailover(\RedisCluster::FAILOVER_ERROR); - $cacheInstance = CacheManager::getInstance('RedisCluster', $config); - $testHelper->runCRUDTests($cacheInstance); -} catch (\RedisException $e) { - $testHelper->assertFail('A Redis exception occurred: ' . $e->getMessage()); -} - -$testHelper->terminateTest(); diff --git a/tests/cases/RedisCustomClient.test.php b/tests/cases/RedisCustomClient.test.php deleted file mode 100644 index d175938c5..000000000 --- a/tests/cases/RedisCustomClient.test.php +++ /dev/null @@ -1,44 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -use Phpfastcache\CacheManager; -use Phpfastcache\Exceptions\PhpfastcacheDriverCheckException; -use Phpfastcache\Exceptions\PhpfastcacheDriverConnectException; -use Phpfastcache\Tests\Helper\TestHelper; -use Phpfastcache\Drivers\Redis\Config as RedisConfig; -use Redis as RedisClient; - -chdir(__DIR__); -require_once __DIR__ . '/../../vendor/autoload.php'; -$testHelper = new TestHelper('Redis custom client'); - -try { - if (!class_exists(RedisClient::class)) { - throw new PhpfastcacheDriverCheckException('Unable to test Redis client because the extension seems to be missing'); - } - try{ - $redisClient = new RedisClient(); - $redisClient->connect('127.0.0.1', 6379, 5); - }catch (\RedisException $e){ - throw new PhpfastcacheDriverConnectException('Redis server unreachable.'); - } - - $redisClient->select(0); - $cacheInstance = CacheManager::getInstance('Redis', (new RedisConfig())->setRedisClient($redisClient)); - $testHelper->runCRUDTests($cacheInstance); -} catch (\RedisException $e) { - $testHelper->assertFail('A Redis exception occurred: ' . $e->getMessage()); -} - -$testHelper->terminateTest(); diff --git a/tests/cases/RedisExpireTtl0.test.php b/tests/cases/RedisExpireTtl0.test.php deleted file mode 100644 index 27dcfcb50..000000000 --- a/tests/cases/RedisExpireTtl0.test.php +++ /dev/null @@ -1,67 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -use Phpfastcache\CacheManager; -use Phpfastcache\Tests\Helper\TestHelper; - -chdir(__DIR__); -require_once __DIR__ . '/../../vendor/autoload.php'; -$testHelper = new TestHelper('(P)Redis Expire TTL to 0'); -$cacheInstance = CacheManager::getInstance('Redis'); -$cacheKey = 'cacheKey'; -$RandomCacheValue = str_shuffle(uniqid('pfc', true)); -$loops = 10; - -$testHelper->printText('See https://redis.io/commands/setex'); -$testHelper->printText('See https://redis.io/commands/expire'); -$testHelper->printNewLine(); - -for ($i = 0; $i <= $loops; $i++) { - $cacheItem = $cacheInstance->getItem("{$cacheKey}-{$i}"); - $cacheItem->set($RandomCacheValue) - ->expiresAt(new DateTime()); - - $cacheInstance->saveDeferred($cacheItem); -} - -try { - $cacheInstance->commit(); - $testHelper->assertPass('The COMMIT operation has finished successfully'); -} catch (Predis\Response\ServerException $e) { - if (strpos($e->getMessage(), 'setex')) { - $testHelper->assertFail('The COMMIT operation has failed due to to an invalid time detection.'); - } else { - $testHelper->assertFail('The COMMIT operation has failed due to to an unexpected error: ' . $e->getMessage()); - } -} -$cacheInstance->detachAllItems(); - -$testHelper->printText('Sleeping a second...'); - - -sleep(1); - -for ($i = 0; $i <= $loops; $i++) { - $cacheItem = $cacheInstance->getItem("{$cacheKey}-{$i}"); - - if ($cacheItem->isHit()) { - $testHelper->assertFail(sprintf('The cache item "%s" is considered as HIT with the following value: %s', $cacheItem->getKey(), $cacheItem->get())); - } else { - $testHelper->assertPass(sprintf('The cache item "%s" is not considered as HIT.', $cacheItem->getKey())); - } -} - -$cacheInstance->clear(); - -$testHelper->terminateTest(); diff --git a/tests/cases/Sqlite.test.php b/tests/cases/Sqlite.test.php deleted file mode 100644 index e3bdfee21..000000000 --- a/tests/cases/Sqlite.test.php +++ /dev/null @@ -1,28 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -use Phpfastcache\CacheManager; -use Phpfastcache\Config\ConfigurationOption; -use Phpfastcache\Tests\Helper\TestHelper; - -chdir(__DIR__); -require_once __DIR__ . '/../../vendor/autoload.php'; -$testHelper = new TestHelper('Sqlite'); -CacheManager::setDefaultConfig(new ConfigurationOption(['path' => __DIR__ . '/../../cache'])); - -$cacheInstance = CacheManager::getInstance('Sqlite'); - -$testHelper->runCRUDTests($cacheInstance); - -$testHelper->terminateTest(); diff --git a/tests/cases/Ssdb.test.php b/tests/cases/Ssdb.test.php deleted file mode 100644 index 72b70316c..000000000 --- a/tests/cases/Ssdb.test.php +++ /dev/null @@ -1,28 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -use Phpfastcache\CacheManager; -use Phpfastcache\Exceptions\PhpfastcacheDriverCheckException; -use Phpfastcache\Tests\Helper\TestHelper; -use Phpfastcache\Drivers\Ssdb\Config as SsdbConfig; -use Redis as RedisClient; - -chdir(__DIR__); -require_once __DIR__ . '/../../vendor/autoload.php'; -$testHelper = new TestHelper('SSDB'); - -$cacheInstance = CacheManager::getInstance('Ssdb', new SsdbConfig()); -$testHelper->runCRUDTests($cacheInstance); - -$testHelper->terminateTest(); diff --git a/tests/cases/UnsupportedKeyCharacters.test.php b/tests/cases/UnsupportedKeyCharacters.test.php deleted file mode 100644 index f6d7032b2..000000000 --- a/tests/cases/UnsupportedKeyCharacters.test.php +++ /dev/null @@ -1,54 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -use Phpfastcache\CacheManager; -use Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException; -use Phpfastcache\Tests\Helper\TestHelper; -use Psr\Cache\CacheItemPoolInterface; - -chdir(__DIR__); -require_once __DIR__ . '/../../vendor/autoload.php'; -$testHelper = new TestHelper('Unsupported key characters'); -$defaultDriver = (!empty($argv[1]) ? ucfirst($argv[1]) : 'Files'); -$driverInstance = CacheManager::getInstance($defaultDriver); - -try { - $driverInstance->getItem('test{test'); - $testHelper->assertFail('1/4 An unsupported key character did not get caught by regular expression'); -} catch (PhpfastcacheInvalidArgumentException $e) { - $testHelper->assertPass('1/4 An unsupported key character has been caught by regular expression'); -} - -try { - $driverInstance->getItem(':testtest'); - $testHelper->assertFail('2/4 An unsupported key character did not get caught by regular expression'); -} catch (PhpfastcacheInvalidArgumentException $e) { - $testHelper->assertPass('2/4 An unsupported key character has been caught by regular expression'); -} - -try { - $driverInstance->getItem('testtest}'); - $testHelper->assertFail('3/4 An unsupported key character did not get caught by regular expression'); -} catch (PhpfastcacheInvalidArgumentException $e) { - $testHelper->assertPass('3/4 An unsupported key character has been caught by regular expression'); -} - -try { - $driverInstance->getItem('testtest'); - $testHelper->assertPass('4/4 No exception caught while trying with a key without unsupported character'); -} catch (PhpfastcacheInvalidArgumentException $e) { - $testHelper->assertFail('4/4 An exception has been caught while trying with a key without unsupported character'); -} - -$testHelper->terminateTest(); diff --git a/tests/cases/Wincache.test.php b/tests/cases/Wincache.test.php deleted file mode 100644 index a43aea8d5..000000000 --- a/tests/cases/Wincache.test.php +++ /dev/null @@ -1,28 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -use Phpfastcache\CacheManager; -use Phpfastcache\Exceptions\PhpfastcacheDriverCheckException; -use Phpfastcache\Tests\Helper\TestHelper; -use Phpfastcache\Drivers\Wincache\Config as WincacheConfig; -use Redis as RedisClient; - -chdir(__DIR__); -require_once __DIR__ . '/../../vendor/autoload.php'; -$testHelper = new TestHelper('Wincache'); - -$cacheInstance = CacheManager::getInstance('Wincache', new WincacheConfig()); -$testHelper->runCRUDTests($cacheInstance); - -$testHelper->terminateTest(); diff --git a/tests/cases/subprocess/CacheSlamsProtection.subprocess.php b/tests/cases/subprocess/CacheSlamsProtection.subprocess.php deleted file mode 100644 index 4490f0a75..000000000 --- a/tests/cases/subprocess/CacheSlamsProtection.subprocess.php +++ /dev/null @@ -1,39 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -use Phpfastcache\CacheManager; -use Phpfastcache\Config\IOConfigurationOption; -use Phpfastcache\Entities\ItemBatch; - -chdir(__DIR__); -require_once __DIR__ . '/../../../vendor/autoload.php'; - -$driverInstance = CacheManager::getInstance('Files', new IOConfigurationOption([ - 'preventCacheSlams' => true, - 'cacheSlamsTimeout' => 15 -])); - -/** - * Emulate an active ItemBatch - */ -$batchItem = $driverInstance->getItem('TestCacheSlamsProtection'); -$batchItem->set(new ItemBatch($batchItem->getKey(), new \DateTime()))->expiresAfter(3600); -$driverInstance->save($batchItem); - -sleep(mt_rand(5, 15)); - -$batchItem->set(1337); -$driverInstance->save($batchItem); - -exit(0); diff --git a/tests/cases/subprocess/DisabledStaticItemCaching.subprocess.php b/tests/cases/subprocess/DisabledStaticItemCaching.subprocess.php deleted file mode 100644 index 9ab475cfa..000000000 --- a/tests/cases/subprocess/DisabledStaticItemCaching.subprocess.php +++ /dev/null @@ -1,25 +0,0 @@ - - */ - -use Phpfastcache\CacheManager; -use Phpfastcache\Config\ConfigurationOption; -use Phpfastcache\Entities\ItemBatch; - -chdir(__DIR__); -require_once __DIR__ . '/../../../vendor/autoload.php'; - -$driverInstance = CacheManager::getInstance('Files', new ConfigurationOption([ - 'useStaticItemCaching' => false, -])); - -/** - * Emulate an active ItemBatch - */ -$batchItem = $driverInstance->getItem('TestUseStaticItemCaching'); -$batchItem->set('abcdef-123456'); -$driverInstance->save($batchItem); - -exit(0); diff --git a/tests/issues/Github-373.test.php b/tests/issues/Github-373.test.php deleted file mode 100644 index 3300c53d3..000000000 --- a/tests/issues/Github-373.test.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -use Phpfastcache\CacheManager; -use Phpfastcache\Config\ConfigurationOption; -use Phpfastcache\Tests\Helper\TestHelper; - -chdir(__DIR__); -require_once __DIR__ . '/../../vendor/autoload.php'; -$testHelper = new TestHelper('Github issue #373 - Files driver issue after clearing cache'); -CacheManager::setDefaultConfig(new ConfigurationOption(['path' => __DIR__ . '/../../cache'])); -$cacheInstance = CacheManager::getInstance('Files'); - -$key = 'test'; -$cacheItem = $cacheInstance->getItem($key); -$cacheItem->set('value'); - -$cacheInstance->save($cacheItem); -$cacheInstance->deleteItem($key); -$cacheInstance->clear(); - -try { - $has = $cacheInstance->hasItem($key); - $testHelper->assertPass('No error thrown while trying to test if an item exists after clearing'); -} catch (Exception $e) { - $testHelper->assertFail('An error has been thrown while trying to test if an item exists after clearing'); -} - -$testHelper->terminateTest(); diff --git a/tests/issues/Github-392.test.php b/tests/issues/Github-392.test.php deleted file mode 100644 index 671af1815..000000000 --- a/tests/issues/Github-392.test.php +++ /dev/null @@ -1,71 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -use Phpfastcache\CacheManager; -use Phpfastcache\Tests\Helper\TestHelper; - -chdir(__DIR__); -require_once __DIR__ . '/../../vendor/autoload.php'; -$testHelper = new TestHelper('Github issue #392 - Issue after calling removeTag'); - -$InstanceCache = CacheManager::getInstance('Files'); - -$CachedElement1 = $InstanceCache->getItem('el1'); -$CachedElement1->set('element1')->expiresAfter(600); -$CachedElement1->addTags(array('tag_12')); -$InstanceCache->save($CachedElement1); -/** - * var_dump($CachedElement1->getTags()); Outputs: tag_12 - */ - -$CachedElement1 = $InstanceCache->getItem('el1'); -$CachedElement1->setTags(array('tag_34')); -$InstanceCache->save($CachedElement1); -/** - * var_dump($CachedElement1->getTags()); Outputs: tag_34 - */ - -$CachedElement1 = $InstanceCache->getItem('el1'); -$CachedElement1->removeTag('tag_12'); - -/** - * Save after removing a non existing tag: works as expected - */ -try { - $InstanceCache->save($CachedElement1); - $testHelper->assertPass('Save after removing a non existing tag: works as expected'); -} catch (Exception $e) { - $testHelper->assertFail('Save after removing a non existing tag failed with message: ' . $e->getMessage() . ' in ' . $e->getFile() . ' at line ' . $e->getLine()); -} -/** - * var_dump($CachedElement1->getTags()); Outputs: tag_34 - */ - -$CachedElement1 = $InstanceCache->getItem('el1'); -$CachedElement1->removeTags(array('tag_34')); - -/** - * Save after removing an existing tag: fails - */ -try { - $InstanceCache->save($CachedElement1); - $testHelper->assertPass('Save after removing an existing tag'); -} catch (Exception $e) { - $testHelper->assertFail('Save after removing an existing tag failed with message: ' . $e->getMessage() . ' in ' . $e->getFile() . ' at line ' . $e->getLine()); -} -/** - * var_dump($CachedElement1->getTags()); Outputs: empty - */ - -$testHelper->terminateTest(); diff --git a/tests/issues/Github-467.test.php b/tests/issues/Github-467.test.php deleted file mode 100644 index cc44bceea..000000000 --- a/tests/issues/Github-467.test.php +++ /dev/null @@ -1,47 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -use Phpfastcache\CacheManager; -use Phpfastcache\Drivers\Files\Config as FilesConfig; -use Phpfastcache\Exceptions\PhpfastcacheInvalidConfigurationException; -use Phpfastcache\Tests\Helper\TestHelper; -use \Phpfastcache\Config\ConfigurationOption; - -chdir(__DIR__); -require_once __DIR__ . '/../../vendor/autoload.php'; -$testHelper = new TestHelper('Github issue #467 - Allow to specify the file extension in the File Driver'); -CacheManager::setDefaultConfig(new ConfigurationOption(['path' => __DIR__ . '/../../cache'])); - -try { - $cacheInstance = CacheManager::getInstance('Files', new FilesConfig(['cacheFileExtension' => 'php'])); - $testHelper->assertFail('No error thrown while trying to setup a dangerous file extension'); -} catch (PhpfastcacheInvalidConfigurationException $e) { - $testHelper->assertPass('An error has been thrown while trying to setup a dangerous file extension'); -} - -try { - $cacheInstance = CacheManager::getInstance('Files', new FilesConfig(['cacheFileExtension' => '.cache'])); - $testHelper->assertFail('No error thrown while trying to setup a dotted file extension'); -} catch (PhpfastcacheInvalidConfigurationException $e) { - $testHelper->assertPass('An error has been thrown while trying to setup a dotted file extension'); -} - -try { - $cacheInstance = CacheManager::getInstance('Files', new FilesConfig(['cacheFileExtension' => 'cache'])); - $testHelper->assertPass('No error thrown while trying to setup a safe file extension'); -} catch (PhpfastcacheInvalidConfigurationException $e) { - $testHelper->assertFail('An error has been thrown while trying to setup a safe file extension'); -} - -$testHelper->terminateTest(); diff --git a/tests/issues/Github-522.test.php b/tests/issues/Github-522.test.php deleted file mode 100644 index 822863836..000000000 --- a/tests/issues/Github-522.test.php +++ /dev/null @@ -1,78 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -use Phpfastcache\CacheManager; -use Phpfastcache\Tests\Helper\TestHelper; - -chdir(__DIR__); -require_once __DIR__ . '/../../vendor/autoload.php'; -$testHelper = new TestHelper('Github issue #522 - Predis returns wrong type hints'); -$testHelper->mutePhpNotices(); -// Hide php Redis extension notice by using a little @ -$cacheInstance = CacheManager::getInstance('Predis'); -$stringObject = new stdClass; -$stringObject->test = ''; - -try { - - /** - * Clear Predis cache - */ - $cacheInstance->clear(); - for ($i = 0; $i < 1000; $i++) { - $stringObject->test .= md5(uniqid('pfc', true)); - } - $stringObject->test = str_shuffle($stringObject->test); - - $item1 = $cacheInstance->getItem('item1'); - $item2 = $cacheInstance->getItem('item2'); - $item3 = $cacheInstance->getItem('item3'); - - $item1->isHit() ?: $item1->set(clone $stringObject)->expiresAfter(20); - $item2->isHit() ?: $item2->set(clone $stringObject)->expiresAfter(20); - $item3->isHit() ?: $item3->set(clone $stringObject)->expiresAfter(20); - - $item1->isHit() ?: $cacheInstance->save($item1); - $item2->isHit() ?: $cacheInstance->save($item2); - $item3->isHit() ?: $cacheInstance->save($item3); - - $cacheInstance->deleteItem($item2->getKey()); - $cacheInstance->deleteItem($item3->getKey()); - $cacheInstance->detachAllItems(); - unset($item1, $item2, $item3); - - if ($cacheInstance->getItem('item1')->isHit() && $cacheInstance->getItem('item1')->get()->test === $stringObject->test) { - $testHelper->assertPass('The cache item "item1" returned the expected value.'); - } else { - $testHelper->assertFail('The cache item "item1" returned an expected value: ' . gettype($stringObject)); - } - - if (!$cacheInstance->getItem('item2')->isHit() && !$cacheInstance->getItem('item2')->isHit()) { - $testHelper->assertPass('The cache items "item2, item3" are not stored in cache as expected.'); - } else { - $testHelper->assertFail('The cache items "item2, item3" are unexpectedly stored in cache.'); - } - - $cacheInstance->clear(); - - if (!$cacheInstance->getItem('item1')->isHit() && $cacheInstance->getItem('item1')->get() === null) { - $testHelper->assertPass('After a cache clear the cache item "item1" is not stored in cache as expected.'); - } else { - $testHelper->assertFail('After a cache clear the cache item "item1" is still unexpectedly stored in cache.'); - } -} catch (\Throwable $e) { - $testHelper->assertFail('The test did not ended well, an error occurred: ' . $e->getMessage()); -} - -$testHelper->terminateTest(); diff --git a/tests/issues/Github-529.test.php b/tests/issues/Github-529.test.php deleted file mode 100644 index 04f2b6079..000000000 --- a/tests/issues/Github-529.test.php +++ /dev/null @@ -1,66 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -use Phpfastcache\CacheManager; -use Phpfastcache\Tests\Helper\TestHelper; - -chdir(__DIR__); -require_once __DIR__ . '/../../vendor/autoload.php'; -$testHelper = new TestHelper('Github issue #529 - Memory leak caused by item tags'); -// Hide php Redis extension notice by using a little @ -$cacheInstance = CacheManager::getInstance('Files'); -$string = uniqid('pfc', true); - -/** - * Populate the cache with some data - */ -[$item, $item2] = array_values($cacheInstance->getItems(['item1', 'item2'])); - -$item->set($string) - ->addTags(['tag-all', 'tag1']) - ->expiresAfter(3600); - -$item2->set($string) - ->addTags(['tag-all', 'tag2']) - ->expiresAfter(3600); - -$cacheInstance->saveMultiple(...[$item, $item2]); -$cacheInstance->detachAllItems(); -unset($item, $item2); - -/** - * Destroy the populated items - */ -$cacheInstance->deleteItemsByTag('tag-all'); - -/** - * First test memory, as we will write the item inside in the second test - */ -$itemInstances = $testHelper->accessInaccessibleMember($cacheInstance, 'itemInstances'); -if (isset($itemInstances[$cacheInstance::DRIVER_TAGS_KEY_PREFIX . 'tag-all'])) { - $testHelper->assertFail('The internal cache item tag is still stored in memory'); -} else { - $testHelper->assertPass('The internal cache item tag is no longer stored in memory'); -} - -/** - * Then test disk to see if the item is still there - */ -if ($cacheInstance->getItem($cacheInstance::DRIVER_TAGS_KEY_PREFIX . 'tag-all')->isHit()) { - $testHelper->assertFail('The internal cache item tag is still stored on disk'); -} else { - $testHelper->assertPass('The internal cache item tag is no longer stored on disk'); -} - -$testHelper->terminateTest(); diff --git a/tests/issues/Github-545.test.php b/tests/issues/Github-545.test.php deleted file mode 100644 index 1b35fd13e..000000000 --- a/tests/issues/Github-545.test.php +++ /dev/null @@ -1,44 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -use Phpfastcache\Helper\Psr16Adapter; -use Phpfastcache\Tests\Helper\TestHelper; - -chdir(__DIR__); -require_once __DIR__ . '/../../vendor/autoload.php'; -$testHelper = new TestHelper('Github issue #545 - Psr16Adapter get item even if it is expired'); -$defaultDriver = (!empty($argv[1]) ? ucfirst($argv[1]) : 'Files'); -$Psr16Adapter = new Psr16Adapter($defaultDriver); -$ttl = 5; - -$testHelper->printText('Preparing test item...'); -$value = str_shuffle(uniqid('pfc', true)); -$Psr16Adapter->set('test-key', $value, $ttl); -$testHelper->printText(sprintf('Sleeping for %d seconds...', $ttl + 1)); - -sleep($ttl + 1); - -if (!$Psr16Adapter->has('test-key')) { - $testHelper->assertPass('1/2 [Testing has()] Psr16 adapter does not return an expired cache item anymore'); -} else { - $testHelper->assertFail('1/2 [Testing has()] Psr16 adapter returned an expired cache item'); -} - -if (!$Psr16Adapter->has('test-key')) { - $testHelper->assertPass('2/2 [Testing get()] Psr16 adapter does not return an expired cache item anymore'); -} else { - $testHelper->assertFail('2/2 [Testing get()] Psr16 adapter returned an expired cache item'); -} - -$testHelper->terminateTest(); diff --git a/tests/issues/Github-560.test.php b/tests/issues/Github-560.test.php deleted file mode 100644 index 30e03ec7b..000000000 --- a/tests/issues/Github-560.test.php +++ /dev/null @@ -1,64 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -use Phpfastcache\CacheManager; -use Phpfastcache\Config\ConfigurationOption; -use Phpfastcache\Tests\Helper\TestHelper; - -chdir(__DIR__); -require_once __DIR__ . '/../../vendor/autoload.php'; -$testHelper = new TestHelper('Github issue #560 - Expiration date bug with sqlite driver'); -$defaultTTl = 60 * 60 * 24 * 31; -$cacheInstance = CacheManager::getInstance('Sqlite', new ConfigurationOption([ - 'defaultTtl' => $defaultTTl -])); - -/** - * Clear the cache to avoid - * unexpected results - */ -$cacheInstance->clear(); - -$cacheKey = uniqid('ck', true); -$string = uniqid('pfc', true); -$testHelper->printText('Preparing test item...'); - -/** - * Setup the cache item - */ -$cacheItem = $cacheInstance->getItem($cacheKey); -$cacheItem->set($string); -$cacheInstance->save($cacheItem); - -/** - * Delete memory references - * to be sure that the values - * come from the cache itself - */ -unset($cacheItem); -$cacheInstance->detachAllItems(); -$cacheItem = $cacheInstance->getItem($cacheKey); - -/** - * Round up to the nearest 10 to avoid a potential issue - * due to the time spend to write the cache on disk that will - * loss 1 second to the cache ttl :/ - */ -if ((int) ceil($cacheItem->getTtl() / 10) * 10 === $defaultTTl) { - $testHelper->assertPass('The cache Item TTL matches the default TTL after 30 days.'); -} else { - $testHelper->assertFail('The cache Item TTL des not matches the default TTL after 30 days, got the following value: ' . ceil($cacheItem->getTtl() / 10) * 10); -} - -$testHelper->terminateTest(); diff --git a/tests/issues/Github-581.test.php b/tests/issues/Github-581.test.php deleted file mode 100644 index 9c6903410..000000000 --- a/tests/issues/Github-581.test.php +++ /dev/null @@ -1,54 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -use Phpfastcache\CacheManager; -use Phpfastcache\Tests\Helper\TestHelper; - -chdir(__DIR__); -require_once __DIR__ . '/../../vendor/autoload.php'; -$testHelper = new TestHelper('Github issue #581 - Files driver "securityKey" option configuration not working as documented'); -$cacheInstance = CacheManager::getInstance('Files'); - -/** - * Force the HTTP_HOST in CLI to - * simulate a Web request - */ -$_SERVER[ 'HTTP_HOST' ] = uniqid('test.', true) . '.pfc.net'; - -/** - * Clear the cache to avoid - * unexpected results - */ -$cacheInstance->clear(); - -$cacheKey = uniqid('ck', true); -$string = uniqid('pfc', true); -$testHelper->printText('Preparing test item...'); - -/** - * Setup the cache item - */ -$cacheItem = $cacheInstance->getItem($cacheKey); -$cacheItem->set($string); -$cacheInstance->save($cacheItem); -unset($cacheItem); -$cacheInstance->detachAllItems(); - -if (strpos($cacheInstance->getPath(), 'phpfastcache' . DIRECTORY_SEPARATOR . $_SERVER[ 'HTTP_HOST' ]) !== false) { - $testHelper->assertPass('The "securityKey" option in automatic mode writes the HTTP_HOST directory as expected.'); -} else { - $testHelper->assertFail('The "securityKey" option in automatic mode leads to the following path: ' . $cacheInstance->getPath()); -} - -$testHelper->terminateTest(); diff --git a/tests/issues/Github-627.test.php b/tests/issues/Github-627.test.php deleted file mode 100644 index 0e1ed13d3..000000000 --- a/tests/issues/Github-627.test.php +++ /dev/null @@ -1,82 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -use Phpfastcache\CacheManager; -use Phpfastcache\Tests\Helper\TestHelper; -use Phpfastcache\Drivers\Redis\Config as RedisConfig; -use Phpfastcache\Drivers\Predis\Config as PredisConfig; - -chdir(__DIR__); -require_once __DIR__ . '/../../vendor/autoload.php'; -$testHelper = new TestHelper('Github issue #627 - Redis/Predis "prefix" option'); -$testHelper->mutePhpNotices(); -$redisInstance = CacheManager::getInstance('Redis', new RedisConfig(['optPrefix' => uniqid('pfc', true) . '_'])); -$predisInstance = CacheManager::getInstance('Predis', new PredisConfig(['optPrefix' => uniqid('pfc', true) . '_'])); - -$testHelper->printInfoText('Testing Redis 1/2'); - -/** - * Clear the cache to avoid - * unexpected results - */ -$redisInstance->clear(); - -$cacheKey = uniqid('ck', true); -$string = uniqid('pfc', true); -$testHelper->printText('Preparing test item...'); - -/** - * Setup the cache item - */ -$cacheItem = $redisInstance->getItem($cacheKey); -$cacheItem->set($string); -$redisInstance->save($cacheItem); -unset($cacheItem); -$redisInstance->detachAllItems(); - -if ($redisInstance->getItem($cacheKey)->isHit()) { - $testHelper->assertPass('The cache item has been found in cache'); -} else { - $testHelper->assertFail('The cache item was not found in cache'); -} - -$testHelper->printInfoText('Testing Predis 2/2'); - -/** - * Clear the cache to avoid - * unexpected results - */ -$predisInstance->clear(); - -$cacheKey = uniqid('ck', true); -$string = uniqid('pfc', true); -$testHelper->printText('Preparing test item...'); - -/** - * Setup the cache item - */ -$cacheItem = $predisInstance->getItem($cacheKey); -$cacheItem->set($string); -$predisInstance->save($cacheItem); -unset($cacheItem); -$predisInstance->detachAllItems(); - -if ($predisInstance->getItem($cacheKey)->isHit()) { - $testHelper->assertPass('The cache item has been found in cache'); -} else { - $testHelper->assertFail('The cache item was not found in cache'); -} - - -$testHelper->terminateTest(); diff --git a/tests/issues/Github-675.test.php b/tests/issues/Github-675.test.php deleted file mode 100644 index e571e9773..000000000 --- a/tests/issues/Github-675.test.php +++ /dev/null @@ -1,82 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -use Phpfastcache\CacheManager; -use Phpfastcache\Drivers\Memcached\Config; -use Phpfastcache\Exceptions\PhpfastcacheDriverException; -use Phpfastcache\Exceptions\PhpfastcacheInvalidConfigurationException; -use Phpfastcache\Tests\Helper\TestHelper; - -chdir(__DIR__); -require_once __DIR__ . '/../../vendor/autoload.php'; -$testHelper = new TestHelper('Github issue #675 - Memcached ignores custom host/port configurations'); - -try { - $config = new Config(); - $config->setServers([ - [ - 'invalidHostKey' => '120.0.13.37', - 'invalidPortKey' => 8080, - 'saslUser' => false, - 'saslPassword' => false, - ] - ]); - $testHelper->assertFail('1/4 Memcached config accepted unknown key(s) from $servers array.'); -} catch (PhpfastcacheInvalidConfigurationException $e) { - $testHelper->assertPass('1/4 Memcached config detected unknown key(s) from $servers array: ' . $e->getMessage()); -} - -try { - $config = new Config(); - $config->setServers([ - [ - 'host' => '120.0.13.37', - 'unwantedKey' => '120.0.13.37', - 'unwantedKey2' => '120.0.13.37', - 'port' => 8080, - 'saslUser' => false, - 'saslPassword' => false, - ] - ]); - $testHelper->assertFail('2/4 Memcached config accepted unwanted key(s) from $servers array.'); -} catch (PhpfastcacheInvalidConfigurationException $e) { - $testHelper->assertPass('2/4 Memcached config detected unwanted key(s) from $servers array: ' . $e->getMessage()); -} - -try { - $config = new Config(); - $config->setServers([ - [ - 'host' => '120.0.13.37', - 'port' => '8080', - 'saslUser' => false, - 'saslPassword' => false, - ] - ]); - $testHelper->assertFail('3/4 Memcached config does not detected invalid types fort host and port'); -} catch (PhpfastcacheInvalidConfigurationException $e) { - $testHelper->assertPass('3/4 Memcached config detected invalid types fort host and port: ' . $e->getMessage()); -} - -try { - $config = new Config(); - $config->setHost('255.255.255.255'); - $config->setPort(1337); - $cacheInstance = CacheManager::getInstance('Memcached', $config); - $testHelper->assertFail('4/4 Memcached succeeded to connect with invalid host/port specified (used default combination of "$config->servers")'); -} catch (PhpfastcacheDriverException $e) { - $testHelper->assertPass('4/4 Memcached failed to connect with invalid host/port specified'); -} - -$testHelper->terminateTest(); diff --git a/tests/issues/Github-853.test.php b/tests/issues/Github-853.test.php deleted file mode 100644 index bb9bdb20e..000000000 --- a/tests/issues/Github-853.test.php +++ /dev/null @@ -1,371 +0,0 @@ - https://www.phpfastcache.com - * @author Georges.L (Geolim4) - */ - -use Phpfastcache\CacheManager; -use Phpfastcache\Drivers\Memcached\Config as MemcachedConfig; -use Phpfastcache\Drivers\Memcache\Config as MemcacheConfig; -use Phpfastcache\Exceptions\PhpfastcacheDriverCheckException; -use Phpfastcache\Exceptions\PhpfastcacheInvalidConfigurationException; -use Phpfastcache\Tests\Helper\TestHelper; - -chdir(__DIR__); -require_once __DIR__ . '/../../vendor/autoload.php'; -$testHelper = new TestHelper('Github issue #675 - Configuration validation issue with Memcached socket (path)'); - -/** - * MEMCACHED ASSERTIONS - */ -$testHelper->printInfoText('Testing MEMCACHED configuration validation errors...'); -try { - new MemcachedConfig([ - 'servers' => [ - [ - 'host' => '', - 'path' => '', - ] - ] - ]); - $testHelper->assertFail('[MEMCACHED] An empty host and path did not thrown an exception'); -} catch (PhpfastcacheInvalidConfigurationException $e){ - $testHelper->assertPass('[MEMCACHED] An empty host and path thrown an exception: ' . $e->getMessage()); -} - -try { - new MemcachedConfig([ - 'servers' => [ - [ - 'host' => '127.0.0.1', - 'path' => 'a/nice/path', - 'port' => 11211, - ] - ] - ]); - $testHelper->assertFail('[MEMCACHED] Both path and host configured did not thrown an exception'); -} catch (PhpfastcacheInvalidConfigurationException $e){ - $testHelper->assertPass('[MEMCACHED] Both path and host configured thrown an exception: ' . $e->getMessage()); -} - -try { - new MemcachedConfig([ - 'servers' => [ - [ - 'host' => '', - 'path' => 'a/nice/path', - 'port' => 11211, - ] - ] - ]); - $testHelper->assertFail('[MEMCACHED] Both path and port configured did not thrown an exception'); -} catch (PhpfastcacheInvalidConfigurationException $e){ - $testHelper->assertPass('[MEMCACHED] Both path and port configured thrown an exception: ' . $e->getMessage()); -} - -try { - new MemcachedConfig([ - 'servers' => [ - [ - 'host' => '', - 'path' => true, - ] - ] - ]); - $testHelper->assertFail('[MEMCACHED] Invalid non-string path value not thrown an exception'); -} catch (PhpfastcacheInvalidConfigurationException $e){ - $testHelper->assertPass('[MEMCACHED] Invalid non-string path value thrown an exception: ' . $e->getMessage()); -} - -try { - new MemcachedConfig([ - 'servers' => [ - [ - 'host' => true, - 'path' => '', - ] - ] - ]); - $testHelper->assertFail('[MEMCACHED] Invalid non-string host value not thrown an exception'); -} catch (PhpfastcacheInvalidConfigurationException $e){ - $testHelper->assertPass('[MEMCACHED] Invalid non-string host value thrown an exception: ' . $e->getMessage()); -} - - -try { - new MemcachedConfig([ - 'servers' => [ - [ - 'host' => '127.0.0.1', - ] - ] - ]); - $testHelper->assertFail('[MEMCACHED] An host without port configured did not thrown an exception'); -} catch (PhpfastcacheInvalidConfigurationException $e){ - $testHelper->assertPass('[MEMCACHED] An host without port configured thrown an exception: ' . $e->getMessage()); -} - -try { - new MemcachedConfig([ - 'servers' => [ - [ - 'unknown_key_1' => '', - 'unknown_key_2' => true, - ] - ] - ]); - $testHelper->assertFail('[MEMCACHED] Unknowns keys configured did not thrown an exception'); -} catch (PhpfastcacheInvalidConfigurationException $e){ - $testHelper->assertPass('[MEMCACHED] Unknowns keys configured thrown an exception: ' . $e->getMessage()); -} - -try { - new MemcachedConfig([ - 'servers' => [ - [ - 'host' => '127.0.0.1', - 'path' => '', - 'port' => 11211, - 'saslUser' => true, - 'saslPassword' => [1337], - ] - ] - ]); - $testHelper->assertFail('[MEMCACHED] Both saslUser and saslPassword misconfigurations did not thrown an exception'); -} catch (PhpfastcacheInvalidConfigurationException $e){ - $testHelper->assertPass('[MEMCACHED] Both saslUser and saslPassword misconfigurations thrown an exception: ' . $e->getMessage()); -} - - -/** - * MEMCACHE ASSERTIONS - */ -$testHelper->printNewLine(); -$testHelper->printInfoText('Testing MEMCACHE configuration validation errors...'); -try { - new MemcacheConfig([ - 'servers' => [ - [ - 'host' => '', - 'path' => '', - ] - ] - ]); - $testHelper->assertFail('[MEMCACHE] An empty host and path did not thrown an exception'); -} catch (PhpfastcacheInvalidConfigurationException $e){ - $testHelper->assertPass('[MEMCACHE] An empty host and path thrown an exception: ' . $e->getMessage()); -} - -try { - new MemcacheConfig([ - 'servers' => [ - [ - 'host' => '127.0.0.1', - 'path' => 'a/nice/path', - 'port' => 11211, - ] - ] - ]); - $testHelper->assertFail('[MEMCACHE] Both path and host configured did not thrown an exception'); -} catch (PhpfastcacheInvalidConfigurationException $e){ - $testHelper->assertPass('[MEMCACHE] Both path and host configured thrown an exception: ' . $e->getMessage()); -} - -try { - new MemcacheConfig([ - 'servers' => [ - [ - 'host' => '', - 'path' => 'a/nice/path', - 'port' => 11211, - ] - ] - ]); - $testHelper->assertFail('[MEMCACHE] Both path and port configured did not thrown an exception'); -} catch (PhpfastcacheInvalidConfigurationException $e){ - $testHelper->assertPass('[MEMCACHE] Both path and port configured thrown an exception: ' . $e->getMessage()); -} - -try { - new MemcacheConfig([ - 'servers' => [ - [ - 'host' => '', - 'path' => true, - ] - ] - ]); - $testHelper->assertFail('[MEMCACHE] Invalid non-string path value not thrown an exception'); -} catch (PhpfastcacheInvalidConfigurationException $e){ - $testHelper->assertPass('[MEMCACHE] Invalid non-string path value thrown an exception: ' . $e->getMessage()); -} - -try { - new MemcacheConfig([ - 'servers' => [ - [ - 'host' => true, - 'path' => '', - ] - ] - ]); - $testHelper->assertFail('[MEMCACHE] Invalid non-string host value not thrown an exception'); -} catch (PhpfastcacheInvalidConfigurationException $e){ - $testHelper->assertPass('[MEMCACHE] Invalid non-string host value thrown an exception: ' . $e->getMessage()); -} - - -try { - new MemcacheConfig([ - 'servers' => [ - [ - 'host' => '127.0.0.1', - ] - ] - ]); - $testHelper->assertFail('[MEMCACHE] An host without port configured did not thrown an exception'); -} catch (PhpfastcacheInvalidConfigurationException $e){ - $testHelper->assertPass('[MEMCACHE] An host without port configured thrown an exception: ' . $e->getMessage()); -} - -try { - new MemcacheConfig([ - 'servers' => [ - [ - 'unknown_key_1' => '', - 'unknown_key_2' => true, - ] - ] - ]); - $testHelper->assertFail('[MEMCACHE] Unknowns keys configured did not thrown an exception'); -} catch (PhpfastcacheInvalidConfigurationException $e){ - $testHelper->assertPass('[MEMCACHE] Unknowns keys configured thrown an exception: ' . $e->getMessage()); -} - -try { - new MemcacheConfig([ - 'servers' => [ - [ - 'host' => '', - 'path' => 'a/nice/path', - 'port' => 11211, - 'saslUser' => 'lorem', - 'saslPassword' => 'ipsum', - ] - ] - ]); - $testHelper->assertFail('[MEMCACHE] Unsupported SASL configuration did not thrown an exception'); -} catch (PhpfastcacheInvalidConfigurationException $e){ - $testHelper->assertPass('[MEMCACHE] Unsupported SASL configuration thrown an exception: ' . $e->getMessage()); -} - -/** - * GOOD CONFIGURATIONS ASSERTIONS - */ -$testHelper->printNewLine(); -$testHelper->printInfoText('Testing valid configurations...'); -try { - new MemcacheConfig([ - 'servers' => [ - [ - 'host' => '', - 'path' => 'a/nice/path', - 'port' => null, - ] - ] - ]); - $testHelper->assertPass('[MEMCACHE] Valid Memcache socket configuration did not thrown an exception'); -} catch (PhpfastcacheInvalidConfigurationException $e){ - $testHelper->assertFail('[MEMCACHE] Valid Memcache socket configuration thrown an exception: ' . $e->getMessage()); -} - -try { - new MemcacheConfig([ - 'servers' => [ - [ - 'host' => '127.0.0.1', - 'path' => '', - 'port' => 11211, - ] - ] - ]); - $testHelper->assertPass('[MEMCACHE] Valid Memcache host configuration did not thrown an exception'); -} catch (PhpfastcacheInvalidConfigurationException $e){ - $testHelper->assertFail('[MEMCACHE] Valid Memcache host configuration thrown an exception: ' . $e->getMessage()); -} - -try { - new MemcachedConfig([ - 'servers' => [ - [ - 'host' => '', - 'path' => 'a/nice/path', - 'port' => null, - ] - ] - ]); - $testHelper->assertPass('[MEMCACHED] Valid Memcached socket configuration did not thrown an exception'); -} catch (PhpfastcacheInvalidConfigurationException $e){ - $testHelper->assertFail('[MEMCACHED] Valid Memcached socket configuration thrown an exception: ' . $e->getMessage()); -} - -try { - new MemcachedConfig([ - 'servers' => [ - [ - 'host' => '127.0.0.1', - 'path' => '', - 'port' => 11211, - ] - ] - ]); - $testHelper->assertPass('[MEMCACHED] Valid Memcached host configuration did not thrown an exception'); -} catch (PhpfastcacheInvalidConfigurationException $e){ - $testHelper->assertFail('[MEMCACHED] Valid Memcached host configuration thrown an exception: ' . $e->getMessage()); -} - -try { - new MemcachedConfig([ - 'servers' => [ - [ - 'host' => '127.0.0.1', - 'path' => '', - 'port' => 11211, - 'saslUser' => 'lorem', - 'saslPassword' => 'ipsum', - ] - ] - ]); - $testHelper->assertPass('[MEMCACHED] Valid Memcached host + SASL authentication configuration did not thrown an exception'); -} catch (PhpfastcacheInvalidConfigurationException $e){ - $testHelper->assertFail('[MEMCACHED] Valid Memcached host + SASL authentication configuration thrown an exception: ' . $e->getMessage()); -} - -/** - * BASIC CONFIGURATIONS ASSERTIONS - */ -$testHelper->printNewLine(); -$testHelper->printInfoText('Testing basic configurations...'); - -try { - CacheManager::getInstance('Memcached', new MemcachedConfig()); - $testHelper->assertPass('[MEMCACHED] Default configuration did not thrown an exception'); -} catch (PhpfastcacheInvalidConfigurationException $e){ - $testHelper->assertFail('[MEMCACHED] Default configuration thrown an exception: ' . $e->getMessage()); -} catch (PhpfastcacheDriverCheckException $e){ - // If the driver fails to initialize it is not an issue, the validation process has at least succeeded - $testHelper->assertPass('[MEMCACHED] Default configuration did not thrown an exception (with failed driver initialization)'); -} - -try { - CacheManager::getInstance('Memcache', new MemcacheConfig()); - $testHelper->assertPass('[MEMCACHE] Default configuration did not thrown an exception'); -} catch (PhpfastcacheInvalidConfigurationException $e){ - $testHelper->assertFail('[MEMCACHE] Default configuration thrown an exception: ' . $e->getMessage()); -} catch (PhpfastcacheDriverCheckException $e){ - // If the driver fails to initialize it is not an issue, the validation process has at least succeeded - $testHelper->assertPass('[MEMCACHE] Default configuration did not thrown an exception (with failed driver initialization)'); -} - -$testHelper->terminateTest(); diff --git a/tests/issues/Github-860.test.php b/tests/issues/Github-860.test.php deleted file mode 100644 index 6ff05159c..000000000 --- a/tests/issues/Github-860.test.php +++ /dev/null @@ -1,35 +0,0 @@ - https://www.phpfastcache.com - * @author Georges.L (Geolim4) - */ - -use Phpfastcache\CacheManager; -use Phpfastcache\Drivers\Files\Config as FilesConfig; -use Phpfastcache\Tests\Helper\TestHelper; - -chdir(__DIR__); -require_once __DIR__ . '/../../vendor/autoload.php'; -$testHelper = new TestHelper('Github issue #860 - Cache item throw an error on reading with DateTimeImmutable date objects'); - -$config = new FilesConfig(); -$testHelper->preConfigure($config); -$cacheInstance = CacheManager::getInstance('Files', $config); -$cacheInstance->clear(); - -try { - $key = 'pfc_' . bin2hex(random_bytes(12)); - $item = $cacheInstance->getItem($key); - $item->set(random_int(1000, 999999)) - ->setExpirationDate(new DateTimeImmutable('+1 month')) - ->setCreationDate(new DateTimeImmutable()) - ->setModificationDate(new DateTimeImmutable('+1 week')); - $cacheInstance->save($item); - $cacheInstance->detachAllItems(); - $item = $cacheInstance->getItem($key); - $testHelper->assertPass('Github issue #860 have not regressed.'); -} catch (\TypeError $e) { - $testHelper->assertFail('Github issue #860 have regressed, exception caught: ' . $e->getMessage()); -} - diff --git a/tests/issues/Github-893.test.php b/tests/issues/Github-893.test.php deleted file mode 100644 index f4b8bcb2f..000000000 --- a/tests/issues/Github-893.test.php +++ /dev/null @@ -1,57 +0,0 @@ - https://www.phpfastcache.com - * @author Georges.L (Geolim4) - */ - -use Phpfastcache\CacheManager; -use Phpfastcache\Drivers\Files\Config as FilesConfig; -use Phpfastcache\Tests\Helper\TestHelper; - -chdir(__DIR__); -require_once __DIR__ . '/../../vendor/autoload.php'; -$testHelper = new TestHelper('Github issue #893 - getItemsByTag() - empty after one item has expired'); - -$config = new FilesConfig(); -$testHelper->preConfigure($config); -$cacheInstance = CacheManager::getInstance('Files', $config); -$cacheInstance->clear(); - -$testHelper->printInfoText('Creating cache item "key_1" & "key_2"...'); - -$CachedString1 = $cacheInstance->getItem("key_1"); -if (is_null($CachedString1->get())) { - $CachedString1->set("data1")->expiresAfter(10); - $CachedString1->addTag("query"); - $cacheInstance->save($CachedString1); -} - - -$CachedString2 = $cacheInstance->getItem("key_2"); -if (is_null($CachedString2->get())) { - $CachedString2->set("data2")->expiresAfter(5); - $CachedString2->addTag("query"); - $cacheInstance->save($CachedString2); -} - -$CachedString3 = $cacheInstance->getItem("key_3"); -if (is_null($CachedString3->get())) { - $CachedString3->set("data3")->expiresAfter(4); - $CachedString3->addTag("query"); - $cacheInstance->save($CachedString3); -} - -$cacheInstance->detachAllItems(); -$testHelper->printInfoText('Items created and saved, sleeping 6 secondes to force "key_1" to expire'); -sleep(6); - -$cacheItems = $cacheInstance->getItemsByTag("query"); - -if(count($cacheItems) === 1 && isset($cacheItems['key_1']) && $cacheItems['key_1']->get() === 'data1') { - $testHelper->assertPass('getItemsByTag() has returned only cache item "key_1"'); -} else { - $testHelper->assertFail(sprintf('getItemsByTag() returned unknown results: %d item(s)...', \count($cacheItems))); -} - -$testHelper->terminateTest(); diff --git a/tests/lexer/LexerCheck.test.php b/tests/lexer/LexerCheck.test.php deleted file mode 100644 index a27fb615d..000000000 --- a/tests/lexer/LexerCheck.test.php +++ /dev/null @@ -1,60 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -$pfcReadDir = static function ($dir, $ext = null) use (&$pfcReadDir) { - $list = [[]]; - $dir .= '/'; - if (($res = opendir($dir)) === false) { - exit(1); - } - while (($name = readdir($res)) !== false) { - if ($name === '.' || $name === '..') { - continue; - } - $name = $dir . $name; - if (is_dir($name)) { - $list[] = $pfcReadDir($name, $ext); - } elseif (is_file($name)) { - if (!is_null($ext) && substr(strrchr($name, '.'), 1) !== $ext) { - continue; - } - $list[] = [$name]; - } - } - - return array_merge(...$list); -}; - -$list = $pfcReadDir('./lib', 'php'); - -foreach (array_map('realpath', $list) as $file) { - $output = ''; - \exec(($testHelper->isHHVM() ? 'hhvm' : 'php') . ' -l "' . $file . '"', $output, $status); - - $output = trim(implode("\n", $output)); - - if ($status !== 0) { - $testHelper->assertFail($output ?: "Syntax error found in {$file}"); - } else { - $testHelper->assertPass($output ?: "No syntax errors detected in {$file}"); - } -} -$testHelper->terminateTest(); diff --git a/tests/mock/Autoload.php b/tests/mock/Autoload.php deleted file mode 100644 index adb25f1f8..000000000 --- a/tests/mock/Autoload.php +++ /dev/null @@ -1,36 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -/** - * Register Mock Autoload - */ -\spl_autoload_register(function ($entity) { - $module = \explode('\\', $entity, 2); - if ($module[ 0 ] !== 'Phpfastcache') { - /** - * Not a part of phpFastCache file - * then we return here. - */ - return; - } - - $entity = \str_replace('\\', '/', $entity); - $path = __DIR__ . DIRECTORY_SEPARATOR . $entity . '.php'; - - if (\is_readable($path)) { - require_once $path; - } -}); diff --git a/tests/mock/Phpfastcache/DriverTest/Files2/Config.php b/tests/mock/Phpfastcache/DriverTest/Files2/Config.php deleted file mode 100644 index 096a58362..000000000 --- a/tests/mock/Phpfastcache/DriverTest/Files2/Config.php +++ /dev/null @@ -1,46 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -namespace Phpfastcache\DriverTest\Files2; - -use Phpfastcache\Drivers\Files\Config as FilesConfig; - -/** - * Class Config - * @package Phpfastcache\DriverTest\Files2 - */ -class Config extends FilesConfig -{ - /** - * @var bool - */ - protected $customOption = true; - - /** - * @return bool - */ - public function isCustomOption(): bool - { - return $this->customOption; - } - - /** - * @param bool $customOption - * @return Config - */ - public function setCustomOption(bool $customOption): Config - { - $this->customOption = $customOption; - return $this; - } -} diff --git a/tests/mock/Phpfastcache/DriverTest/Files2/Driver.php b/tests/mock/Phpfastcache/DriverTest/Files2/Driver.php deleted file mode 100644 index df9eb9320..000000000 --- a/tests/mock/Phpfastcache/DriverTest/Files2/Driver.php +++ /dev/null @@ -1,25 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -namespace Phpfastcache\DriverTest\Files2; - -use Phpfastcache\Drivers\Files\Driver as FilesDriver; - -/** - * Class Driver - * @package Phpfastcache\DriverTest\Files2 - */ -class Driver extends FilesDriver -{ - -} diff --git a/tests/mock/Phpfastcache/DriverTest/Files2/Item.php b/tests/mock/Phpfastcache/DriverTest/Files2/Item.php deleted file mode 100644 index 928a83d1e..000000000 --- a/tests/mock/Phpfastcache/DriverTest/Files2/Item.php +++ /dev/null @@ -1,25 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -namespace Phpfastcache\DriverTest\Files2; - -use Phpfastcache\Drivers\Files\Item as FilesItem; - -/** - * Class Item - * @package Phpfastcache\DriverTest\Files2 - */ -class Item extends FilesItem -{ - -} diff --git a/tests/mock/Phpfastcache/Drivers/Failfiles/Config.php b/tests/mock/Phpfastcache/Drivers/Failfiles/Config.php deleted file mode 100644 index 81e7a00f0..000000000 --- a/tests/mock/Phpfastcache/Drivers/Failfiles/Config.php +++ /dev/null @@ -1,46 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -namespace Phpfastcache\Drivers\Failfiles; - -use Phpfastcache\Drivers\Files\Config as FilesConfig; - -/** - * Class Config - * @package Phpfastcache\Drivers\Files2 - */ -class Config extends FilesConfig -{ - /** - * @var bool - */ - protected $customOption = true; - - /** - * @return bool - */ - public function isCustomOption(): bool - { - return $this->customOption; - } - - /** - * @param bool $customOption - * @return Config - */ - public function setCustomOption(bool $customOption): Config - { - $this->customOption = $customOption; - return $this; - } -} diff --git a/tests/mock/Phpfastcache/Drivers/Failfiles/Driver.php b/tests/mock/Phpfastcache/Drivers/Failfiles/Driver.php deleted file mode 100644 index 02f60c190..000000000 --- a/tests/mock/Phpfastcache/Drivers/Failfiles/Driver.php +++ /dev/null @@ -1,66 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -namespace Phpfastcache\Drivers\Failfiles; - -use Phpfastcache\Core\Item\ExtendedCacheItemInterface; -use Phpfastcache\Drivers\Files\Driver as FilesDriver; -use Phpfastcache\Exceptions\PhpfastcacheDriverException; -use Psr\Cache\CacheItemInterface; -use Random\RandomException; - -/** - * Class Driver - * @package Phpfastcache\Drivers\Files2 - */ -class Driver extends FilesDriver -{ - /** - * @return bool - * @throws PhpfastcacheDriverException - */ - protected function driverRead(ExtendedCacheItemInterface $item): ?array - { - throw new PhpfastcacheDriverException('Error code found: ' . \bin2hex(\random_bytes(8))); - } - - /** - * @return bool - * @throws PhpfastcacheDriverException - */ - protected function driverWrite(ExtendedCacheItemInterface $item): bool - { - throw new PhpfastcacheDriverException('Error code found: ' . \bin2hex(\random_bytes(8))); - } - - /** - * @param string $key - * @param string $encodedKey - * @return bool - * @throws PhpfastcacheDriverException - * @throws RandomException - */ - protected function driverDelete(string $key, string $encodedKey): bool - { - throw new PhpfastcacheDriverException('Error code found: ' . \bin2hex(\random_bytes(8))); - } - - /** - * @return bool - * @throws PhpfastcacheDriverException - */ - protected function driverClear(): bool - { - throw new PhpfastcacheDriverException('Error code found: ' . \bin2hex(\random_bytes(8))); - } -} diff --git a/tests/mock/Phpfastcache/Drivers/Failfiles/Item.php b/tests/mock/Phpfastcache/Drivers/Failfiles/Item.php deleted file mode 100644 index 51ac3d243..000000000 --- a/tests/mock/Phpfastcache/Drivers/Failfiles/Item.php +++ /dev/null @@ -1,25 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -namespace Phpfastcache\Drivers\Failfiles; - -use Phpfastcache\Drivers\Files\Item as FilesItem; - -/** - * Class Item - * @package Phpfastcache\Drivers\Files2 - */ -class Item extends FilesItem -{ - -} diff --git a/tests/mock/Phpfastcache/Drivers/Fakefiles/Config.php b/tests/mock/Phpfastcache/Drivers/Fakefiles/Config.php deleted file mode 100644 index a329e14ea..000000000 --- a/tests/mock/Phpfastcache/Drivers/Fakefiles/Config.php +++ /dev/null @@ -1,46 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -namespace Phpfastcache\Drivers\Fakefiles; - -use Phpfastcache\Drivers\Files\Config as FilesConfig; - -/** - * Class Config - * @package Phpfastcache\Drivers\Files2 - */ -class Config extends FilesConfig -{ - /** - * @var bool - */ - protected $customOption = true; - - /** - * @return bool - */ - public function isCustomOption(): bool - { - return $this->customOption; - } - - /** - * @param bool $customOption - * @return Config - */ - public function setCustomOption(bool $customOption): Config - { - $this->customOption = $customOption; - return $this; - } -} diff --git a/tests/mock/Phpfastcache/Drivers/Fakefiles/Driver.php b/tests/mock/Phpfastcache/Drivers/Fakefiles/Driver.php deleted file mode 100644 index 6f15af7fc..000000000 --- a/tests/mock/Phpfastcache/Drivers/Fakefiles/Driver.php +++ /dev/null @@ -1,31 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -namespace Phpfastcache\Drivers\Fakefiles; - -use Phpfastcache\Drivers\Files\Driver as FilesDriver; - -/** - * Class Driver - * @package Phpfastcache\Drivers\Files2 - */ -class Driver extends FilesDriver -{ - /** - * @return bool - */ - public function driverCheck(): bool - { - return false; - } -} diff --git a/tests/mock/Phpfastcache/Drivers/Fakefiles/Item.php b/tests/mock/Phpfastcache/Drivers/Fakefiles/Item.php deleted file mode 100644 index 4baf7da53..000000000 --- a/tests/mock/Phpfastcache/Drivers/Fakefiles/Item.php +++ /dev/null @@ -1,25 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -namespace Phpfastcache\Drivers\Fakefiles; - -use Phpfastcache\Drivers\Files\Item as FilesItem; - -/** - * Class Item - * @package Phpfastcache\Drivers\Files2 - */ -class Item extends FilesItem -{ - -} diff --git a/tests/mock/Phpfastcache/Extensions/Drivers/Extensiontest/Config.php b/tests/mock/Phpfastcache/Extensions/Drivers/Extensiontest/Config.php deleted file mode 100644 index 1afb9bc12..000000000 --- a/tests/mock/Phpfastcache/Extensions/Drivers/Extensiontest/Config.php +++ /dev/null @@ -1,42 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -namespace Phpfastcache\Extensions\Drivers\Extensiontest; - -use Phpfastcache\Drivers\Files\Config as FilesConfig; - -class Config extends FilesConfig -{ - /** - * @var bool - */ - protected bool $customOption = true; - - /** - * @return bool - */ - public function isCustomOption(): bool - { - return $this->customOption; - } - - /** - * @param bool $customOption - * @return Config - */ - public function setCustomOption(bool $customOption): Config - { - $this->customOption = $customOption; - return $this; - } -} diff --git a/tests/mock/Phpfastcache/Extensions/Drivers/Extensiontest/Driver.php b/tests/mock/Phpfastcache/Extensions/Drivers/Extensiontest/Driver.php deleted file mode 100644 index 0e9647820..000000000 --- a/tests/mock/Phpfastcache/Extensions/Drivers/Extensiontest/Driver.php +++ /dev/null @@ -1,21 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -namespace Phpfastcache\Extensions\Drivers\Extensiontest; - -use Phpfastcache\Drivers\Files\Driver as FilesDriver; - -class Driver extends FilesDriver -{ - -} diff --git a/tests/mock/Phpfastcache/Extensions/Drivers/Extensiontest/Item.php b/tests/mock/Phpfastcache/Extensions/Drivers/Extensiontest/Item.php deleted file mode 100644 index 3ea8ad051..000000000 --- a/tests/mock/Phpfastcache/Extensions/Drivers/Extensiontest/Item.php +++ /dev/null @@ -1,22 +0,0 @@ - - * @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors - */ - -namespace Phpfastcache\Extensions\Drivers\Extensiontest; - -use Phpfastcache\Drivers\Files\Item as FilesItem; - - -class Item extends FilesItem -{ - -}