diff --git a/.editorconfig b/.editorconfig index 6f313c6ab..9cd0b6d21 100644 --- a/.editorconfig +++ b/.editorconfig @@ -11,5 +11,5 @@ trim_trailing_whitespace = true [*.md] trim_trailing_whitespace = false -[*.yml] +[*.{yml,yaml,yaml.example}] indent_size = 2 diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index d4597af17..d128557bc 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -38,5 +38,8 @@ jobs: - name: Install dependencies run: composer install --prefer-dist --no-interaction --no-progress + - name: Run PhpStan + run: vendor/bin/phpstan analyse src tests + - name: Execute tests run: vendor/bin/phpunit --verbose diff --git a/Homestead.yaml.example b/Homestead.yaml.example index 98e9d9dde..c23c64ba9 100644 --- a/Homestead.yaml.example +++ b/Homestead.yaml.example @@ -7,42 +7,42 @@ provider: virtualbox authorize: ~/.ssh/id_rsa.pub keys: - - ~/.ssh/id_rsa + - ~/.ssh/id_rsa folders: - - map: ~/code - to: /home/vagrant/code + - map: ~/code + to: /home/vagrant/code sites: - - map: homestead.test - to: /home/vagrant/code/public + - map: homestead.test + to: /home/vagrant/code/public databases: - - homestead + - homestead features: - - mariadb: false - - postgresql: false - - ohmyzsh: false - - webdriver: false - - influxdb: false + - mariadb: false + - postgresql: false + - ohmyzsh: false + - webdriver: false + - influxdb: false services: - - enabled: - - "mysql" -# - disabled: -# - "postgresql@11-main" - -#ports: -# - send: 33060 # MySQL/MariaDB -# to: 3306 -# - send: 4040 -# to: 4040 -# - send: 54320 # PostgreSQL -# to: 5432 -# - send: 8025 # Mailpit -# to: 8025 -# - send: 9600 -# to: 9600 -# - send: 27017 -# to: 27017 + - enabled: + - "mysql" +# - disabled: +# - "postgresql@11-main" + +# ports: +# - send: 33060 # MySQL/MariaDB +# to: 3306 +# - send: 4040 +# to: 4040 +# - send: 54320 # PostgreSQL +# to: 5432 +# - send: 8025 # Mailpit +# to: 8025 +# - send: 9600 +# to: 9600 +# - send: 27017 +# to: 27017 diff --git a/bin/homestead b/bin/homestead index 9172941a0..4410e586c 100755 --- a/bin/homestead +++ b/bin/homestead @@ -8,7 +8,7 @@ if(is_file( __DIR__.'/../vendor/autoload.php')) { require __DIR__.'/../../../autoload.php'; } -$app = new Symfony\Component\Console\Application('Laravel Homestead', '15.0.2'); +$app = new Symfony\Component\Console\Application('Laravel Homestead', '15.0.3'); $app->add(new Laravel\Homestead\MakeCommand); $app->add(new Laravel\Homestead\WslApplyFeatures); diff --git a/composer.json b/composer.json index f7751426a..673e0fde7 100644 --- a/composer.json +++ b/composer.json @@ -9,7 +9,8 @@ }, "require-dev": { "phpunit/phpunit": "^9.5", - "dms/phpunit-arraysubset-asserts": "^0.2.1" + "dms/phpunit-arraysubset-asserts": "^0.2.1", + "phpstan/phpstan": "^1.10" }, "license": "MIT", "authors": [ diff --git a/composer.lock b/composer.lock index d3d947f22..f975aeb18 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "f661151eb1a23240797e306139755a5b", + "content-hash": "186632e5fcfc8b65dc45f3bb657fd6b8", "packages": [ { "name": "psr/container", @@ -1196,6 +1196,68 @@ }, "time": "2022-02-21T01:04:05+00:00" }, + { + "name": "phpstan/phpstan", + "version": "1.10.57", + "source": { + "type": "git", + "url": "https://github.com/phpstan/phpstan.git", + "reference": "1627b1d03446904aaa77593f370c5201d2ecc34e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/1627b1d03446904aaa77593f370c5201d2ecc34e", + "reference": "1627b1d03446904aaa77593f370c5201d2ecc34e", + "shasum": "" + }, + "require": { + "php": "^7.2|^8.0" + }, + "conflict": { + "phpstan/phpstan-shim": "*" + }, + "bin": [ + "phpstan", + "phpstan.phar" + ], + "type": "library", + "autoload": { + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "PHPStan - PHP Static Analysis Tool", + "keywords": [ + "dev", + "static analysis" + ], + "support": { + "docs": "https://phpstan.org/user-guide/getting-started", + "forum": "https://github.com/phpstan/phpstan/discussions", + "issues": "https://github.com/phpstan/phpstan/issues", + "security": "https://github.com/phpstan/phpstan/security/policy", + "source": "https://github.com/phpstan/phpstan-src" + }, + "funding": [ + { + "url": "https://github.com/ondrejmirtes", + "type": "github" + }, + { + "url": "https://github.com/phpstan", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/phpstan/phpstan", + "type": "tidelift" + } + ], + "time": "2024-01-24T11:51:34+00:00" + }, { "name": "phpunit/php-code-coverage", "version": "9.2.30", diff --git a/phpstan.src.neon.dist b/phpstan.src.neon.dist new file mode 100644 index 000000000..f5d4e5750 --- /dev/null +++ b/phpstan.src.neon.dist @@ -0,0 +1,17 @@ +parameters: + paths: + - src + level: 0 + ignoreErrors: + - "#\\(void\\) is used#" + - "#Access to an undefined property#" + - "#Call to an undefined method#" + - "#but return statement is missing.#" + - "#Caught class [a-zA-Z0-9\\\\_]+ not found.#" + - "#Class [a-zA-Z0-9\\\\_]+ not found.#" + - "#has invalid type#" + - "#should always throw an exception or terminate script execution#" + - "#Instantiated class [a-zA-Z0-9\\\\_]+ not found.#" + - "#Unsafe usage of new static#" + excludePaths: + - "src/Illuminate/Testing/ParallelRunner.php" diff --git a/resources/Homestead.yaml b/resources/Homestead.yaml index 407ee8ec3..fad682774 100644 --- a/resources/Homestead.yaml +++ b/resources/Homestead.yaml @@ -7,41 +7,41 @@ provider: virtualbox authorize: ~/.ssh/id_rsa.pub keys: - - ~/.ssh/id_rsa + - ~/.ssh/id_rsa folders: - - map: ~/code - to: /home/vagrant/code + - map: ~/code + to: /home/vagrant/code sites: - - map: homestead.test - to: /home/vagrant/code/public + - map: homestead.test + to: /home/vagrant/code/public databases: - - homestead + - homestead features: - - mariadb: false - - postgresql: false - - ohmyzsh: false - - webdriver: false + - mariadb: false + - postgresql: false + - ohmyzsh: false + - webdriver: false services: - - enabled: - - "mysql" -# - disabled: -# - "postgresql@11-main" - -#ports: -# - send: 33060 # MySQL/MariaDB -# to: 3306 -# - send: 4040 -# to: 4040 -# - send: 54320 # PostgreSQL -# to: 5432 -# - send: 8025 # Mailpit -# to: 8025 -# - send: 9600 -# to: 9600 -# - send: 27017 -# to: 27017 + - enabled: + - "mysql" +# - disabled: +# - "postgresql@11-main" + +# ports: +# - send: 33060 # MySQL/MariaDB +# to: 3306 +# - send: 4040 +# to: 4040 +# - send: 54320 # PostgreSQL +# to: 5432 +# - send: 8025 # Mailpit +# to: 8025 +# - send: 9600 +# to: 9600 +# - send: 27017 +# to: 27017 diff --git a/scripts/features/dockstead/mysql-5.7.yaml b/scripts/features/dockstead/mysql-5.7.yaml index d13b3c3a6..83525cde1 100644 --- a/scripts/features/dockstead/mysql-5.7.yaml +++ b/scripts/features/dockstead/mysql-5.7.yaml @@ -4,22 +4,22 @@ # version: "3.7" services: - mysql: - image: mysql:5.7 - volumes: - - type: volume - source: mysql-data - target: /var/lib/mysql - volume: - nocopy: true - ports: - - "3306:3306" - healthcheck: - test: mysqladmin ping -h 127.0.0.1 -u $$MYSQL_USER --password=$$MYSQL_PASSWORD - interval: 3s - timeout: 1s - retries: 5 - env_file: - - env.docker + mysql: + image: mysql:5.7 + volumes: + - type: volume + source: mysql-data + target: /var/lib/mysql + volume: + nocopy: true + ports: + - "3306:3306" + healthcheck: + test: mysqladmin ping -h 127.0.0.1 -u $$MYSQL_USER --password=$$MYSQL_PASSWORD + interval: 3s + timeout: 1s + retries: 5 + env_file: + - env.docker volumes: - mysql-data: + mysql-data: diff --git a/scripts/features/php8.2.sh b/scripts/features/php8.2.sh index cff621735..3d09ef7a9 100644 --- a/scripts/features/php8.2.sh +++ b/scripts/features/php8.2.sh @@ -10,6 +10,14 @@ fi export DEBIAN_FRONTEND=noninteractive +SERVICE_STATUS=$(systemctl is-enabled php8.2-fpm.service) + +if [ "$SERVICE_STATUS" == "disabled" ]; +then + systemctl enable php8.2-fpm + service php8.2-fpm restart +fi + if [ -f /home/$WSL_USER_NAME/.homestead-features/php82 ] then echo "PHP 8.2 already installed." @@ -60,3 +68,6 @@ sed -i "s/group = www-data/group = vagrant/" /etc/php/8.2/fpm/pool.d/www.conf sed -i "s/listen\.owner.*/listen.owner = vagrant/" /etc/php/8.2/fpm/pool.d/www.conf sed -i "s/listen\.group.*/listen.group = vagrant/" /etc/php/8.2/fpm/pool.d/www.conf sed -i "s/;listen\.mode.*/listen.mode = 0666/" /etc/php/8.2/fpm/pool.d/www.conf + +systemctl enable php8.2-fpm +service php8.2-fpm restart diff --git a/scripts/features/php8.3.sh b/scripts/features/php8.3.sh index 6171232aa..4cc3346d3 100644 --- a/scripts/features/php8.3.sh +++ b/scripts/features/php8.3.sh @@ -10,6 +10,14 @@ fi export DEBIAN_FRONTEND=noninteractive +SERVICE_STATUS=$(systemctl is-enabled php8.3-fpm.service) + +if [ "$SERVICE_STATUS" == "disabled" ]; +then + systemctl enable php8.3-fpm + service php8.3-fpm restart +fi + if [ -f /home/$WSL_USER_NAME/.homestead-features/php83 ] then echo "PHP 8.3 already installed." diff --git a/scripts/features/webdriver.sh b/scripts/features/webdriver.sh index d2f2c0460..0b9ecdcf2 100755 --- a/scripts/features/webdriver.sh +++ b/scripts/features/webdriver.sh @@ -24,7 +24,7 @@ ARCH=$(arch) # Install The Chrome Web Driver & Dusk Utilities if [[ "$ARCH" != "aarch64" ]]; then wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb -O /tmp/chrome.deb - dpkg -i /tmp/chrome.deb + apt-get install -y /tmp/chrome.deb rm -f /tmp/chrome.deb fi diff --git a/scripts/homestead.rb b/scripts/homestead.rb index 0c79a3a41..1fd98ecaf 100644 --- a/scripts/homestead.rb +++ b/scripts/homestead.rb @@ -673,7 +673,7 @@ def self.configure(config, settings) # Update Composer On Every Provision config.vm.provision 'shell' do |s| s.name = 'Update Composer' - s.inline = 'sudo chown -R vagrant:vagrant /usr/local/bin && sudo -u vagrant /usr/local/bin/composer self-update --no-progress && sudo chown -R vagrant:vagrant /home/vagrant/.config/' + s.inline = 'sudo chown -R vagrant:vagrant /usr/local/bin && sudo -u vagrant /usr/bin/php8.3 /usr/local/bin/composer self-update --no-progress && sudo chown -R vagrant:vagrant /home/vagrant/.config/' s.privileged = false end diff --git a/scripts/site-types/apache-proxy.sh b/scripts/site-types/apache-proxy.sh index c4016c53e..0e04d793b 100644 --- a/scripts/site-types/apache-proxy.sh +++ b/scripts/site-types/apache-proxy.sh @@ -23,16 +23,35 @@ if [ -n "$2" ] then if ! [[ "$2" =~ ^[0-9]+$ ]] then + if ! [[ "$2" =~ ^https: ]] + then + socket=$(echo "$2" | sed -E "s/^http(s?):\/\//ws:\/\//g") + else + socket=$(echo "$2" | sed -E "s/^http(s?):\/\//wss:\/\//g") + fi + proxyPass=" + RewriteEngine On + RewriteCond %{HTTP:Upgrade} =websocket [NC] + RewriteRule /(.*) $socket/ [P,L] + ProxyPass / ${2}/ ProxyPassReverse / ${2}/ " else proxyPass=" + RewriteEngine On + RewriteCond %{HTTP:Upgrade} =websocket [NC] + RewriteRule /(.*) ws://127.0.0.1:$2/ [P,L] + ProxyPass / http://127.0.0.1:$2/ ProxyPassReverse / http://127.0.0.1:$2/ " fi else proxyPass=" +RewriteEngine On +RewriteCond %{HTTP:Upgrade} =websocket [NC] +RewriteRule /(.*) ws://127.0.0.1/ [P,L] + ProxyPass / http://127.0.0.1/ ProxyPassReverse / http://127.0.0.1/ " diff --git a/src/MakeCommand.php b/src/MakeCommand.php index e81f746d1..07b27b849 100644 --- a/src/MakeCommand.php +++ b/src/MakeCommand.php @@ -40,7 +40,7 @@ class MakeCommand extends Command * * @return void */ - protected function configure() + protected function configure(): void { $this->basePath = getcwd(); $this->projectName = basename($this->basePath); @@ -65,7 +65,7 @@ protected function configure() * @param \Symfony\Component\Console\Output\OutputInterface $output * @return int */ - public function execute(InputInterface $input, OutputInterface $output) + public function execute(InputInterface $input, OutputInterface $output): int { if (! $this->vagrantfileExists()) { $this->createVagrantfile(); diff --git a/src/Settings/JsonSettings.php b/src/Settings/JsonSettings.php index e25c88f34..cf891d419 100644 --- a/src/Settings/JsonSettings.php +++ b/src/Settings/JsonSettings.php @@ -2,7 +2,7 @@ namespace Laravel\Homestead\Settings; -class JsonSettings extends HomesteadSettings +final class JsonSettings extends HomesteadSettings { /** * Create an instance from a file. diff --git a/src/Settings/YamlSettings.php b/src/Settings/YamlSettings.php index d136613d2..d25924b14 100644 --- a/src/Settings/YamlSettings.php +++ b/src/Settings/YamlSettings.php @@ -4,7 +4,7 @@ use Symfony\Component\Yaml\Yaml; -class YamlSettings extends HomesteadSettings +final class YamlSettings extends HomesteadSettings { /** * Create an instance from a file. diff --git a/src/WslApplyFeatures.php b/src/WslApplyFeatures.php index 76f80f232..851351b8d 100644 --- a/src/WslApplyFeatures.php +++ b/src/WslApplyFeatures.php @@ -47,7 +47,7 @@ class WslApplyFeatures extends Command * * @return void */ - protected function configure() + protected function configure(): void { $this->basePath = getcwd(); $this->projectName = basename($this->basePath); @@ -67,7 +67,7 @@ protected function configure() * @param OutputInterface $output * @return int */ - public function execute(InputInterface $input, OutputInterface $output) + public function execute(InputInterface $input, OutputInterface $output): int { // Grab the current settings or create an example configuration $format = $input->getOption('json') ? 'json' : 'yaml'; diff --git a/src/WslCreateDatabaseCommand.php b/src/WslCreateDatabaseCommand.php index 4448ef02e..0d64462f9 100644 --- a/src/WslCreateDatabaseCommand.php +++ b/src/WslCreateDatabaseCommand.php @@ -40,7 +40,7 @@ class WslCreateDatabaseCommand extends Command * * @return void */ - protected function configure() + protected function configure(): void { $this->basePath = getcwd(); $this->projectName = basename($this->basePath); @@ -59,7 +59,7 @@ protected function configure() * @param OutputInterface $output * @return int */ - public function execute(InputInterface $input, OutputInterface $output) + public function execute(InputInterface $input, OutputInterface $output): int { // Grab the current settings or create an example configuration $format = $input->getOption('json') ? 'json' : 'yaml'; @@ -85,7 +85,7 @@ public function execute(InputInterface $input, OutputInterface $output) * @param array $options * @return mixed */ - protected function parseSettingsFromFile(string $format, array $options) + protected function parseSettingsFromFile(string $format, array $options): mixed { $SettingsClass = ($format === 'json') ? JsonSettings::class : YamlSettings::class; $filename = __DIR__."/../Homestead.{$format}"; diff --git a/src/WslCreateSiteCommand.php b/src/WslCreateSiteCommand.php index 7bb2420c9..3a4c57e3e 100644 --- a/src/WslCreateSiteCommand.php +++ b/src/WslCreateSiteCommand.php @@ -40,7 +40,7 @@ class WslCreateSiteCommand extends Command * * @return void */ - protected function configure() + protected function configure(): void { $this->basePath = getcwd(); $this->projectName = basename($this->basePath); @@ -59,7 +59,7 @@ protected function configure() * @param OutputInterface $output * @return int */ - public function execute(InputInterface $input, OutputInterface $output) + public function execute(InputInterface $input, OutputInterface $output): int { // Remove any existing nginx sites $shell_output = shell_exec('sudo rm -rf /etc/nginx/sites-available/*');