Repository: laravel/tinker Branch: 2.x Commit: eaa762692fda Files: 33 Total size: 41.7 KB Directory structure: gitextract_67snpc5q/ ├── .editorconfig ├── .gitattributes ├── .github/ │ ├── CODE_OF_CONDUCT.md │ ├── CONTRIBUTING.md │ ├── ISSUE_TEMPLATE/ │ │ ├── 1_Bug_report.yml │ │ └── config.yml │ ├── PULL_REQUEST_TEMPLATE.md │ ├── SECURITY.md │ ├── SUPPORT.md │ └── workflows/ │ ├── issues.yml │ ├── pull-requests.yml │ ├── static-analysis.yml │ ├── tests.yml │ └── update-changelog.yml ├── .gitignore ├── .styleci.yml ├── CHANGELOG.md ├── LICENSE.md ├── README.md ├── composer.json ├── config/ │ └── tinker.php ├── phpstan.neon.dist ├── phpunit.xml.dist ├── src/ │ ├── ClassAliasAutoloader.php │ ├── Console/ │ │ └── TinkerCommand.php │ ├── TinkerCaster.php │ └── TinkerServiceProvider.php └── tests/ ├── ClassAliasAutoloaderTest.php ├── TinkerCasterTest.php └── fixtures/ ├── app/ │ ├── Baz/ │ │ └── Qux.php │ └── Foo/ │ └── Bar.php └── vendor/ ├── composer/ │ └── autoload_classmap.php └── one/ └── two/ └── Three.php ================================================ FILE CONTENTS ================================================ ================================================ FILE: .editorconfig ================================================ root = true [*] charset = utf-8 end_of_line = lf insert_final_newline = true indent_style = space indent_size = 4 trim_trailing_whitespace = true [*.md] trim_trailing_whitespace = false [*.{yml,yaml}] indent_size = 2 ================================================ FILE: .gitattributes ================================================ * text=auto *.blade.php diff=html *.css diff=css *.html diff=html *.md diff=markdown *.php diff=php /.github export-ignore /art export-ignore /tests export-ignore .editorconfig export-ignore .gitattributes export-ignore .gitignore export-ignore .styleci.yml export-ignore CHANGELOG.md export-ignore phpstan.neon.dist export-ignore phpunit.xml.dist export-ignore ================================================ FILE: .github/CODE_OF_CONDUCT.md ================================================ # Code of Conduct The Laravel Code of Conduct can be found in the [Laravel documentation](https://laravel.com/docs/contributions#code-of-conduct). ================================================ FILE: .github/CONTRIBUTING.md ================================================ # Contribution Guide The Laravel contributing guide can be found in the [Laravel documentation](https://laravel.com/docs/contributions). ================================================ FILE: .github/ISSUE_TEMPLATE/1_Bug_report.yml ================================================ name: Bug Report description: "Report something that's broken." body: - type: markdown attributes: value: "Please read [our full contribution guide](https://laravel.com/docs/contributions#bug-reports) before submitting bug reports. If you notice improper DocBlock, PHPStan, or IDE warnings while using Laravel, do not create a GitHub issue. Instead, please submit a pull request to fix the problem." - type: input attributes: label: Tinker Version description: Provide the Tinker version that you are using. placeholder: 1.6.1 validations: required: true - type: input attributes: label: Laravel Version description: Provide the Laravel version that you are using. [Please ensure it is still supported.](https://laravel.com/docs/releases#support-policy) placeholder: 10.4.1 validations: required: true - type: input attributes: label: PHP Version description: Provide the PHP version that you are using. placeholder: 8.1.4 validations: required: true - type: input attributes: label: Database Driver & Version description: If applicable, provide the database driver and version you are using. placeholder: "MySQL 8.0.31 for macOS 13.0 on arm64 (Homebrew)" validations: required: false - type: textarea attributes: label: Description description: Provide a detailed description of the issue you are facing. validations: required: true - type: textarea attributes: label: Steps To Reproduce description: Provide detailed steps to reproduce your issue. If necessary, please provide a GitHub repository to demonstrate your issue using `laravel new bug-report --github="--public"`. validations: required: true ================================================ FILE: .github/ISSUE_TEMPLATE/config.yml ================================================ blank_issues_enabled: false contact_links: - name: Feature request url: https://github.com/laravel/tinker/pulls about: 'For ideas or feature requests, send in a pull request' - name: Support Questions & Other url: https://laravel.com/docs/contributions#support-questions about: 'This repository is only for reporting bugs. If you have a question or need help using the library, click:' - name: Documentation issue url: https://github.com/laravel/docs about: For documentation issues, open a pull request at the laravel/docs repository ================================================ FILE: .github/PULL_REQUEST_TEMPLATE.md ================================================ ================================================ FILE: .github/SECURITY.md ================================================ # Security Policy **PLEASE DON'T DISCLOSE SECURITY-RELATED ISSUES PUBLICLY, [SEE BELOW](#reporting-a-vulnerability).** ## Supported Versions Only the latest major version receives security fixes. ## Reporting a Vulnerability If you discover a security vulnerability within Laravel, please send an email to Taylor Otwell at taylor@laravel.com. All security vulnerabilities will be promptly addressed. ### Public PGP Key ``` -----BEGIN PGP PUBLIC KEY BLOCK----- Version: OpenPGP v2.0.8 Comment: Report Security Vulnerabilities to taylor@laravel.com xsFNBFugFSQBEACxEKhIY9IoJzcouVTIYKJfWFGvwFgbRjQWBiH3QdHId5vCrbWo s2l+4Rv03gMG+yHLJ3rWElnNdRaNdQv59+lShrZF7Bvu7Zvc0mMNmFOM/mQ/K2Lt OK/8bh6iwNNbEuyOhNQlarEy/w8hF8Yf55hBeu/rajGtcyURJDloQ/vNzcx4RWGK G3CLr8ka7zPYIjIFUvHLt27mcYFF9F4/G7b4HKpn75ICKC4vPoQSaYNAHlHQBLFb Jg/WPl93SySHLugU5F58sICs+fBZadXYQG5dWmbaF5OWB1K2XgRs45BQaBzf/8oS qq0scN8wVhAdBeYlVFf0ImDOxGlZ2suLK1BKJboR6zCIkBAwufKss4NV1R9KSUMv YGn3mq13PGme0QoIkvQkua5VjTwWfQx7wFDxZ3VQSsjIlbVyRL/Ac/hq71eAmiIR t6ZMNMPFpuSwBfYimrXqqb4EOffrfsTzRenG1Cxm4jNZRzX/6P4an7F/euoqXeXZ h37TiC7df+eHKcBI4mL+qOW4ibBqg8WwWPJ+jvuhANyQpRVzf3NNEOwJYCNbQPM/ PbqYvMruAH+gg7uyu9u0jX3o/yLSxJMV7kF4x/SCDuBKIxSSUI4cgbjIlnxWLXZC wl7KW4xAKkerO3wgIPnxNfxQoiYiEKA1c3PShWRA0wHIMt3rVRJxwGM4CwARAQAB zRJ0YXlsb3JAbGFyYXZlbC5jb23CwXAEEwEKABoFAlugFSQCGy8DCwkHAxUKCAIe AQIXgAIZAQAKCRDKAI7r/Ml7Zo0SD/9zwu9K87rbqXbvZ3TVu7TnN+z7mPvVBzl+ SFEK360TYq8a4GosghZuGm4aNEyZ90CeUjPQwc5fHwa26tIwqgLRppsG21B/mZwu 0m8c5RaBFRFX/mCTEjlpvBkOwMJZ8f05nNdaktq6W98DbMN03neUwnpWlNSL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qgqBKlcpf1wD5X9qCrl9vq19asVOHaKhiFZGxZIVbBpBOdvAKaMj4p/uln yklN3YFIfgmGPYbL0elvXVn7XfvwSV1mCQV5LtMbLHsFf0VsA16UsG8A/tLWtwgt 0antzftRHXb+DI4qr+qEYKFkv9F3oCOXyH4QBhPA42EzKqhMXByEkEK9bu6skioL mHhDQ7yHjTWcxstqQjkUQ0T/IF9ls+Sm5u7rVXEifpyI7MCb+76kSCDawesvInKt WBGOG/qJGDlNiqBYYt2xNqzHCJoC =zXOv -----END PGP PUBLIC KEY BLOCK----- ``` ================================================ FILE: .github/SUPPORT.md ================================================ # Support Questions The Laravel support guide can be found in the [Laravel documentation](https://laravel.com/docs/contributions#support-questions). ================================================ FILE: .github/workflows/issues.yml ================================================ name: issues on: issues: types: [labeled] permissions: issues: write jobs: help-wanted: uses: laravel/.github/.github/workflows/issues.yml@main ================================================ FILE: .github/workflows/pull-requests.yml ================================================ name: pull requests on: pull_request_target: types: [opened] permissions: pull-requests: write jobs: uneditable: uses: laravel/.github/.github/workflows/pull-requests.yml@main ================================================ FILE: .github/workflows/static-analysis.yml ================================================ name: static analysis on: push: branches: - master - '*.x' pull_request: permissions: contents: read jobs: tests: uses: laravel/.github/.github/workflows/static-analysis.yml@main ================================================ FILE: .github/workflows/tests.yml ================================================ name: tests on: push: branches: - master - '*.x' pull_request: schedule: - cron: '0 0 * * *' jobs: tests: runs-on: ubuntu-22.04 strategy: fail-fast: true matrix: php: [7.2, 7.3, 7.4, '8.0', 8.1, 8.2, 8.3] laravel: [6, 7, 8, 9, 10, 11, 12] include: - php: 8.4 laravel: 11 - php: 8.4 laravel: 12 - php: 8.5 laravel: 12 exclude: - php: 7.2 laravel: 8 - php: 7.2 laravel: 9 - php: 7.2 laravel: 10 - php: 7.2 laravel: 11 - php: 7.2 laravel: 12 - php: 7.3 laravel: 9 - php: 7.3 laravel: 10 - php: 7.3 laravel: 11 - php: 7.3 laravel: 12 - php: 7.4 laravel: 9 - php: 7.4 laravel: 10 - php: 7.4 laravel: 11 - php: 7.4 laravel: 12 - php: '8.0' laravel: 10 - php: '8.0' laravel: 11 - php: '8.0' laravel: 12 - php: 8.1 laravel: 6 - php: 8.1 laravel: 7 - php: 8.1 laravel: 11 - php: 8.1 laravel: 12 - php: 8.2 laravel: 6 - php: 8.2 laravel: 7 - php: 8.2 laravel: 8 - php: 8.3 laravel: 6 - php: 8.3 laravel: 7 - php: 8.3 laravel: 8 - php: 8.3 laravel: 9 name: PHP ${{ matrix.php }} - Laravel ${{ matrix.laravel }} steps: - name: Checkout code uses: actions/checkout@v4 - name: Setup PHP uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php }} extensions: dom, curl, libxml, mbstring, zip ini-values: error_reporting=E_ALL tools: composer:v2 coverage: none - name: Install dependencies run: | composer update --prefer-dist --no-interaction --no-progress --with="illuminate/contracts=^${{ matrix.laravel }}" - name: Execute tests run: vendor/bin/phpunit ================================================ FILE: .github/workflows/update-changelog.yml ================================================ name: update changelog on: release: types: [released] permissions: {} jobs: update: permissions: contents: write uses: laravel/.github/.github/workflows/update-changelog.yml@main ================================================ FILE: .gitignore ================================================ /vendor composer.lock /phpunit.xml .phpunit.result.cache ================================================ FILE: .styleci.yml ================================================ php: preset: laravel js: true css: true ================================================ FILE: CHANGELOG.md ================================================ # Release Notes ## [Unreleased](https://github.com/laravel/tinker/compare/v2.11.1...2.x) ## [v2.11.1](https://github.com/laravel/tinker/compare/v2.11.0...v2.11.1) - 2026-02-06 * Avoid trust project prompts from PsySH by [@WendellAdriel](https://github.com/WendellAdriel) in https://github.com/laravel/tinker/pull/198 ## [v2.11.0](https://github.com/laravel/tinker/compare/v2.10.2...v2.11.0) - 2025-12-19 * perf: optimize ClassAliasAutoloader using contains() by [@Ayoub-Mabrouk](https://github.com/Ayoub-Mabrouk) in https://github.com/laravel/tinker/pull/194 * Allow Symfony v8 by [@jnoordsij](https://github.com/jnoordsij) in https://github.com/laravel/tinker/pull/195 ## [v2.10.2](https://github.com/laravel/tinker/compare/v2.10.1...v2.10.2) - 2025-11-20 * [2.x] PHP 8.5 Compatibility by [@crynobone](https://github.com/crynobone) in https://github.com/laravel/tinker/pull/192 ## [v2.10.1](https://github.com/laravel/tinker/compare/v2.10.0...v2.10.1) - 2025-01-27 * Update logo to support dark/light theme by [@milewski](https://github.com/milewski) in https://github.com/laravel/tinker/pull/183 * [2.x] Supports Laravel 12 by [@crynobone](https://github.com/crynobone) in https://github.com/laravel/tinker/pull/185 ## [v2.10.0](https://github.com/laravel/tinker/compare/v2.9.0...v2.10.0) - 2024-09-23 * Use actions/checkout[@v4](https://github.com/v4) by [@Jubeki](https://github.com/Jubeki) in https://github.com/laravel/tinker/pull/172 * Use new static analysis workflow by [@Jubeki](https://github.com/Jubeki) in https://github.com/laravel/tinker/pull/173 * Replace dead link in Security Policy by [@Jubeki](https://github.com/Jubeki) in https://github.com/laravel/tinker/pull/180 * [2.x] Supports PHP 8.4 by [@crynobone](https://github.com/crynobone) in https://github.com/laravel/tinker/pull/182 ## [v2.9.0](https://github.com/laravel/tinker/compare/v2.8.2...v2.9.0) - 2024-01-04 * Update PsySH dependency to v0.12 by [@bobthecow](https://github.com/bobthecow) in https://github.com/laravel/tinker/pull/170 * [2.x] Merging develop by [@nunomaduro](https://github.com/nunomaduro) in https://github.com/laravel/tinker/pull/171 ## [v2.8.2](https://github.com/laravel/tinker/compare/v2.8.1...v2.8.2) - 2023-08-15 - [2.x] Adds type checking by [@nunomaduro](https://github.com/nunomaduro) in https://github.com/laravel/tinker/pull/160 - [2.x] Remove unused `orchestra/testbench` deps by [@crynobone](https://github.com/crynobone) in https://github.com/laravel/tinker/pull/166 ## [v2.8.1](https://github.com/laravel/tinker/compare/v2.8.0...v2.8.1) - 2023-02-15 - Cast ProcessResult objects by @mpociot in https://github.com/laravel/tinker/pull/159 ## [v2.8.0](https://github.com/laravel/tinker/compare/v2.7.3...v2.8.0) - 2023-01-10 ### Added - Laravel v10 support ## [v2.7.3](https://github.com/laravel/tinker/compare/v2.7.2...v2.7.3) - 2022-11-09 ### Changed - Set raw output when using `--execute` by @innocenzi in https://github.com/laravel/tinker/pull/155 ## [v2.7.2](https://github.com/laravel/tinker/compare/v2.7.1...v2.7.2) - 2022-03-23 ### Fixed - Add Laravel app instance to command by @driesvints in https://github.com/laravel/tinker/pull/146 ## [v2.7.1](https://github.com/laravel/tinker/compare/v2.7.0...v2.7.1) - 2022-03-15 ### Fixed - Fix command resolving by @driesvints in https://github.com/laravel/tinker/pull/144 and https://github.com/laravel/tinker/commit/1e2d500585a4e546346fadd3adc6f9c1a97e15f4 ## [v2.7.0 (2022-01-12)](https://github.com/laravel/tinker/compare/v2.6.3...v2.7.0) ### Changed - Laravel 9 and psych v0.11.x support ([#139](https://github.com/laravel/tinker/pull/139)) ## [v2.6.3 (2021-12-07)](https://github.com/laravel/tinker/compare/v2.6.2...v2.6.3) ### Changed - Add `migrate:install` to whitelisted commands ([#137](https://github.com/laravel/tinker/pull/137)) ## [v2.6.2 (2021-09-28)](https://github.com/laravel/tinker/compare/v2.6.1...v2.6.2) ### Added - Added custom caster support ([#133](https://github.com/laravel/tinker/pull/133)) ## [v2.6.1 (2021-03-02)](https://github.com/laravel/tinker/compare/v2.6.0...v2.6.1) ### Fixed - Display hidden/appended attributes for models ([#123](https://github.com/laravel/tinker/pull/123)) ## [v2.6.0 (2021-01-26)](https://github.com/laravel/tinker/compare/v2.5.0...v2.6.0) ### Added - Add Stringable caster ([#121](https://github.com/laravel/tinker/pull/121)) ## [v2.5.0 (2020-10-29)](https://github.com/laravel/tinker/compare/v2.4.2...v2.5.0) ### Added - PHP 8 Support ([#116](https://github.com/laravel/tinker/pull/116)) ## [v2.4.2 (2020-08-11)](https://github.com/laravel/tinker/compare/v2.4.1...v2.4.2) ### Fixed - Fix missing output while using execute option ([#109](https://github.com/laravel/tinker/pull/109)) ## [v2.4.1 (2020-07-07)](https://github.com/laravel/tinker/compare/v2.4.0...v2.4.1) ### Fixed - Fixed execute not unregistering loader and exit code ([#100](https://github.com/laravel/tinker/pull/100)) ## [v2.4.0 (2020-04-07)](https://github.com/laravel/tinker/compare/v2.3.0...v2.4.0) ### Changed - Forward input options to psysh ([#98](https://github.com/laravel/tinker/pull/98)) ## [v2.3.0 (2020-03-17)](https://github.com/laravel/tinker/compare/v2.2.0...v2.3.0) ### Added - Allow Laravel 8 ([#90](https://github.com/laravel/tinker/pull/90)) - Allow psy/psysh 0.10 ([#95](https://github.com/laravel/tinker/pull/95)) ## [v2.2.0 (2020-02-05)](https://github.com/laravel/tinker/compare/v2.1.0...v2.2.0) ### Added - Support vendor class aliasing ([#88](https://github.com/laravel/tinker/pull/88)) - Add `--execute` option to console command ([#89](https://github.com/laravel/tinker/pull/89)) ## [v2.1.0 (2020-01-14)](https://github.com/laravel/tinker/compare/v2.0.0...v2.1.0) ### Added - Add `HtmlString` caster ([#87](https://github.com/laravel/tinker/pull/87)) ## [v2.0.0 (2019-11-26)](https://github.com/laravel/tinker/compare/v1.0.10...v2.0.0) ### Added - Allow Laravel 7 ([#74](https://github.com/laravel/tinker/pull/74)) ### Changed - Require PHP 7.2 as the new minimum version ([8d6104c](https://github.com/laravel/tinker/commit/8d6104cf50695e3f256d0389626c692e144d946b)) - Allow Symfony 5 ([49982fd](https://github.com/laravel/tinker/commit/49982fd563035025998efe7f32d005bc6da2ce0a)) - Laravel now only check for `DeferrableProvider` ([#81](https://github.com/laravel/tinker/pull/81)) ### Removed - Drop support for old Psysh versions ([a05922f](https://github.com/laravel/tinker/commit/a05922fa3b959d92efd16defe8e30a9895a69727)) - Drop Symfony 3.x support ([7175b49](https://github.com/laravel/tinker/commit/7175b4931917d507989cda2c753113f71aa18816)) - Drop support for Laravel 5.x ([4f3e609](https://github.com/laravel/tinker/commit/4f3e6098dff7ec4c0eedc5348184838598bc30c8)) ## v1.0.0 (2016-12-30) Initial commit. ================================================ FILE: LICENSE.md ================================================ The MIT License (MIT) Copyright (c) Taylor Otwell 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. ================================================ FILE: README.md ================================================

Logo Laravel Tinker

Build Status Total Downloads Latest Stable Version License

## Introduction Laravel Tinker is a powerful REPL for the Laravel framework. ## Official Documentation Documentation for Tinker can be found on the [Laravel website](https://laravel.com/docs/artisan#tinker). ## Contributing Thank you for considering contributing to Tinker! The contribution guide can be found in the [Laravel documentation](https://laravel.com/docs/contributions). ## Code of Conduct In order to ensure that the Laravel community is welcoming to all, please review and abide by the [Code of Conduct](https://laravel.com/docs/contributions#code-of-conduct). ## Security Vulnerabilities Please review [our security policy](https://github.com/laravel/tinker/security/policy) on how to report security vulnerabilities. ## License Laravel Tinker is open-sourced software licensed under the [MIT license](LICENSE.md). ================================================ FILE: composer.json ================================================ { "name": "laravel/tinker", "description": "Powerful REPL for the Laravel framework.", "keywords": ["tinker", "repl", "psysh", "laravel"], "license": "MIT", "authors": [ { "name": "Taylor Otwell", "email": "taylor@laravel.com" } ], "require": { "php": "^7.2.5|^8.0", "illuminate/console": "^6.0|^7.0|^8.0|^9.0|^10.0|^11.0|^12.0", "illuminate/contracts": "^6.0|^7.0|^8.0|^9.0|^10.0|^11.0|^12.0", "illuminate/support": "^6.0|^7.0|^8.0|^9.0|^10.0|^11.0|^12.0", "psy/psysh": "^0.11.1|^0.12.0", "symfony/var-dumper": "^4.3.4|^5.0|^6.0|^7.0|^8.0" }, "require-dev": { "mockery/mockery": "~1.3.3|^1.4.2", "phpstan/phpstan": "^1.10", "phpunit/phpunit": "^8.5.8|^9.3.3|^10.0" }, "suggest": { "illuminate/database": "The Illuminate Database package (^6.0|^7.0|^8.0|^9.0|^10.0|^11.0|^12.0)." }, "autoload": { "psr-4": { "Laravel\\Tinker\\": "src/" } }, "autoload-dev": { "psr-4": { "Laravel\\Tinker\\Tests\\": "tests/", "App\\": "tests/fixtures/app", "One\\Two\\": "tests/fixtures/vendor/one/two" } }, "extra": { "laravel": { "providers": [ "Laravel\\Tinker\\TinkerServiceProvider" ] } }, "config": { "sort-packages": true }, "minimum-stability": "dev", "prefer-stable": true } ================================================ FILE: config/tinker.php ================================================ [ // App\Console\Commands\ExampleCommand::class, ], /* |-------------------------------------------------------------------------- | Auto Aliased Classes |-------------------------------------------------------------------------- | | Tinker will not automatically alias classes in your vendor namespaces | but you may explicitly allow a subset of classes to get aliased by | adding the names of each of those classes to the following list. | */ 'alias' => [ // ], /* |-------------------------------------------------------------------------- | Classes That Should Not Be Aliased |-------------------------------------------------------------------------- | | Typically, Tinker automatically aliases classes as you require them in | Tinker. However, you may wish to never alias certain classes, which | you may accomplish by listing the classes in the following array. | */ 'dont_alias' => [ 'App\Nova', ], /* |-------------------------------------------------------------------------- | Project Trust Mode |-------------------------------------------------------------------------- | | PsySH restricts local project features unless your project is trusted. | Set this to "always" to avoid untrusted project warnings in Tinker. | Accepted values: "prompt", "always", "never", true, false, null. | */ 'trust_project' => env('TINKER_TRUST_PROJECT', 'always'), ]; ================================================ FILE: phpstan.neon.dist ================================================ parameters: paths: - config - src level: 0 ignoreErrors: - "#Unsafe usage of new static\\(\\)#" - "#Class Illuminate\\\\Foundation\\\\Application not found.#" - "#Class Laravel\\\\Lumen\\\\Application not found.#" ================================================ FILE: phpunit.xml.dist ================================================ ./tests/ ================================================ FILE: src/ClassAliasAutoloader.php ================================================ shell = $shell; $this->vendorPath = dirname(dirname($classMapPath)); $this->includedAliases = collect($includedAliases); $this->excludedAliases = collect($excludedAliases); $classes = require $classMapPath; foreach ($classes as $class => $path) { if (! $this->isAliasable($class, $path)) { continue; } $name = class_basename($class); if (! isset($this->classes[$name])) { $this->classes[$name] = $class; } } } /** * Find the closest class by name. * * @param string $class * @return void */ public function aliasClass($class) { if (Str::contains($class, '\\')) { return; } $fullName = $this->classes[$class] ?? false; if ($fullName) { $this->shell->writeStdout("[!] Aliasing '{$class}' to '{$fullName}' for this Tinker session.\n"); class_alias($fullName, $class); } } /** * Unregister the alias loader instance. * * @return void */ public function unregister() { spl_autoload_unregister([$this, 'aliasClass']); } /** * Handle the destruction of the instance. * * @return void */ public function __destruct() { $this->unregister(); } /** * Whether a class may be aliased. * * @param string $class * @param string $path */ public function isAliasable($class, $path) { if (! Str::contains($class, '\\')) { return false; } if ($this->includedAliases->contains(function ($alias) use ($class) { return Str::startsWith($class, $alias); })) { return true; } if (Str::startsWith($path, $this->vendorPath)) { return false; } if ($this->excludedAliases->contains(function ($alias) use ($class) { return Str::startsWith($class, $alias); })) { return false; } return true; } } ================================================ FILE: src/Console/TinkerCommand.php ================================================ getApplication()->setCatchExceptions(false); $config = Configuration::fromInput($this->input); $config->setUpdateCheck(Checker::NEVER); $appConfig = $this->getLaravel()->make('config'); $config->setTrustProject($appConfig->get('tinker.trust_project')); $config->getPresenter()->addCasters( $this->getCasters() ); if ($this->option('execute')) { $config->setRawOutput(true); } $shell = new Shell($config); $shell->addCommands($this->getCommands()); $shell->setIncludes($this->argument('include')); $path = Env::get('COMPOSER_VENDOR_DIR', $this->getLaravel()->basePath().DIRECTORY_SEPARATOR.'vendor'); $path .= '/composer/autoload_classmap.php'; $loader = ClassAliasAutoloader::register( $shell, $path, $appConfig->get('tinker.alias', []), $appConfig->get('tinker.dont_alias', []) ); if ($code = $this->option('execute')) { try { $shell->setOutput($this->output); $shell->execute($code); } finally { $loader->unregister(); } return 0; } try { return $shell->run(); } finally { $loader->unregister(); } } /** * Get artisan commands to pass through to PsySH. * * @return array */ protected function getCommands() { $commands = []; foreach ($this->getApplication()->all() as $name => $command) { if (in_array($name, $this->commandWhitelist)) { $commands[] = $command; } } $config = $this->getLaravel()->make('config'); foreach ($config->get('tinker.commands', []) as $command) { $commands[] = $this->getApplication()->add( $this->getLaravel()->make($command) ); } return $commands; } /** * Get an array of Laravel tailored casters. * * @return array */ protected function getCasters() { $casters = [ 'Illuminate\Support\Collection' => 'Laravel\Tinker\TinkerCaster::castCollection', 'Illuminate\Support\HtmlString' => 'Laravel\Tinker\TinkerCaster::castHtmlString', 'Illuminate\Support\Stringable' => 'Laravel\Tinker\TinkerCaster::castStringable', ]; if (class_exists('Illuminate\Database\Eloquent\Model')) { $casters['Illuminate\Database\Eloquent\Model'] = 'Laravel\Tinker\TinkerCaster::castModel'; } if (class_exists('Illuminate\Process\ProcessResult')) { $casters['Illuminate\Process\ProcessResult'] = 'Laravel\Tinker\TinkerCaster::castProcessResult'; } if (class_exists('Illuminate\Foundation\Application')) { $casters['Illuminate\Foundation\Application'] = 'Laravel\Tinker\TinkerCaster::castApplication'; } $config = $this->getLaravel()->make('config'); return array_merge($casters, (array) $config->get('tinker.casters', [])); } /** * Get the console command arguments. * * @return array */ protected function getArguments() { return [ ['include', InputArgument::IS_ARRAY, 'Include file(s) before starting tinker'], ]; } /** * Get the console command options. * * @return array */ protected function getOptions() { return [ ['execute', null, InputOption::VALUE_OPTIONAL, 'Execute the given code using Tinker'], ]; } } ================================================ FILE: src/TinkerCaster.php ================================================ $property(); if (! is_null($val)) { $results[Caster::PREFIX_VIRTUAL.$property] = $val; } } catch (Exception $e) { // } } return $results; } /** * Get an array representing the properties of a collection. * * @param \Illuminate\Support\Collection $collection * @return array */ public static function castCollection($collection) { return [ Caster::PREFIX_VIRTUAL.'all' => $collection->all(), ]; } /** * Get an array representing the properties of an html string. * * @param \Illuminate\Support\HtmlString $htmlString * @return array */ public static function castHtmlString($htmlString) { return [ Caster::PREFIX_VIRTUAL.'html' => $htmlString->toHtml(), ]; } /** * Get an array representing the properties of a fluent string. * * @param \Illuminate\Support\Stringable $stringable * @return array */ public static function castStringable($stringable) { return [ Caster::PREFIX_VIRTUAL.'value' => (string) $stringable, ]; } /** * Get an array representing the properties of a process result. * * @param \Illuminate\Process\ProcessResult $result * @return array */ public static function castProcessResult($result) { return [ Caster::PREFIX_VIRTUAL.'output' => $result->output(), Caster::PREFIX_VIRTUAL.'errorOutput' => $result->errorOutput(), Caster::PREFIX_VIRTUAL.'exitCode' => $result->exitCode(), Caster::PREFIX_VIRTUAL.'successful' => $result->successful(), ]; } /** * Get an array representing the properties of a model. * * @param \Illuminate\Database\Eloquent\Model $model * @return array */ public static function castModel($model) { $attributes = array_merge( $model->getAttributes(), $model->getRelations() ); $visible = array_flip( $model->getVisible() ?: array_diff(array_keys($attributes), $model->getHidden()) ); $hidden = array_flip($model->getHidden()); $appends = (function () { return array_combine($this->appends, $this->appends); // @phpstan-ignore-line })->bindTo($model, $model)(); foreach ($appends as $appended) { $attributes[$appended] = $model->{$appended}; } $results = []; foreach ($attributes as $key => $value) { $prefix = ''; if (isset($visible[$key])) { $prefix = Caster::PREFIX_VIRTUAL; } if (isset($hidden[$key])) { $prefix = Caster::PREFIX_PROTECTED; } $results[$prefix.$key] = $value; } return $results; } } ================================================ FILE: src/TinkerServiceProvider.php ================================================ app instanceof LaravelApplication && $this->app->runningInConsole()) { $this->publishes([$source => $this->app->configPath('tinker.php')]); } elseif ($this->app instanceof LumenApplication) { $this->app->configure('tinker'); } $this->mergeConfigFrom($source, 'tinker'); } /** * Register the service provider. * * @return void */ public function register() { $this->app->singleton('command.tinker', function () { return new TinkerCommand; }); $this->commands(['command.tinker']); } /** * Get the services provided by the provider. * * @return array */ public function provides() { return ['command.tinker']; } } ================================================ FILE: tests/ClassAliasAutoloaderTest.php ================================================ classmapPath = __DIR__.'/fixtures/vendor/composer/autoload_classmap.php'; } protected function tearDown(): void { $this->loader->unregister(); } public function testCanAliasClasses() { $this->loader = ClassAliasAutoloader::register( $shell = Mockery::mock(Shell::class), $this->classmapPath ); $shell->shouldReceive('writeStdout') ->with("[!] Aliasing 'Bar' to 'App\Foo\Bar' for this Tinker session.\n") ->once(); $this->assertTrue(class_exists('Bar')); $this->assertInstanceOf(\App\Foo\Bar::class, new \Bar); } public function testCanExcludeNamespacesFromAliasing() { $this->loader = ClassAliasAutoloader::register( $shell = Mockery::mock(Shell::class), $this->classmapPath, [], ['App\Baz'] ); $shell->shouldNotReceive('writeStdout'); $this->assertFalse(class_exists('Qux')); } public function testVendorClassesAreExcluded() { $this->loader = ClassAliasAutoloader::register( $shell = Mockery::mock(Shell::class), $this->classmapPath ); $shell->shouldNotReceive('writeStdout'); $this->assertFalse(class_exists('Three')); } public function testVendorClassesCanBeWhitelisted() { $this->loader = ClassAliasAutoloader::register( $shell = Mockery::mock(Shell::class), $this->classmapPath, ['One\Two'] ); $shell->shouldReceive('writeStdout') ->with("[!] Aliasing 'Three' to 'One\Two\Three' for this Tinker session.\n") ->once(); $this->assertTrue(class_exists('Three')); $this->assertInstanceOf(\One\Two\Three::class, new \Three); } } ================================================ FILE: tests/TinkerCasterTest.php ================================================ castCollection(new Collection(['foo', 'bar'])); $this->assertSame([['foo', 'bar']], array_values($result)); } } ================================================ FILE: tests/fixtures/app/Baz/Qux.php ================================================ $baseDir.'/app/Foo/Bar.php', 'App\\Baz\\Qux' => $baseDir.'/app/Baz/Qux.php', 'One\\Two\\Three' => $vendorDir.'/one/two/src/Three.php', 'Four\\Five\\Six' => $vendorDir.'/four/five/src/Six.php', ); ================================================ FILE: tests/fixtures/vendor/one/two/Three.php ================================================